mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 07:33:52 +02:00
Simplified settings of notification sound.
This commit is contained in:
parent
93563358ca
commit
4dd5be9356
10 changed files with 21 additions and 93 deletions
BIN
Telegram/Resources/icons/menu/sound_disable.png
Normal file
BIN
Telegram/Resources/icons/menu/sound_disable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 748 B |
BIN
Telegram/Resources/icons/menu/sound_disable@2x.png
Normal file
BIN
Telegram/Resources/icons/menu/sound_disable@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
BIN
Telegram/Resources/icons/menu/sound_disable@3x.png
Normal file
BIN
Telegram/Resources/icons/menu/sound_disable@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
Telegram/Resources/icons/menu/sound_enable.png
Normal file
BIN
Telegram/Resources/icons/menu/sound_enable.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 585 B |
BIN
Telegram/Resources/icons/menu/sound_enable@2x.png
Normal file
BIN
Telegram/Resources/icons/menu/sound_enable@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
BIN
Telegram/Resources/icons/menu/sound_enable@3x.png
Normal file
BIN
Telegram/Resources/icons/menu/sound_enable@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
|
@ -899,11 +899,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_mute_menu_duration" = "Mute for...";
|
"lng_mute_menu_duration" = "Mute for...";
|
||||||
"lng_mute_menu_duration_forever" = "Mute forever";
|
"lng_mute_menu_duration_forever" = "Mute forever";
|
||||||
"lng_mute_menu_duration_unmute" = "Unmute";
|
"lng_mute_menu_duration_unmute" = "Unmute";
|
||||||
"lng_mute_menu_sound_on" = "Sound On";
|
"lng_mute_menu_sound_on" = "Enable sound";
|
||||||
"lng_mute_menu_sound_off" = "Sound Off";
|
"lng_mute_menu_sound_off" = "Disable sound";
|
||||||
"lng_mute_box_title" = "Mute notifications for...";
|
"lng_mute_box_title" = "Mute notifications for...";
|
||||||
"lng_mute_box_no_notifications" = "No notifications";
|
|
||||||
"lng_mute_box_silent_notifications" = "Silent notifications";
|
|
||||||
"lng_mute_box_days#one" = "{count} day";
|
"lng_mute_box_days#one" = "{count} day";
|
||||||
"lng_mute_box_days#other" = "{count} days";
|
"lng_mute_box_days#other" = "{count} days";
|
||||||
"lng_mute_box_hours#one" = "{count} hour";
|
"lng_mute_box_hours#one" = "{count} hour";
|
||||||
|
|
|
@ -11,7 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "menu/menu_check_item.h"
|
|
||||||
#include "ui/boxes/choose_time.h"
|
#include "ui/boxes/choose_time.h"
|
||||||
#include "ui/effects/animation_value.h"
|
#include "ui/effects/animation_value.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
|
@ -99,99 +98,28 @@ void MuteItem::paintEvent(QPaintEvent *e) {
|
||||||
icon.paint(p, _itemIconPosition, width(), color);
|
icon.paint(p, _itemIconPosition, width(), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FillSoundMenu(
|
|
||||||
not_null<Ui::PopupMenu*> menu,
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
rpl::producer<QString> &&soundOnText,
|
|
||||||
rpl::producer<QString> &&soundOffText,
|
|
||||||
Fn<void(bool)> notifySound) {
|
|
||||||
const auto createView = [&](rpl::producer<QString> &&text, bool checked) {
|
|
||||||
auto item = base::make_unique_q<Menu::ItemWithCheck>(
|
|
||||||
menu->menu(),
|
|
||||||
st::popupMenuWithIcons.menu,
|
|
||||||
new QAction(QString(), menu->menu()),
|
|
||||||
nullptr,
|
|
||||||
nullptr);
|
|
||||||
std::move(
|
|
||||||
text
|
|
||||||
) | rpl::start_with_next([action = item->action()](QString text) {
|
|
||||||
action->setText(text);
|
|
||||||
}, item->lifetime());
|
|
||||||
item->init(checked);
|
|
||||||
const auto view = item->checkView();
|
|
||||||
menu->addAction(std::move(item));
|
|
||||||
return view;
|
|
||||||
};
|
|
||||||
|
|
||||||
const auto soundIsNone = peer->owner().notifySoundIsNone(peer);
|
|
||||||
const auto soundOn = createView(std::move(soundOnText), !soundIsNone);
|
|
||||||
const auto soundOff = createView(std::move(soundOffText), soundIsNone);
|
|
||||||
|
|
||||||
soundOn->checkedChanges(
|
|
||||||
) | rpl::start_with_next([=](bool checked) {
|
|
||||||
soundOff->setChecked(!checked, anim::type::normal);
|
|
||||||
notifySound(!checked);
|
|
||||||
}, menu->lifetime());
|
|
||||||
soundOff->checkedChanges(
|
|
||||||
) | rpl::start_with_next([=](bool checked) {
|
|
||||||
soundOn->setChecked(!checked, anim::type::normal);
|
|
||||||
notifySound(checked);
|
|
||||||
}, menu->lifetime());
|
|
||||||
}
|
|
||||||
|
|
||||||
void MuteBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
void MuteBox(not_null<Ui::GenericBox*> box, not_null<PeerData*> peer) {
|
||||||
struct State {
|
struct State {
|
||||||
base::unique_qptr<Ui::PopupMenu> menu;
|
|
||||||
rpl::variable<bool> noSoundChanges;
|
|
||||||
int lastSeconds = 0;
|
int lastSeconds = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto chooseTimeResult = ChooseTimeWidget(box, kMuteDurSecondsDefault);
|
auto chooseTimeResult = ChooseTimeWidget(box, kMuteDurSecondsDefault);
|
||||||
box->addRow(std::move(chooseTimeResult.widget));
|
box->addRow(std::move(chooseTimeResult.widget));
|
||||||
|
|
||||||
const auto state = box->lifetime().make_state<State>(State{
|
const auto state = box->lifetime().make_state<State>();
|
||||||
.noSoundChanges = false,
|
|
||||||
});
|
|
||||||
|
|
||||||
box->setTitle(tr::lng_mute_box_title());
|
box->setTitle(tr::lng_mute_box_title());
|
||||||
|
|
||||||
const auto topButton = box->addTopButton(st::infoTopBarMenu);
|
auto confirmText = std::move(
|
||||||
topButton->setClickedCallback([=] {
|
chooseTimeResult.secondsValue
|
||||||
if (state->menu) {
|
) | rpl::map([=](int seconds) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
|
||||||
topButton,
|
|
||||||
st::popupMenuWithIcons);
|
|
||||||
FillSoundMenu(
|
|
||||||
state->menu.get(),
|
|
||||||
peer,
|
|
||||||
tr::lng_mute_box_no_notifications(),
|
|
||||||
tr::lng_mute_box_silent_notifications(),
|
|
||||||
[=](bool silent) {
|
|
||||||
state->noSoundChanges = silent;
|
|
||||||
});
|
|
||||||
state->menu->popup(QCursor::pos());
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
|
|
||||||
auto confirmText = rpl::combine(
|
|
||||||
std::move(chooseTimeResult.secondsValue),
|
|
||||||
state->noSoundChanges.value()
|
|
||||||
) | rpl::map([=](int seconds, bool noSound) {
|
|
||||||
state->lastSeconds = seconds;
|
state->lastSeconds = seconds;
|
||||||
return !seconds
|
return !seconds
|
||||||
? tr::lng_mute_menu_unmute()
|
? tr::lng_mute_menu_unmute()
|
||||||
: noSound
|
|
||||||
? tr::lng_mute_box_silent_notifications()
|
|
||||||
: tr::lng_mute_menu_mute();
|
: tr::lng_mute_menu_mute();
|
||||||
}) | rpl::flatten_latest();
|
}) | rpl::flatten_latest();
|
||||||
const auto confirm = box->addButton(std::move(confirmText), [=] {
|
const auto confirm = box->addButton(std::move(confirmText), [=] {
|
||||||
peer->owner().updateNotifySettings(
|
peer->owner().updateNotifySettings(peer, state->lastSeconds);
|
||||||
peer,
|
|
||||||
state->lastSeconds,
|
|
||||||
std::nullopt,
|
|
||||||
state->noSoundChanges.current());
|
|
||||||
box->closeBox();
|
box->closeBox();
|
||||||
});
|
});
|
||||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||||
|
@ -204,16 +132,16 @@ void FillMuteMenu(
|
||||||
Args args) {
|
Args args) {
|
||||||
const auto peer = args.peer;
|
const auto peer = args.peer;
|
||||||
|
|
||||||
FillSoundMenu(
|
const auto soundIsNone = peer->owner().notifySoundIsNone(peer);
|
||||||
menu,
|
menu->addAction(
|
||||||
peer,
|
soundIsNone
|
||||||
tr::lng_mute_menu_sound_on(),
|
? tr::lng_mute_menu_sound_on(tr::now)
|
||||||
tr::lng_mute_menu_sound_off(),
|
: tr::lng_mute_menu_sound_off(tr::now),
|
||||||
[peer](bool silent) {
|
[=] {
|
||||||
peer->owner().updateNotifySettings(peer, {}, {}, silent);
|
const auto soundIsNone = peer->owner().notifySoundIsNone(peer);
|
||||||
});
|
peer->owner().updateNotifySettings(peer, {}, {}, !soundIsNone);
|
||||||
|
},
|
||||||
menu->addSeparator();
|
soundIsNone ? &st::menuIconSoundOn : &st::menuIconSoundOff);
|
||||||
|
|
||||||
menu->addAction(
|
menu->addAction(
|
||||||
tr::lng_mute_menu_duration(tr::now),
|
tr::lng_mute_menu_duration(tr::now),
|
||||||
|
|
|
@ -97,6 +97,8 @@ menuIconViolence: icon {{ "menu/violence", menuIconColor }};
|
||||||
menuIconMuteFor: icon {{ "menu/mute_for", menuIconColor }};
|
menuIconMuteFor: icon {{ "menu/mute_for", menuIconColor }};
|
||||||
menuIconSilent: icon {{ "menu/silent", menuIconColor }};
|
menuIconSilent: icon {{ "menu/silent", menuIconColor }};
|
||||||
menuIconCustomize: icon {{ "menu/customize", menuIconColor }};
|
menuIconCustomize: icon {{ "menu/customize", menuIconColor }};
|
||||||
|
menuIconSoundOn: icon {{ "menu/sound_enable", menuIconColor }};
|
||||||
|
menuIconSoundOff: icon {{ "menu/sound_disable", menuIconColor }};
|
||||||
|
|
||||||
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
||||||
menuIconTTLAnyTextPosition: point(11px, 22px);
|
menuIconTTLAnyTextPosition: point(11px, 22px);
|
||||||
|
|
|
@ -133,7 +133,7 @@ void PeerMenuAddMuteSubmenuAction(
|
||||||
peer->owner().requestNotifySettings(peer);
|
peer->owner().requestNotifySettings(peer);
|
||||||
const auto isMuted = peer->owner().notifyIsMuted(peer);
|
const auto isMuted = peer->owner().notifyIsMuted(peer);
|
||||||
if (isMuted) {
|
if (isMuted) {
|
||||||
const auto text = tr::lng_mute_menu_unmute(tr::now)
|
const auto text = tr::lng_context_unmute(tr::now)
|
||||||
+ '\t'
|
+ '\t'
|
||||||
+ Ui::FormatMuteForTiny(peer->notifyMuteUntil().value_or(0)
|
+ Ui::FormatMuteForTiny(peer->notifyMuteUntil().value_or(0)
|
||||||
- base::unixtime::now());
|
- base::unixtime::now());
|
||||||
|
@ -143,7 +143,7 @@ void PeerMenuAddMuteSubmenuAction(
|
||||||
} else {
|
} else {
|
||||||
const auto show = std::make_shared<Window::Show>(controller);
|
const auto show = std::make_shared<Window::Show>(controller);
|
||||||
addAction(PeerMenuCallback::Args{
|
addAction(PeerMenuCallback::Args{
|
||||||
.text = tr::lng_mute_menu_mute(tr::now),
|
.text = tr::lng_context_mute(tr::now),
|
||||||
.handler = nullptr,
|
.handler = nullptr,
|
||||||
.icon = peer->owner().notifySoundIsNone(peer)
|
.icon = peer->owner().notifySoundIsNone(peer)
|
||||||
? &st::menuIconSilent
|
? &st::menuIconSilent
|
||||||
|
|
Loading…
Add table
Reference in a new issue