mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-16 23:42:15 -07:00
Refactor CardSizeWidget: don't update setting directly (#5903)
This commit is contained in:
parent
5b9cb4fc8d
commit
c4e42b94f9
4 changed files with 14 additions and 9 deletions
|
|
@ -34,14 +34,7 @@ CardSizeWidget::CardSizeWidget(QWidget *parent, FlowWidget *_flowWidget, int def
|
|||
|
||||
// Debounce setup
|
||||
debounceTimer.setSingleShot(true);
|
||||
connect(&debounceTimer, &QTimer::timeout, this, [this]() {
|
||||
// Check the type of the parent widget
|
||||
if (qobject_cast<PrintingSelector *>(parentWidget())) {
|
||||
SettingsCache::instance().setPrintingSelectorCardSize(pendingValue);
|
||||
} else if (qobject_cast<VisualDeckStorageWidget *>(parentWidget())) {
|
||||
SettingsCache::instance().setVisualDeckStorageCardSize(pendingValue);
|
||||
}
|
||||
});
|
||||
connect(&debounceTimer, &QTimer::timeout, this, [this] { emit cardSizeSettingUpdated(pendingValue); });
|
||||
|
||||
connect(cardSizeSlider, &QSlider::valueChanged, this, &CardSizeWidget::updateCardSizeSetting);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,17 @@ public:
|
|||
explicit CardSizeWidget(QWidget *parent, FlowWidget *flowWidget = nullptr, int defaultValue = 100);
|
||||
[[nodiscard]] QSlider *getSlider() const;
|
||||
|
||||
public slots:
|
||||
private slots:
|
||||
void updateCardSizeSetting(int newValue);
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Emitted when the slider value changes, but on a debounce timer.
|
||||
* Any parents that care about saving the value to settings should use this signal to indicate when to save the new
|
||||
* value to settings.
|
||||
*/
|
||||
void cardSizeSettingUpdated(int newValue);
|
||||
|
||||
private:
|
||||
QWidget *parent;
|
||||
FlowWidget *flowWidget;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue