2022-04-01 14:54:31 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the 3-clause BSD License
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "ButtonPage.h"
|
|
|
|
|
|
|
|
#include <QskSwitchButton.h>
|
|
|
|
#include <QskPushButton.h>
|
2022-04-04 14:14:07 +02:00
|
|
|
#include <QskCheckBox.h>
|
2023-02-08 21:49:04 +01:00
|
|
|
#include <QskRadioBox.h>
|
2022-04-01 14:54:31 +02:00
|
|
|
#include <QskSeparator.h>
|
|
|
|
#include <QskLinearBox.h>
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
class ButtonBox : public QskLinearBox
|
|
|
|
{
|
|
|
|
public:
|
2023-02-27 14:07:42 +01:00
|
|
|
ButtonBox( Qt::Orientation orientation, QQuickItem* parent = nullptr )
|
|
|
|
: ButtonBox( orientation, -1, parent )
|
2022-04-01 14:54:31 +02:00
|
|
|
{
|
2023-02-27 14:07:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ButtonBox( Qt::Orientation orientation,
|
|
|
|
uint dimension, QQuickItem* parent = nullptr )
|
|
|
|
: QskLinearBox( orientation, dimension, parent )
|
|
|
|
{
|
|
|
|
setSpacing( 10 );
|
|
|
|
setExtraSpacingAt( Qt::LeftEdge | Qt::RightEdge | Qt::BottomEdge );
|
|
|
|
}
|
|
|
|
};
|
2022-04-01 14:54:31 +02:00
|
|
|
|
2023-02-27 14:07:42 +01:00
|
|
|
class PushButtonBox : public ButtonBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
PushButtonBox( QQuickItem* parent = nullptr )
|
|
|
|
: ButtonBox( Qt::Horizontal, 3, parent )
|
|
|
|
{
|
|
|
|
setDefaultAlignment( Qt::AlignCenter );
|
2023-03-05 10:36:18 +01:00
|
|
|
setSpacing( 30 );
|
2022-04-01 14:54:31 +02:00
|
|
|
populate();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void populate()
|
|
|
|
{
|
2023-02-24 15:06:00 +01:00
|
|
|
auto* filledButton1 = new QskPushButton( this );
|
|
|
|
filledButton1->setGraphicSource( "airport_shuttle" );
|
|
|
|
filledButton1->setText( "normal" );
|
|
|
|
|
|
|
|
auto* filledButton2 = new QskPushButton( this );
|
|
|
|
filledButton2->setText( "normal" );
|
|
|
|
|
|
|
|
auto* filledButton3 = new QskPushButton( this );
|
|
|
|
filledButton3->setGraphicSource( "airport_shuttle" );
|
2022-04-01 14:54:31 +02:00
|
|
|
|
2023-02-03 11:53:43 +01:00
|
|
|
|
2023-02-24 15:06:00 +01:00
|
|
|
auto* checkableButton1 = new QskPushButton( this );
|
|
|
|
checkableButton1->setGraphicSource( "airport_shuttle" );
|
|
|
|
checkableButton1->setText( "checkable" );
|
|
|
|
checkableButton1->setCheckable( true );
|
|
|
|
|
|
|
|
auto* checkableButton2 = new QskPushButton( this );
|
|
|
|
checkableButton2->setText( "checkable" );
|
|
|
|
checkableButton2->setCheckable( true );
|
|
|
|
|
|
|
|
auto* checkableButton3 = new QskPushButton( this );
|
|
|
|
checkableButton3->setGraphicSource( "airport_shuttle" );
|
|
|
|
checkableButton3->setCheckable( true );
|
|
|
|
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* outlinedButton1 = new QskPushButton( this );
|
|
|
|
outlinedButton1->setEmphasis( QskPushButton::LowEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
outlinedButton1->setGraphicSource( "flight" );
|
|
|
|
outlinedButton1->setText( "low emphasis" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* outlinedButton2 = new QskPushButton( this );
|
|
|
|
outlinedButton2->setEmphasis( QskPushButton::LowEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
outlinedButton2->setText( "low emphasis" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* outlinedButton3 = new QskPushButton( this );
|
|
|
|
outlinedButton3->setEmphasis( QskPushButton::LowEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
outlinedButton3->setGraphicSource( "flight" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
auto* textButton1 = new QskPushButton( this );
|
|
|
|
textButton1->setEmphasis( QskPushButton::VeryLowEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
textButton1->setGraphicSource( "local_pizza" );
|
|
|
|
textButton1->setText( "very low emphasis" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* textButton2 = new QskPushButton( this );
|
|
|
|
textButton2->setEmphasis( QskPushButton::VeryLowEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
textButton2->setText( "very low emphasis" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* textButton3 = new QskPushButton( this );
|
|
|
|
textButton3->setEmphasis( QskPushButton::VeryLowEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
textButton3->setGraphicSource( "local_pizza" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
auto* elevatedButton1 = new QskPushButton( this );
|
|
|
|
elevatedButton1->setEmphasis( QskPushButton::HighEmphasis );
|
|
|
|
elevatedButton1->setGraphicSource( "plus" );
|
2023-02-24 15:06:00 +01:00
|
|
|
elevatedButton1->setText( "high emphasis" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* elevatedButton2 = new QskPushButton( this );
|
|
|
|
elevatedButton2->setEmphasis( QskPushButton::HighEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
elevatedButton2->setText( "high emphasis" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* elevatedButton3 = new QskPushButton( this );
|
|
|
|
elevatedButton3->setEmphasis( QskPushButton::HighEmphasis );
|
|
|
|
elevatedButton3->setGraphicSource( "plus" );
|
|
|
|
|
|
|
|
|
|
|
|
auto* tonalButton1 = new QskPushButton( this );
|
|
|
|
tonalButton1->setEmphasis( QskPushButton::VeryHighEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
tonalButton1->setGraphicSource( "sports_soccer" );
|
|
|
|
tonalButton1->setText( "very high emphasis" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* tonalButton2 = new QskPushButton( this );
|
|
|
|
tonalButton2->setEmphasis( QskPushButton::VeryHighEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
tonalButton2->setText( "very high emphasis" );
|
2023-02-03 11:53:43 +01:00
|
|
|
|
|
|
|
auto* tonalButton3 = new QskPushButton( this );
|
|
|
|
tonalButton3->setEmphasis( QskPushButton::VeryHighEmphasis );
|
2023-02-24 15:06:00 +01:00
|
|
|
tonalButton3->setGraphicSource( "sports_soccer" );
|
2022-04-01 14:54:31 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-27 14:07:42 +01:00
|
|
|
class SwitchButtonBox : public ButtonBox
|
2022-04-01 14:54:31 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SwitchButtonBox( QQuickItem* parent = nullptr )
|
2023-02-27 14:07:42 +01:00
|
|
|
: ButtonBox( Qt::Horizontal, parent )
|
2022-04-01 14:54:31 +02:00
|
|
|
{
|
|
|
|
for ( auto orientation : { Qt::Vertical, Qt::Horizontal } )
|
|
|
|
{
|
|
|
|
(void) new QskSwitchButton( orientation, this );
|
|
|
|
|
|
|
|
auto button = new QskSwitchButton( orientation, this );
|
|
|
|
button->setInverted( true );
|
2022-04-03 16:37:36 +02:00
|
|
|
button->setChecked( true );
|
2022-04-01 14:54:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2022-04-04 14:14:07 +02:00
|
|
|
|
2023-02-27 14:07:42 +01:00
|
|
|
class CheckButtonBox : public ButtonBox
|
2022-04-20 15:25:15 +02:00
|
|
|
{
|
2022-04-04 14:14:07 +02:00
|
|
|
public:
|
|
|
|
CheckButtonBox( QQuickItem* parent = nullptr )
|
2023-02-27 14:07:42 +01:00
|
|
|
: ButtonBox( Qt::Horizontal, 2, parent )
|
2022-04-20 15:25:15 +02:00
|
|
|
{
|
2022-07-01 11:10:59 +02:00
|
|
|
auto button1 = new QskCheckBox( "Options 1", this );
|
|
|
|
button1->setChecked( true );
|
|
|
|
|
|
|
|
auto button2 = new QskCheckBox( "Options 2", this );
|
|
|
|
button2->setLayoutMirroring( true );
|
2023-01-08 18:22:33 +01:00
|
|
|
|
|
|
|
auto button3 = new QskCheckBox( "Error", this );
|
|
|
|
button3->setSkinStateFlag( QskCheckBox::Error );
|
2023-02-26 17:04:47 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-02-27 14:07:42 +01:00
|
|
|
class RadioButtonBox : public ButtonBox
|
2023-02-26 17:04:47 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
RadioButtonBox( QQuickItem* parent = nullptr )
|
2023-02-27 14:07:42 +01:00
|
|
|
: ButtonBox( Qt::Horizontal, parent )
|
2023-02-26 17:04:47 +01:00
|
|
|
{
|
2023-03-03 12:49:22 +01:00
|
|
|
auto radioBox1 = new QskRadioBox( { "One", "Two", "Three" }, this );
|
|
|
|
radioBox1->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
2023-02-26 17:04:47 +01:00
|
|
|
|
2023-03-03 12:49:22 +01:00
|
|
|
auto radioBox2 = new QskRadioBox( { "One", "Two", "Three" }, this );
|
|
|
|
radioBox2->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
|
|
|
|
radioBox2->setLayoutMirroring( true );
|
2022-04-04 14:14:07 +02:00
|
|
|
}
|
|
|
|
};
|
2022-04-01 14:54:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ButtonPage::ButtonPage( QQuickItem* parent )
|
|
|
|
: Page( Qt::Vertical, parent )
|
|
|
|
{
|
2023-02-27 14:07:42 +01:00
|
|
|
setSpacing( 20 );
|
2022-04-01 14:54:31 +02:00
|
|
|
|
2023-02-27 14:07:42 +01:00
|
|
|
new PushButtonBox( this );
|
2022-04-04 14:14:07 +02:00
|
|
|
new QskSeparator( Qt::Horizontal, this );
|
2023-02-26 17:04:47 +01:00
|
|
|
|
|
|
|
auto hBox = new QskLinearBox( Qt::Horizontal, this );
|
2023-02-27 14:07:42 +01:00
|
|
|
|
|
|
|
new SwitchButtonBox( hBox );
|
|
|
|
new QskSeparator( Qt::Vertical, hBox );
|
2023-02-26 17:04:47 +01:00
|
|
|
new CheckButtonBox( hBox );
|
2023-02-27 14:07:42 +01:00
|
|
|
new QskSeparator( Qt::Vertical, hBox );
|
2023-02-26 17:04:47 +01:00
|
|
|
new RadioButtonBox( hBox );
|
2022-04-01 14:54:31 +02:00
|
|
|
}
|