mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-23 10:52:16 -07:00
Persist card size slider selection in SettingsCache.
This commit is contained in:
parent
2d59540f15
commit
61b33aa808
7 changed files with 36 additions and 4 deletions
|
|
@ -1,6 +1,8 @@
|
|||
#include "card_size_widget.h"
|
||||
|
||||
CardSizeWidget::CardSizeWidget(QWidget *parent, FlowWidget *flowWidget) : parent(parent), flowWidget(flowWidget)
|
||||
#include "../../../../settings/cache_settings.h"
|
||||
|
||||
CardSizeWidget::CardSizeWidget(QWidget *parent, FlowWidget *flowWidget, int defaultValue) : parent(parent), flowWidget(flowWidget)
|
||||
{
|
||||
cardSizeLayout = new QHBoxLayout(this);
|
||||
setLayout(cardSizeLayout);
|
||||
|
|
@ -9,7 +11,7 @@ CardSizeWidget::CardSizeWidget(QWidget *parent, FlowWidget *flowWidget) : parent
|
|||
cardSizeLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
cardSizeSlider = new QSlider(Qt::Horizontal, this);
|
||||
cardSizeSlider->setRange(50, 250);
|
||||
cardSizeSlider->setValue(100);
|
||||
cardSizeSlider->setValue(defaultValue);
|
||||
|
||||
cardSizeLayout->addWidget(cardSizeLabel);
|
||||
cardSizeLayout->addWidget(cardSizeSlider);
|
||||
|
|
@ -17,6 +19,13 @@ CardSizeWidget::CardSizeWidget(QWidget *parent, FlowWidget *flowWidget) : parent
|
|||
if (flowWidget != nullptr) {
|
||||
connect(cardSizeSlider, &QSlider::valueChanged, flowWidget, &FlowWidget::setMinimumSizeToMaxSizeHint);
|
||||
}
|
||||
|
||||
connect(cardSizeSlider, &QSlider::valueChanged, this, &CardSizeWidget::updateCardSizeSetting);
|
||||
}
|
||||
|
||||
void CardSizeWidget::updateCardSizeSetting(int newValue)
|
||||
{
|
||||
SettingsCache::instance().setPrintingSelectorCardSize(newValue);
|
||||
}
|
||||
|
||||
QSlider *CardSizeWidget::getSlider() const
|
||||
|
|
|
|||
|
|
@ -13,8 +13,10 @@ class CardSizeWidget : public QWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CardSizeWidget(QWidget *parent, FlowWidget *flowWidget = nullptr);
|
||||
explicit CardSizeWidget(QWidget *parent, FlowWidget *flowWidget = nullptr, int defaultValue = 100);
|
||||
QSlider *getSlider() const;
|
||||
public slots:
|
||||
void updateCardSizeSetting(int newValue);
|
||||
|
||||
private:
|
||||
QWidget *parent;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ PrintingSelector::PrintingSelector(QWidget *parent,
|
|||
flowWidget = new FlowWidget(this, Qt::ScrollBarAlwaysOff, Qt::ScrollBarAsNeeded);
|
||||
layout->addWidget(flowWidget);
|
||||
|
||||
cardSizeWidget = new CardSizeWidget(this);
|
||||
cardSizeWidget = new CardSizeWidget(this, flowWidget, SettingsCache::instance().getPrintingSelectorCardSize());
|
||||
layout->addWidget(cardSizeWidget);
|
||||
|
||||
cardSelectionBar = new PrintingSelectorCardSelectionWidget(this);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue