minor improvements

This commit is contained in:
Uwe Rathmann 2023-02-27 14:07:42 +01:00
parent a67d23420f
commit bb960be42e
3 changed files with 33 additions and 39 deletions

View File

@ -17,13 +17,27 @@ namespace
class ButtonBox : public QskLinearBox class ButtonBox : public QskLinearBox
{ {
public: public:
ButtonBox( QQuickItem* parent = nullptr ) ButtonBox( Qt::Orientation orientation, QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, 3, parent ) : ButtonBox( orientation, -1, parent )
{ {
setSpacing( 20 ); }
setExtraSpacingAt( Qt::BottomEdge );
setDefaultAlignment( Qt::AlignCenter );
ButtonBox( Qt::Orientation orientation,
uint dimension, QQuickItem* parent = nullptr )
: QskLinearBox( orientation, dimension, parent )
{
setSpacing( 10 );
setExtraSpacingAt( Qt::LeftEdge | Qt::RightEdge | Qt::BottomEdge );
}
};
class PushButtonBox : public ButtonBox
{
public:
PushButtonBox( QQuickItem* parent = nullptr )
: ButtonBox( Qt::Horizontal, 3, parent )
{
setDefaultAlignment( Qt::AlignCenter );
populate(); populate();
} }
@ -112,43 +126,29 @@ namespace
} }
}; };
class SwitchButtonBox : public QskLinearBox class SwitchButtonBox : public ButtonBox
{ {
public: public:
SwitchButtonBox( QQuickItem* parent = nullptr ) SwitchButtonBox( QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, parent ) : ButtonBox( Qt::Horizontal, parent )
{ {
setSpacing( 20 );
setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed );
setExtraSpacingAt( Qt::LeftEdge | Qt::RightEdge | Qt::BottomEdge );
for ( auto orientation : { Qt::Vertical, Qt::Horizontal } ) for ( auto orientation : { Qt::Vertical, Qt::Horizontal } )
{ {
(void) new QskSwitchButton( orientation, this ); (void) new QskSwitchButton( orientation, this );
auto button = new QskSwitchButton( orientation, this ); auto button = new QskSwitchButton( orientation, this );
button->setChecked( true );
button = new QskSwitchButton( orientation, this );
button->setInverted( true );
button = new QskSwitchButton( orientation, this );
button->setInverted( true ); button->setInverted( true );
button->setChecked( true ); button->setChecked( true );
} }
} }
}; };
class CheckButtonBox : public QskLinearBox class CheckButtonBox : public ButtonBox
{ {
public: public:
CheckButtonBox( QQuickItem* parent = nullptr ) CheckButtonBox( QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, 2, parent ) : ButtonBox( Qt::Horizontal, 2, parent )
{ {
setSpacing( 20 );
setExtraSpacingAt( Qt::LeftEdge | Qt::RightEdge | Qt::BottomEdge );
auto button1 = new QskCheckBox( "Options 1", this ); auto button1 = new QskCheckBox( "Options 1", this );
button1->setChecked( true ); button1->setChecked( true );
@ -160,15 +160,12 @@ namespace
} }
}; };
class RadioButtonBox : public QskLinearBox class RadioButtonBox : public ButtonBox
{ {
public: public:
RadioButtonBox( QQuickItem* parent = nullptr ) RadioButtonBox( QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, parent ) : ButtonBox( Qt::Horizontal, parent )
{ {
setSpacing( 20 );
setExtraSpacingAt( Qt::LeftEdge | Qt::RightEdge | Qt::BottomEdge );
new QskRadioBox( { "One", "Two", "Three" }, this ); new QskRadioBox( { "One", "Two", "Three" }, this );
auto radioBox = new QskRadioBox( { "One", "Two", "Three" }, this ); auto radioBox = new QskRadioBox( { "One", "Two", "Three" }, this );
@ -180,18 +177,16 @@ namespace
ButtonPage::ButtonPage( QQuickItem* parent ) ButtonPage::ButtonPage( QQuickItem* parent )
: Page( Qt::Vertical, parent ) : Page( Qt::Vertical, parent )
{ {
setSpacing( 40 ); setSpacing( 20 );
populate();
}
void ButtonPage::populate() new PushButtonBox( this );
{
new ButtonBox( this );
new QskSeparator( Qt::Horizontal, this );
new SwitchButtonBox( this );
new QskSeparator( Qt::Horizontal, this ); new QskSeparator( Qt::Horizontal, this );
auto hBox = new QskLinearBox( Qt::Horizontal, this ); auto hBox = new QskLinearBox( Qt::Horizontal, this );
new SwitchButtonBox( hBox );
new QskSeparator( Qt::Vertical, hBox );
new CheckButtonBox( hBox ); new CheckButtonBox( hBox );
new QskSeparator( Qt::Vertical, hBox );
new RadioButtonBox( hBox ); new RadioButtonBox( hBox );
} }

View File

@ -11,7 +11,4 @@ class ButtonPage : public Page
{ {
public: public:
ButtonPage( QQuickItem* = nullptr ); ButtonPage( QQuickItem* = nullptr );
private:
void populate();
}; };

View File

@ -178,6 +178,8 @@ namespace
Header( QQuickItem* parent = nullptr ) Header( QQuickItem* parent = nullptr )
: QskLinearBox( Qt::Horizontal, parent ) : QskLinearBox( Qt::Horizontal, parent )
{ {
setPaddingHint( QskBox::Panel, 5 );
initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::Fixed ); initSizePolicy( QskSizePolicy::Ignored, QskSizePolicy::Fixed );
setPanel( true ); setPanel( true );