diff --git a/src/ui/NhekoGlobalObject.cpp b/src/ui/NhekoGlobalObject.cpp index 0573d5ee..d89acf1b 100644 --- a/src/ui/NhekoGlobalObject.cpp +++ b/src/ui/NhekoGlobalObject.cpp @@ -6,6 +6,8 @@ #include "NhekoGlobalObject.h" #include +#include +#include #include #include #include @@ -21,6 +23,17 @@ Nheko::Nheko() { connect( UserSettings::instance().get(), &UserSettings::themeChanged, this, &Nheko::colorsChanged); +#ifdef NHEKO_DBUS_SYS + nhlog::ui()->debug("got a bus? {}", + QDBusConnection::sessionBus().connect(QLatin1String("org.freedesktop.portal.Desktop"), + QLatin1String("/org/freedesktop/portal/desktop"), + QLatin1String("org.freedesktop.portal.Settings"), + QLatin1String("SettingChanged"), + this, + SLOT(handleThemeChange(QString,QString,QVariant)))); + auto x = QDBusConnection::sessionBus().lastError(); + nhlog::ui()->debug(x.message().toStdString()); +#endif connect(ChatPage::instance(), &ChatPage::contentLoaded, this, &Nheko::updateUserProfile); connect(ChatPage::instance(), &ChatPage::showRoomJoinPrompt, this, &Nheko::showRoomJoinPrompt); connect(this, &Nheko::joinRoom, ChatPage::instance(), &ChatPage::joinRoom); @@ -37,6 +50,18 @@ Nheko::updateUserProfile() emit profileChanged(); } +#ifdef NHEKO_DBUS_SYS +void +Nheko::handleThemeChange(QString interface, QString setting, QVariant) +//Nheko::handleThemeChange(const QString &interface, const QString &setting, const QVariant &) +{ + nhlog::ui()->debug("theme change {} {}", interface.toStdString(), setting.toStdString()); + if (interface == QLatin1String("org.freedesktop.appearance") && + setting == QLatin1String("color-scheme")) + emit colorsChanged(); +} +#endif + QPalette Nheko::colors() const { diff --git a/src/ui/NhekoGlobalObject.h b/src/ui/NhekoGlobalObject.h index 6ef71bcc..507e93e0 100644 --- a/src/ui/NhekoGlobalObject.h +++ b/src/ui/NhekoGlobalObject.h @@ -74,6 +74,9 @@ public: public slots: void updateUserProfile(); +#ifdef NHEKO_DBUS_SYS + void handleThemeChange(QString interface, QString setting, QVariant); +#endif signals: void colorsChanged();