qskinny/examples/gallery/switchbutton/SwitchButtonPage.cpp

57 lines
1.7 KiB
C++
Raw Normal View History

/******************************************************************************
* 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>
2021-08-02 19:17:04 +02:00
#include <QskSeparator.h>
#include <QskRgbValue.h>
SwitchButtonPage::SwitchButtonPage( QQuickItem* parent )
: Page( Qt::Horizontal, parent )
{
setGradient( QskRgb::AliceBlue );
setSpacing( 40 );
populate();
}
void SwitchButtonPage::populate()
{
2021-08-02 19:17:04 +02:00
auto hbox1 = new QskLinearBox();
hbox1->setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed );
hbox1->setExtraSpacingAt( Qt::LeftEdge );
auto label = new QskTextLabel( "Disable the switches:", hbox1 );
2021-08-02 19:17:04 +02:00
label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
auto button0 = new QskSwitchButton( hbox1 );
2021-08-02 19:17:04 +02:00
auto hbox2 = new QskLinearBox( Qt::Horizontal );
hbox2->setDefaultAlignment( Qt::AlignHCenter | Qt::AlignTop );
hbox2->setMargins( 30 );
2021-08-02 19:17:04 +02:00
(void) new QskSwitchButton( Qt::Vertical, hbox2 );
(void) new QskSwitchButton( Qt::Horizontal, hbox2 );
2021-08-02 19:17:04 +02:00
auto button3 = new QskSwitchButton( Qt::Vertical, hbox2 );
button3->setInverted( true );
2021-08-02 19:17:04 +02:00
auto button4 = new QskSwitchButton( Qt::Horizontal, hbox2 );
button4->setInverted( true );
2021-08-02 19:17:04 +02:00
auto vbox = new QskLinearBox( Qt::Vertical, this );
vbox->addItem( hbox1 );
vbox->addItem( new QskSeparator() );
vbox->addItem( hbox2 );
vbox->setExtraSpacingAt( Qt::BottomEdge );
2021-08-02 19:17:04 +02:00
QObject::connect( button0, &QskSwitchButton::checkedChanged,
hbox2, &QskQuickItem::setDisabled );
}