Examples: add scrollbar to allow viewing all options on Android

This fix is most relevant for Android for affine and gradients examples.
Currently, if the screen size is small the settings will show cramped
and not usable. Thus, adding a scrollbar to fix that.

Task-number: QTBUG-80717
Change-Id: Ic25460e5ce37a5c53bbcae48e11b6b787c45e999
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
Assam Boudjelthia 2020-02-23 23:37:11 +02:00
parent 8a6e1de87c
commit b711ee2555
2 changed files with 33 additions and 12 deletions

View File

@ -787,8 +787,8 @@ XFormWidget::XFormWidget(QWidget *parent)
view = new XFormView(this);
view->setMinimumSize(200, 200);
QGroupBox *mainGroup = new QGroupBox(this);
mainGroup->setFixedWidth(180);
QWidget *mainContentWidget = new QWidget();
QGroupBox *mainGroup = new QGroupBox(mainContentWidget);
mainGroup->setTitle(tr("Affine Transformations"));
QGroupBox *rotateGroup = new QGroupBox(mainGroup);
@ -837,10 +837,6 @@ XFormWidget::XFormWidget(QWidget *parent)
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
QHBoxLayout *viewLayout = new QHBoxLayout(this);
viewLayout->addWidget(view);
viewLayout->addWidget(mainGroup);
QVBoxLayout *rotateGroupLayout = new QVBoxLayout(rotateGroup);
rotateGroupLayout->addWidget(rotateSlider);
@ -871,6 +867,20 @@ XFormWidget::XFormWidget(QWidget *parent)
#endif
mainGroupLayout->addWidget(whatsThisButton);
mainGroup->setLayout(mainGroupLayout);
QVBoxLayout *mainContentLayout = new QVBoxLayout();
mainContentLayout->addWidget(mainGroup);
mainContentWidget->setLayout(mainContentLayout);
QScrollArea *mainScrollArea = new QScrollArea();
mainScrollArea->setWidget(mainContentWidget);
mainScrollArea->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
QHBoxLayout *viewLayout = new QHBoxLayout(this);
viewLayout->addWidget(view);
viewLayout->addWidget(mainScrollArea);
connect(rotateSlider, &QSlider::valueChanged, view, &XFormView::changeRotation);
connect(shearSlider, &QSlider::valueChanged, view, &XFormView::changeShear);
connect(scaleSlider, &QSlider::valueChanged, view, &XFormView::changeScale);

View File

@ -282,7 +282,8 @@ GradientWidget::GradientWidget(QWidget *parent)
m_renderer = new GradientRenderer(this);
QGroupBox *mainGroup = new QGroupBox(this);
QWidget *mainContentWidget = new QWidget();
QGroupBox *mainGroup = new QGroupBox(mainContentWidget);
mainGroup->setTitle(tr("Gradients"));
QGroupBox *editorGroup = new QGroupBox(mainGroup);
@ -327,11 +328,6 @@ GradientWidget::GradientWidget(QWidget *parent)
whatsThisButton->setText(tr("What's This?"));
whatsThisButton->setCheckable(true);
// Layouts
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->addWidget(m_renderer);
mainLayout->addWidget(mainGroup);
mainGroup->setFixedWidth(200);
QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup);
mainGroupLayout->addWidget(editorGroup);
@ -370,6 +366,21 @@ GradientWidget::GradientWidget(QWidget *parent)
defaultsGroupLayout->addWidget(default3Button);
editorGroupLayout->addWidget(default4Button);
mainGroup->setLayout(mainGroupLayout);
QVBoxLayout *mainContentLayout = new QVBoxLayout();
mainContentLayout->addWidget(mainGroup);
mainContentWidget->setLayout(mainContentLayout);
QScrollArea *mainScrollArea = new QScrollArea();
mainScrollArea->setWidget(mainContentWidget);
mainScrollArea->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
// Layouts
QHBoxLayout *mainLayout = new QHBoxLayout(this);
mainLayout->addWidget(m_renderer);
mainLayout->addWidget(mainScrollArea);
connect(m_editor, &GradientEditor::gradientStopsChanged,
m_renderer, &GradientRenderer::setGradientStops);
connect(m_linearButton, &QRadioButton::clicked,