Add setTheme D-Bus API

Signed-off-by: weeman <weeman@frankfurt.ccc.de>
This commit is contained in:
weeman 2025-08-17 13:01:33 +02:00
parent 398cef5f8f
commit ffaa12cc19
No known key found for this signature in database
GPG key ID: 77942618835C6903
4 changed files with 20 additions and 0 deletions

View file

@ -170,6 +170,14 @@ setStatusMessage(const QString &message)
interface.call(QDBus::NoBlock, QStringLiteral("setStatusMessage"), message); interface.call(QDBus::NoBlock, QStringLiteral("setStatusMessage"), message);
} }
void
setTheme(const QString &theme)
{
if (QDBusInterface interface{QStringLiteral(NHEKO_DBUS_SERVICE_NAME), QStringLiteral("/")};
interface.isValid())
interface.call(QDBus::NoBlock, QStringLiteral("setTheme"), theme);
}
} // nheko::dbus } // nheko::dbus
/** /**

View file

@ -85,6 +85,9 @@ statusMessage();
//! Sets the user's status message (if supported by the homeserver). //! Sets the user's status message (if supported by the homeserver).
void void
setStatusMessage(const QString &message); setStatusMessage(const QString &message);
//! Sets the current theme (supported values: "light", "dark" or "system")
void
setTheme(const QString &theme);
QDBusArgument & QDBusArgument &
operator<<(QDBusArgument &arg, const RoomInfoItem &item); operator<<(QDBusArgument &arg, const RoomInfoItem &item);

View file

@ -11,6 +11,7 @@
#include "Logging.h" #include "Logging.h"
#include "MainWindow.h" #include "MainWindow.h"
#include "MxcImageProvider.h" #include "MxcImageProvider.h"
#include "UserSettingsPage.h"
#include "timeline/RoomlistModel.h" #include "timeline/RoomlistModel.h"
#include "timeline/TimelineModel.h" #include "timeline/TimelineModel.h"
@ -112,6 +113,12 @@ NhekoDBusBackend::setStatusMessage(const QString &message)
ChatPage::instance()->setStatus(message); ChatPage::instance()->setStatus(message);
} }
void
NhekoDBusBackend::setTheme(const QString &theme)
{
UserSettings::instance()->setTheme(theme);
}
void void
NhekoDBusBackend::bringWindowToTop() const NhekoDBusBackend::bringWindowToTop() const
{ {

View file

@ -40,6 +40,8 @@ public slots:
Q_SCRIPTABLE QString statusMessage() const; Q_SCRIPTABLE QString statusMessage() const;
//! Sets the user's status message. //! Sets the user's status message.
Q_SCRIPTABLE void setStatusMessage(const QString &message); Q_SCRIPTABLE void setStatusMessage(const QString &message);
//! Sets the current theme (supported values: "light", "dark" or "system")
Q_SCRIPTABLE void setTheme(const QString &theme);
private: private:
void bringWindowToTop() const; void bringWindowToTop() const;