kio: implement interface to change the "StartupWMClass" key of .desktop files

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-20 03:03:09 +03:00
parent 1d2947b476
commit 14b62a7d3d
2 changed files with 41 additions and 2 deletions

View file

@ -134,7 +134,27 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3" >
<item row="1" column="0" >
<widget class="QLabel" name="startupClassLabel" >
<property name="whatsThis" >
<string>Enter the window class here.</string>
</property>
<property name="text" >
<string>&amp;Window class:</string>
</property>
<property name="buddy" >
<cstring>startupClassEdit</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="startupClassEdit" >
<property name="whatsThis" >
<string>Enter the window class here.</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3" >
<widget class="QCheckBox" name="systrayCheck" >
<property name="whatsThis" >
<string>Check this option if you want to have a system tray handle for your application.</string>
@ -237,5 +257,17 @@
</hint>
</hints>
</connection>
<connection>
<sender>startupInfoCheck</sender>
<signal>toggled(bool)</signal>
<receiver>startupClassEdit</receiver>
<slot>setEnabled(bool)</slot>
</connection>
<connection>
<sender>startupInfoCheck</sender>
<signal>toggled(bool)</signal>
<receiver>startupClassLabel</receiver>
<slot>setEnabled(bool)</slot>
</connection>
</connections>
</ui>

View file

@ -3006,6 +3006,7 @@ public:
QString m_origCommandStr;
QString m_terminalOptionStr;
QString m_suidUserStr;
QString m_startupClassStr;
QString m_origDesktopFile;
bool m_terminalBool;
bool m_suidBool;
@ -3081,6 +3082,7 @@ KDesktopPropsPlugin::KDesktopPropsPlugin(KPropertiesDialog *props)
d->m_suidBool = config.readEntry("X-KDE-SubstituteUID", false);
d->m_suidUserStr = config.readEntry("X-KDE-Username");
d->m_startupBool = config.readEntry("StartupNotify", false);
d->m_startupClassStr = config.readEntry("StartupWMClass", QString());
const QStringList mimeTypes = config.readXdgListEntry("MimeType");
@ -3250,7 +3252,7 @@ void KDesktopPropsPlugin::applyChanges()
config.writeEntry("X-KDE-SubstituteUID", d->m_suidBool);
config.writeEntry("X-KDE-Username", d->m_suidUserStr);
config.writeEntry("StartupNotify", d->m_startupBool);
#warning TODO: StartupWMClass
config.writeEntry("StartupWMClass", d->m_startupClassStr);
config.sync();
// KSycoca update needed?
@ -3320,6 +3322,9 @@ void KDesktopPropsPlugin::slotAdvanced()
w.suidEditLabel->setEnabled(d->m_suidBool);
w.startupInfoCheck->setChecked(d->m_startupBool);
w.startupClassEdit->setText(d->m_startupClassStr);
w.startupClassEdit->setEnabled(d->m_startupBool);
w.startupClassLabel->setEnabled(d->m_startupBool);
w.systrayCheck->setChecked(d->m_systrayBool);
// Provide username completion up to 1000 users.
@ -3345,6 +3350,7 @@ void KDesktopPropsPlugin::slotAdvanced()
connect(w.suidCheck, SIGNAL(toggled(bool)), this, SIGNAL(changed()));
connect(w.suidEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed()) );
connect(w.startupInfoCheck, SIGNAL(toggled(bool)), this, SIGNAL(changed()) );
connect(w.startupClassEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed()) );
connect(w.systrayCheck, SIGNAL(toggled(bool)), this, SIGNAL(changed()) );
if (dlg.exec() == QDialog::Accepted) {
@ -3353,6 +3359,7 @@ void KDesktopPropsPlugin::slotAdvanced()
d->m_suidBool = w.suidCheck->isChecked();
d->m_suidUserStr = w.suidEdit->text().trimmed();
d->m_startupBool = w.startupInfoCheck->isChecked();
d->m_startupClassStr = w.startupClassEdit->text().trimmed();
d->m_systrayBool = w.systrayCheck->isChecked();
if (w.terminalCloseCheck->isChecked()) {