2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-29 05:29:23 +00:00

Added global settings for master volume of notifications.

This commit is contained in:
23rd 2025-08-12 15:30:22 +03:00
parent e886ca16ff
commit 30ce6d3895
3 changed files with 20 additions and 3 deletions

View File

@ -240,7 +240,8 @@ QByteArray Settings::serialize() const {
+ Serialize::stringSize(_customFontFamily) + Serialize::stringSize(_customFontFamily)
+ sizeof(qint32) * 3 + sizeof(qint32) * 3
+ Serialize::bytearraySize(_tonsiteStorageToken) + Serialize::bytearraySize(_tonsiteStorageToken)
+ sizeof(qint32) * 8; + sizeof(qint32) * 8
+ sizeof(ushort);
auto result = QByteArray(); auto result = QByteArray();
result.reserve(size); result.reserve(size);
@ -402,7 +403,8 @@ QByteArray Settings::serialize() const {
<< SerializeVideoQuality(_videoQuality) << SerializeVideoQuality(_videoQuality)
<< qint32(_ivZoom.current()) << qint32(_ivZoom.current())
<< qint32(_systemDarkModeEnabled.current() ? 1 : 0) << qint32(_systemDarkModeEnabled.current() ? 1 : 0)
<< qint32(_quickDialogAction); << qint32(_quickDialogAction)
<< _notificationsVolume;
} }
Ensures(result.size() == size); Ensures(result.size() == size);
@ -532,6 +534,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
quint32 videoQuality = SerializeVideoQuality(_videoQuality); quint32 videoQuality = SerializeVideoQuality(_videoQuality);
quint32 chatFiltersHorizontal = _chatFiltersHorizontal.current() ? 1 : 0; quint32 chatFiltersHorizontal = _chatFiltersHorizontal.current() ? 1 : 0;
quint32 quickDialogAction = quint32(_quickDialogAction); quint32 quickDialogAction = quint32(_quickDialogAction);
ushort notificationsVolume = _notificationsVolume;
stream >> themesAccentColors; stream >> themesAccentColors;
if (!stream.atEnd()) { if (!stream.atEnd()) {
@ -863,6 +866,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
if (!stream.atEnd()) { if (!stream.atEnd()) {
stream >> quickDialogAction; stream >> quickDialogAction;
} }
if (!stream.atEnd()) {
stream >> notificationsVolume;
}
if (stream.status() != QDataStream::Ok) { if (stream.status() != QDataStream::Ok) {
LOG(("App Error: " LOG(("App Error: "
"Bad data for Core::Settings::constructFromSerialized()")); "Bad data for Core::Settings::constructFromSerialized()"));
@ -1085,6 +1091,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
_videoQuality = DeserializeVideoQuality(videoQuality); _videoQuality = DeserializeVideoQuality(videoQuality);
_chatFiltersHorizontal = (chatFiltersHorizontal == 1); _chatFiltersHorizontal = (chatFiltersHorizontal == 1);
_quickDialogAction = Dialogs::Ui::QuickDialogAction(quickDialogAction); _quickDialogAction = Dialogs::Ui::QuickDialogAction(quickDialogAction);
_notificationsVolume = notificationsVolume;
} }
QString Settings::getSoundPath(const QString &key) const { QString Settings::getSoundPath(const QString &key) const {
@ -1477,6 +1484,7 @@ void Settings::resetOnLastLogout() {
_videoQuality = {}; _videoQuality = {};
_chatFiltersHorizontal = false; _chatFiltersHorizontal = false;
_quickDialogAction = Dialogs::Ui::QuickDialogAction::Disabled; _quickDialogAction = Dialogs::Ui::QuickDialogAction::Disabled;
_notificationsVolume = 100;
_recentEmojiPreload.clear(); _recentEmojiPreload.clear();
_recentEmoji.clear(); _recentEmoji.clear();

View File

@ -950,6 +950,13 @@ public:
[[nodiscard]] Dialogs::Ui::QuickDialogAction quickDialogAction() const; [[nodiscard]] Dialogs::Ui::QuickDialogAction quickDialogAction() const;
void setQuickDialogAction(Dialogs::Ui::QuickDialogAction); void setQuickDialogAction(Dialogs::Ui::QuickDialogAction);
[[nodiscard]] ushort notificationsVolume() const {
return _notificationsVolume;
}
void setNotificationsVolume(ushort value) {
_notificationsVolume = value;
}
void resetOnLastLogout(); void resetOnLastLogout();
private: private:
@ -1093,6 +1100,8 @@ private:
Dialogs::Ui::QuickDialogAction _quickDialogAction Dialogs::Ui::QuickDialogAction _quickDialogAction
= Dialogs::Ui::QuickDialogAction::Disabled; = Dialogs::Ui::QuickDialogAction::Disabled;
ushort _notificationsVolume = 100;
QByteArray _photoEditorBrush; QByteArray _photoEditorBrush;
}; };

View File

@ -157,7 +157,7 @@ void Track::playWithLooping(bool looping, float64 volumeOverride) {
AL_GAIN, AL_GAIN,
(volumeOverride > 0) (volumeOverride > 0)
? volumeOverride ? volumeOverride
: _volume); : float64(Core::App().settings().notificationsVolume()) / 100.);
alSourcePlay(_alSource); alSourcePlay(_alSource);
_instance->trackStarted(this); _instance->trackStarted(this);
} }