mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-22 10:17:10 +00:00
Added ability to change volume of specific notifications from settings.
This commit is contained in:
parent
85054e5987
commit
21dcb7f8ef
@ -553,12 +553,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
"lng_notification_title_private_chats" = "Notifications for private chats";
|
"lng_notification_title_private_chats" = "Notifications for private chats";
|
||||||
"lng_notification_about_private_chats#one" = "Please note that **{count} chat** is listed as an exception and won't be affected by this change.";
|
"lng_notification_about_private_chats#one" = "Please note that **{count} chat** is listed as an exception and won't be affected by this change.";
|
||||||
"lng_notification_about_private_chats#other" = "Please note that **{count} chats** are listed as exceptions and won't be affected by this change.";
|
"lng_notification_about_private_chats#other" = "Please note that **{count} chats** are listed as exceptions and won't be affected by this change.";
|
||||||
|
"lng_notification_volume_private_chats" = "Notifications volume for private chats";
|
||||||
"lng_notification_title_groups" = "Notifications for groups";
|
"lng_notification_title_groups" = "Notifications for groups";
|
||||||
"lng_notification_about_groups#one" = "Please note that **{count} group** is listed as an exception and won't be affected by this change.";
|
"lng_notification_about_groups#one" = "Please note that **{count} group** is listed as an exception and won't be affected by this change.";
|
||||||
"lng_notification_about_groups#other" = "Please note that **{count} groups** are listed as exceptions and won't be affected by this change.";
|
"lng_notification_about_groups#other" = "Please note that **{count} groups** are listed as exceptions and won't be affected by this change.";
|
||||||
|
"lng_notification_volume_groups" = "Notifications volume for groups";
|
||||||
"lng_notification_title_channels" = "Notifications for channels";
|
"lng_notification_title_channels" = "Notifications for channels";
|
||||||
"lng_notification_about_channels#one" = "Please note that **{count} channel** is listed as an exception and won't be affected by this change.";
|
"lng_notification_about_channels#one" = "Please note that **{count} channel** is listed as an exception and won't be affected by this change.";
|
||||||
"lng_notification_about_channels#other" = "Please note that **{count} channels** are listed as exceptions and won't be affected by this change.";
|
"lng_notification_about_channels#other" = "Please note that **{count} channels** are listed as exceptions and won't be affected by this change.";
|
||||||
|
"lng_notification_volume_channel" = "Notifications volume for channels";
|
||||||
"lng_notification_exceptions_view" = "View exceptions";
|
"lng_notification_exceptions_view" = "View exceptions";
|
||||||
"lng_notification_enable" = "Enable notifications";
|
"lng_notification_enable" = "Enable notifications";
|
||||||
"lng_notification_sound" = "Sound";
|
"lng_notification_sound" = "Sound";
|
||||||
@ -6335,6 +6338,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
|
|
||||||
"lng_ringtones_box_title" = "Notification Sound";
|
"lng_ringtones_box_title" = "Notification Sound";
|
||||||
"lng_ringtones_box_cloud_subtitle" = "Choose your tone";
|
"lng_ringtones_box_cloud_subtitle" = "Choose your tone";
|
||||||
|
"lng_ringtones_box_volume" = "Volume";
|
||||||
"lng_ringtones_box_upload_choose" = "Choose a tone";
|
"lng_ringtones_box_upload_choose" = "Choose a tone";
|
||||||
"lng_ringtones_box_upload_button" = "Upload Sound";
|
"lng_ringtones_box_upload_button" = "Upload Sound";
|
||||||
"lng_ringtones_box_about" = "Right click on any short voice note or MP3 file in chat and select \"Save for Notifications\". It will appear here.";
|
"lng_ringtones_box_about" = "Right click on any short voice note or MP3 file in chat and select \"Save for Notifications\". It will appear here.";
|
||||||
|
@ -7,8 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
*/
|
*/
|
||||||
#include "boxes/ringtones_box.h"
|
#include "boxes/ringtones_box.h"
|
||||||
|
|
||||||
|
#include "data/notify/data_peer_notify_volume.h"
|
||||||
|
#include "data/notify/data_peer_notify_settings.h"
|
||||||
#include "api/api_ringtones.h"
|
#include "api/api_ringtones.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
|
#include "ui/widgets/continuous_sliders.h"
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
#include "base/timer_rpl.h"
|
#include "base/timer_rpl.h"
|
||||||
@ -21,11 +24,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "data/data_document_media.h"
|
#include "data/data_document_media.h"
|
||||||
#include "data/data_document_resolver.h"
|
#include "data/data_document_resolver.h"
|
||||||
#include "data/data_thread.h"
|
#include "data/data_thread.h"
|
||||||
|
#include "data/data_peer.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/notify/data_notify_settings.h"
|
#include "data/notify/data_notify_settings.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
|
#include "main/main_session_settings.h"
|
||||||
#include "media/audio/media_audio.h"
|
#include "media/audio/media_audio.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
#include "platform/platform_notifications_manager.h"
|
#include "platform/platform_notifications_manager.h"
|
||||||
#include "settings/settings_common.h"
|
#include "settings/settings_common.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
@ -111,7 +117,8 @@ void RingtonesBox(
|
|||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
Data::NotifySound selected,
|
Data::NotifySound selected,
|
||||||
Fn<void(Data::NotifySound)> save) {
|
Fn<void(Data::NotifySound)> save,
|
||||||
|
Data::VolumeController volumeController) {
|
||||||
box->setTitle(tr::lng_ringtones_box_title());
|
box->setTitle(tr::lng_ringtones_box_title());
|
||||||
|
|
||||||
const auto container = box->verticalLayout();
|
const auto container = box->verticalLayout();
|
||||||
@ -320,6 +327,14 @@ void RingtonesBox(
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Ui::AddRingtonesVolumeSlider(
|
||||||
|
container,
|
||||||
|
state->group->value() | rpl::map([=](int value) {
|
||||||
|
return value != kNoSoundValue;
|
||||||
|
}),
|
||||||
|
tr::lng_ringtones_box_volume(),
|
||||||
|
volumeController);
|
||||||
|
|
||||||
box->addSkip(st::ringtonesBoxSkip);
|
box->addSkip(st::ringtonesBoxSkip);
|
||||||
Ui::AddDividerText(container, tr::lng_ringtones_box_about());
|
Ui::AddDividerText(container, tr::lng_ringtones_box_about());
|
||||||
|
|
||||||
@ -345,5 +360,5 @@ void ThreadRingtonesBox(
|
|||||||
const auto now = thread->owner().notifySettings().sound(thread);
|
const auto now = thread->owner().notifySettings().sound(thread);
|
||||||
RingtonesBox(box, &thread->session(), now, [=](Data::NotifySound sound) {
|
RingtonesBox(box, &thread->session(), now, [=](Data::NotifySound sound) {
|
||||||
thread->owner().notifySettings().update(thread, {}, {}, sound);
|
thread->owner().notifySettings().update(thread, {}, {}, sound);
|
||||||
});
|
}, Data::ThreadRingtonesVolumeController(thread));
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace Data {
|
|||||||
struct NotifySound;
|
struct NotifySound;
|
||||||
class Thread;
|
class Thread;
|
||||||
enum class DefaultNotify : uint8_t;
|
enum class DefaultNotify : uint8_t;
|
||||||
|
struct VolumeController;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
@ -29,7 +30,8 @@ void RingtonesBox(
|
|||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
Data::NotifySound selected,
|
Data::NotifySound selected,
|
||||||
Fn<void(Data::NotifySound)> save);
|
Fn<void(Data::NotifySound)> save,
|
||||||
|
Data::VolumeController volumeController);
|
||||||
|
|
||||||
void ThreadRingtonesBox(
|
void ThreadRingtonesBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
|
@ -253,6 +253,7 @@ Descriptor ThreadDescriptor(not_null<Data::Thread*> thread) {
|
|||||||
.currentSound = currentSound,
|
.currentSound = currentSound,
|
||||||
.updateSound = updateSound,
|
.updateSound = updateSound,
|
||||||
.updateMutePeriod = updateMutePeriod,
|
.updateMutePeriod = updateMutePeriod,
|
||||||
|
.volumeController = Data::ThreadRingtonesVolumeController(thread),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,6 +291,7 @@ Descriptor DefaultDescriptor(
|
|||||||
.currentSound = currentSound,
|
.currentSound = currentSound,
|
||||||
.updateSound = updateSound,
|
.updateSound = updateSound,
|
||||||
.updateMutePeriod = updateMutePeriod,
|
.updateMutePeriod = updateMutePeriod,
|
||||||
|
.volumeController = DefaultRingtonesVolumeController(session, type),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +306,8 @@ void FillMuteMenu(
|
|||||||
RingtonesBox,
|
RingtonesBox,
|
||||||
session,
|
session,
|
||||||
*currentSound,
|
*currentSound,
|
||||||
descriptor.updateSound));
|
descriptor.updateSound,
|
||||||
|
descriptor.volumeController));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
menu->addAction(
|
menu->addAction(
|
||||||
|
@ -7,10 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "data/notify/data_peer_notify_volume.h" // VolumeController
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
class Thread;
|
class Thread;
|
||||||
struct NotifySound;
|
struct NotifySound;
|
||||||
enum class DefaultNotify : uint8_t;
|
enum class DefaultNotify : uint8_t;
|
||||||
|
struct VolumeController;
|
||||||
} // namespace Data
|
} // namespace Data
|
||||||
|
|
||||||
namespace Main {
|
namespace Main {
|
||||||
@ -31,6 +34,7 @@ struct Descriptor {
|
|||||||
Fn<std::optional<Data::NotifySound>()> currentSound;
|
Fn<std::optional<Data::NotifySound>()> currentSound;
|
||||||
Fn<void(Data::NotifySound)> updateSound;
|
Fn<void(Data::NotifySound)> updateSound;
|
||||||
Fn<void(TimeId)> updateMutePeriod;
|
Fn<void(TimeId)> updateMutePeriod;
|
||||||
|
Data::VolumeController volumeController;
|
||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] Descriptor ThreadDescriptor(not_null<Data::Thread*> thread);
|
[[nodiscard]] Descriptor ThreadDescriptor(not_null<Data::Thread*> thread);
|
||||||
|
@ -380,6 +380,15 @@ void ExceptionsController::sort() {
|
|||||||
Unexpected("Type in Title.");
|
Unexpected("Type in Title.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] rpl::producer<QString> VolumeSubtitle(Notify type) {
|
||||||
|
switch (type) {
|
||||||
|
case Notify::User: return tr::lng_notification_volume_private_chats();
|
||||||
|
case Notify::Group: return tr::lng_notification_volume_groups();
|
||||||
|
case Notify::Broadcast: return tr::lng_notification_volume_channel();
|
||||||
|
}
|
||||||
|
Unexpected("Type in VolumeSubtitle.");
|
||||||
|
}
|
||||||
|
|
||||||
void SetupChecks(
|
void SetupChecks(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
@ -479,9 +488,8 @@ void SetupChecks(
|
|||||||
|
|
||||||
Ui::AddRingtonesVolumeSlider(
|
Ui::AddRingtonesVolumeSlider(
|
||||||
toneInner,
|
toneInner,
|
||||||
true,
|
|
||||||
rpl::single(true),
|
rpl::single(true),
|
||||||
rpl::single(u"Volume"_q),
|
VolumeSubtitle(type),
|
||||||
DefaultRingtonesVolumeController(session, type));
|
DefaultRingtonesVolumeController(session, type));
|
||||||
|
|
||||||
enabled->toggledValue(
|
enabled->toggledValue(
|
||||||
|
@ -36,8 +36,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
#include "api/api_updates.h"
|
#include "api/api_updates.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_session.h"
|
|
||||||
#include "main/main_domain.h"
|
#include "main/main_domain.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "main/main_session_settings.h"
|
||||||
#include "ui/text/text_utilities.h"
|
#include "ui/text/text_utilities.h"
|
||||||
|
|
||||||
#include <QtGui/QWindow>
|
#include <QtGui/QWindow>
|
||||||
@ -695,9 +696,18 @@ void System::showNext() {
|
|||||||
if (settings.soundNotify()) {
|
if (settings.soundNotify()) {
|
||||||
const auto owner = &alertThread->owner();
|
const auto owner = &alertThread->owner();
|
||||||
const auto id = owner->notifySettings().sound(alertThread).id;
|
const auto id = owner->notifySettings().sound(alertThread).id;
|
||||||
|
auto volume
|
||||||
|
= owner->session().settings().ringtoneVolume(
|
||||||
|
alertThread->peer()->id,
|
||||||
|
alertThread->topicRootId(),
|
||||||
|
alertThread->monoforumPeerId());
|
||||||
|
if (!volume) {
|
||||||
|
volume = owner->session().settings().ringtoneVolume(
|
||||||
|
Data::DefaultNotifyType(alertThread->peer()));
|
||||||
|
}
|
||||||
_manager->maybePlaySound(crl::guard(&owner->session(), [=] {
|
_manager->maybePlaySound(crl::guard(&owner->session(), [=] {
|
||||||
const auto track = lookupSound(owner, id);
|
const auto track = lookupSound(owner, id);
|
||||||
track->playOnce();
|
track->playOnce(volume ? volume * 0.01 : 0);
|
||||||
Media::Player::mixer()->suppressAll(track->getLengthMs());
|
Media::Player::mixer()->suppressAll(track->getLengthMs());
|
||||||
Media::Player::mixer()->scheduleFaderCallback();
|
Media::Player::mixer()->scheduleFaderCallback();
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user