mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-09-05 08:55:59 +00:00
Most of the new Settings sections filled with widgets.
Some animations added: new scale slider, widget_slide_wrap<TWidget>. Any TWidget now can resizeToWidth() with overriden resizeGetHeight().
This commit is contained in:
@@ -23,21 +23,105 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||
|
||||
#include "styles/style_settings.h"
|
||||
#include "lang.h"
|
||||
#include "localstorage.h"
|
||||
#include "ui/widgets/widget_slide_wrap.h"
|
||||
#include "ui/flatcheckbox.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
namespace Settings {
|
||||
|
||||
NotificationsWidget::NotificationsWidget(QWidget *parent, UserData *self) : BlockWidget(parent, self, lang(lng_settings_section_notify)) {
|
||||
refreshControls();
|
||||
createControls();
|
||||
}
|
||||
|
||||
void NotificationsWidget::refreshControls() {
|
||||
void NotificationsWidget::createControls() {
|
||||
style::margins margin(0, 0, 0, st::settingsSmallSkip);
|
||||
style::margins slidedPadding(0, margin.bottom() / 2, 0, margin.bottom() - (margin.bottom() / 2));
|
||||
addChildRow(_desktopNotifications, margin, lang(lng_settings_desktop_notify), SLOT(onDesktopNotifications()), cDesktopNotify());
|
||||
addChildRow(_showSenderName, margin, slidedPadding, lang(lng_settings_show_name), SLOT(onShowSenderName()), cNotifyView() <= dbinvShowName);
|
||||
addChildRow(_showMessagePreview, margin, slidedPadding, lang(lng_settings_show_preview), SLOT(onShowMessagePreview()), cNotifyView() <= dbinvShowPreview);
|
||||
if (!_showSenderName->entity()->checked()) {
|
||||
_showMessagePreview->hideFast();
|
||||
}
|
||||
if (!_desktopNotifications->checked()) {
|
||||
_showSenderName->hideFast();
|
||||
_showMessagePreview->hideFast();
|
||||
}
|
||||
#ifdef Q_OS_WIN
|
||||
if (App::wnd()->psHasNativeNotifications()) {
|
||||
addChildRow(_windowsNative, margin, lang(lng_settings_use_windows), SLOT(onWindowsNative()), cWindowsNotifications());
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
addChildRow(_playSound, margin, lang(lng_settings_sound_notify), SLOT(onPlaySound()), cSoundNotify());
|
||||
addChildRow(_includeMuted, margin, lang(lng_settings_include_muted), SLOT(onIncludeMuted()), cIncludeMuted());
|
||||
}
|
||||
|
||||
int NotificationsWidget::resizeGetHeight(int newWidth) {
|
||||
int newHeight = contentTop();
|
||||
void NotificationsWidget::onDesktopNotifications() {
|
||||
cSetDesktopNotify(_desktopNotifications->checked());
|
||||
Local::writeUserSettings();
|
||||
if (App::wnd()) App::wnd()->updateTrayMenu();
|
||||
|
||||
newHeight += st::settingsBlockMarginBottom;
|
||||
return newHeight;
|
||||
if (_desktopNotifications->checked()) {
|
||||
_showSenderName->slideDown();
|
||||
if (_showSenderName->entity()->checked()) {
|
||||
_showMessagePreview->slideDown();
|
||||
}
|
||||
} else {
|
||||
App::wnd()->notifyClear();
|
||||
_showSenderName->slideUp();
|
||||
_showMessagePreview->slideUp();
|
||||
}
|
||||
}
|
||||
|
||||
void NotificationsWidget::onShowSenderName() {
|
||||
if (_showSenderName->entity()->checked()) {
|
||||
_showMessagePreview->slideDown();
|
||||
} else {
|
||||
_showMessagePreview->slideUp();
|
||||
}
|
||||
|
||||
if (!_showSenderName->entity()->checked()) {
|
||||
cSetNotifyView(dbinvShowNothing);
|
||||
} else if (!_showMessagePreview->entity()->checked()) {
|
||||
cSetNotifyView(dbinvShowName);
|
||||
} else {
|
||||
cSetNotifyView(dbinvShowPreview);
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
App::wnd()->notifyUpdateAll();
|
||||
}
|
||||
|
||||
void NotificationsWidget::onShowMessagePreview() {
|
||||
if (_showMessagePreview->entity()->checked()) {
|
||||
cSetNotifyView(dbinvShowPreview);
|
||||
} else if (_showSenderName->entity()->checked()) {
|
||||
cSetNotifyView(dbinvShowName);
|
||||
} else {
|
||||
cSetNotifyView(dbinvShowNothing);
|
||||
}
|
||||
Local::writeUserSettings();
|
||||
App::wnd()->notifyUpdateAll();
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
void NotificationsWidget::onWindowsNative() {
|
||||
if (cPlatform() != dbipWindows) return;
|
||||
cSetWindowsNotifications(!cWindowsNotifications());
|
||||
App::wnd()->notifyClearFast();
|
||||
cSetCustomNotifies(!cWindowsNotifications());
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
#endif // Q_OS_WIN
|
||||
|
||||
void NotificationsWidget::onPlaySound() {
|
||||
cSetSoundNotify(_playSound->checked());
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
|
||||
void NotificationsWidget::onIncludeMuted() {
|
||||
cSetIncludeMuted(_includeMuted->checked());
|
||||
Notify::unreadCounterUpdated();
|
||||
Local::writeUserSettings();
|
||||
}
|
||||
|
||||
} // namespace Settings
|
||||
|
Reference in New Issue
Block a user