diff --git a/kcm/src/kcm_kscreen.h b/kcm/src/kcm_kscreen.h --- a/kcm/src/kcm_kscreen.h +++ b/kcm/src/kcm_kscreen.h @@ -41,11 +41,13 @@ virtual void load(); virtual void save(); virtual void defaults(); + void changed(); private: void configReady(KScreen::ConfigOperation *op); Widget *mKScreenWidget; + bool m_blockChanges = false; }; diff --git a/kcm/src/kcm_kscreen.cpp b/kcm/src/kcm_kscreen.cpp --- a/kcm/src/kcm_kscreen.cpp +++ b/kcm/src/kcm_kscreen.cpp @@ -80,8 +80,8 @@ if (!mKScreenWidget) { mKScreenWidget = new Widget(this); layout->addWidget(mKScreenWidget); - connect(mKScreenWidget, SIGNAL(changed()), - this, SLOT(changed())); + QObject::connect(mKScreenWidget, &Widget::changed, + this, &KCMKScreen::changed); } mKScreenWidget->setConfig(qobject_cast(op)->config()); @@ -91,6 +91,13 @@ { } +void KCMKScreen::changed() +{ + if (!m_blockChanges) { + KCModule::changed(); + } +} + void KCMKScreen::save() { qDebug() << "Saving"; @@ -137,11 +144,20 @@ return; } + m_blockChanges = true; /* Store the current config, apply settings */ auto *op = new SetConfigOperation(config); /* Block until the operation is completed, otherwise KCMShell will terminate * before we get to execute the Operation */ op->exec(); + + // The 1000ms is a bit "random" here, it's what works on the systems I've tested, but ultimately, this is a hack + // due to the fact that we just can't be sure when xrandr is done changing things, 1000 doesn't seem to get in the way + QTimer::singleShot(1000, this, + [this] () { + m_blockChanges = false; + } + ); } void KCMKScreen::defaults()