From 73c8f6a2c0bd21e0afc0fbd5a5f6706afd426149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Mon, 24 Aug 2026 18:20:38 +0200 Subject: [PATCH] Resize on show Took 7 minutes --- .../playmat/playmat_settings_dialog.cpp | 39 ++++++++++++------- .../widgets/playmat/playmat_settings_dialog.h | 4 +- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/cockatrice/src/interface/widgets/playmat/playmat_settings_dialog.cpp b/cockatrice/src/interface/widgets/playmat/playmat_settings_dialog.cpp index a9be1c466..57706cf93 100644 --- a/cockatrice/src/interface/widgets/playmat/playmat_settings_dialog.cpp +++ b/cockatrice/src/interface/widgets/playmat/playmat_settings_dialog.cpp @@ -112,13 +112,16 @@ void PlaymatSettingsDialog::setupUi() }); auto *form = new QFormLayout; + controlsForm = form; cardNameLabel = new QLabel; printingLabel = new QLabel; form->addRow(cardNameLabel, searchBar); form->addRow(printingLabel, providerComboBox); // Numerical editors expose the raw PlaymatParams for precise input. They - // stay hidden until requested since the crop surface is the primary control. + // share the same form as the rows above so every field lines up on one + // label column. They stay hidden until requested since the crop surface + // is the primary control. marginLSpin = makeSpinBox(0.0, 0.95, currentParams.marginPctL, 0.01); marginRSpin = makeSpinBox(0.0, 0.95, currentParams.marginPctR, 0.01); verticalOffsetSpin = makeSpinBox(0.0, 1.0, currentParams.verticalOffset, 0.01); @@ -129,19 +132,13 @@ void PlaymatSettingsDialog::setupUi() verticalOffsetLabel = new QLabel; zoomLabel = new QLabel; - auto *numericForm = new QFormLayout; - numericForm->addRow(leftMarginLabel, marginLSpin); - numericForm->addRow(rightMarginLabel, marginRSpin); - numericForm->addRow(verticalOffsetLabel, verticalOffsetSpin); - numericForm->addRow(zoomLabel, zoomSpin); - numericEditors = new QWidget; - numericEditors->setLayout(numericForm); - numericEditors->setVisible(false); - showNumericEditorsCheck = new QCheckBox; form->addRow(showNumericEditorsCheck); - form->addRow(numericEditors); + form->addRow(leftMarginLabel, marginLSpin); + form->addRow(rightMarginLabel, marginRSpin); + form->addRow(verticalOffsetLabel, verticalOffsetSpin); + form->addRow(zoomLabel, zoomSpin); controlsGroup = new QGroupBox; controlsGroup->setLayout(form); @@ -169,8 +166,8 @@ void PlaymatSettingsDialog::setupUi() accept(); }); - // The crop surface is the primary control: dragging pans, wheel/keys zoom - //, editing exactly the same stored parameters the old numeric fields did. + // The crop surface is the primary control: dragging pans, wheel/keys zoom, + // editing exactly the same stored parameters the numeric fields do. connect(preview, &PlaymatPreviewWidget::paramsEdited, this, [this](const PlaymatParams &edited) { currentParams = edited; @@ -184,7 +181,8 @@ void PlaymatSettingsDialog::setupUi() zoomSpin->setValue(edited.zoom); }); - connect(showNumericEditorsCheck, &QCheckBox::toggled, numericEditors, &QWidget::setVisible); + connect(showNumericEditorsCheck, &QCheckBox::toggled, this, &PlaymatSettingsDialog::setNumericEditorsVisible); + setNumericEditorsVisible(false); connect(marginLSpin, &QDoubleSpinBox::valueChanged, this, &PlaymatSettingsDialog::onParamChanged); connect(marginRSpin, &QDoubleSpinBox::valueChanged, this, &PlaymatSettingsDialog::onParamChanged); @@ -293,6 +291,19 @@ void PlaymatSettingsDialog::onParamChanged() preview->setParams(currentParams); } +void PlaymatSettingsDialog::setNumericEditorsVisible(bool visible) +{ + controlsForm->setRowVisible(leftMarginLabel, visible); + controlsForm->setRowVisible(rightMarginLabel, visible); + controlsForm->setRowVisible(verticalOffsetLabel, visible); + controlsForm->setRowVisible(zoomLabel, visible); + + // A QDialog never resizes itself when its content requirements change, + // so revealing the editors would squeeze the crop group until the info + // caption ran into the preview. Re-fit the dialog to the new size hint. + adjustSize(); +} + void PlaymatSettingsDialog::retranslateUi() { setWindowTitle(tr("Playmat Settings")); diff --git a/cockatrice/src/interface/widgets/playmat/playmat_settings_dialog.h b/cockatrice/src/interface/widgets/playmat/playmat_settings_dialog.h index 56a2de757..9ef306a5f 100644 --- a/cockatrice/src/interface/widgets/playmat/playmat_settings_dialog.h +++ b/cockatrice/src/interface/widgets/playmat/playmat_settings_dialog.h @@ -9,6 +9,7 @@ class QCheckBox; class QComboBox; class QCompleter; class QDoubleSpinBox; +class QFormLayout; class QGroupBox; class QLabel; class QLineEdit; @@ -51,6 +52,7 @@ private: void populateProviderCombo(const QString &cardName); void initializeSearchBar(); void retranslateUi(); + void setNumericEditorsVisible(bool visible); QDoubleSpinBox *makeSpinBox(double min, double max, double value, double step); QLineEdit *searchBar; @@ -68,7 +70,7 @@ private: QLabel *printingLabel; QLabel *previewCaptionLabel; QCheckBox *showNumericEditorsCheck; - QWidget *numericEditors; + QFormLayout *controlsForm; QLabel *leftMarginLabel; QLabel *rightMarginLabel; QLabel *verticalOffsetLabel;