1
/***************************************************************************
2
* Copyright (C) 2009 by Kai Dombrowe <just89@gmx.de> *
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 *
16
* Free Software Foundation, Inc., *
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
18
***************************************************************************/
22
#include "configdialog.h"
23
#include <recorditnow.h>
24
#include "recorditnowpluginmanager.h"
25
#include "mouseconfig.h"
29
#include <kpluginselector.h>
30
#include <kshortcutseditor.h>
33
ConfigDialog::ConfigDialog(QWidget *parent, KActionCollection *collection,
34
RecordItNowPluginManager *manager)
35
: KConfigDialog(parent, "settings", Settings::self()),
36
m_pluginManager(manager),
37
m_collection(collection)
40
Q_ASSERT(m_pluginManager);
41
setAttribute(Qt::WA_DeleteOnClose);
42
setInitialSize(QSize(550, 500));
48
ConfigDialog::~ConfigDialog()
56
void ConfigDialog::init()
59
QWidget *generalPage = new QWidget(this);
60
ui_settings.setupUi(generalPage);
62
m_pluginSelector = new KPluginSelector(this);
63
connect(m_pluginSelector, SIGNAL(changed(bool)), this, SLOT(pluginSettingsChanged(bool)));
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");
76
ui_settings.encoderCombo->setCurrentItem(Settings::encoderName(), false);
78
connect(ui_settings.encoderCombo, SIGNAL(currentIndexChanged(QString)), this,
79
SLOT(encoderChanged()));
82
m_mousePage = new MouseConfig(this);
83
connect(m_mousePage, SIGNAL(configChanged()), this, SLOT(pageConfigChanged()));
84
m_mousePage->loadConfig();
86
QWidget *zoomPage = new QWidget(this);
87
ui_zoom.setupUi(zoomPage);
89
QWidget *timelinePage = new QWidget(this);
90
ui_timeline.setupUi(timelinePage);
92
m_shortcutsPage = new KShortcutsEditor(m_collection, this);
93
connect(m_shortcutsPage, SIGNAL(keyChange()), this, SLOT(pageConfigChanged()));
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");
102
connect(this, SIGNAL(finished(int)), this, SLOT(configFinished(int)));
107
void ConfigDialog::updateEncoderCombo()
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());
117
ui_settings.encoderCombo->setCurrentItem(oldEncoder, false);
122
void ConfigDialog::configFinished(const int &code)
125
if (code == KConfigDialog::Accepted) {
126
m_pluginSelector->updatePluginsState();
127
m_pluginSelector->save();
128
Settings::setEncoderName(ui_settings.encoderCombo->currentText());
130
m_mousePage->saveConfig();
131
m_shortcutsPage->save();
133
emit dialogFinished();
138
void ConfigDialog::pluginSettingsChanged(const bool &changed)
141
enableButtonApply(true);
145
m_pluginSelector->updatePluginsState();
146
updateEncoderCombo();
151
void ConfigDialog::encoderChanged()
154
enableButtonApply(true);
159
void ConfigDialog::pageConfigChanged()
162
enableButtonApply(true);
167
void ConfigDialog::updateWidgetsDefault()
170
KConfigDialog::updateWidgetsDefault();
171
m_mousePage->defaults();
172
m_shortcutsPage->allDefault();
177
void ConfigDialog::updateSettings()
180
KConfigDialog::updateSettings();
181
enableButtonApply(false);
186
#include "configdialog.moc"