[kcmkwin/deco] Reconfigure deco after applying changes

Required hooks also added to KWin core and Aurorae.
This commit is contained in:
Martin Gräßlin 2014-12-05 15:58:05 +01:00
parent 798b1ad860
commit 521627396f
6 changed files with 27 additions and 43 deletions

View file

@ -277,6 +277,7 @@ void Decoration::init()
{
KDecoration2::Decoration::init();
auto s = settings();
connect(s.data(), &KDecoration2::DecorationSettings::reconfigured, this, &Decoration::configChanged);
// recreate scene when compositing gets disabled, TODO: remove with rendercontrol
#if !HAVE_RENDER_CONTROL
if (!m_recreateNonCompositedConnection) {
@ -713,46 +714,13 @@ void ConfigurationModule::init()
uiFile.close();
layout()->addWidget(customConfigForm);
// connect the ui file with the skeleton
m_configManager = new KConfigDialogManager(customConfigForm, m_skeleton);
m_configManager->updateWidgets();
connect(m_configManager, &KConfigDialogManager::widgetModified,
this, static_cast<void (ConfigurationModule::*)()>(&KCModule::changed));
addConfig(m_skeleton, customConfigForm);
// send a custom event to the translator to retranslate using our translator
QEvent le(QEvent::LanguageChange);
QCoreApplication::sendEvent(customConfigForm, &le);
}
void ConfigurationModule::defaults()
{
if (m_configManager) {
m_configManager->updateWidgetsDefault();
}
KCModule::defaults();
}
void ConfigurationModule::load()
{
if (m_skeleton) {
m_skeleton->load();
}
if (m_configManager) {
m_configManager->updateWidgets();
}
KCModule::load();
}
void ConfigurationModule::save()
{
if (m_configManager) {
m_configManager->updateSettings();
}
if (m_skeleton) {
m_skeleton->save();
}
KCModule::save();
}
}
#include "aurorae.moc"

View file

@ -34,7 +34,6 @@ class QQuickWindow;
class QWindow;
class KConfigLoader;
class KConfigDialogManager;
namespace KWin
{
@ -62,6 +61,9 @@ public Q_SLOTS:
void init() override;
void installTitleItem(QQuickItem *item);
Q_SIGNALS:
void configChanged();
protected:
void hoverEnterEvent(QHoverEvent *event) override;
void hoverLeaveEvent(QHoverEvent *event) override;
@ -119,16 +121,10 @@ class ConfigurationModule : public KCModule
public:
ConfigurationModule(QWidget *parent, const QVariantList &args);
public Q_SLOTS:
void defaults() override;
void load() override;
void save() override;
private:
void init();
QString m_theme;
KConfigLoader *m_skeleton = nullptr;
KConfigDialogManager *m_configManager = nullptr;
};
}

View file

@ -413,4 +413,8 @@ Decoration {
maximizedBorders.setTitle(top.maximizedHeight);
readConfig();
}
Connections {
target: decoration
onConfigChanged: root.readConfig()
}
}

View file

@ -180,6 +180,8 @@ void SettingsImpl::readSettings()
m_borderSize = size;
emit decorationSettings()->borderSizeChanged(m_borderSize);
}
emit decorationSettings()->reconfigured();
}
}

View file

@ -11,6 +11,7 @@ add_library(kdecorationprivatedeclarative SHARED ${plugin_SRCS})
target_link_libraries(kdecorationprivatedeclarative
KDecoration2::KDecoration
KDecoration2::KDecoration2Private
Qt5::DBus
Qt5::Quick
KF5::CoreAddons
KF5::ConfigWidgets

View file

@ -31,6 +31,8 @@
#include <KPluginTrader>
#include <QDebug>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDialog>
#include <QDialogButtonBox>
#include <QPushButton>
@ -195,7 +197,18 @@ void PreviewBridge::configure()
return;
}
connect(&dialog, &QDialog::accepted, kcm, &KCModule::save);
auto save = [this,kcm] {
kcm->save();
if (!m_lastCreatedSettings) {
}
emit m_lastCreatedSettings->decorationSettings()->reconfigured();
// Send signal to all kwin instances
QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/KWin"),
QStringLiteral("org.kde.KWin"),
QStringLiteral("reloadConfig"));
QDBusConnection::sessionBus().send(message);
};
connect(&dialog, &QDialog::accepted, this, save);
QDialogButtonBox *buttons = new QDialogButtonBox(QDialogButtonBox::Ok |
QDialogButtonBox::Cancel |
@ -211,7 +224,7 @@ void PreviewBridge::configure()
// Here we connect our buttons with the dialog
connect(buttons, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
connect(buttons, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
connect(apply, &QPushButton::clicked, kcm, &KCModule::save);
connect(apply, &QPushButton::clicked, this, save);
connect(reset, &QPushButton::clicked, kcm, &KCModule::load);
auto changedSignal = static_cast<void(KCModule::*)(bool)>(&KCModule::changed);
connect(kcm, changedSignal, apply, &QPushButton::setEnabled);