Notification sound tray menu option
This commit is contained in:
parent
c06486d2ce
commit
6116188e8b
5 changed files with 35 additions and 1 deletions
|
|
@ -2391,4 +2391,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
"ktg_settings_adaptive_bubbles" = "Adaptive bubbles";
|
"ktg_settings_adaptive_bubbles" = "Adaptive bubbles";
|
||||||
|
|
||||||
|
"ktg_settings_disable_sound_from_tray" = "Disable sound";
|
||||||
|
"ktg_settings_enable_sound_from_tray" = "Enable sound";
|
||||||
|
|
||||||
// Keys finished
|
// Keys finished
|
||||||
|
|
|
||||||
|
|
@ -88,5 +88,7 @@
|
||||||
"ktg_settings_call_confirm": "Подтверждение перед звонком",
|
"ktg_settings_call_confirm": "Подтверждение перед звонком",
|
||||||
"ktg_call_sure": "Вы уверены, что хотите позвонить этому пользователю?",
|
"ktg_call_sure": "Вы уверены, что хотите позвонить этому пользователю?",
|
||||||
"ktg_call_button": "Позвонить",
|
"ktg_call_button": "Позвонить",
|
||||||
"ktg_settings_adaptive_bubbles": "Адаптивные пузырьки сообщений"
|
"ktg_settings_adaptive_bubbles": "Адаптивные пузырьки сообщений",
|
||||||
|
"ktg_settings_disable_sound_from_tray": "Отключить звук",
|
||||||
|
"ktg_settings_enable_sound_from_tray": "Включить звук"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,11 +142,16 @@ void MainWindow::createTrayIconMenu() {
|
||||||
? tr::lng_disable_notifications_from_tray(tr::now)
|
? tr::lng_disable_notifications_from_tray(tr::now)
|
||||||
: tr::lng_enable_notifications_from_tray(tr::now);
|
: tr::lng_enable_notifications_from_tray(tr::now);
|
||||||
|
|
||||||
|
auto soundActionText = Global::SoundNotify()
|
||||||
|
? tr::ktg_settings_disable_sound_from_tray(tr::now)
|
||||||
|
: tr::ktg_settings_enable_sound_from_tray(tr::now);
|
||||||
|
|
||||||
if (Platform::IsLinux()) {
|
if (Platform::IsLinux()) {
|
||||||
trayIconMenu->addAction(tr::ktg_open_from_tray(tr::now), this, SLOT(showFromTray()));
|
trayIconMenu->addAction(tr::ktg_open_from_tray(tr::now), this, SLOT(showFromTray()));
|
||||||
}
|
}
|
||||||
trayIconMenu->addAction(tr::lng_minimize_to_tray(tr::now), this, SLOT(minimizeToTray()));
|
trayIconMenu->addAction(tr::lng_minimize_to_tray(tr::now), this, SLOT(minimizeToTray()));
|
||||||
trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray()));
|
trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray()));
|
||||||
|
trayIconMenu->addAction(soundActionText, this, SLOT(toggleSoundNotifyFromTray()));
|
||||||
trayIconMenu->addAction(tr::ktg_quit_from_tray(tr::now), this, SLOT(quitFromTray()));
|
trayIconMenu->addAction(tr::ktg_quit_from_tray(tr::now), this, SLOT(quitFromTray()));
|
||||||
|
|
||||||
initTrayMenuHook();
|
initTrayMenuHook();
|
||||||
|
|
@ -613,6 +618,12 @@ void MainWindow::updateTrayMenu(bool force) {
|
||||||
: tr::lng_enable_notifications_from_tray(tr::now);
|
: tr::lng_enable_notifications_from_tray(tr::now);
|
||||||
notificationAction->setText(notificationActionText);
|
notificationAction->setText(notificationActionText);
|
||||||
|
|
||||||
|
auto soundAction = actions.at(Platform::IsLinux() ? 3 : 2);
|
||||||
|
auto soundActionText = Global::SoundNotify()
|
||||||
|
? tr::ktg_settings_disable_sound_from_tray(tr::now)
|
||||||
|
: tr::ktg_settings_enable_sound_from_tray(tr::now);
|
||||||
|
soundAction->setText(soundActionText);
|
||||||
|
|
||||||
psTrayMenuUpdated();
|
psTrayMenuUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -782,6 +793,22 @@ void MainWindow::toggleDisplayNotifyFromTray() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::toggleSoundNotifyFromTray() {
|
||||||
|
if (Core::App().locked()) {
|
||||||
|
if (!isActive()) showFromTray();
|
||||||
|
Ui::show(Box<InformBox>(tr::lng_passcode_need_unblock(tr::now)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!account().sessionExists()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Global::SetSoundNotify(!Global::SoundNotify());
|
||||||
|
Local::writeUserSettings();
|
||||||
|
account().session().notifications().settingsChanged().notify(
|
||||||
|
Window::Notifications::ChangeType::SoundEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent *e) {
|
void MainWindow::closeEvent(QCloseEvent *e) {
|
||||||
if (Core::Sandbox::Instance().isSavingSession()) {
|
if (Core::Sandbox::Instance().isSavingSession()) {
|
||||||
e->accept();
|
e->accept();
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ public slots:
|
||||||
void quitFromTray();
|
void quitFromTray();
|
||||||
void showFromTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown);
|
void showFromTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown);
|
||||||
void toggleDisplayNotifyFromTray();
|
void toggleDisplayNotifyFromTray();
|
||||||
|
void toggleSoundNotifyFromTray();
|
||||||
|
|
||||||
void onClearFinished(int task, void *manager);
|
void onClearFinished(int task, void *manager);
|
||||||
void onClearFailed(int task, void *manager);
|
void onClearFailed(int task, void *manager);
|
||||||
|
|
|
||||||
|
|
@ -1113,6 +1113,7 @@ bool _readSetting(quint32 blockId, QDataStream &stream, int version, ReadSetting
|
||||||
if (!_checkStreamStatus(stream)) return false;
|
if (!_checkStreamStatus(stream)) return false;
|
||||||
|
|
||||||
Global::SetSoundNotify(v == 1);
|
Global::SetSoundNotify(v == 1);
|
||||||
|
if (App::wnd()) App::wnd()->updateTrayMenu();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case dbiAutoDownloadOld: {
|
case dbiAutoDownloadOld: {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue