switchbuttons example moved to the gallery

This commit is contained in:
Uwe Rathmann 2021-08-02 13:27:30 +02:00
parent 13faf53495
commit 4a7d7d0e2d
7 changed files with 80 additions and 59 deletions

View File

@ -3,7 +3,6 @@ TEMPLATE = subdirs
# c++ # c++
SUBDIRS += \ SUBDIRS += \
desktop \ desktop \
switchbuttons \
gallery \ gallery \
layouts \ layouts \
listbox \ listbox \

View File

@ -24,6 +24,12 @@ HEADERS += \
SOURCES += \ SOURCES += \
progressbar/ProgressBarPage.cpp \ progressbar/ProgressBarPage.cpp \
HEADERS += \
switchbutton/SwitchButtonPage.h
SOURCES += \
switchbutton/SwitchButtonPage.cpp \
HEADERS += \ HEADERS += \
Page.h Page.h

View File

@ -6,6 +6,7 @@
#include "label/LabelPage.h" #include "label/LabelPage.h"
#include "progressbar/ProgressBarPage.h" #include "progressbar/ProgressBarPage.h"
#include "slider/SliderPage.h" #include "slider/SliderPage.h"
#include "switchbutton/SwitchButtonPage.h"
#include <SkinnyFont.h> #include <SkinnyFont.h>
#include <SkinnyShortcut.h> #include <SkinnyShortcut.h>
@ -40,6 +41,7 @@ int main( int argc, char* argv[] )
tabView->addTab( "Labels", new LabelPage() ); tabView->addTab( "Labels", new LabelPage() );
tabView->addTab( "Sliders", new SliderPage() ); tabView->addTab( "Sliders", new SliderPage() );
tabView->addTab( "Progress\nBars", new ProgressBarPage() ); tabView->addTab( "Progress\nBars", new ProgressBarPage() );
tabView->addTab( "Switches", new SwitchButtonPage() );
QSize size( 800, 600 ); QSize size( 800, 600 );
size = size.expandedTo( tabView->sizeHint().toSize() ); size = size.expandedTo( tabView->sizeHint().toSize() );

View File

@ -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 <QskSwitchButton.h>
#include <QskLinearBox.h>
#include <QskTextLabel.h>
#include <QskRgbValue.h>
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 );
}

View File

@ -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

View File

@ -1,54 +0,0 @@
#include <QGuiApplication>
#include <QskLinearBox.h>
#include <QskSwitchButton.h>
#include <QskTextLabel.h>
#include <QskWindow.h>
#include <SkinnyShortcut.h>
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();
}

View File

@ -1,4 +0,0 @@
CONFIG += qskexample
SOURCES += \
main.cpp\