~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kcontrol/keys/select_scheme_dialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright 2008 Michael Jansen <kde@michael-jansen.biz>
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 */
 
18
#include "select_scheme_dialog.h"
 
19
#include "ui_select_scheme_dialog.h"
 
20
 
 
21
 
 
22
#include "KDialog"
 
23
#include "KStandardDirs"
 
24
#include <KLineEdit>
 
25
 
 
26
SelectSchemeDialog::SelectSchemeDialog(QWidget *parent)
 
27
 : KDialog(parent),
 
28
   ui(new Ui::SelectSchemeDialog)
 
29
{
 
30
    m_schemes = KGlobal::dirs()->findAllResources("data", "kcmkeys/*.kksrc");
 
31
 
 
32
    ui->setupUi(this);
 
33
    setMainWidget(ui->layoutWidget);
 
34
 
 
35
    foreach (const QString &res, m_schemes) {
 
36
        KConfig config(res, KConfig::SimpleConfig);
 
37
        KConfigGroup group(&config, "Settings");
 
38
        QString name = group.readEntry("Name");
 
39
 
 
40
        if (name.isEmpty()) {
 
41
            name = res;
 
42
        }
 
43
        ui->m_schemes->addItem(name);
 
44
    }
 
45
 
 
46
    ui->m_schemes->setCurrentIndex(-1);
 
47
 
 
48
    ui->m_url->setMode(KFile::LocalOnly | KFile::ExistingOnly);
 
49
 
 
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);
 
55
}
 
56
 
 
57
 
 
58
SelectSchemeDialog::~SelectSchemeDialog()
 
59
{
 
60
    delete ui;
 
61
}
 
62
 
 
63
void SelectSchemeDialog::schemeActivated(int index)
 
64
{
 
65
    ui->m_url->setUrl(m_schemes[index]);
 
66
}
 
67
 
 
68
 
 
69
KUrl SelectSchemeDialog::selectedScheme() const
 
70
{
 
71
    return ui->m_url->url();
 
72
}
 
73
 
 
74
void SelectSchemeDialog::slotUrlChanged(const QString &_text)
 
75
{
 
76
    enableButtonOk(!_text.isEmpty());
 
77
}
 
78
 
 
79
#include "moc_select_scheme_dialog.cpp"