From 4a7d7d0e2de2f21bffbcb4ddfb1aaedc53698ef9 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Mon, 2 Aug 2021 13:27:30 +0200 Subject: [PATCH] switchbuttons example moved to the gallery --- examples/examples.pro | 1 - examples/gallery/gallery.pro | 6 +++ examples/gallery/main.cpp | 2 + .../gallery/switchbutton/SwitchButtonPage.cpp | 52 ++++++++++++++++++ .../gallery/switchbutton/SwitchButtonPage.h | 20 +++++++ examples/switchbuttons/main.cpp | 54 ------------------- examples/switchbuttons/switchbuttons.pro | 4 -- 7 files changed, 80 insertions(+), 59 deletions(-) create mode 100644 examples/gallery/switchbutton/SwitchButtonPage.cpp create mode 100644 examples/gallery/switchbutton/SwitchButtonPage.h delete mode 100644 examples/switchbuttons/main.cpp delete mode 100644 examples/switchbuttons/switchbuttons.pro diff --git a/examples/examples.pro b/examples/examples.pro index 9e943dad..0402f44c 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -3,7 +3,6 @@ TEMPLATE = subdirs # c++ SUBDIRS += \ desktop \ - switchbuttons \ gallery \ layouts \ listbox \ diff --git a/examples/gallery/gallery.pro b/examples/gallery/gallery.pro index 2e8af737..75cd1071 100644 --- a/examples/gallery/gallery.pro +++ b/examples/gallery/gallery.pro @@ -24,6 +24,12 @@ HEADERS += \ SOURCES += \ progressbar/ProgressBarPage.cpp \ +HEADERS += \ + switchbutton/SwitchButtonPage.h + +SOURCES += \ + switchbutton/SwitchButtonPage.cpp \ + HEADERS += \ Page.h diff --git a/examples/gallery/main.cpp b/examples/gallery/main.cpp index 38a71997..a7567fd0 100644 --- a/examples/gallery/main.cpp +++ b/examples/gallery/main.cpp @@ -6,6 +6,7 @@ #include "label/LabelPage.h" #include "progressbar/ProgressBarPage.h" #include "slider/SliderPage.h" +#include "switchbutton/SwitchButtonPage.h" #include #include @@ -40,6 +41,7 @@ int main( int argc, char* argv[] ) tabView->addTab( "Labels", new LabelPage() ); tabView->addTab( "Sliders", new SliderPage() ); tabView->addTab( "Progress\nBars", new ProgressBarPage() ); + tabView->addTab( "Switches", new SwitchButtonPage() ); QSize size( 800, 600 ); size = size.expandedTo( tabView->sizeHint().toSize() ); diff --git a/examples/gallery/switchbutton/SwitchButtonPage.cpp b/examples/gallery/switchbutton/SwitchButtonPage.cpp new file mode 100644 index 00000000..1ed05e36 --- /dev/null +++ b/examples/gallery/switchbutton/SwitchButtonPage.cpp @@ -0,0 +1,52 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the 3-clause BSD License + *****************************************************************************/ + +#include "SwitchButtonPage.h" + +#include +#include +#include + +#include + +SwitchButtonPage::SwitchButtonPage( QQuickItem* parent ) + : Page( Qt::Horizontal, parent ) +{ + setGradient( QskRgb::AliceBlue ); + setSpacing( 40 ); + + populate(); +} + +void SwitchButtonPage::populate() +{ + auto vbox = new QskLinearBox( Qt::Vertical, this ); + + auto hbox = new QskLinearBox( vbox ); + new QskTextLabel( "Disable the boxes: ", hbox ); + auto disabler = new QskSwitchButton( hbox ); + + auto targets = new QskLinearBox( Qt::Horizontal, vbox ); + + auto target1 = new QskSwitchButton( targets ); + target1->setOrientation( Qt::Vertical ); + + auto target2 = new QskSwitchButton( targets ); + target2->setOrientation( Qt::Horizontal ); + + auto target3 = new QskSwitchButton( targets ); + target3->setChecked( true ); + target3->setOrientation( Qt::Vertical ); + + auto target4 = new QskSwitchButton( targets ); + target4->setChecked( true ); + target4->setOrientation( Qt::Horizontal ); + + QObject::connect( disabler, &QskSwitchButton::checkedChanged, + targets, &QskQuickItem::setDisabled ); + + targets->setExtraSpacingAt( Qt::RightEdge ); + vbox->setExtraSpacingAt( Qt::BottomEdge ); +} diff --git a/examples/gallery/switchbutton/SwitchButtonPage.h b/examples/gallery/switchbutton/SwitchButtonPage.h new file mode 100644 index 00000000..b7ef82fe --- /dev/null +++ b/examples/gallery/switchbutton/SwitchButtonPage.h @@ -0,0 +1,20 @@ +/****************************************************************************** + * QSkinny - Copyright (C) 2016 Uwe Rathmann + * This file may be used under the terms of the 3-clause BSD License + *****************************************************************************/ + +#ifndef SWITCH_BUTTON_PAGE_H +#define SWITCH_BUTTON_PAGE_H + +#include "Page.h" + +class SwitchButtonPage : public Page +{ + public: + SwitchButtonPage( QQuickItem* = nullptr ); + + private: + void populate(); +}; + +#endif diff --git a/examples/switchbuttons/main.cpp b/examples/switchbuttons/main.cpp deleted file mode 100644 index 88f5205f..00000000 --- a/examples/switchbuttons/main.cpp +++ /dev/null @@ -1,54 +0,0 @@ -#include - -#include -#include -#include -#include - -#include - -int main(int argc, char* argv[]) -{ - QGuiApplication app( argc, argv ); - QskWindow window; - - SkinnyShortcut::enable( SkinnyShortcut::Quit | - SkinnyShortcut::DebugShortcuts ); - - auto vbox = new QskLinearBox(Qt::Vertical); - auto hbox = new QskLinearBox(vbox); - new QskTextLabel("Disable the boxes: ", hbox); - auto disabler = new QskSwitchButton(hbox); - - auto targets = new QskLinearBox(Qt::Horizontal, vbox); - - auto target1 = new QskSwitchButton(targets); - target1->setOrientation(Qt::Vertical); - - auto target2 = new QskSwitchButton(targets); - target2->setOrientation(Qt::Horizontal); - - auto target3 = new QskSwitchButton(targets); - target3->setChecked(true); - target3->setOrientation(Qt::Vertical); - - auto target4 = new QskSwitchButton(targets); - target4->setChecked(true); - target4->setOrientation(Qt::Horizontal); - - QObject::connect(disabler, &QskSwitchButton::checkedChanged, - targets, [target1, target2, target3, target4](bool c){ - target1->setEnabled(!c); - target2->setEnabled(!c); - target3->setEnabled(!c); - target4->setEnabled(!c); - }); - - targets->setExtraSpacingAt(Qt::RightEdge); - vbox->setExtraSpacingAt(Qt::BottomEdge); - - window.addItem( vbox ); - window.show(); - - return app.exec(); -} diff --git a/examples/switchbuttons/switchbuttons.pro b/examples/switchbuttons/switchbuttons.pro deleted file mode 100644 index 4539fa38..00000000 --- a/examples/switchbuttons/switchbuttons.pro +++ /dev/null @@ -1,4 +0,0 @@ -CONFIG += qskexample - -SOURCES += \ - main.cpp\