1 /***************************************************************************
2 componentchooserbrowser.cpp
4 copyright : (C) 2002 by Joseph Wenninger
6 ***************************************************************************/
8 /***************************************************************************
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License version 2 as *
12 * published by the Free Software Foundationi *
14 ***************************************************************************/
16 #include "componentchooserbrowser.h"
17 #include <kopenwithdialog.h>
18 #include <kglobalsettings.h>
19 #include <kconfiggroup.h>
23 CfgBrowser::CfgBrowser(QWidget
*parent
)
24 : QWidget(parent
), Ui::BrowserConfig_UI(),CfgPlugin()
27 connect(lineExec
,SIGNAL(textChanged(const QString
&)),this,SLOT(configChanged()));
28 connect(radioKIO
,SIGNAL(toggled(bool)),this,SLOT(configChanged()));
29 connect(radioExec
,SIGNAL(toggled(bool)),this,SLOT(configChanged()));
30 connect(btnSelectBrowser
,SIGNAL(clicked()),this, SLOT(selectBrowser()));
33 CfgBrowser::~CfgBrowser() {
36 void CfgBrowser::configChanged()
41 void CfgBrowser::defaults()
47 void CfgBrowser::load(KConfig
*) {
48 KConfigGroup
config(KSharedConfig::openConfig("kdeglobals"), "General");
49 QString exec
= config
.readEntry("BrowserApplication");
52 radioKIO
->setChecked(true);
58 radioExec
->setChecked(true);
59 if (exec
.startsWith('!'))
61 m_browserExec
= exec
.mid(1);
66 m_browserService
= KService::serviceByStorageId( exec
);
68 m_browserExec
= m_browserService
->desktopEntryName();
70 m_browserExec
.clear();
74 lineExec
->setText(m_browserExec
);
79 void CfgBrowser::save(KConfig
*)
81 KConfigGroup
config(KSharedConfig::openConfig("kdeglobals"), "General");
83 if (radioExec
->isChecked())
85 exec
= lineExec
->text();
86 if (m_browserService
&& (exec
== m_browserExec
))
87 exec
= m_browserService
->storageId(); // Use service
89 exec
= '!' + exec
; // Literal command
91 config
.writePathEntry("BrowserApplication", exec
, KConfig::Normal
|KConfig::Global
);
94 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged
);
99 void CfgBrowser::selectBrowser()
102 KOpenWithDialog
dlg(urlList
, i18n("Select preferred Web browser application:"), QString(), this);
103 if (dlg
.exec() != QDialog::Accepted
)
105 m_browserService
= dlg
.service();
106 if (m_browserService
)
107 m_browserExec
= m_browserService
->desktopEntryName();
109 m_browserExec
= dlg
.text();
111 lineExec
->setText(m_browserExec
);