mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Moved DBINotifyView to Core::Settings.
This commit is contained in:
parent
5334372671
commit
da3e140069
7 changed files with 42 additions and 34 deletions
Telegram/SourceFiles
|
@ -432,11 +432,11 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
|||
_soundNotify = (soundNotify == 1);
|
||||
_desktopNotify = (desktopNotify == 1);
|
||||
_flashBounceNotify = (flashBounceNotify == 1);
|
||||
const auto uncheckedNotifyView = static_cast<DBINotifyView>(notifyView);
|
||||
const auto uncheckedNotifyView = static_cast<NotifyView>(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;
|
||||
|
|
|
@ -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<bool> _nativeNotifications;
|
||||
int _notificationsCount = 3;
|
||||
ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -582,6 +582,7 @@ void SetupMultiAccountNotifications(
|
|||
void SetupNotificationsContent(
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<Ui::VerticalLayout*> 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());
|
||||
|
|
|
@ -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<Notify>(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;
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue