diff --git a/Telegram/SourceFiles/core/core_settings.cpp b/Telegram/SourceFiles/core/core_settings.cpp index ebb7ecb94..9fdd28b42 100644 --- a/Telegram/SourceFiles/core/core_settings.cpp +++ b/Telegram/SourceFiles/core/core_settings.cpp @@ -432,11 +432,11 @@ void Settings::addFromSerialized(const QByteArray &serialized) { _soundNotify = (soundNotify == 1); _desktopNotify = (desktopNotify == 1); _flashBounceNotify = (flashBounceNotify == 1); - const auto uncheckedNotifyView = static_cast(notifyView); + const auto uncheckedNotifyView = static_cast(notifyView); switch (uncheckedNotifyView) { - case dbinvShowNothing: - case dbinvShowName: - case dbinvShowPreview: _notifyView = uncheckedNotifyView; break; + case NotifyView::ShowNothing: + case NotifyView::ShowName: + case NotifyView::ShowPreview: _notifyView = uncheckedNotifyView; break; } switch (nativeNotifications) { case 0: _nativeNotifications = std::nullopt; break; @@ -732,7 +732,7 @@ void Settings::resetOnLastLogout() { _soundNotify = true; _desktopNotify = true; _flashBounceNotify = true; - _notifyView = dbinvShowPreview; + _notifyView = NotifyView::ShowPreview; //_nativeNotifications = std::nullopt; //_notificationsCount = 3; //_notificationsCorner = ScreenCorner::BottomRight; diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h index d9d50f1d7..2c9d4d3a2 100644 --- a/Telegram/SourceFiles/core/core_settings.h +++ b/Telegram/SourceFiles/core/core_settings.h @@ -48,6 +48,11 @@ public: BottomRight = 2, BottomLeft = 3, }; + enum class NotifyView { + ShowPreview = 0, + ShowName = 1, + ShowNothing = 2, + }; static constexpr auto kDefaultVolume = 0.9; @@ -147,10 +152,10 @@ public: void setFlashBounceNotify(bool value) { _flashBounceNotify = value; } - [[nodiscard]] DBINotifyView notifyView() const { + [[nodiscard]] NotifyView notifyView() const { return _notifyView; } - void setNotifyView(DBINotifyView value) { + void setNotifyView(NotifyView value) { _notifyView = value; } [[nodiscard]] bool nativeNotifications() const { @@ -598,7 +603,7 @@ private: bool _soundNotify = true; bool _desktopNotify = true; bool _flashBounceNotify = true; - DBINotifyView _notifyView = dbinvShowPreview; + NotifyView _notifyView = NotifyView::ShowPreview; std::optional _nativeNotifications; int _notificationsCount = 3; ScreenCorner _notificationsCorner = ScreenCorner::BottomRight; diff --git a/Telegram/SourceFiles/core/utils.h b/Telegram/SourceFiles/core/utils.h index f2d47c438..d70919d0f 100644 --- a/Telegram/SourceFiles/core/utils.h +++ b/Telegram/SourceFiles/core/utils.h @@ -121,12 +121,6 @@ void memset_rand(void *data, uint32 len); QString translitRusEng(const QString &rus); QString rusKeyboardLayoutSwitch(const QString &from); -enum DBINotifyView { - dbinvShowPreview = 0, - dbinvShowName = 1, - dbinvShowNothing = 2, -}; - enum DBIWorkMode { dbiwmWindowAndTray = 0, dbiwmTrayOnly = 1, diff --git a/Telegram/SourceFiles/settings/settings_notifications.cpp b/Telegram/SourceFiles/settings/settings_notifications.cpp index 9362a27f7..a95ef5571 100644 --- a/Telegram/SourceFiles/settings/settings_notifications.cpp +++ b/Telegram/SourceFiles/settings/settings_notifications.cpp @@ -582,6 +582,7 @@ void SetupMultiAccountNotifications( void SetupNotificationsContent( not_null controller, not_null container) { + using NotifyView = Core::Settings::NotifyView; SetupMultiAccountNotifications(controller, container); AddSubsectionTitle(container, tr::lng_settings_notify_title()); @@ -612,10 +613,10 @@ void SetupNotificationsContent( settings.desktopNotify()); const auto name = addSlidingCheckbox( tr::lng_settings_show_name(tr::now), - (settings.notifyView() <= dbinvShowName)); + (settings.notifyView() <= NotifyView::ShowName)); const auto preview = addSlidingCheckbox( tr::lng_settings_show_preview(tr::now), - (settings.notifyView() <= dbinvShowPreview)); + (settings.notifyView() <= NotifyView::ShowPreview)); const auto sound = addCheckbox( tr::lng_settings_sound_notify(tr::now), settings.soundNotify()); @@ -752,14 +753,14 @@ void SetupNotificationsContent( name->entity()->checkedChanges( ) | rpl::map([=](bool checked) { if (!checked) { - return dbinvShowNothing; + return NotifyView::ShowNothing; } else if (!preview->entity()->checked()) { - return dbinvShowName; + return NotifyView::ShowName; } - return dbinvShowPreview; - }) | rpl::filter([=](DBINotifyView value) { + return NotifyView::ShowPreview; + }) | rpl::filter([=](NotifyView value) { return (value != Core::App().settings().notifyView()); - }) | rpl::start_with_next([=](DBINotifyView value) { + }) | rpl::start_with_next([=](NotifyView value) { Core::App().settings().setNotifyView(value); changed(Change::ViewParams); }, name->lifetime()); @@ -767,14 +768,14 @@ void SetupNotificationsContent( preview->entity()->checkedChanges( ) | rpl::map([=](bool checked) { if (checked) { - return dbinvShowPreview; + return NotifyView::ShowPreview; } else if (name->entity()->checked()) { - return dbinvShowName; + return NotifyView::ShowName; } - return dbinvShowNothing; - }) | rpl::filter([=](DBINotifyView value) { + return NotifyView::ShowNothing; + }) | rpl::filter([=](NotifyView value) { return (value != Core::App().settings().notifyView()); - }) | rpl::start_with_next([=](DBINotifyView value) { + }) | rpl::start_with_next([=](NotifyView value) { Core::App().settings().setNotifyView(value); changed(Change::ViewParams); }, preview->lifetime()); diff --git a/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp b/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp index 5ec2ded4c..0bdd2c183 100644 --- a/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp +++ b/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp @@ -881,11 +881,16 @@ bool ReadSetting( stream >> v; if (!CheckStreamStatus(stream)) return false; - switch (v) { - case dbinvShowNothing: Core::App().settings().setNotifyView(dbinvShowNothing); break; - case dbinvShowName: Core::App().settings().setNotifyView(dbinvShowName); break; - default: Core::App().settings().setNotifyView(dbinvShowPreview); break; - } + const auto newView = [&] { + using Notify = Core::Settings::NotifyView; + switch (static_cast(v)) { + case Notify::ShowNothing: return Notify::ShowNothing; + case Notify::ShowName: return Notify::ShowName; + } + return Notify::ShowPreview; + }(); + Core::App().settings().setNotifyView(newView); + context.legacyRead = true; } break; diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 4b3c08392..db352c9b6 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -594,8 +594,10 @@ Manager::DisplayOptions Manager::getNotificationOptions( const auto view = Core::App().settings().notifyView(); DisplayOptions result; - result.hideNameAndPhoto = hideEverything || (view > dbinvShowName); - result.hideMessageText = hideEverything || (view > dbinvShowPreview); + result.hideNameAndPhoto = hideEverything + || (view > Core::Settings::NotifyView::ShowName); + result.hideMessageText = hideEverything + || (view > Core::Settings::NotifyView::ShowPreview); result.hideReplyButton = result.hideMessageText || !item || ((item->out() || item->history()->peer->isSelf()) diff --git a/Telegram/SourceFiles/window/notifications_manager_default.cpp b/Telegram/SourceFiles/window/notifications_manager_default.cpp index 0e77fc448..47432713a 100644 --- a/Telegram/SourceFiles/window/notifications_manager_default.cpp +++ b/Telegram/SourceFiles/window/notifications_manager_default.cpp @@ -902,7 +902,8 @@ bool Notification::canReply() const { return !_hideReplyButton && (_item != nullptr) && !Core::App().passcodeLocked() - && (Core::App().settings().notifyView() <= dbinvShowPreview); + && (Core::App().settings().notifyView() + <= Core::Settings::NotifyView::ShowPreview); } void Notification::unlinkHistoryInManager() {