2020-08-11 17:56:53 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the 3-clause BSD License
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "label/LabelPage.h"
|
|
|
|
#include "progressbar/ProgressBarPage.h"
|
|
|
|
#include "slider/SliderPage.h"
|
2022-04-01 14:54:31 +02:00
|
|
|
#include "button/ButtonPage.h"
|
2022-04-19 08:42:53 +02:00
|
|
|
#include "textinput/TextInputPage.h"
|
2022-04-20 15:25:15 +02:00
|
|
|
#include "selector/SelectorPage.h"
|
2020-08-11 17:56:53 +02:00
|
|
|
|
|
|
|
#include <SkinnyShortcut.h>
|
|
|
|
#include <SkinnyShapeProvider.h>
|
2022-04-01 15:58:47 +02:00
|
|
|
#include <SkinnyNamespace.h>
|
2020-08-11 17:56:53 +02:00
|
|
|
|
|
|
|
#include <QskFocusIndicator.h>
|
|
|
|
#include <QskObjectCounter.h>
|
|
|
|
#include <QskTabView.h>
|
2022-04-01 14:54:31 +02:00
|
|
|
#include <QskTextLabel.h>
|
2022-06-07 11:18:11 +02:00
|
|
|
#include <QskSetup.h>
|
2022-04-01 14:54:31 +02:00
|
|
|
#include <QskSwitchButton.h>
|
2022-04-01 15:58:47 +02:00
|
|
|
#include <QskPushButton.h>
|
2022-04-05 10:41:36 +02:00
|
|
|
#include <QskMenu.h>
|
2020-08-11 17:56:53 +02:00
|
|
|
#include <QskWindow.h>
|
2022-04-19 08:42:53 +02:00
|
|
|
#include <QskDialog.h>
|
2020-08-11 17:56:53 +02:00
|
|
|
|
|
|
|
#include <QGuiApplication>
|
|
|
|
|
2021-12-06 19:20:59 +01:00
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class TabView : public QskTabView
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
TabView( QQuickItem* parent = nullptr )
|
|
|
|
: QskTabView( parent )
|
|
|
|
{
|
|
|
|
setMargins( 10 );
|
2022-04-17 12:37:13 +02:00
|
|
|
setTabBarEdge( Qt::LeftEdge );
|
2021-12-06 19:20:59 +01:00
|
|
|
setAutoFitTabs( true );
|
|
|
|
}
|
2022-04-01 14:54:31 +02:00
|
|
|
|
|
|
|
void setTabsEnabled( bool on )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < count(); i++ )
|
|
|
|
itemAt( i )->setEnabled( on );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-05 10:41:36 +02:00
|
|
|
class MenuButton : public QskPushButton
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MenuButton( const QString& text, QQuickItem* parent = nullptr )
|
|
|
|
: QskPushButton( text, parent )
|
|
|
|
{
|
|
|
|
setFlat( true ); // until we have the section bit in QskAspect
|
|
|
|
|
|
|
|
connect( this, &QskPushButton::pressed, this, &MenuButton::openMenu );
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void openMenu()
|
|
|
|
{
|
2022-04-05 11:38:23 +02:00
|
|
|
auto menu = new QskMenu( window()->contentItem() );
|
2022-04-05 10:41:36 +02:00
|
|
|
|
2022-04-05 11:38:23 +02:00
|
|
|
menu->addOption( "image://shapes/Rectangle/White", "Print" );
|
|
|
|
menu->addOption( "image://shapes/Diamond/Yellow", "Save As" );
|
|
|
|
menu->addOption( "image://shapes/Ellipse/Red", "Setup" );
|
|
|
|
menu->addSeparator();
|
2022-05-30 07:49:58 +02:00
|
|
|
menu->addOption( "image://shapes/Hexagon/PapayaWhip", "Quit" );
|
|
|
|
|
|
|
|
// see https://github.com/uwerat/qskinny/issues/192
|
|
|
|
connect( menu, &QskMenu::triggered,
|
|
|
|
[]( int index ) { if ( index == 3 ) qApp->quit(); } );
|
2022-04-05 10:41:36 +02:00
|
|
|
|
2022-04-05 11:38:23 +02:00
|
|
|
menu->setOrigin( geometry().bottomLeft() );
|
|
|
|
menu->open();
|
2022-04-05 10:41:36 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-04-01 14:54:31 +02:00
|
|
|
/*
|
|
|
|
Once QskApplicationView and friends are implemented we can replace
|
|
|
|
Header/ApplicationWindow with it. TODO ...
|
|
|
|
*/
|
|
|
|
class Header : public QskLinearBox
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Header( QQuickItem* parent = nullptr )
|
|
|
|
: QskLinearBox( Qt::Horizontal, parent )
|
|
|
|
{
|
|
|
|
initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::Fixed );
|
2022-04-01 15:58:47 +02:00
|
|
|
|
2022-04-01 14:54:31 +02:00
|
|
|
setMargins( 10 );
|
2022-04-01 15:58:47 +02:00
|
|
|
setBackgroundColor( Qt::lightGray );
|
|
|
|
|
|
|
|
{
|
|
|
|
auto button = new QskPushButton( "Skin", this );
|
|
|
|
#if 1
|
|
|
|
button->setFlat( true ); // until we have the section bit in QskAspect
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// transition leads to errors, when changing the tab before being completed. TODO ...
|
|
|
|
connect( button, &QskSwitchButton::clicked,
|
|
|
|
[] { Skinny::changeSkin( 500 ); } );
|
|
|
|
}
|
2022-04-01 14:54:31 +02:00
|
|
|
|
2022-04-05 10:41:36 +02:00
|
|
|
{
|
|
|
|
new MenuButton( "Menu", this );
|
|
|
|
}
|
|
|
|
|
2022-04-01 14:54:31 +02:00
|
|
|
addStretch( 10 );
|
|
|
|
|
2022-04-01 15:58:47 +02:00
|
|
|
{
|
|
|
|
new QskTextLabel( "Enabled", this );
|
2022-04-01 14:54:31 +02:00
|
|
|
|
2022-04-01 15:58:47 +02:00
|
|
|
auto button = new QskSwitchButton( this );
|
|
|
|
button->setChecked( true );
|
2022-04-01 14:54:31 +02:00
|
|
|
|
2022-04-01 15:58:47 +02:00
|
|
|
connect( button, &QskSwitchButton::toggled,
|
|
|
|
this, &Header::enabledToggled );
|
|
|
|
}
|
2022-04-01 14:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void enabledToggled( bool );
|
|
|
|
};
|
|
|
|
|
|
|
|
class ApplicationView : public QskLinearBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ApplicationView( QQuickItem* parent = nullptr )
|
|
|
|
: QskLinearBox( Qt::Vertical, parent )
|
|
|
|
{
|
|
|
|
auto header = new Header( this );
|
|
|
|
|
|
|
|
auto tabView = new TabView( this );
|
|
|
|
tabView->addTab( "Labels", new LabelPage() );
|
|
|
|
tabView->addTab( "Buttons", new ButtonPage() );
|
|
|
|
tabView->addTab( "Sliders", new SliderPage() );
|
|
|
|
tabView->addTab( "Progress\nBars", new ProgressBarPage() );
|
2022-04-19 08:42:53 +02:00
|
|
|
tabView->addTab( "Text\nInputs", new TextInputPage() );
|
2022-04-20 15:25:15 +02:00
|
|
|
tabView->addTab( "Selectors", new SelectorPage() );
|
2022-04-01 14:54:31 +02:00
|
|
|
|
|
|
|
connect( header, &Header::enabledToggled,
|
|
|
|
tabView, &TabView::setTabsEnabled );
|
|
|
|
}
|
2021-12-06 19:20:59 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
int main( int argc, char* argv[] )
|
|
|
|
{
|
|
|
|
#ifdef ITEM_STATISTICS
|
|
|
|
QskObjectCounter counter( true );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
Qsk::addGraphicProvider( "shapes", new SkinnyShapeProvider() );
|
|
|
|
|
2022-04-19 08:42:53 +02:00
|
|
|
// dialogs in faked windows -> QskSubWindow
|
|
|
|
QskDialog::instance()->setPolicy( QskDialog::EmbeddedBox );
|
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
QGuiApplication app( argc, argv );
|
|
|
|
|
2022-06-07 11:18:11 +02:00
|
|
|
qskSetup->setItemUpdateFlag( QskQuickItem::PreferRasterForTextures, true );
|
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts );
|
|
|
|
|
2022-04-01 14:54:31 +02:00
|
|
|
auto mainView = new ApplicationView();
|
2020-08-11 17:56:53 +02:00
|
|
|
|
|
|
|
QSize size( 800, 600 );
|
2022-04-01 14:54:31 +02:00
|
|
|
size = size.expandedTo( mainView->sizeHint().toSize() );
|
2020-08-11 17:56:53 +02:00
|
|
|
|
|
|
|
QskWindow window;
|
2022-04-01 14:54:31 +02:00
|
|
|
window.addItem( mainView );
|
2020-08-11 17:56:53 +02:00
|
|
|
window.addItem( new QskFocusIndicator() );
|
|
|
|
|
|
|
|
window.resize( size );
|
|
|
|
window.show();
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|
2022-04-01 14:54:31 +02:00
|
|
|
|
|
|
|
#include "main.moc"
|