mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-08-23 09:15:02 -05:00
add settings
This commit is contained in:
@@ -18,12 +18,17 @@ ReplayQuickSettingsWidget::ReplayQuickSettingsWidget(QWidget *parent) : Settings
|
||||
connect(&fastForwardSpeedBox, qOverload<double>(&QDoubleSpinBox::valueChanged), this,
|
||||
&ReplayQuickSettingsWidget::actUpdateFastForwardSpeed);
|
||||
|
||||
skipEmptyCheckBox.setChecked(SettingsCache::instance().interface().getSkipEmptySections());
|
||||
connect(&skipEmptyCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
|
||||
&ReplayQuickSettingsWidget::actUpdateSkipEmptySections);
|
||||
|
||||
// putting it all together
|
||||
auto *widget = new QWidget;
|
||||
auto *grid = new QGridLayout(widget);
|
||||
grid->setContentsMargins(0, 0, 0, 0);
|
||||
grid->addWidget(&fastForwardSpeedLabel, 0, 0, 1, 1);
|
||||
grid->addWidget(&fastForwardSpeedBox, 0, 1, 1, 1);
|
||||
grid->addWidget(&skipEmptyCheckBox, 1, 0, 1, 2);
|
||||
|
||||
this->addSettingsWidget(widget);
|
||||
|
||||
@@ -36,6 +41,8 @@ void ReplayQuickSettingsWidget::retranslateUi()
|
||||
{
|
||||
fastForwardSpeedLabel.setText(tr("Fast forward speed:"));
|
||||
fastForwardSpeedBox.setSuffix("x");
|
||||
|
||||
skipEmptyCheckBox.setText(tr("Skip empty sections"));
|
||||
}
|
||||
|
||||
void ReplayQuickSettingsWidget::actUpdateFastForwardSpeed(qreal value)
|
||||
@@ -43,3 +50,9 @@ void ReplayQuickSettingsWidget::actUpdateFastForwardSpeed(qreal value)
|
||||
SettingsCache::instance().interface().setFastForwardSpeed(value);
|
||||
emit fastForwardSpeedChanged(value);
|
||||
}
|
||||
|
||||
void ReplayQuickSettingsWidget::actUpdateSkipEmptySections(QT_STATE_CHANGED_T value)
|
||||
{
|
||||
SettingsCache::instance().interface().setSkipEmptySections(value);
|
||||
emit skipEmptySectionsChanged(value);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
#include "../../interface/widgets/quick_settings/settings_button_widget.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <libcockatrice/utility/macros.h>
|
||||
|
||||
class ReplayQuickSettingsWidget : public SettingsButtonWidget
|
||||
{
|
||||
@@ -16,13 +18,17 @@ public:
|
||||
|
||||
signals:
|
||||
void fastForwardSpeedChanged(qreal speed);
|
||||
void skipEmptySectionsChanged(bool skip);
|
||||
|
||||
private:
|
||||
QLabel fastForwardSpeedLabel;
|
||||
QDoubleSpinBox fastForwardSpeedBox;
|
||||
|
||||
QCheckBox skipEmptyCheckBox;
|
||||
|
||||
private slots:
|
||||
void actUpdateFastForwardSpeed(qreal value);
|
||||
void actUpdateSkipEmptySections(QT_STATE_CHANGED_T value);
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_REPLAY_QUICK_SETTINGS_WIDGET_H
|
||||
|
||||
@@ -32,6 +32,7 @@ public:
|
||||
[[nodiscard]] virtual bool getOpenDeckInNewTab() const = 0;
|
||||
[[nodiscard]] virtual int getRewindBufferingMs() const = 0;
|
||||
[[nodiscard]] virtual qreal getFastForwardSpeed() const = 0;
|
||||
[[nodiscard]] virtual bool getSkipEmptySections() const = 0;
|
||||
[[nodiscard]] virtual bool getStyleUserList() const = 0;
|
||||
[[nodiscard]] virtual bool getLeftJustified() const = 0;
|
||||
[[nodiscard]] virtual int getZoneViewGroupByIndex() const = 0;
|
||||
|
||||
@@ -125,6 +125,11 @@ qreal InterfaceSettings::getFastForwardSpeed() const
|
||||
return getValue("fastForwardSpeed", "replay", QString(), 10).toReal();
|
||||
}
|
||||
|
||||
bool InterfaceSettings::getSkipEmptySections() const
|
||||
{
|
||||
return getValue("skipEmptySections", "replay", QString(), false).toBool();
|
||||
}
|
||||
|
||||
bool InterfaceSettings::getStyleUserList() const
|
||||
{
|
||||
return getValue("styleUserList", "appearance", QString(), true).toBool();
|
||||
@@ -284,6 +289,11 @@ void InterfaceSettings::setFastForwardSpeed(qreal _value)
|
||||
setValue(_value, "fastForwardSpeed", "replay");
|
||||
}
|
||||
|
||||
void InterfaceSettings::setSkipEmptySections(bool _value)
|
||||
{
|
||||
setValue(_value, "skipEmptySections", "replay");
|
||||
}
|
||||
|
||||
void InterfaceSettings::setStyleUserList(bool _styleUserList)
|
||||
{
|
||||
setValue(_styleUserList, "styleUserList", "appearance");
|
||||
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
[[nodiscard]] bool getOpenDeckInNewTab() const override;
|
||||
[[nodiscard]] int getRewindBufferingMs() const override;
|
||||
[[nodiscard]] qreal getFastForwardSpeed() const override;
|
||||
[[nodiscard]] bool getSkipEmptySections() const override;
|
||||
[[nodiscard]] bool getStyleUserList() const override;
|
||||
[[nodiscard]] bool getLeftJustified() const override;
|
||||
[[nodiscard]] int getZoneViewGroupByIndex() const override;
|
||||
@@ -66,6 +67,7 @@ public:
|
||||
void setOpenDeckInNewTab(bool _openDeckInNewTab);
|
||||
void setRewindBufferingMs(int _rewindBufferingMs);
|
||||
void setFastForwardSpeed(qreal _value);
|
||||
void setSkipEmptySections(bool _value);
|
||||
void setStyleUserList(bool _styleUserList);
|
||||
void setLeftJustified(bool _leftJustified);
|
||||
void setZoneViewGroupByIndex(int _zoneViewGroupByIndex);
|
||||
|
||||
Reference in New Issue
Block a user