diff --git a/kcms/componentchooser/CMakeLists.txt b/kcms/componentchooser/CMakeLists.txt index 15c93cbc9..36f324d81 100644 --- a/kcms/componentchooser/CMakeLists.txt +++ b/kcms/componentchooser/CMakeLists.txt @@ -1,51 +1,53 @@ # KI18N Translation Domain for this library add_definitions(-DTRANSLATION_DOMAIN=\"kcm5_componentchooser\") add_subdirectory( componentservices ) ########### next target ############### set(kcm_componentchooser_SRCS componentchooser.cpp componentchooserbrowser.cpp componentchooserfilemanager.cpp componentchooseremail.cpp componentchooserterminal.cpp 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 filemanagerconfig_ui.ui emailclientconfig_ui.ui componentchooser_ui.ui componentconfig_ui.ui terminalemulatorconfig_ui.ui ) add_library(kcm_componentchooser MODULE ${kcm_componentchooser_SRCS}) target_link_libraries(kcm_componentchooser KF5::I18n KF5::Completion KF5::ConfigWidgets KF5::Service KF5::KIOWidgets KF5::KDELibs4Support Qt5::DBus Qt5::X11Extras ) install(TARGETS kcm_componentchooser DESTINATION ${KDE_INSTALL_PLUGINDIR} ) ########### install files ############### 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}) diff --git a/kcms/componentchooser/componentchooserterminal.cpp b/kcms/componentchooser/componentchooserterminal.cpp index 7d0eaa097..4ceff2e90 100644 --- a/kcms/componentchooser/componentchooserterminal.cpp +++ b/kcms/componentchooser/componentchooserterminal.cpp @@ -1,115 +1,114 @@ /*************************************************************************** componentchooser.cpp - description ------------------- copyright : (C) 2002 by Joseph Wenninger email : jowenn@kde.org ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License verstion 2 as * * published by the Free Software Foundation * * * ***************************************************************************/ #include "componentchooserterminal.h" +#include "terminal_settings.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "../migrationlib/kdelibs4config.h" CfgTerminalEmulator::CfgTerminalEmulator(QWidget *parent) : QWidget(parent), Ui::TerminalEmulatorConfig_UI(), CfgPlugin() { setupUi(this); connect(terminalLE, &QLineEdit::textChanged, this, &CfgTerminalEmulator::configChanged); connect(terminalCB, &QRadioButton::toggled, this, &CfgTerminalEmulator::configChanged); connect(otherCB, &QRadioButton::toggled, this, &CfgTerminalEmulator::configChanged); connect(btnSelectTerminal, &QToolButton::clicked, this, &CfgTerminalEmulator::selectTerminalApp); } CfgTerminalEmulator::~CfgTerminalEmulator() { } void CfgTerminalEmulator::configChanged() { emit changed(true); } 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")); terminalCB->setChecked(true); } else { terminalLE->setText(terminal); otherCB->setChecked(true); } emit changed(false); } 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); } void CfgTerminalEmulator::selectTerminalApp() { QList urlList; KOpenWithDialog dlg(urlList, i18n("Select preferred terminal application:"), QString(), this); // hide "Run in &terminal" here, we don't need it for a Terminal Application dlg.hideRunInTerminal(); if (dlg.exec() != QDialog::Accepted) return; QString client = dlg.text(); if (!client.isEmpty()) { terminalLE->setText(client); } } // vim: sw=4 ts=4 noet diff --git a/kcms/componentchooser/terminal_settings.kcfg b/kcms/componentchooser/terminal_settings.kcfg new file mode 100644 index 000000000..ee7c1afac --- /dev/null +++ b/kcms/componentchooser/terminal_settings.kcfg @@ -0,0 +1,13 @@ + + + + + + + konsole + + + diff --git a/kcms/componentchooser/terminal_settings.kcfgc b/kcms/componentchooser/terminal_settings.kcfgc new file mode 100644 index 000000000..b30245ab8 --- /dev/null +++ b/kcms/componentchooser/terminal_settings.kcfgc @@ -0,0 +1,5 @@ +File=terminal_settings.kcfg +ClassName=TerminalSettings +Mutators=true +DefaultValueGetters=true +ParentInConstructor=true