switchbuttons example moved to the gallery
This commit is contained in:
parent
13faf53495
commit
4a7d7d0e2d
@ -3,7 +3,6 @@ TEMPLATE = subdirs
|
|||||||
# c++
|
# c++
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
desktop \
|
desktop \
|
||||||
switchbuttons \
|
|
||||||
gallery \
|
gallery \
|
||||||
layouts \
|
layouts \
|
||||||
listbox \
|
listbox \
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -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() );
|
||||||
|
52
examples/gallery/switchbutton/SwitchButtonPage.cpp
Normal file
52
examples/gallery/switchbutton/SwitchButtonPage.cpp
Normal 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 );
|
||||||
|
}
|
20
examples/gallery/switchbutton/SwitchButtonPage.h
Normal file
20
examples/gallery/switchbutton/SwitchButtonPage.h
Normal 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
|
@ -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();
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
CONFIG += qskexample
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
main.cpp\
|
|
Loading…
x
Reference in New Issue
Block a user