Add volume increment setting

This commit is contained in:
jj 2024-06-03 19:39:34 +02:00 committed by Jonas Kvinge
parent e357ba0125
commit ef99f0ef36
4 changed files with 55 additions and 3 deletions

View File

@ -96,6 +96,7 @@ Player::Player(Application *app, QObject *parent)
greyout_(true), greyout_(true),
menu_previousmode_(BehaviourSettingsPage::PreviousBehaviour::DontRestart), menu_previousmode_(BehaviourSettingsPage::PreviousBehaviour::DontRestart),
seek_step_sec_(10), seek_step_sec_(10),
volume_increment_(5),
play_offset_nanosec_(0) { play_offset_nanosec_(0) {
Settings s; Settings s;
@ -217,6 +218,7 @@ void Player::ReloadSettings() {
s.beginGroup(BehaviourSettingsPage::kSettingsGroup); s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
menu_previousmode_ = static_cast<BehaviourSettingsPage::PreviousBehaviour>(s.value("menu_previousmode", static_cast<int>(BehaviourSettingsPage::PreviousBehaviour::DontRestart)).toInt()); menu_previousmode_ = static_cast<BehaviourSettingsPage::PreviousBehaviour>(s.value("menu_previousmode", static_cast<int>(BehaviourSettingsPage::PreviousBehaviour::DontRestart)).toInt());
seek_step_sec_ = s.value("seek_step_sec", 10).toInt(); seek_step_sec_ = s.value("seek_step_sec", 10).toInt();
volume_increment_ = s.value("volume_increment", 5).toUInt();
s.endGroup(); s.endGroup();
engine_->ReloadSettings(); engine_->ReloadSettings();
@ -700,7 +702,7 @@ void Player::SetVolume(const uint volume) {
void Player::VolumeUp() { void Player::VolumeUp() {
uint old_volume = GetVolume(); uint old_volume = GetVolume();
uint new_volume = std::min(old_volume + 5, static_cast<uint>(100)); uint new_volume = std::min(old_volume + volume_increment_, static_cast<uint>(100));
if (new_volume == old_volume) return; if (new_volume == old_volume) return;
SetVolume(new_volume); SetVolume(new_volume);
@ -709,7 +711,7 @@ void Player::VolumeUp() {
void Player::VolumeDown() { void Player::VolumeDown() {
uint old_volume = GetVolume(); uint old_volume = GetVolume();
uint new_volume = static_cast<uint>(std::max(static_cast<int>(old_volume) - 5, 0)); uint new_volume = static_cast<uint>(std::max(static_cast<int>(old_volume) - static_cast<int>(volume_increment_), 0));
if (new_volume == old_volume) return; if (new_volume == old_volume) return;
SetVolume(new_volume); SetVolume(new_volume);

View File

@ -244,6 +244,7 @@ class Player : public PlayerInterface {
bool greyout_; bool greyout_;
BehaviourSettingsPage::PreviousBehaviour menu_previousmode_; BehaviourSettingsPage::PreviousBehaviour menu_previousmode_;
int seek_step_sec_; int seek_step_sec_;
uint volume_increment_;
QDateTime pause_time_; QDateTime pause_time_;
quint64 play_offset_nanosec_; quint64 play_offset_nanosec_;

View File

@ -214,6 +214,8 @@ void BehaviourSettingsPage::Load() {
ui_->spinbox_seekstepsec->setValue(s.value("seek_step_sec", 10).toInt()); ui_->spinbox_seekstepsec->setValue(s.value("seek_step_sec", 10).toInt());
ui_->spinbox_volumeincrement->setValue(s.value("volume_increment", 5).toInt());
s.endGroup(); s.endGroup();
Init(ui_->layout_behavioursettingspage->parentWidget()); Init(ui_->layout_behavioursettingspage->parentWidget());
@ -263,6 +265,8 @@ void BehaviourSettingsPage::Save() {
s.setValue("seek_step_sec", ui_->spinbox_seekstepsec->value()); s.setValue("seek_step_sec", ui_->spinbox_seekstepsec->value());
s.setValue("volume_increment", ui_->spinbox_volumeincrement->value());
s.endGroup(); s.endGroup();
} }

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>572</width> <width>572</width>
<height>915</height> <height>931</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -326,6 +326,51 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupbox_volumeincrement">
<property name="title">
<string>Volume Increment</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_volumeincrement">
<property name="text">
<string>Volume Increment</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinbox_volumeincrement">
<property name="suffix">
<string/>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>25</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item>
<spacer name="spacer_volumeincrement">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="spacer_bottom"> <spacer name="spacer_bottom">
<property name="orientation"> <property name="orientation">