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);
}
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
/**

View file

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

View file

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

View file

@ -40,6 +40,8 @@ public slots:
Q_SCRIPTABLE QString statusMessage() const;
//! Sets the user's status 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:
void bringWindowToTop() const;