Changeset View
Changeset View
Standalone View
Standalone View
kcms/componentchooser/componentchooserterminal.cpp
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | componentchooser.cpp - description | 2 | componentchooser.cpp - description | ||
3 | ------------------- | 3 | ------------------- | ||
4 | copyright : (C) 2002 by Joseph Wenninger | 4 | copyright : (C) 2002 by Joseph Wenninger | ||
5 | email : jowenn@kde.org | 5 | email : jowenn@kde.org | ||
6 | ***************************************************************************/ | 6 | ***************************************************************************/ | ||
7 | 7 | | |||
8 | /*************************************************************************** | 8 | /*************************************************************************** | ||
9 | * * | 9 | * * | ||
10 | * This program is free software; you can redistribute it and/or modify * | 10 | * This program is free software; you can redistribute it and/or modify * | ||
11 | * it under the terms of the GNU General Public License verstion 2 as * | 11 | * it under the terms of the GNU General Public License verstion 2 as * | ||
12 | * published by the Free Software Foundation * | 12 | * published by the Free Software Foundation * | ||
13 | * * | 13 | * * | ||
14 | ***************************************************************************/ | 14 | ***************************************************************************/ | ||
15 | 15 | | |||
16 | #include "componentchooserterminal.h" | 16 | #include "componentchooserterminal.h" | ||
17 | #include "terminal_settings.h" | ||||
17 | 18 | | |||
18 | #include <ktoolinvocation.h> | 19 | #include <ktoolinvocation.h> | ||
19 | #include <QDBusConnection> | 20 | #include <QDBusConnection> | ||
20 | #include <QDBusMessage> | 21 | #include <QDBusMessage> | ||
21 | #include <QCheckBox> | 22 | #include <QCheckBox> | ||
22 | 23 | | |||
23 | #include <kmessagebox.h> | 24 | #include <kmessagebox.h> | ||
24 | #include <kopenwithdialog.h> | 25 | #include <kopenwithdialog.h> | ||
Show All 25 Lines | |||||
50 | void CfgTerminalEmulator::configChanged() | 51 | void CfgTerminalEmulator::configChanged() | ||
51 | { | 52 | { | ||
52 | emit changed(true); | 53 | emit changed(true); | ||
53 | } | 54 | } | ||
54 | 55 | | |||
55 | void CfgTerminalEmulator::defaults() | 56 | void CfgTerminalEmulator::defaults() | ||
56 | { | 57 | { | ||
57 | load(nullptr); | 58 | load(nullptr); | ||
59 | terminalCB->setChecked(true); | ||||
58 | } | 60 | } | ||
59 | 61 | | |||
60 | bool CfgTerminalEmulator::isDefaults() const | 62 | bool CfgTerminalEmulator::isDefaults() const | ||
61 | { | 63 | { | ||
62 | return false; | 64 | return terminalCB->isChecked(); | ||
63 | } | 65 | } | ||
64 | 66 | | |||
65 | 67 | | |||
66 | void CfgTerminalEmulator::load(KConfig *) { | 68 | void CfgTerminalEmulator::load(KConfig *) | ||
ervin: I'd use the opportunity to fix that opening curly brace to have it on its own line | |||||
67 | KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "General"); | 69 | { | ||
68 | QString terminal = config.readPathEntry("TerminalApplication",QStringLiteral("konsole")); | 70 | TerminalSettings settings; | ||
71 | QString terminal = settings.terminalApplication(); | ||||
69 | if (terminal == QLatin1String("konsole")) | 72 | if (terminal == QLatin1String("konsole")) | ||
70 | { | 73 | { | ||
71 | terminalLE->setText(QStringLiteral("xterm")); | 74 | terminalLE->setText(QStringLiteral("xterm")); | ||
72 | terminalCB->setChecked(true); | 75 | terminalCB->setChecked(true); | ||
73 | } | 76 | } | ||
74 | else | 77 | else | ||
75 | { | 78 | { | ||
76 | terminalLE->setText(terminal); | 79 | terminalLE->setText(terminal); | ||
77 | otherCB->setChecked(true); | 80 | otherCB->setChecked(true); | ||
78 | } | 81 | } | ||
79 | 82 | | |||
80 | emit changed(false); | 83 | emit changed(false); | ||
81 | } | 84 | } | ||
82 | 85 | | |||
83 | void CfgTerminalEmulator::save(KConfig *) | 86 | void CfgTerminalEmulator::save(KConfig *) | ||
84 | { | 87 | { | ||
85 | KSharedConfig::Ptr profile = KSharedConfig::openConfig(QStringLiteral("kdeglobals")); | 88 | TerminalSettings settings; | ||
86 | KConfigGroup config(profile, QStringLiteral("General")); | 89 | settings.setTerminalApplication(terminalCB->isChecked() ? settings.defaultTerminalApplicationValue() : terminalLE->text()); | ||
87 | const QString terminal = terminalCB->isChecked() ? QStringLiteral("konsole") : terminalLE->text(); | 90 | settings.save(); | ||
88 | config.writePathEntry("TerminalApplication", terminal); // KConfig::Normal|KConfig::Global); | | |||
89 | | ||||
90 | config.sync(); | | |||
91 | Kdelibs4SharedConfig::syncConfigGroup(QLatin1String("General"), "kdeglobals"); | | |||
92 | 91 | | |||
93 | QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.klauncher5"), | 92 | QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.klauncher5"), | ||
94 | QStringLiteral("/KLauncher"), | 93 | QStringLiteral("/KLauncher"), | ||
95 | QStringLiteral("org.kde.KLauncher"), | 94 | QStringLiteral("org.kde.KLauncher"), | ||
96 | QStringLiteral("reparseConfiguration")); | 95 | QStringLiteral("reparseConfiguration")); | ||
97 | QDBusConnection::sessionBus().send(message); | 96 | QDBusConnection::sessionBus().send(message); | ||
98 | emit changed(false); | 97 | emit changed(false); | ||
99 | } | 98 | } | ||
Show All 16 Lines |
I'd use the opportunity to fix that opening curly brace to have it on its own line