mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
Revert "Fallback to portal on Linux if QStyleHints::colorScheme is unknown"
This reverts commit a88f48cd93
.
This commit is contained in:
parent
d3142ebe6d
commit
39b90092ff
3 changed files with 16 additions and 45 deletions
|
@ -17,7 +17,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/random.h"
|
||||
|
||||
#include <QtCore/QAbstractEventDispatcher>
|
||||
#include <QtGui/QStyleHints>
|
||||
|
||||
#include <gio/gio.hpp>
|
||||
#include <xdpinhibit/xdpinhibit.hpp>
|
||||
|
@ -190,30 +189,24 @@ private:
|
|||
|
||||
const gi::ref_ptr<Application> _application;
|
||||
XdpInhibit::InhibitProxy _inhibitProxy;
|
||||
rpl::variable<std::optional<bool>> _darkMode;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
|
||||
base::Platform::XDP::SettingWatcher _darkModeWatcher;
|
||||
rpl::lifetime _lifetime;
|
||||
#endif // Qt < 6.5.0
|
||||
};
|
||||
|
||||
LinuxIntegration::LinuxIntegration()
|
||||
: _application(MakeApplication())
|
||||
, _darkMode([]() -> std::optional<bool> {
|
||||
if (auto value = base::Platform::XDP::ReadSetting(
|
||||
"org.freedesktop.appearance",
|
||||
"color-scheme")) {
|
||||
return value->get_uint32() == 1;
|
||||
}
|
||||
return std::nullopt;
|
||||
}())
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
|
||||
, _darkModeWatcher(
|
||||
"org.freedesktop.appearance",
|
||||
"color-scheme",
|
||||
[=](GLib::Variant value) {
|
||||
[](GLib::Variant value) {
|
||||
Core::Sandbox::Instance().customEnterFromEventLoop([&] {
|
||||
_darkMode = value.get_uint32() == 1;
|
||||
Core::App().settings().setSystemDarkMode(value.get_uint32() == 1);
|
||||
});
|
||||
}
|
||||
) {
|
||||
})
|
||||
#endif // Qt < 6.5.0
|
||||
{
|
||||
LOG(("Icon theme: %1").arg(QIcon::themeName()));
|
||||
LOG(("Fallback icon theme: %1").arg(QIcon::fallbackThemeName()));
|
||||
|
||||
|
@ -237,30 +230,6 @@ void LinuxIntegration::init() {
|
|||
|
||||
initInhibit();
|
||||
}));
|
||||
|
||||
_darkMode.value()
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
| rpl::filter([] {
|
||||
return QGuiApplication::styleHints()->colorScheme()
|
||||
== Qt::ColorScheme::Unknown;
|
||||
})
|
||||
#endif // Qt >= 6.5.0
|
||||
| rpl::start_with_next([](std::optional<bool> value) {
|
||||
Core::App().settings().setSystemDarkMode(value);
|
||||
}, _lifetime);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
Core::App().settings().systemDarkModeValue(
|
||||
) | rpl::filter([=](std::optional<bool> value) {
|
||||
return !value && _darkMode.current();
|
||||
}) | rpl::start_with_next([=] {
|
||||
crl::on_main(this, [=] {
|
||||
if (!Core::App().settings().systemDarkMode()) {
|
||||
Core::App().settings().setSystemDarkMode(_darkMode.current());
|
||||
}
|
||||
});
|
||||
}, _lifetime);
|
||||
#endif // Qt >= 6.5.0
|
||||
}
|
||||
|
||||
void LinuxIntegration::initInhibit() {
|
||||
|
|
|
@ -535,7 +535,13 @@ QString SingleInstanceLocalServerName(const QString &hash) {
|
|||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
|
||||
std::optional<bool> IsDarkMode() {
|
||||
return std::nullopt;
|
||||
auto result = base::Platform::XDP::ReadSetting(
|
||||
"org.freedesktop.appearance",
|
||||
"color-scheme");
|
||||
|
||||
return result.has_value()
|
||||
? std::make_optional(result->get_uint32() == 1)
|
||||
: std::nullopt;
|
||||
}
|
||||
#endif // Qt < 6.5.0
|
||||
|
||||
|
|
|
@ -529,8 +529,6 @@ void ChatBackground::start() {
|
|||
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
|
||||
rpl::single(
|
||||
QGuiApplication::styleHints()->colorScheme()
|
||||
) | rpl::filter(
|
||||
rpl::mappers::_1 != Qt::ColorScheme::Unknown
|
||||
) | rpl::then(
|
||||
base::qt_signal_producer(
|
||||
QGuiApplication::styleHints(),
|
||||
|
@ -544,9 +542,7 @@ void ChatBackground::start() {
|
|||
Core::App().settings().setSystemDarkMode(dark);
|
||||
}, _lifetime);
|
||||
#else // Qt >= 6.5.0
|
||||
if (const auto dark = Platform::IsDarkMode()) {
|
||||
Core::App().settings().setSystemDarkMode(dark);
|
||||
}
|
||||
Core::App().settings().setSystemDarkMode(Platform::IsDarkMode());
|
||||
#endif // Qt < 6.5.0
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue