From 963f0aff27fbcb12e0fed88f47cc7a3a0008505a Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Tue, 22 Oct 2024 15:45:09 +0200 Subject: [PATCH] code adjusted to M3 wordings --- examples/gallery/inputs/InputPage.cpp | 65 +++++++++++++++++++-------- 1 file changed, 46 insertions(+), 19 deletions(-) diff --git a/examples/gallery/inputs/InputPage.cpp b/examples/gallery/inputs/InputPage.cpp index 07c6905d0..90d037f5e 100644 --- a/examples/gallery/inputs/InputPage.cpp +++ b/examples/gallery/inputs/InputPage.cpp @@ -15,24 +15,43 @@ namespace class Slider : public QskSlider { public: + enum Style + { + Continous, + Discrete, + Centered + }; + Slider( Qt::Orientation orientation, - bool snap, QQuickItem* parent = nullptr ) + Style style, QQuickItem* parent = nullptr ) : QskSlider( orientation, parent ) { setBoundaries( 0, 100 ); setValue( 30 ); - setSnap( snap ); - - if ( snap ) - { - setStepSize( 5 ); - setPageSteps( 4 ); - } - else + switch( style ) { - setStepSize( 1 ); - setPageSteps( 10 ); + case Discrete: + { + setSnap( true ); + setStepSize( 5 ); + setPageSteps( 4 ); + + break; + } + case Continous: + { + setSnap( false ); + setStepSize( 1 ); + setPageSteps( 10 ); + + break; + } + case Centered: + { + // TODO + break; + } } #if 0 @@ -75,11 +94,19 @@ namespace InputPage::InputPage( QQuickItem* parent ) : Page( Qt::Horizontal, parent ) { - auto sliderH = new Slider( Qt::Horizontal, false ); - auto discreteSliderH = new Slider( Qt::Horizontal, true ); + struct + { + Slider* continous; + Slider* descrete; + } sliders[2]; + + for ( int i = 0; i < 2; i++ ) + { + const auto orientation = static_cast< Qt::Orientation >( i + 1 ); - auto sliderV = new Slider( Qt::Vertical, false ); - auto discreteSliderV = new Slider( Qt::Vertical, true ); + sliders[i].continous = new Slider( orientation, Slider::Continous ); + sliders[i].descrete = new Slider( orientation, Slider::Discrete ); + } auto spinBox = new QskSpinBox( 0.0, 100.0, 1.0 ); spinBox->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed ); @@ -91,15 +118,15 @@ InputPage::InputPage( QQuickItem* parent ) vBox->setSpacing( 30 ); vBox->setExtraSpacingAt( Qt::RightEdge | Qt::BottomEdge ); - vBox->addItem( sliderH ); - vBox->addItem( discreteSliderH ); + vBox->addItem( sliders[0].continous ); + vBox->addItem( sliders[0].descrete ); vBox->addItem( inputBox ); vBox->addItem( spinBox ); auto mainBox = new QskLinearBox( Qt::Horizontal, this ); mainBox->setSpacing( 30 ); - mainBox->addItem( sliderV ); - mainBox->addItem( discreteSliderV ); + mainBox->addItem( sliders[1].continous ); + mainBox->addItem( sliders[1].descrete ); mainBox->addItem( vBox ); auto inputs = findChildren< QskBoundedValueInput* >();