mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add "Respect the Focus settings" on Windows.
This commit is contained in:
parent
e6af33367e
commit
285c96fd2e
5 changed files with 47 additions and 4 deletions
|
@ -499,8 +499,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_settings_notify_global" = "Global settings";
|
"lng_settings_notify_global" = "Global settings";
|
||||||
"lng_settings_notify_title" = "Notifications for chats";
|
"lng_settings_notify_title" = "Notifications for chats";
|
||||||
"lng_settings_desktop_notify" = "Desktop notifications";
|
"lng_settings_desktop_notify" = "Desktop notifications";
|
||||||
"lng_settings_native_title" = "Native notifications";
|
"lng_settings_native_title" = "System integration";
|
||||||
"lng_settings_use_windows" = "Use Windows notifications";
|
"lng_settings_use_windows" = "Use Windows notifications";
|
||||||
|
"lng_settings_skip_in_focus" = "Respect system Focus mode";
|
||||||
"lng_settings_use_native_notifications" = "Use native notifications";
|
"lng_settings_use_native_notifications" = "Use native notifications";
|
||||||
"lng_settings_notifications_position" = "Location on the screen";
|
"lng_settings_notifications_position" = "Location on the screen";
|
||||||
"lng_settings_notifications_count" = "Notifications count";
|
"lng_settings_notifications_count" = "Notifications count";
|
||||||
|
|
|
@ -222,7 +222,7 @@ QByteArray Settings::serialize() const {
|
||||||
+ Serialize::stringSize(_customFontFamily)
|
+ Serialize::stringSize(_customFontFamily)
|
||||||
+ sizeof(qint32) * 3
|
+ sizeof(qint32) * 3
|
||||||
+ Serialize::bytearraySize(_tonsiteStorageToken)
|
+ Serialize::bytearraySize(_tonsiteStorageToken)
|
||||||
+ sizeof(qint32) * 2;
|
+ sizeof(qint32) * 3;
|
||||||
|
|
||||||
auto result = QByteArray();
|
auto result = QByteArray();
|
||||||
result.reserve(size);
|
result.reserve(size);
|
||||||
|
@ -378,7 +378,8 @@ QByteArray Settings::serialize() const {
|
||||||
<< qint32(!_weatherInCelsius ? 0 : *_weatherInCelsius ? 1 : 2)
|
<< qint32(!_weatherInCelsius ? 0 : *_weatherInCelsius ? 1 : 2)
|
||||||
<< _tonsiteStorageToken
|
<< _tonsiteStorageToken
|
||||||
<< qint32(_includeMutedCounterFolders ? 1 : 0)
|
<< qint32(_includeMutedCounterFolders ? 1 : 0)
|
||||||
<< qint32(_ivZoom.current());
|
<< qint32(_ivZoom.current())
|
||||||
|
<< qint32(_skipToastsInFocus ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ensures(result.size() == size);
|
Ensures(result.size() == size);
|
||||||
|
@ -503,6 +504,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
qint32 weatherInCelsius = !_weatherInCelsius ? 0 : *_weatherInCelsius ? 1 : 2;
|
qint32 weatherInCelsius = !_weatherInCelsius ? 0 : *_weatherInCelsius ? 1 : 2;
|
||||||
QByteArray tonsiteStorageToken = _tonsiteStorageToken;
|
QByteArray tonsiteStorageToken = _tonsiteStorageToken;
|
||||||
qint32 ivZoom = _ivZoom.current();
|
qint32 ivZoom = _ivZoom.current();
|
||||||
|
qint32 skipToastsInFocus = _skipToastsInFocus ? 1 : 0;
|
||||||
|
|
||||||
stream >> themesAccentColors;
|
stream >> themesAccentColors;
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
|
@ -815,6 +817,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
if (!stream.atEnd()) {
|
if (!stream.atEnd()) {
|
||||||
stream >> ivZoom;
|
stream >> ivZoom;
|
||||||
}
|
}
|
||||||
|
if (!stream.atEnd()) {
|
||||||
|
stream >> skipToastsInFocus;
|
||||||
|
}
|
||||||
if (stream.status() != QDataStream::Ok) {
|
if (stream.status() != QDataStream::Ok) {
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Bad data for Core::Settings::constructFromSerialized()"));
|
"Bad data for Core::Settings::constructFromSerialized()"));
|
||||||
|
@ -1027,6 +1032,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
|
||||||
: (weatherInCelsius == 1);
|
: (weatherInCelsius == 1);
|
||||||
_tonsiteStorageToken = tonsiteStorageToken;
|
_tonsiteStorageToken = tonsiteStorageToken;
|
||||||
_ivZoom = ivZoom;
|
_ivZoom = ivZoom;
|
||||||
|
_skipToastsInFocus = (skipToastsInFocus == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getSoundPath(const QString &key) const {
|
QString Settings::getSoundPath(const QString &key) const {
|
||||||
|
@ -1353,6 +1359,7 @@ void Settings::resetOnLastLogout() {
|
||||||
_flashBounceNotify = true;
|
_flashBounceNotify = true;
|
||||||
_notifyView = NotifyView::ShowPreview;
|
_notifyView = NotifyView::ShowPreview;
|
||||||
//_nativeNotifications = std::nullopt;
|
//_nativeNotifications = std::nullopt;
|
||||||
|
//_skipToastsInFocus = false;
|
||||||
//_notificationsCount = 3;
|
//_notificationsCount = 3;
|
||||||
//_notificationsCorner = ScreenCorner::BottomRight;
|
//_notificationsCorner = ScreenCorner::BottomRight;
|
||||||
_includeMutedCounter = true;
|
_includeMutedCounter = true;
|
||||||
|
@ -1472,6 +1479,14 @@ void Settings::setNativeNotifications(bool value) {
|
||||||
: std::make_optional(value);
|
: std::make_optional(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::skipToastsInFocus() const {
|
||||||
|
return _skipToastsInFocus;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setSkipToastsInFocus(bool value) {
|
||||||
|
_skipToastsInFocus = value;
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::setTranslateButtonEnabled(bool value) {
|
void Settings::setTranslateButtonEnabled(bool value) {
|
||||||
_translateButtonEnabled = value;
|
_translateButtonEnabled = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,6 +220,9 @@ public:
|
||||||
[[nodiscard]] bool nativeNotifications() const;
|
[[nodiscard]] bool nativeNotifications() const;
|
||||||
void setNativeNotifications(bool value);
|
void setNativeNotifications(bool value);
|
||||||
|
|
||||||
|
[[nodiscard]] bool skipToastsInFocus() const;
|
||||||
|
void setSkipToastsInFocus(bool value);
|
||||||
|
|
||||||
[[nodiscard]] int notificationsCount() const {
|
[[nodiscard]] int notificationsCount() const {
|
||||||
return _notificationsCount;
|
return _notificationsCount;
|
||||||
}
|
}
|
||||||
|
@ -958,6 +961,7 @@ private:
|
||||||
bool _flashBounceNotify = true;
|
bool _flashBounceNotify = true;
|
||||||
NotifyView _notifyView = NotifyView::ShowPreview;
|
NotifyView _notifyView = NotifyView::ShowPreview;
|
||||||
std::optional<bool> _nativeNotifications;
|
std::optional<bool> _nativeNotifications;
|
||||||
|
bool _skipToastsInFocus = false;
|
||||||
int _notificationsCount = 3;
|
int _notificationsCount = 3;
|
||||||
ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
|
ScreenCorner _notificationsCorner = ScreenCorner::BottomRight;
|
||||||
bool _includeMutedCounter = true;
|
bool _includeMutedCounter = true;
|
||||||
|
|
|
@ -367,6 +367,7 @@ bool SkipSoundForCustom() {
|
||||||
|
|
||||||
return (UserNotificationState == QUNS_NOT_PRESENT)
|
return (UserNotificationState == QUNS_NOT_PRESENT)
|
||||||
|| (UserNotificationState == QUNS_PRESENTATION_MODE)
|
|| (UserNotificationState == QUNS_PRESENTATION_MODE)
|
||||||
|
|| (FocusAssistBlocks && Core::App().settings().skipToastsInFocus())
|
||||||
|| Core::App().screenIsLocked();
|
|| Core::App().screenIsLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +388,8 @@ bool SkipToastForCustom() {
|
||||||
QuerySystemNotificationSettings();
|
QuerySystemNotificationSettings();
|
||||||
|
|
||||||
return (UserNotificationState == QUNS_PRESENTATION_MODE)
|
return (UserNotificationState == QUNS_PRESENTATION_MODE)
|
||||||
|| (UserNotificationState == QUNS_RUNNING_D3D_FULL_SCREEN);
|
|| (UserNotificationState == QUNS_RUNNING_D3D_FULL_SCREEN)
|
||||||
|
|| (FocusAssistBlocks && Core::App().settings().skipToastsInFocus());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaybeFlashBounceForCustom(Fn<void()> flashBounce) {
|
void MaybeFlashBounceForCustom(Fn<void()> flashBounce) {
|
||||||
|
|
|
@ -864,6 +864,27 @@ NotifyViewCheckboxes SetupNotifyViewOptions(
|
||||||
void SetupAdvancedNotifications(
|
void SetupAdvancedNotifications(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
not_null<Ui::VerticalLayout*> container) {
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
|
if (Platform::IsWindows()) {
|
||||||
|
const auto skipInFocus = container->add(object_ptr<Button>(
|
||||||
|
container,
|
||||||
|
tr::lng_settings_skip_in_focus(),
|
||||||
|
st::settingsButtonNoIcon
|
||||||
|
))->toggleOn(rpl::single(Core::App().settings().skipToastsInFocus()));
|
||||||
|
|
||||||
|
skipInFocus->toggledChanges(
|
||||||
|
) | rpl::filter([](bool checked) {
|
||||||
|
return (checked != Core::App().settings().skipToastsInFocus());
|
||||||
|
}) | rpl::start_with_next([=](bool checked) {
|
||||||
|
Core::App().settings().setSkipToastsInFocus(checked);
|
||||||
|
Core::App().saveSettingsDelayed();
|
||||||
|
if (checked && Platform::Notifications::SkipToastForCustom()) {
|
||||||
|
using Change = Window::Notifications::ChangeType;
|
||||||
|
Core::App().notifications().notifySettingsChanged(
|
||||||
|
Change::DesktopEnabled);
|
||||||
|
}
|
||||||
|
}, skipInFocus->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
Ui::AddSkip(container, st::settingsCheckboxesSkip);
|
Ui::AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
Ui::AddDivider(container);
|
Ui::AddDivider(container);
|
||||||
Ui::AddSkip(container, st::settingsCheckboxesSkip);
|
Ui::AddSkip(container, st::settingsCheckboxesSkip);
|
||||||
|
|
Loading…
Add table
Reference in a new issue