delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / kcontrol / componentchooser / componentchooserbrowser.cpp
blob2956fa2a3415bfdec83b81836bcc5a301c6ed914
1 /***************************************************************************
2 componentchooserbrowser.cpp
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 version 2 as *
12 * published by the Free Software Foundationi *
13 * *
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()
26 setupUi(this);
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()
38 emit changed(true);
41 void CfgBrowser::defaults()
43 load(0);
47 void CfgBrowser::load(KConfig *) {
48 KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), "General");
49 QString exec = config.readEntry("BrowserApplication");
50 if (exec.isEmpty())
52 radioKIO->setChecked(true);
53 m_browserExec = exec;
54 m_browserService = 0;
56 else
58 radioExec->setChecked(true);
59 if (exec.startsWith('!'))
61 m_browserExec = exec.mid(1);
62 m_browserService = 0;
64 else
66 m_browserService = KService::serviceByStorageId( exec );
67 if (m_browserService)
68 m_browserExec = m_browserService->desktopEntryName();
69 else
70 m_browserExec.clear();
74 lineExec->setText(m_browserExec);
76 emit changed(false);
79 void CfgBrowser::save(KConfig *)
81 KConfigGroup config(KSharedConfig::openConfig("kdeglobals"), "General");
82 QString exec;
83 if (radioExec->isChecked())
85 exec = lineExec->text();
86 if (m_browserService && (exec == m_browserExec))
87 exec = m_browserService->storageId(); // Use service
88 else
89 exec = '!' + exec; // Literal command
91 config.writePathEntry("BrowserApplication", exec, KConfig::Normal|KConfig::Global);
92 config.sync();
94 KGlobalSettings::self()->emitChange(KGlobalSettings::SettingsChanged);
96 emit changed(false);
99 void CfgBrowser::selectBrowser()
101 KUrl::List urlList;
102 KOpenWithDialog dlg(urlList, i18n("Select preferred Web browser application:"), QString(), this);
103 if (dlg.exec() != QDialog::Accepted)
104 return;
105 m_browserService = dlg.service();
106 if (m_browserService)
107 m_browserExec = m_browserService->desktopEntryName();
108 else
109 m_browserExec = dlg.text();
111 lineExec->setText(m_browserExec);