add more spacing
[personal-kdebase.git] / workspace / kcontrol / keys / select_scheme_dialog.cpp
blob7f1fcbff4d375d479b64bc1f40b5fb548174c551
1 /*
2 * Copyright 2008 Michael Jansen <kde@michael-jansen.biz>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #include "select_scheme_dialog.h"
19 #include "ui_select_scheme_dialog.h"
22 #include "KDialog"
23 #include "KStandardDirs"
24 #include <KLineEdit>
26 SelectSchemeDialog::SelectSchemeDialog(QWidget *parent)
27 : KDialog(parent),
28 ui(new Ui::SelectSchemeDialog)
30 m_schemes = KGlobal::dirs()->findAllResources("data", "kcmkeys/*.kksrc");
32 ui->setupUi(this);
33 setMainWidget(ui->widget);
35 foreach (const QString &res, m_schemes) {
36 KConfig config(res, KConfig::SimpleConfig);
37 KConfigGroup group(&config, "Settings");
38 QString name = group.readEntry("Name");
40 if (name.isEmpty()) {
41 name = res;
43 ui->m_schemes->addItem(name);
46 ui->m_schemes->setCurrentIndex(-1);
48 ui->m_url->setMode(KFile::LocalOnly | KFile::ExistingOnly);
50 connect(ui->m_schemes, SIGNAL(activated(int)),
51 this, SLOT(schemeActivated(int)));
52 connect(ui->m_url->lineEdit(), SIGNAL(textChanged(const QString&)),
53 this, SLOT(slotUrlChanged(const QString&)));
54 enableButtonOk(false);
58 SelectSchemeDialog::~SelectSchemeDialog()
60 delete ui;
63 void SelectSchemeDialog::schemeActivated(int index)
65 ui->m_url->setPath(m_schemes[index]);
69 KUrl SelectSchemeDialog::selectedScheme() const
71 return ui->m_url->url();
74 void SelectSchemeDialog::slotUrlChanged(const QString &_text)
76 enableButtonOk(!_text.isEmpty());
79 #include "moc_select_scheme_dialog.cpp"