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

« back to all changes in this revision

Viewing changes to kwin/kcmkwin/kwinoptions/main.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
 *
 
3
 * Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
 
4
 *
 
5
 *  This program is free software; you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation; either version 2 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
18
 */
 
19
 
 
20
#include "main.h"
 
21
 
 
22
#include <QLayout>
 
23
//Added by qt3to4:
 
24
#include <QVBoxLayout>
 
25
 
 
26
#include <QtDBus/QtDBus>
 
27
 
 
28
#include <kapplication.h>
 
29
#include <kglobal.h>
 
30
#include <klocale.h>
 
31
#include <kconfig.h>
 
32
#include <kaboutdata.h>
 
33
#include <kdialog.h>
 
34
#include <KPluginFactory>
 
35
#include <KPluginLoader>
 
36
 
 
37
#include "mouse.h"
 
38
#include "windows.h"
 
39
 
 
40
K_PLUGIN_FACTORY_DECLARATION(KWinOptionsFactory)
 
41
 
 
42
class KFocusConfigStandalone : public KFocusConfig
 
43
{
 
44
    Q_OBJECT
 
45
public:
 
46
    KFocusConfigStandalone(QWidget* parent, const QVariantList &)
 
47
        : KFocusConfig(true, new KConfig("kwinrc"), KWinOptionsFactory::componentData(), parent)
 
48
    {}
 
49
};
 
50
 
 
51
class KMovingConfigStandalone : public KMovingConfig
 
52
{
 
53
    Q_OBJECT
 
54
public:
 
55
    KMovingConfigStandalone(QWidget* parent, const QVariantList &)
 
56
        : KMovingConfig(true, new KConfig("kwinrc"), KWinOptionsFactory::componentData(), parent)
 
57
    {}
 
58
};
 
59
 
 
60
class KAdvancedConfigStandalone : public KAdvancedConfig
 
61
{
 
62
    Q_OBJECT
 
63
public:
 
64
    KAdvancedConfigStandalone(QWidget* parent, const QVariantList &)
 
65
        : KAdvancedConfig(true, new KConfig("kwinrc"), KWinOptionsFactory::componentData(), parent)
 
66
    {}
 
67
};
 
68
 
 
69
KWinOptions::KWinOptions(QWidget *parent, const QVariantList &)
 
70
    : KCModule(KWinOptionsFactory::componentData(), parent)
 
71
{
 
72
    mConfig = new KConfig("kwinrc", KConfig::IncludeGlobals);
 
73
 
 
74
    QVBoxLayout *layout = new QVBoxLayout(this);
 
75
    layout->setMargin(0);
 
76
    tab = new KTabWidget(this);
 
77
    layout->addWidget(tab);
 
78
 
 
79
    mFocus = new KFocusConfig(false, mConfig, componentData(), this);
 
80
    mFocus->setObjectName(QLatin1String("KWin Focus Config"));
 
81
    tab->addTab(mFocus, i18n("&Focus"));
 
82
    connect(mFocus, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
 
83
 
 
84
    mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, componentData(), this);
 
85
    mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions"));
 
86
    tab->addTab(mTitleBarActions, i18n("&Titlebar Actions"));
 
87
    connect(mTitleBarActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
 
88
 
 
89
    mWindowActions = new KWindowActionsConfig(false, mConfig, componentData(), this);
 
90
    mWindowActions->setObjectName(QLatin1String("KWin Window Actions"));
 
91
    tab->addTab(mWindowActions, i18n("Window Actio&ns"));
 
92
    connect(mWindowActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
 
93
 
 
94
    mMoving = new KMovingConfig(false, mConfig, componentData(), this);
 
95
    mMoving->setObjectName(QLatin1String("KWin Moving"));
 
96
    tab->addTab(mMoving, i18n("&Moving"));
 
97
    connect(mMoving, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
 
98
 
 
99
    mAdvanced = new KAdvancedConfig(false, mConfig, componentData(), this);
 
100
    mAdvanced->setObjectName(QLatin1String("KWin Advanced"));
 
101
    tab->addTab(mAdvanced, i18n("Ad&vanced"));
 
102
    connect(mAdvanced, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
 
103
 
 
104
    KAboutData *about =
 
105
        new KAboutData(I18N_NOOP("kcmkwinoptions"), 0, ki18n("Window Behavior Configuration Module"),
 
106
                       0, KLocalizedString(), KAboutData::License_GPL,
 
107
                       ki18n("(c) 1997 - 2002 KWin and KControl Authors"));
 
108
 
 
109
    about->addAuthor(ki18n("Matthias Ettrich"), KLocalizedString(), "ettrich@kde.org");
 
110
    about->addAuthor(ki18n("Waldo Bastian"), KLocalizedString(), "bastian@kde.org");
 
111
    about->addAuthor(ki18n("Cristian Tibirna"), KLocalizedString(), "tibirna@kde.org");
 
112
    about->addAuthor(ki18n("Matthias Kalle Dalheimer"), KLocalizedString(), "kalle@kde.org");
 
113
    about->addAuthor(ki18n("Daniel Molkentin"), KLocalizedString(), "molkentin@kde.org");
 
114
    about->addAuthor(ki18n("Wynn Wilkes"), KLocalizedString(), "wynnw@caldera.com");
 
115
    about->addAuthor(ki18n("Pat Dowler"), KLocalizedString(), "dowler@pt1B1106.FSH.UVic.CA");
 
116
    about->addAuthor(ki18n("Bernd Wuebben"), KLocalizedString(), "wuebben@kde.org");
 
117
    about->addAuthor(ki18n("Matthias Hoelzer-Kluepfel"), KLocalizedString(), "hoelzer@kde.org");
 
118
    setAboutData(about);
 
119
}
 
120
 
 
121
KWinOptions::~KWinOptions()
 
122
{
 
123
    delete mConfig;
 
124
}
 
125
 
 
126
void KWinOptions::load()
 
127
{
 
128
    mConfig->reparseConfiguration();
 
129
    mFocus->load();
 
130
    mTitleBarActions->load();
 
131
    mWindowActions->load();
 
132
    mMoving->load();
 
133
    mAdvanced->load();
 
134
    emit KCModule::changed(false);
 
135
}
 
136
 
 
137
 
 
138
void KWinOptions::save()
 
139
{
 
140
    mFocus->save();
 
141
    mTitleBarActions->save();
 
142
    mWindowActions->save();
 
143
    mMoving->save();
 
144
    mAdvanced->save();
 
145
 
 
146
    emit KCModule::changed(false);
 
147
    // Send signal to kwin
 
148
    mConfig->sync();
 
149
    // Send signal to all kwin instances
 
150
    QDBusMessage message =
 
151
        QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
 
152
    QDBusConnection::sessionBus().send(message);
 
153
 
 
154
 
 
155
}
 
156
 
 
157
 
 
158
void KWinOptions::defaults()
 
159
{
 
160
    mFocus->defaults();
 
161
    mTitleBarActions->defaults();
 
162
    mWindowActions->defaults();
 
163
    mMoving->defaults();
 
164
    mAdvanced->defaults();
 
165
}
 
166
 
 
167
QString KWinOptions::quickHelp() const
 
168
{
 
169
    return i18n("<p><h1>Window Behavior</h1> Here you can customize the way windows behave when being"
 
170
                " moved, resized or clicked on. You can also specify a focus policy as well as a placement"
 
171
                " policy for new windows.</p>"
 
172
                " <p>Please note that this configuration will not take effect if you do not use"
 
173
                " KWin as your window manager. If you do use a different window manager, please refer to its documentation"
 
174
                " for how to customize window behavior.</p>");
 
175
}
 
176
 
 
177
void KWinOptions::moduleChanged(bool state)
 
178
{
 
179
    emit KCModule::changed(state);
 
180
}
 
181
 
 
182
KActionsOptions::KActionsOptions(QWidget *parent, const QVariantList &)
 
183
    : KCModule(KWinOptionsFactory::componentData(), parent)
 
184
{
 
185
    mConfig = new KConfig("kwinrc", KConfig::IncludeGlobals);
 
186
 
 
187
    QVBoxLayout *layout = new QVBoxLayout(this);
 
188
    layout->setMargin(0);
 
189
    tab = new KTabWidget(this);
 
190
    layout->addWidget(tab);
 
191
 
 
192
    mTitleBarActions = new KTitleBarActionsConfig(false, mConfig, componentData(), this);
 
193
    mTitleBarActions->setObjectName(QLatin1String("KWin TitleBar Actions"));
 
194
    tab->addTab(mTitleBarActions, i18n("&Titlebar Actions"));
 
195
    connect(mTitleBarActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
 
196
 
 
197
    mWindowActions = new KWindowActionsConfig(false, mConfig, componentData(), this);
 
198
    mWindowActions->setObjectName(QLatin1String("KWin Window Actions"));
 
199
    tab->addTab(mWindowActions, i18n("Window Actio&ns"));
 
200
    connect(mWindowActions, SIGNAL(changed(bool)), this, SLOT(moduleChanged(bool)));
 
201
}
 
202
 
 
203
KActionsOptions::~KActionsOptions()
 
204
{
 
205
    delete mConfig;
 
206
}
 
207
 
 
208
void KActionsOptions::load()
 
209
{
 
210
    mTitleBarActions->load();
 
211
    mWindowActions->load();
 
212
    emit KCModule::changed(false);
 
213
}
 
214
 
 
215
 
 
216
void KActionsOptions::save()
 
217
{
 
218
    mTitleBarActions->save();
 
219
    mWindowActions->save();
 
220
 
 
221
    emit KCModule::changed(false);
 
222
    // Send signal to kwin
 
223
    mConfig->sync();
 
224
    // Send signal to all kwin instances
 
225
    QDBusMessage message =
 
226
        QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
 
227
    QDBusConnection::sessionBus().send(message);
 
228
 
 
229
}
 
230
 
 
231
 
 
232
void KActionsOptions::defaults()
 
233
{
 
234
    mTitleBarActions->defaults();
 
235
    mWindowActions->defaults();
 
236
}
 
237
 
 
238
void KActionsOptions::moduleChanged(bool state)
 
239
{
 
240
    emit KCModule::changed(state);
 
241
}
 
242
 
 
243
K_PLUGIN_FACTORY_DEFINITION(KWinOptionsFactory,
 
244
                            registerPlugin<KActionsOptions>("kwinactions");
 
245
                            registerPlugin<KFocusConfigStandalone>("kwinfocus");
 
246
                            registerPlugin<KMovingConfigStandalone>("kwinmoving");
 
247
                            registerPlugin<KAdvancedConfigStandalone>("kwinadvanced");
 
248
                            registerPlugin<KWinOptions>("kwinoptions");
 
249
                           )
 
250
K_EXPORT_PLUGIN(KWinOptionsFactory("kcmkwm"))
 
251
 
 
252
#include "main.moc"
 
253
#include "moc_main.cpp"