Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit a1fa8ba4 authored by Jan Grulich's avatar Jan Grulich

Settings portal: initial support for settingChanged() signal

parent 9e15ba69
......@@ -91,6 +91,13 @@ SettingsPortal::SettingsPortal(QObject *parent)
qDBusRegisterMetaType<VariantMapMap>();
m_kdeglobals = KSharedConfig::openConfig();
QDBusConnection::sessionBus().connect(QString(), QStringLiteral("/KDEPlatformTheme"), QStringLiteral("org.kde.KDEPlatformTheme"),
QStringLiteral("refreshFonts"), this, SLOT(fontChanged()));
QDBusConnection::sessionBus().connect(QString(), QStringLiteral("/KGlobalSettings"), QStringLiteral("org.kde.KGlobalSettings"),
QStringLiteral("notifyChange"), this, SLOT(globalSettingChanged(int,int)));
QDBusConnection::sessionBus().connect(QString(), QStringLiteral("/KToolBar"), QStringLiteral("org.kde.KToolBar"),
QStringLiteral("styleChanged"), this, SLOT(toolbarStyleChanged()));
}
SettingsPortal::~SettingsPortal()
......@@ -171,3 +178,56 @@ QDBusVariant SettingsPortal::Read(const QString &group, const QString &key)
return QDBusVariant(configGroup.readEntry(key));
}
void SettingsPortal::fontChanged()
{
Q_EMIT SettingChanged(QStringLiteral("org.kde.kdeglobals.General"), QStringLiteral("font"), Read(QStringLiteral("org.kde.kdeglobals.General"), QStringLiteral("font")));
}
void SettingsPortal::globalSettingChanged(int type, int arg)
{
m_kdeglobals->reparseConfiguration();
// Mostly based on plasma-integration needs
switch (type) {
case PaletteChanged:
// Plasma-integration will be loading whole palette again, there is no reason to try to identify
// particular categories or colors
Q_EMIT SettingChanged(QStringLiteral("org.kde.kdeglobals.General"), QStringLiteral("ColorScheme"), Read(QStringLiteral("org.kde.kdeglobals.General"), QStringLiteral("ColorScheme")));
break;
case FontChanged:
fontChanged();
break;
case StyleChanged:
Q_EMIT SettingChanged(QStringLiteral("org.kde.kdeglobals.KDE"), QStringLiteral("widgetStyle"), Read(QStringLiteral("org.kde.kdeglobals.KDE"), QStringLiteral("widgetStyle")));
break;
case SettingsChanged: {
SettingsCategory category = static_cast<SettingsCategory>(arg);
if (category == SETTINGS_QT || category == SETTINGS_MOUSE) {
// TODO
} else if (category == SETTINGS_STYLE) {
// TODO
}
break;
}
case IconChanged:
// we will get notified about each category, but it probably makes sense to send this signal just once
if (arg == 0) { // KIconLoader::Desktop
Q_EMIT SettingChanged(QStringLiteral("org.kde.kdeglobals.Icons"), QStringLiteral("Theme"), Read(QStringLiteral("org.kde.kdeglobals.Icons"), QStringLiteral("Theme")));
}
break;
case CursorChanged:
// TODO
break;
case ToolbarStyleChanged:
toolbarStyleChanged();
break;
default:
break;
}
}
void SettingsPortal::toolbarStyleChanged()
{
Q_EMIT SettingChanged(QStringLiteral("org.kde.kdeglobals.Toolbar style"), QStringLiteral("ToolButtonStyle"), Read(QStringLiteral("org.kde.kdeglobals.Toolbar style"), QStringLiteral("ToolButtonStyle")));
}
......@@ -32,6 +32,25 @@ class SettingsPortal : public QDBusAbstractAdaptor
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.freedesktop.impl.portal.Settings")
public:
/**
* An identifier for change signals.
* @note Copied from KGlobalSettings
*/
enum ChangeType { PaletteChanged = 0, FontChanged, StyleChanged,
SettingsChanged, IconChanged, CursorChanged,
ToolbarStyleChanged, ClipboardConfigChanged,
BlockShortcuts, NaturalSortingChanged
};
/**
* Valid values for the settingsChanged signal
* @note Copied from KGlobalSettings
*/
enum SettingsCategory { SETTINGS_MOUSE, SETTINGS_COMPLETION, SETTINGS_PATHS,
SETTINGS_POPUPMENU, SETTINGS_QT, SETTINGS_SHORTCUTS,
SETTINGS_LOCALE, SETTINGS_STYLE
};
explicit SettingsPortal(QObject *parent);
~SettingsPortal();
......@@ -44,9 +63,12 @@ public Q_SLOTS:
QDBusVariant Read(const QString &group, const QString &keys);
Q_SIGNALS:
// TODO not implemented yet
void SettingChanged(const QString &group, const QString &key, const QVariant &value);
void SettingChanged(const QString &group, const QString &key, const QDBusVariant &value);
private Q_SLOTS:
void fontChanged();
void globalSettingChanged(int type, int arg);
void toolbarStyleChanged();
private:
KSharedConfigPtr m_kdeglobals;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment