add more spacing
[personal-kdebase.git] / runtime / kcontrol / componentchooser / componentchooserterminal.cpp
blob656f9d626ff16469dca20b89f6d1e38d080d368e
1 /***************************************************************************
2 componentchooser.cpp - description
3 -------------------
4 copyright : (C) 2002 by Joseph Wenninger
5 email : jowenn@kde.org
6 ***************************************************************************/
8 /***************************************************************************
9 * *
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 *
12 * published by the Free Software Foundation *
13 * *
14 ***************************************************************************/
16 #include "componentchooserterminal.h"
17 #include "componentchooserterminal.moc"
19 #include <ktoolinvocation.h>
20 #include <klauncher_iface.h>
21 #include <QtDBus/QtDBus>
22 #include <QCheckBox>
23 #include <QLabel>
24 #include <QLayout>
25 #include <QRadioButton>
27 #include <kdebug.h>
28 #include <kapplication.h>
29 #include <klocale.h>
30 #include <kmessagebox.h>
31 #include <kopenwithdialog.h>
32 #include <kconfig.h>
33 #include <kstandarddirs.h>
34 #include <kmimetypetrader.h>
35 #include <kurlrequester.h>
36 #include <kconfiggroup.h>
39 CfgTerminalEmulator::CfgTerminalEmulator(QWidget *parent)
40 : QWidget(parent), Ui::TerminalEmulatorConfig_UI(), CfgPlugin()
42 setupUi(this);
43 connect(terminalLE,SIGNAL(textChanged(QString)), this, SLOT(configChanged()));
44 connect(terminalCB,SIGNAL(toggled(bool)),this,SLOT(configChanged()));
45 connect(otherCB,SIGNAL(toggled(bool)),this,SLOT(configChanged()));
46 connect(btnSelectTerminal,SIGNAL(clicked()),this,SLOT(selectTerminalApp()));
50 CfgTerminalEmulator::~CfgTerminalEmulator() {
53 void CfgTerminalEmulator::configChanged()
55 emit changed(true);
58 void CfgTerminalEmulator::defaults()
60 load(0);
64 void CfgTerminalEmulator::load(KConfig *) {
65 KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), "General");
66 QString terminal = config.readPathEntry("TerminalApplication","konsole");
67 if (terminal == "konsole")
69 terminalLE->setText("xterm");
70 terminalCB->setChecked(true);
72 else
74 terminalLE->setText(terminal);
75 otherCB->setChecked(true);
78 emit changed(false);
81 void CfgTerminalEmulator::save(KConfig *)
83 KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), "General");
84 const QString terminal = terminalCB->isChecked() ? "konsole" : terminalLE->text();
85 config.writePathEntry("TerminalApplication", terminal, KConfig::Normal|KConfig::Global);
86 config.sync();
88 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged);
89 KToolInvocation::klauncher()->reparseConfiguration();
91 emit changed(false);
94 void CfgTerminalEmulator::selectTerminalApp()
96 KUrl::List urlList;
97 KOpenWithDialog dlg(urlList, i18n("Select preferred terminal application:"), QString(), this);
98 // hide "Run in &terminal" here, we don't need it for a Terminal Application
99 dlg.hideRunInTerminal();
100 if (dlg.exec() != QDialog::Accepted) return;
101 QString client = dlg.text();
103 if (!client.isEmpty())
105 terminalLE->setText(client);
108 // vim: sw=4 ts=4 noet