~ubuntu-branches/ubuntu/raring/recorditnow/raring

« back to all changes in this revision

Viewing changes to src/configdialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-09 14:54:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110109145401-gyckb4airz4fio50
Tags: 0.8.1-0ubuntu1
* New upstream release. (LP: #681270)
  - Update debian/copyright.
* Build-depend on recordmydesktop.
* Add a watch file.
* Drop 01_fix_ftbfs_kwarning_call.diff, fixed upstream.
* Add 01_joschy_install_to_usr_lib.diff.
* Add 02_fix_ftbfs_no-add-needed.diff.
* Add 03_dont_install_header_files.diff.
* Replace dependency on libpolkit-qt-1-0 with policykit-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 *   Copyright (C) 2009 by Kai Dombrowe <just89@gmx.de>                    *
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                         *
16
 
 *   Free Software Foundation, Inc.,                                       *
17
 
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
18
 
 ***************************************************************************/
19
 
 
20
 
 
21
 
// own
22
 
#include "configdialog.h"
23
 
#include <recorditnow.h>
24
 
#include "recorditnowpluginmanager.h"
25
 
#include "mouseconfig.h"
26
 
 
27
 
// KDE
28
 
#include <kdebug.h>
29
 
#include <kpluginselector.h>
30
 
#include <kshortcutseditor.h>
31
 
 
32
 
 
33
 
ConfigDialog::ConfigDialog(QWidget *parent, KActionCollection *collection,
34
 
                           RecordItNowPluginManager *manager)
35
 
    : KConfigDialog(parent, "settings", Settings::self()),
36
 
    m_pluginManager(manager),
37
 
    m_collection(collection)
38
 
{
39
 
 
40
 
    Q_ASSERT(m_pluginManager);
41
 
    setAttribute(Qt::WA_DeleteOnClose);
42
 
    setInitialSize(QSize(550, 500));
43
 
    init();
44
 
 
45
 
}
46
 
 
47
 
 
48
 
ConfigDialog::~ConfigDialog()
49
 
{
50
 
 
51
 
 
52
 
 
53
 
}
54
 
 
55
 
 
56
 
void ConfigDialog::init()
57
 
{
58
 
 
59
 
    QWidget *generalPage = new QWidget(this);
60
 
    ui_settings.setupUi(generalPage);
61
 
 
62
 
    m_pluginSelector = new KPluginSelector(this);
63
 
    connect(m_pluginSelector, SIGNAL(changed(bool)), this, SLOT(pluginSettingsChanged(bool)));
64
 
 
65
 
    m_pluginSelector->addPlugins(m_pluginManager->getRecorderList(),
66
 
                               KPluginSelector::ReadConfigFile,
67
 
                               i18n("Record Plugins"), "Recorder");
68
 
    m_pluginSelector->addPlugins(m_pluginManager->getEncoderList(),
69
 
                               KPluginSelector::ReadConfigFile,
70
 
                               i18n("Encode Plugins"), "Encoder");
71
 
    m_pluginSelector->addPlugins(m_pluginManager->getUploaderList(),
72
 
                               KPluginSelector::ReadConfigFile,
73
 
                               i18n("Upload Plugins"), "Uploader");
74
 
    
75
 
    updateEncoderCombo();
76
 
    ui_settings.encoderCombo->setCurrentItem(Settings::encoderName(), false);
77
 
 
78
 
    connect(ui_settings.encoderCombo, SIGNAL(currentIndexChanged(QString)), this,
79
 
            SLOT(encoderChanged()));
80
 
 
81
 
 
82
 
    m_mousePage = new MouseConfig(this);
83
 
    connect(m_mousePage, SIGNAL(configChanged()), this, SLOT(pageConfigChanged()));
84
 
    m_mousePage->loadConfig();
85
 
 
86
 
    QWidget *zoomPage = new QWidget(this);
87
 
    ui_zoom.setupUi(zoomPage);
88
 
 
89
 
    QWidget *timelinePage = new QWidget(this);
90
 
    ui_timeline.setupUi(timelinePage);
91
 
 
92
 
    m_shortcutsPage = new KShortcutsEditor(m_collection, this);
93
 
    connect(m_shortcutsPage, SIGNAL(keyChange()), this, SLOT(pageConfigChanged()));
94
 
 
95
 
    addPage(generalPage, i18n("RecordItNow"), "configure");
96
 
    addPage(m_pluginSelector, i18n("Plugins"), "preferences-plugin");
97
 
    addPage(m_mousePage, i18n("Mouse"), "input-mouse");
98
 
    addPage(zoomPage, i18n("Zoom"), "zoom-in");
99
 
    addPage(timelinePage, i18n("Timeline"), "recorditnow-timeline");
100
 
    addPage(m_shortcutsPage, i18n("Shortcuts"), "configure-shortcuts");
101
 
 
102
 
    connect(this, SIGNAL(finished(int)), this, SLOT(configFinished(int)));
103
 
 
104
 
}
105
 
 
106
 
 
107
 
void ConfigDialog::updateEncoderCombo()
108
 
{
109
 
 
110
 
    const QString oldEncoder = ui_settings.encoderCombo->currentText();
111
 
    ui_settings.encoderCombo->clear();
112
 
    foreach (const KPluginInfo &info, m_pluginManager->getEncoderList()) {
113
 
        if (info.isPluginEnabled()) {
114
 
            ui_settings.encoderCombo->addItem(KIcon(info.icon()), info.name());
115
 
        }
116
 
    }
117
 
    ui_settings.encoderCombo->setCurrentItem(oldEncoder, false);
118
 
 
119
 
}
120
 
 
121
 
 
122
 
void ConfigDialog::configFinished(const int &code)
123
 
{
124
 
 
125
 
    if (code == KConfigDialog::Accepted) {
126
 
        m_pluginSelector->updatePluginsState();
127
 
        m_pluginSelector->save();
128
 
        Settings::setEncoderName(ui_settings.encoderCombo->currentText());
129
 
 
130
 
        m_mousePage->saveConfig();
131
 
        m_shortcutsPage->save();
132
 
    }
133
 
    emit dialogFinished();
134
 
 
135
 
}
136
 
 
137
 
 
138
 
void ConfigDialog::pluginSettingsChanged(const bool &changed)
139
 
{
140
 
 
141
 
    enableButtonApply(true);
142
 
    if (!changed) {
143
 
        return;
144
 
    }
145
 
    m_pluginSelector->updatePluginsState();
146
 
    updateEncoderCombo();
147
 
 
148
 
}
149
 
 
150
 
 
151
 
void ConfigDialog::encoderChanged()
152
 
{
153
 
 
154
 
    enableButtonApply(true);
155
 
 
156
 
}
157
 
 
158
 
 
159
 
void ConfigDialog::pageConfigChanged()
160
 
{
161
 
 
162
 
    enableButtonApply(true);
163
 
 
164
 
}
165
 
 
166
 
 
167
 
void ConfigDialog::updateWidgetsDefault()
168
 
{
169
 
 
170
 
    KConfigDialog::updateWidgetsDefault();
171
 
    m_mousePage->defaults();
172
 
    m_shortcutsPage->allDefault();
173
 
 
174
 
}
175
 
 
176
 
 
177
 
void ConfigDialog::updateSettings()
178
 
{
179
 
 
180
 
    KConfigDialog::updateSettings();
181
 
    enableButtonApply(false);
182
 
 
183
 
}
184
 
 
185
 
 
186
 
#include "configdialog.moc"
187