Use new base::option::changes in a few old options

This commit is contained in:
Ilya Fedin
2026-06-22 19:30:59 +00:00
committed by John Preston
parent ee39aa34b4
commit 156c8e74e5
4 changed files with 21 additions and 11 deletions

View File

@@ -47,7 +47,6 @@ base::options::toggle OptionDeadlockDetector({
.id = kOptionDeadlockDetector,
.name = "Deadlock Detector",
.description = "Check once every 30 seconds that main thread is still responsive.",
.restartRequired = true,
});
} // namespace
@@ -200,10 +199,16 @@ void Sandbox::launchApplication() {
}
setupScreenScale();
if (OptionDeadlockDetector.value()) {
rpl::single(
rpl::empty
) | rpl::then(
OptionDeadlockDetector.changes()
) | rpl::on_next([=] {
using DeadlockDetector::PingThread;
_deadlockDetector = std::make_unique<PingThread>(this);
}
_deadlockDetector = OptionDeadlockDetector.value()
? std::make_unique<PingThread>(this)
: nullptr;
}, _lifetime);
_application = std::make_unique<Application>();

View File

@@ -135,6 +135,8 @@ private:
std::unique_ptr<QThread> _deadlockDetector;
rpl::lifetime _lifetime;
};
} // namespace Core

View File

@@ -332,9 +332,7 @@ void Create(Window::Notifications::System *system) {
Manager::Private::Private(not_null<Manager*> manager)
: _manager(manager)
, _application(UseGNotification()
? Gio::Application::get_default()
: nullptr)
, _application(Gio::Application::get_default())
, _sounds(cWorkingDir() + u"tdata/audio_cache"_q) {
const auto &serverInformation = CurrentServerInformation;
@@ -429,7 +427,7 @@ void Manager::Private::init(XdgNotifications::NotificationsProxy proxy) {
_proxy = proxy;
_interface = proxy;
if (_application || !_interface) {
if (!_interface) {
return;
}
@@ -535,7 +533,7 @@ void Manager::Private::showNotification(
.contextId = key,
.msgId = info.itemId,
};
auto notification = _application
auto notification = UseGNotification()
? Gio::Notification::new_(info.title.toStdString())
: Gio::Notification();

View File

@@ -149,7 +149,6 @@ base::options::toggle OptionCustomNotification({
.scope = [] {
return Platform::Notifications::Enforced();
},
.restartRequired = true,
});
const char kOptionGNotification[] = "gnotification";
@@ -168,7 +167,6 @@ base::options::toggle OptionGNotification({
return false;
#endif // __has_include(<gio/gio.hpp>)
},
.restartRequired = true,
});
base::options::toggle HideReplyButtonOption({
@@ -211,6 +209,13 @@ System::System()
Core::App().domain().notifyUnreadBadgeChanged();
}
}, lifetime());
rpl::merge(
OptionCustomNotification.changes(),
OptionGNotification.changes()
) | rpl::on_next([=] {
createManager();
}, lifetime());
}
void System::createManager() {