81 lines
2.2 KiB
C++
Raw Normal View History

2017-07-21 18:21:34 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include <SkinnyShortcut.h>
#include <SkinnyShapeProvider.h>
#include <QskObjectCounter.h>
#include <QskWindow.h>
#include <QskSubWindow.h>
#include <QskSubWindowArea.h>
#include <QskGraphicLabel.h>
#include <QskGradient.h>
#include <QskAspect.h>
2017-12-05 17:40:21 +01:00
#include <QskShortcut.h>
2017-07-21 18:21:34 +02:00
#include <QGuiApplication>
2017-12-05 17:40:21 +01:00
#include <QKeySequence>
#include <QDebug>
2017-07-21 18:21:34 +02:00
class SubWindow : public QskSubWindow
{
public:
SubWindow( const QString& graphicSource, QQuickItem* parent = nullptr ):
QskSubWindow( parent )
{
setObjectName( graphicSource );
auto label = new QskGraphicLabel( this );
label->setSource( graphicSource );
label->setAlignment( Qt::AlignCenter );
setSizePolicy( QskSizePolicy::MinimumExpanding,
QskSizePolicy::MinimumExpanding );
2017-12-05 17:40:21 +01:00
QskShortcut::addShortcut( this, QKeySequence( Qt::Key_P ), true,
[=] { qDebug() << graphicSource; } );
2017-07-21 18:21:34 +02:00
}
};
int main( int argc, char* argv[] )
{
#ifdef ITEM_STATISTICS
QskObjectCounter counter( true );
#endif
const char providerId[] = "shapes";
Qsk::addGraphicProvider( providerId, new SkinnyShapeProvider() );
QGuiApplication app( argc, argv );
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
QskSubWindowArea* area = new QskSubWindowArea();
area->setGradientHint( QskSubWindowArea::Panel,
QskGradient( QskGradient::Diagonal, "DarkSlateGray", "LightSlateGray" ) );
2017-07-21 18:21:34 +02:00
QRectF windowRect( 0, 0, 250, 250 );
const QStringList shapes = { "ellipse", "ring", "star", "hexagon" };
const QString url = QString( "image://%1/" ).arg( providerId );
for ( int i = 0; i < shapes.count(); i++ )
{
const qreal off = ( i + 1 ) * 100;
SubWindow* subWindow = new SubWindow( url + shapes[i], area );
subWindow->setGeometry( windowRect.translated( off, off ) );
}
QskWindow window;
window.addItem( area );
window.resize( 800, 800 );
window.show();
return app.exec();
}