From ef99f0ef36f66ee4f829deedcc5444b3131172c8 Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 3 Jun 2024 19:39:34 +0200 Subject: [PATCH] Add volume increment setting --- src/core/player.cpp | 6 ++-- src/core/player.h | 1 + src/settings/behavioursettingspage.cpp | 4 +++ src/settings/behavioursettingspage.ui | 47 +++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/core/player.cpp b/src/core/player.cpp index 4d72c1ca2..c6c390279 100644 --- a/src/core/player.cpp +++ b/src/core/player.cpp @@ -96,6 +96,7 @@ Player::Player(Application *app, QObject *parent) greyout_(true), menu_previousmode_(BehaviourSettingsPage::PreviousBehaviour::DontRestart), seek_step_sec_(10), + volume_increment_(5), play_offset_nanosec_(0) { Settings s; @@ -217,6 +218,7 @@ void Player::ReloadSettings() { s.beginGroup(BehaviourSettingsPage::kSettingsGroup); menu_previousmode_ = static_cast(s.value("menu_previousmode", static_cast(BehaviourSettingsPage::PreviousBehaviour::DontRestart)).toInt()); seek_step_sec_ = s.value("seek_step_sec", 10).toInt(); + volume_increment_ = s.value("volume_increment", 5).toUInt(); s.endGroup(); engine_->ReloadSettings(); @@ -700,7 +702,7 @@ void Player::SetVolume(const uint volume) { void Player::VolumeUp() { uint old_volume = GetVolume(); - uint new_volume = std::min(old_volume + 5, static_cast(100)); + uint new_volume = std::min(old_volume + volume_increment_, static_cast(100)); if (new_volume == old_volume) return; SetVolume(new_volume); @@ -709,7 +711,7 @@ void Player::VolumeUp() { void Player::VolumeDown() { uint old_volume = GetVolume(); - uint new_volume = static_cast(std::max(static_cast(old_volume) - 5, 0)); + uint new_volume = static_cast(std::max(static_cast(old_volume) - static_cast(volume_increment_), 0)); if (new_volume == old_volume) return; SetVolume(new_volume); diff --git a/src/core/player.h b/src/core/player.h index 9902ac5e5..95e67b903 100644 --- a/src/core/player.h +++ b/src/core/player.h @@ -244,6 +244,7 @@ class Player : public PlayerInterface { bool greyout_; BehaviourSettingsPage::PreviousBehaviour menu_previousmode_; int seek_step_sec_; + uint volume_increment_; QDateTime pause_time_; quint64 play_offset_nanosec_; diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp index dc56e2a86..5865b5a3c 100644 --- a/src/settings/behavioursettingspage.cpp +++ b/src/settings/behavioursettingspage.cpp @@ -214,6 +214,8 @@ void BehaviourSettingsPage::Load() { ui_->spinbox_seekstepsec->setValue(s.value("seek_step_sec", 10).toInt()); + ui_->spinbox_volumeincrement->setValue(s.value("volume_increment", 5).toInt()); + s.endGroup(); Init(ui_->layout_behavioursettingspage->parentWidget()); @@ -263,6 +265,8 @@ void BehaviourSettingsPage::Save() { s.setValue("seek_step_sec", ui_->spinbox_seekstepsec->value()); + s.setValue("volume_increment", ui_->spinbox_volumeincrement->value()); + s.endGroup(); } diff --git a/src/settings/behavioursettingspage.ui b/src/settings/behavioursettingspage.ui index b5456ed1a..fe557bafd 100644 --- a/src/settings/behavioursettingspage.ui +++ b/src/settings/behavioursettingspage.ui @@ -7,7 +7,7 @@ 0 0 572 - 915 + 931 @@ -326,6 +326,51 @@ + + + + Volume Increment + + + + + + Volume Increment + + + + + + + + + + 1 + + + 25 + + + 5 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + +