From c4ba1d320f52fb33bef9a89fbca5e95c757e00a3 Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Fri, 1 Apr 2022 16:18:30 +0200 Subject: [PATCH] wio --- examples/gallery/button/ButtonPage.cpp | 42 ++++++++++----- examples/gallery/gallery.pro | 4 +- examples/gallery/main.cpp | 4 +- .../gallery/switchbutton/SwitchButtonPage.cpp | 54 ------------------- .../gallery/switchbutton/SwitchButtonPage.h | 17 ------ 5 files changed, 34 insertions(+), 87 deletions(-) delete mode 100644 examples/gallery/switchbutton/SwitchButtonPage.cpp delete mode 100644 examples/gallery/switchbutton/SwitchButtonPage.h diff --git a/examples/gallery/button/ButtonPage.cpp b/examples/gallery/button/ButtonPage.cpp index a0247c27..267a0899 100644 --- a/examples/gallery/button/ButtonPage.cpp +++ b/examples/gallery/button/ButtonPage.cpp @@ -12,6 +12,35 @@ #include +namespace +{ + class ButtonBox : public QskLinearBox + { + public: + ButtonBox( QQuickItem* parent = nullptr ) + : QskLinearBox( Qt::Horizontal, parent ) + { + setDefaultAlignment( Qt::AlignHCenter | Qt::AlignTop ); + setMargins( 30 ); + + populate(); + } + + private: + void populate() + { + (void) new QskSwitchButton( Qt::Vertical, this ); + (void) new QskSwitchButton( Qt::Horizontal, this ); + + auto button3 = new QskSwitchButton( Qt::Vertical, this ); + button3->setInverted( true ); + + auto button4 = new QskSwitchButton( Qt::Horizontal, this ); + button4->setInverted( true ); + } + }; +} + ButtonPage::ButtonPage( QQuickItem* parent ) : Page( Qt::Horizontal, parent ) { @@ -30,18 +59,7 @@ void ButtonPage::populate() auto button0 = new QskSwitchButton( hbox1 ); - auto hbox2 = new QskLinearBox( Qt::Horizontal ); - hbox2->setDefaultAlignment( Qt::AlignHCenter | Qt::AlignTop ); - hbox2->setMargins( 30 ); - - (void) new QskSwitchButton( Qt::Vertical, hbox2 ); - (void) new QskSwitchButton( Qt::Horizontal, hbox2 ); - - auto button3 = new QskSwitchButton( Qt::Vertical, hbox2 ); - button3->setInverted( true ); - - auto button4 = new QskSwitchButton( Qt::Horizontal, hbox2 ); - button4->setInverted( true ); + auto hbox2 = new ButtonBox(); auto vbox = new QskLinearBox( Qt::Vertical, this ); vbox->addItem( hbox1 ); diff --git a/examples/gallery/gallery.pro b/examples/gallery/gallery.pro index 75cd1071..2c1eedb3 100644 --- a/examples/gallery/gallery.pro +++ b/examples/gallery/gallery.pro @@ -25,10 +25,10 @@ SOURCES += \ progressbar/ProgressBarPage.cpp \ HEADERS += \ - switchbutton/SwitchButtonPage.h + button/ButtonPage.h SOURCES += \ - switchbutton/SwitchButtonPage.cpp \ + button/ButtonPage.cpp \ HEADERS += \ Page.h diff --git a/examples/gallery/main.cpp b/examples/gallery/main.cpp index 838d9106..869f06ac 100644 --- a/examples/gallery/main.cpp +++ b/examples/gallery/main.cpp @@ -6,7 +6,7 @@ #include "label/LabelPage.h" #include "progressbar/ProgressBarPage.h" #include "slider/SliderPage.h" -#include "switchbutton/SwitchButtonPage.h" +#include "button/ButtonPage.h" #include #include @@ -52,7 +52,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() ); + tabView->addTab( "Buttons", new ButtonPage() ); QSize size( 800, 600 ); size = size.expandedTo( tabView->sizeHint().toSize() ); diff --git a/examples/gallery/switchbutton/SwitchButtonPage.cpp b/examples/gallery/switchbutton/SwitchButtonPage.cpp deleted file mode 100644 index 1fab35b1..00000000 --- a/examples/gallery/switchbutton/SwitchButtonPage.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/****************************************************************************** - * 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 - -#include - -SwitchButtonPage::SwitchButtonPage( QQuickItem* parent ) - : Page( Qt::Horizontal, parent ) -{ - setSpacing( 40 ); - populate(); -} - -void SwitchButtonPage::populate() -{ - auto hbox1 = new QskLinearBox(); - hbox1->setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed ); - hbox1->setExtraSpacingAt( Qt::LeftEdge ); - - auto label = new QskTextLabel( "Disable the switches:", hbox1 ); - label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); - - auto button0 = new QskSwitchButton( hbox1 ); - - auto hbox2 = new QskLinearBox( Qt::Horizontal ); - hbox2->setDefaultAlignment( Qt::AlignHCenter | Qt::AlignTop ); - hbox2->setMargins( 30 ); - - (void) new QskSwitchButton( Qt::Vertical, hbox2 ); - (void) new QskSwitchButton( Qt::Horizontal, hbox2 ); - - auto button3 = new QskSwitchButton( Qt::Vertical, hbox2 ); - button3->setInverted( true ); - - auto button4 = new QskSwitchButton( Qt::Horizontal, hbox2 ); - button4->setInverted( true ); - - auto vbox = new QskLinearBox( Qt::Vertical, this ); - vbox->addItem( hbox1 ); - vbox->addItem( new QskSeparator() ); - vbox->addItem( hbox2 ); - vbox->setExtraSpacingAt( Qt::BottomEdge ); - - QObject::connect( button0, &QskSwitchButton::checkedChanged, - hbox2, &QskQuickItem::setDisabled ); -} diff --git a/examples/gallery/switchbutton/SwitchButtonPage.h b/examples/gallery/switchbutton/SwitchButtonPage.h deleted file mode 100644 index 377092da..00000000 --- a/examples/gallery/switchbutton/SwitchButtonPage.h +++ /dev/null @@ -1,17 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#pragma once - -#include "Page.h" - -class SwitchButtonPage : public Page -{ - public: - SwitchButtonPage( QQuickItem* = nullptr ); - - private: - void populate(); -};