enforce constraints

This commit is contained in:
RickyRister 2025-02-24 01:57:40 -08:00
parent f7a8e53d18
commit c0be0b8692
2 changed files with 33 additions and 4 deletions

View file

@ -401,13 +401,13 @@ AppearanceSettingsPage::AppearanceSettingsPage()
cardViewInitialRowsMaxBox.setRange(1, 999); cardViewInitialRowsMaxBox.setRange(1, 999);
cardViewInitialRowsMaxBox.setValue(SettingsCache::instance().getCardViewInitialRowsMax()); cardViewInitialRowsMaxBox.setValue(SettingsCache::instance().getCardViewInitialRowsMax());
connect(&cardViewInitialRowsMaxBox, qOverload<int>(&QSpinBox::valueChanged), &SettingsCache::instance(), connect(&cardViewInitialRowsMaxBox, qOverload<int>(&QSpinBox::valueChanged), this,
&SettingsCache::setCardViewInitialRowsMax); &AppearanceSettingsPage::cardViewInitialRowsMaxChanged);
cardViewExpandedRowsMaxBox.setRange(1, 999); cardViewExpandedRowsMaxBox.setRange(1, 999);
cardViewExpandedRowsMaxBox.setValue(SettingsCache::instance().getCardViewExpandedRowsMax()); cardViewExpandedRowsMaxBox.setValue(SettingsCache::instance().getCardViewExpandedRowsMax());
connect(&cardViewExpandedRowsMaxBox, qOverload<int>(&QSpinBox::valueChanged), &SettingsCache::instance(), connect(&cardViewExpandedRowsMaxBox, qOverload<int>(&QSpinBox::valueChanged), this,
&SettingsCache::setCardViewExpandedRowsMax); &AppearanceSettingsPage::cardViewExpandedRowsMaxChanged);
auto *cardsGrid = new QGridLayout; auto *cardsGrid = new QGridLayout;
cardsGrid->addWidget(&displayCardNamesCheckBox, 0, 0, 1, 2); cardsGrid->addWidget(&displayCardNamesCheckBox, 0, 0, 1, 2);
@ -507,6 +507,32 @@ void AppearanceSettingsPage::showShortcutsChanged(QT_STATE_CHANGED_T value)
qApp->setAttribute(Qt::AA_DontShowShortcutsInContextMenus, value == 0); // 0 = unchecked qApp->setAttribute(Qt::AA_DontShowShortcutsInContextMenus, value == 0); // 0 = unchecked
} }
/**
* Updates the settings for cardViewInitialRowsMax.
* Forces expanded rows max to always be >= initial rows max
* @param value The new value
*/
void AppearanceSettingsPage::cardViewInitialRowsMaxChanged(int value)
{
SettingsCache::instance().setCardViewInitialRowsMax(value);
if (cardViewExpandedRowsMaxBox.value() < value) {
cardViewExpandedRowsMaxBox.setValue(value);
}
}
/**
* Updates the settings for cardViewExpandedRowsMax.
* Forces initial rows max to always be <= expanded rows max
* @param value The new value
*/
void AppearanceSettingsPage::cardViewExpandedRowsMaxChanged(int value)
{
SettingsCache::instance().setCardViewExpandedRowsMax(value);
if (cardViewInitialRowsMaxBox.value() > value) {
cardViewInitialRowsMaxBox.setValue(value);
}
}
void AppearanceSettingsPage::retranslateUi() void AppearanceSettingsPage::retranslateUi()
{ {
themeGroupBox->setTitle(tr("Theme settings")); themeGroupBox->setTitle(tr("Theme settings"));

View file

@ -91,6 +91,9 @@ private slots:
void openThemeLocation(); void openThemeLocation();
void showShortcutsChanged(QT_STATE_CHANGED_T enabled); void showShortcutsChanged(QT_STATE_CHANGED_T enabled);
void cardViewInitialRowsMaxChanged(int value);
void cardViewExpandedRowsMaxChanged(int value);
private: private:
QLabel themeLabel; QLabel themeLabel;
QComboBox themeBox; QComboBox themeBox;