Commit 19844315 authored by Méven Car's avatar Méven Car
Browse files

[KCM/Component] Terminal port to KConfigXT, make isDefault work

Reviewers: ervin, #plasma

Reviewed By: ervin

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26323
parent 3bd210f1
......@@ -16,6 +16,7 @@ set(kcm_componentchooser_SRCS
kcm_componentchooser.cpp
)
kconfig_add_kcfg_files(kcm_componentchooser_SRCS browser_settings.kcfgc GENERATE_MOC)
kconfig_add_kcfg_files(kcm_componentchooser_SRCS terminal_settings.kcfgc GENERATE_MOC)
ki18n_wrap_ui(kcm_componentchooser_SRCS
browserconfig_ui.ui
......@@ -48,4 +49,5 @@ install(TARGETS kcm_componentchooser DESTINATION ${KDE_INSTALL_PLUGINDIR} )
install( FILES componentchooser.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR} )
install(FILES browser_settings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
install(FILES terminal_settings.kcfg DESTINATION ${KDE_INSTALL_KCFGDIR})
......@@ -14,6 +14,7 @@
***************************************************************************/
#include "componentchooserterminal.h"
#include "terminal_settings.h"
#include <ktoolinvocation.h>
#include <QDBusConnection>
......@@ -55,17 +56,19 @@ void CfgTerminalEmulator::configChanged()
void CfgTerminalEmulator::defaults()
{
load(nullptr);
terminalCB->setChecked(true);
}
bool CfgTerminalEmulator::isDefaults() const
{
return false;
return terminalCB->isChecked();
}
void CfgTerminalEmulator::load(KConfig *) {
KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General");
QString terminal = config.readPathEntry("TerminalApplication",QStringLiteral("konsole"));
void CfgTerminalEmulator::load(KConfig *)
{
TerminalSettings settings;
QString terminal = settings.terminalApplication();
if (terminal == QLatin1String("konsole"))
{
terminalLE->setText(QStringLiteral("xterm"));
......@@ -82,19 +85,15 @@ void CfgTerminalEmulator::load(KConfig *) {
void CfgTerminalEmulator::save(KConfig *)
{
KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("kdeglobals"));
KConfigGroup config(profile, QStringLiteral("General"));
const QString terminal = terminalCB->isChecked() ? QStringLiteral("konsole") : terminalLE->text();
config.writePathEntry("TerminalApplication", terminal); // KConfig::Normal|KConfig::Global);
config.sync();
Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("General"), "kdeglobals");
QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.klauncher5"),
QStringLiteral("/KLauncher"),
QStringLiteral("org.kde.KLauncher"),
QStringLiteral("reparseConfiguration"));
QDBusConnection::sessionBus().send(message);
TerminalSettings settings;
settings.setTerminalApplication(terminalCB->isChecked() ? settings.defaultTerminalApplicationValue() : terminalLE->text());
settings.save();
QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.klauncher5"),
QStringLiteral("/KLauncher"),
QStringLiteral("org.kde.KLauncher"),
QStringLiteral("reparseConfiguration"));
QDBusConnection::sessionBus().send(message);
emit changed(false);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kdeglobals"/>
<group name="General">
<entry name="terminalApplication" key="TerminalApplication" type="String">
<default>konsole</default>
</entry>
</group>
</kcfg>
File=terminal_settings.kcfg
ClassName=TerminalSettings
Mutators=true
DefaultValueGetters=true
ParentInConstructor=true
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