kgreeter: do not disable the test button if the lightdm process is running

so that the lightdm process can be killed in case widget state changes
while the process is running

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-06-27 01:10:33 +03:00
parent 3fe4d8b021
commit 7bd18eaf34
2 changed files with 14 additions and 2 deletions

View file

@ -42,7 +42,8 @@ K_EXPORT_PLUGIN(KCMGreeterFactory("kcmgreeterconfig", "kcm_greeterconfig"))
KCMGreeter::KCMGreeter(QWidget* parent, const QVariantList& args)
: KCModule(KCMGreeterFactory::componentData(), parent),
m_lightdmexe(KStandardDirs::findRootExe("lightdm")),
m_lightdmproc(nullptr)
m_lightdmproc(nullptr),
m_changed(false)
{
Q_UNUSED(args);
@ -65,6 +66,8 @@ KCMGreeter::KCMGreeter(QWidget* parent, const QVariantList& args)
setDisabled(true);
}
connect(this, SIGNAL(changed(bool)), this, SLOT(slotChanged(bool)));
load();
connect(fontchooser, SIGNAL(fontSelected(QFont)), this, SLOT(slotFontChanged(QFont)));
@ -248,6 +251,7 @@ void KCMGreeter::slotTest()
void KCMGreeter::slotProcessStateChanged(QProcess::ProcessState state)
{
setProcessRunning(state == QProcess::Running);
enableTest(!m_changed);
}
void KCMGreeter::slotProcessFinished(const int exitcode)
@ -257,6 +261,11 @@ void KCMGreeter::slotProcessFinished(const int exitcode)
}
}
void KCMGreeter::slotChanged(bool state)
{
m_changed = state;
}
void KCMGreeter::loadSettings(const QString &font, const QString &style, const QString &color,
const QString &cursor, const QString &background, const QString &rectangle)
{
@ -303,7 +312,7 @@ void KCMGreeter::enableTest(const bool enable)
if (enable) {
testbutton->setEnabled(!m_lightdmexe.isEmpty());
} else {
testbutton->setEnabled(false);
testbutton->setEnabled(m_lightdmproc->state() == QProcess::Running);
}
}

View file

@ -55,6 +55,8 @@ private Q_SLOTS:
void slotProcessStateChanged(QProcess::ProcessState state);
void slotProcessFinished(const int exitcode);
void slotChanged(bool state);
private:
void loadSettings(const QString &font, const QString &style, const QString &color,
const QString &cursor, const QString &background, const QString &rectangle);
@ -64,6 +66,7 @@ private:
QString m_lightdmexe;
QProcess* m_lightdmproc;
bool m_changed;
};
#endif // KGREETERCONFIG_H