symbols example removed, thumbnails example ( showing QskScrollArea +
flicking ) instead
This commit is contained in:
parent
ec5521ab3e
commit
59f2e7c808
@ -1,66 +0,0 @@
|
||||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include <QskAspect.h>
|
||||
#include <QskPushButton.h>
|
||||
#include <QskCorner.h>
|
||||
#include <QskGraphic.h>
|
||||
#include <QskObjectCounter.h>
|
||||
#include <SkinnyShapeFactory.h>
|
||||
#include "ButtonBox.h"
|
||||
|
||||
ButtonBox::ButtonBox( QQuickItem* parent ):
|
||||
QskLinearBox( parent )
|
||||
{
|
||||
setDimension( 3 );
|
||||
setMargins( 5 );
|
||||
|
||||
insertButton( "RoyalBlue", SkinnyShapeFactory::Rectangle );
|
||||
insertButton( "IndianRed", SkinnyShapeFactory::Ellipse );
|
||||
insertButton( "DarkOliveGreen", SkinnyShapeFactory::Ring );
|
||||
insertButton( "SandyBrown", SkinnyShapeFactory::TriangleDown );
|
||||
insertButton( "DarkViolet", SkinnyShapeFactory::Star );
|
||||
insertButton( "DarkSlateGray", SkinnyShapeFactory::Hexagon );
|
||||
|
||||
itemAtIndex( 0 )->setFocus( true );
|
||||
}
|
||||
|
||||
ButtonBox::~ButtonBox()
|
||||
{
|
||||
}
|
||||
|
||||
void ButtonBox::insertButton( const QColor& color, SkinnyShapeFactory::Shape shape )
|
||||
{
|
||||
QskGraphic graphic;
|
||||
|
||||
QPen pen( Qt::black, 3 );
|
||||
pen.setJoinStyle( Qt::MiterJoin );
|
||||
pen.setCosmetic( true );
|
||||
|
||||
QPainter painter( &graphic );
|
||||
painter.setRenderHint( QPainter::Antialiasing, true );
|
||||
painter.setPen( pen );
|
||||
painter.setBrush( color );
|
||||
|
||||
painter.drawPath( SkinnyShapeFactory::shapePath( shape, QSizeF( 40, 40 ) ) );
|
||||
painter.end();
|
||||
|
||||
QskPushButton* button = new QskPushButton( this );
|
||||
button->setObjectName( QString( "Shape %1" ).arg( int( shape ) ) );
|
||||
button->setGraphic( graphic );
|
||||
button->setMetric( QskPushButton::Panel | QskAspect::Border, 3 );
|
||||
//button->setCorner( QskCorner( Qt::RelativeSize, 100 ) );
|
||||
button->setSizePolicy( QskSizePolicy::MinimumExpanding,
|
||||
QskSizePolicy::MinimumExpanding );
|
||||
|
||||
connect( button, SIGNAL( clicked() ), SLOT( onButtonClick() ) );
|
||||
}
|
||||
|
||||
void ButtonBox::onButtonClick()
|
||||
{
|
||||
delete sender();
|
||||
}
|
||||
|
||||
#include "moc_ButtonBox.cpp"
|
@ -1,27 +0,0 @@
|
||||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _BUTTON_BOX_H_
|
||||
#define _BUTTON_BOX_H_
|
||||
|
||||
#include <QskLinearBox.h>
|
||||
#include <SkinnyShapeFactory.h>
|
||||
|
||||
class ButtonBox : public QskLinearBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ButtonBox( QQuickItem* parent = nullptr );
|
||||
virtual ~ButtonBox();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onButtonClick();
|
||||
|
||||
private:
|
||||
void insertButton( const QColor&, SkinnyShapeFactory::Shape );
|
||||
};
|
||||
|
||||
#endif
|
@ -1,60 +0,0 @@
|
||||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include "ButtonBox.h"
|
||||
#include <SkinnyFont.h>
|
||||
#include <SkinnyShortcut.h>
|
||||
|
||||
#include <QskAspect.h>
|
||||
#include <QskWindow.h>
|
||||
#include <QskPushButton.h>
|
||||
#include <QskLinearBox.h>
|
||||
#include <QskFocusIndicator.h>
|
||||
#include <QskObjectCounter.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
#ifdef ITEM_STATISTICS
|
||||
QskObjectCounter counter( true );
|
||||
#endif
|
||||
|
||||
QGuiApplication app( argc, argv );
|
||||
|
||||
SkinnyFont::init( &app );
|
||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||
|
||||
auto box = new ButtonBox();
|
||||
box->setObjectName( "ButtonBox" );
|
||||
|
||||
auto button = new QskPushButton( "Check Me" );
|
||||
button->setObjectName( "CheckMe" );
|
||||
button->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
button->setCheckable( true );
|
||||
button->setChecked( true );
|
||||
|
||||
QObject::connect( button, SIGNAL( toggled( bool ) ),
|
||||
box, SLOT( setVisible( bool ) ) );
|
||||
|
||||
auto layoutBox = new QskLinearBox( Qt::Horizontal );
|
||||
layoutBox->setObjectName( "MainLayout" );
|
||||
layoutBox->setMargins( 5 );
|
||||
layoutBox->addItem( button );
|
||||
layoutBox->addItem( box );
|
||||
|
||||
auto focusIndicator = new QskFocusIndicator();
|
||||
focusIndicator->setObjectName( "FocusIndicator" );
|
||||
focusIndicator->setColor( QskFocusIndicator::Panel | QskAspect::Border, Qt::darkBlue );
|
||||
|
||||
QskWindow window;
|
||||
window.resize( 600, 400 );
|
||||
window.addItem( layoutBox );
|
||||
window.addItem( focusIndicator );
|
||||
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
include( $${PWD}/../examples.pri )
|
||||
|
||||
TARGET = symbols
|
||||
|
||||
QT += quick quick-private
|
||||
CONFIG += no_private_qt_headers_warning
|
||||
|
||||
HEADERS += \
|
||||
ButtonBox.h
|
||||
|
||||
SOURCES += \
|
||||
ButtonBox.cpp \
|
||||
main.cpp
|
135
examples/thumbnails/main.cpp
Normal file
135
examples/thumbnails/main.cpp
Normal file
@ -0,0 +1,135 @@
|
||||
/******************************************************************************
|
||||
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
||||
* This file may be used under the terms of the 3-clause BSD License
|
||||
*****************************************************************************/
|
||||
|
||||
#include <SkinnyShortcut.h>
|
||||
#include <SkinnyShapeFactory.h>
|
||||
|
||||
#include <QskScrollArea.h>
|
||||
#include <QskWindow.h>
|
||||
#include <QskGraphicLabel.h>
|
||||
#include <QskLinearBox.h>
|
||||
#include <QskObjectCounter.h>
|
||||
#include <QskGraphic.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPainter>
|
||||
|
||||
const int gridSize = 20;
|
||||
const int thumbnailSize = 150;
|
||||
|
||||
static QColor randomColor()
|
||||
{
|
||||
static const char* colors[] =
|
||||
{
|
||||
"HotPink",
|
||||
"MediumVioletRed",
|
||||
"FireBrick",
|
||||
"PeachPuff",
|
||||
"Gold",
|
||||
"RosyBrown",
|
||||
"Maroon",
|
||||
"Turquoise",
|
||||
"CadetBlue",
|
||||
"Teal",
|
||||
"LightSteelBlue",
|
||||
"CornflowerBlue",
|
||||
"Thistle",
|
||||
"Plum",
|
||||
"DarkViolet",
|
||||
"DarkSlateBlue",
|
||||
"AntiqueWhite",
|
||||
"MistyRose",
|
||||
"Silver",
|
||||
"DarkSlateGray"
|
||||
};
|
||||
|
||||
const int index = qrand() % ( sizeof( colors ) / sizeof( colors[0] ) );
|
||||
return QColor( colors[ index ] );
|
||||
}
|
||||
|
||||
static int randomShape()
|
||||
{
|
||||
return qrand() % SkinnyShapeFactory::ShapeCount;
|
||||
}
|
||||
|
||||
class Thumbnail : public QskGraphicLabel
|
||||
{
|
||||
public:
|
||||
Thumbnail( const QColor& color, int shape, QQuickItem* parentItem ):
|
||||
QskGraphicLabel( parentItem )
|
||||
{
|
||||
using namespace SkinnyShapeFactory;
|
||||
|
||||
const QSizeF size( thumbnailSize, thumbnailSize );
|
||||
|
||||
QskGraphic graphic;
|
||||
|
||||
QPen pen( Qt::black, 3 );
|
||||
pen.setJoinStyle( Qt::MiterJoin );
|
||||
pen.setCosmetic( true );
|
||||
|
||||
QPainter painter( &graphic );
|
||||
painter.setRenderHint( QPainter::Antialiasing, true );
|
||||
painter.setPen( pen );
|
||||
painter.setBrush( color );
|
||||
|
||||
painter.drawPath( shapePath( static_cast< Shape >( shape ), size ) );
|
||||
painter.end();
|
||||
|
||||
setGraphic( graphic );
|
||||
setFixedSize( size );
|
||||
}
|
||||
};
|
||||
|
||||
class IconGrid : public QskLinearBox
|
||||
{
|
||||
public:
|
||||
IconGrid( QQuickItem* parentItem = nullptr ):
|
||||
QskLinearBox( Qt::Horizontal, gridSize, parentItem )
|
||||
{
|
||||
setMargins( 20 );
|
||||
setSpacing( 20 );
|
||||
|
||||
for ( int col = 0; col < gridSize; col++ )
|
||||
{
|
||||
for ( int row = 0; row < gridSize; row++ )
|
||||
(void) new Thumbnail( randomColor(), randomShape(), this );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
#ifdef ITEM_STATISTICS
|
||||
QskObjectCounter counter( true );
|
||||
#endif
|
||||
|
||||
QGuiApplication app( argc, argv );
|
||||
|
||||
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
||||
|
||||
/*
|
||||
In a real world application a thumbnail viewer would probably implemented
|
||||
with QskScrollView using scene graph node composition - like done
|
||||
in QskListView.
|
||||
|
||||
This example also shows, that blocking of the scene graph node creation
|
||||
( QskControl::DeferredUpdate + QskControl::CleanupOnVisibility )
|
||||
could be extended to respect being inside the window or a clip region.
|
||||
|
||||
But here we only want to demonstrate how QskScrollArea works.
|
||||
*/
|
||||
|
||||
auto scrollArea = new QskScrollArea();
|
||||
scrollArea->setScrolledItem( new IconGrid() );
|
||||
|
||||
QskWindow window;
|
||||
window.resize( 600, 600 );
|
||||
window.addItem( scrollArea );
|
||||
|
||||
window.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
6
examples/thumbnails/thumbnails.pro
Normal file
6
examples/thumbnails/thumbnails.pro
Normal file
@ -0,0 +1,6 @@
|
||||
include( $${PWD}/../examples.pri )
|
||||
|
||||
TARGET = thumbnails
|
||||
|
||||
SOURCES += \
|
||||
main.cpp
|
Loading…
x
Reference in New Issue
Block a user