mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
* [QtUtils] Add parent lookup, layout clearing, scroll area and monospace helpers * [QtUtils] Adopt shared Qt helpers across the client * [QtUtils] Add layout creation and relayout helpers * Swap parameter order (spacing before margin) and remove static from relayout() * [QtUtils] Use relayout() after rebuilding dynamic layouts * [QtUtils] Use makeLayout() for zero-margin layouts * Consolidate setSpacing() calls into makeLayout() using new parameter order --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
62 lines
2.2 KiB
C++
62 lines
2.2 KiB
C++
#include "replay_quick_settings_widget.h"
|
|
|
|
#include "../../../client/settings/cache_settings.h"
|
|
#include "../quick_settings/settings_button_widget.h"
|
|
#include "libcockatrice/utility/macros.h"
|
|
|
|
#include <QDebug>
|
|
#include <QGridLayout>
|
|
#include <QLabel>
|
|
#include <QWidget>
|
|
#include <QtGlobal>
|
|
#include <libcockatrice/settings/interface_settings.h>
|
|
#include <libcockatrice/settings/personal_settings.h>
|
|
#include <libcockatrice/utility/qt_utils.h>
|
|
|
|
ReplayQuickSettingsWidget::ReplayQuickSettingsWidget(QWidget *parent) : SettingsButtonWidget(parent)
|
|
{
|
|
// fast forward speed
|
|
fastForwardSpeedBox.setMinimum(1);
|
|
fastForwardSpeedBox.setMaximum(99.9);
|
|
fastForwardSpeedBox.setDecimals(1);
|
|
fastForwardSpeedBox.setValue(SettingsCache::instance().userInterface().getFastForwardSpeed());
|
|
connect(&fastForwardSpeedBox, qOverload<double>(&QDoubleSpinBox::valueChanged), this,
|
|
&ReplayQuickSettingsWidget::actUpdateFastForwardSpeed);
|
|
|
|
skipEmptyCheckBox.setChecked(SettingsCache::instance().userInterface().getSkipEmptySections());
|
|
connect(&skipEmptyCheckBox, &QCheckBox::QT_STATE_CHANGED, this,
|
|
&ReplayQuickSettingsWidget::actUpdateSkipEmptySections);
|
|
|
|
// putting it all together
|
|
auto *widget = new QWidget;
|
|
auto *grid = QtUtils::makeLayout<QGridLayout>(widget);
|
|
grid->addWidget(&fastForwardSpeedLabel, 0, 0, 1, 1);
|
|
grid->addWidget(&fastForwardSpeedBox, 0, 1, 1, 1);
|
|
grid->addWidget(&skipEmptyCheckBox, 1, 0, 1, 2);
|
|
|
|
this->addSettingsWidget(widget);
|
|
|
|
connect(&SettingsCache::instance().personal(), &PersonalSettings::langChanged, this,
|
|
&ReplayQuickSettingsWidget::retranslateUi);
|
|
retranslateUi();
|
|
}
|
|
|
|
void ReplayQuickSettingsWidget::retranslateUi()
|
|
{
|
|
fastForwardSpeedLabel.setText(tr("Fast forward speed:"));
|
|
fastForwardSpeedBox.setSuffix("x");
|
|
|
|
skipEmptyCheckBox.setText(tr("Skip empty sections"));
|
|
}
|
|
|
|
void ReplayQuickSettingsWidget::actUpdateFastForwardSpeed(qreal value)
|
|
{
|
|
SettingsCache::instance().userInterface().setFastForwardSpeed(value);
|
|
emit fastForwardSpeedChanged(value);
|
|
}
|
|
|
|
void ReplayQuickSettingsWidget::actUpdateSkipEmptySections(QT_STATE_CHANGED_T value)
|
|
{
|
|
SettingsCache::instance().userInterface().setSkipEmptySections(value);
|
|
emit skipEmptySectionsChanged(value);
|
|
}
|