1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2009 Martin Gräßlin <kde@martin-graesslin.com>
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program. If not, see <http://www.gnu.org/licenses/>.
19
*********************************************************************/
23
#include <QtDBus/QtDBus>
24
#include <QVBoxLayout>
27
#include <KAboutApplicationDialog>
29
#include <KActionCollection>
30
#include <KCModuleProxy>
31
#include <KPluginFactory>
32
#include <KPluginInfo>
33
#include <KPluginLoader>
35
#include <KTitleWidget>
36
#include <KServiceTypeTrader>
37
#include <KShortcutsEditor>
40
#include "tabboxconfig.h"
41
#include "layoutconfig.h"
43
K_PLUGIN_FACTORY(KWinTabBoxConfigFactory, registerPlugin<KWin::KWinTabBoxConfig>();)
44
K_EXPORT_PLUGIN(KWinTabBoxConfigFactory("kcm_kwintabbox"))
49
KWinTabBoxConfigForm::KWinTabBoxConfigForm(QWidget* parent)
55
KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args)
56
: KCModule(KWinTabBoxConfigFactory::componentData(), parent, args)
57
, m_config(KSharedConfig::openConfig("kwinrc"))
59
KGlobal::locale()->insertCatalog("kwin_effects");
60
KTabWidget* tabWidget = new KTabWidget(this);
61
m_primaryTabBoxUi = new KWinTabBoxConfigForm(tabWidget);
62
m_alternativeTabBoxUi = new KWinTabBoxConfigForm(tabWidget);
63
m_alternativeTabBoxUi->description->setText(
64
i18n("These settings are used by the \"Walk Through Windows Alternative\" actions."));
65
tabWidget->addTab(m_primaryTabBoxUi, i18n("Main"));
66
tabWidget->addTab(m_alternativeTabBoxUi, i18n("Alternative"));
67
QVBoxLayout* layout = new QVBoxLayout(this);
68
KTitleWidget* infoLabel = new KTitleWidget(tabWidget);
69
infoLabel->setText(i18n("Focus policy settings limit the functionality of navigating through windows."),
70
KTitleWidget::InfoMessage);
71
infoLabel->setPixmap(KTitleWidget::InfoMessage, KTitleWidget::ImageLeft);
72
layout->addWidget(infoLabel);
73
layout->addWidget(tabWidget);
75
m_editor = new KShortcutsEditor(m_primaryTabBoxUi, KShortcutsEditor::GlobalAction);
76
// Shortcut config. The shortcut belongs to the component "kwin"!
77
m_actionCollection = new KActionCollection(this, KComponentData("kwin"));
78
m_actionCollection->setConfigGroup("Navigation");
79
m_actionCollection->setConfigGlobal(true);
80
KAction* a = qobject_cast<KAction*>(m_actionCollection->addAction("Walk Through Windows"));
81
a->setProperty("isConfigurationAction", true);
82
a->setText(i18n("Walk Through Windows"));
83
a->setGlobalShortcut(KShortcut(Qt::ALT + Qt::Key_Tab));
84
a = qobject_cast<KAction*>(m_actionCollection->addAction("Walk Through Windows (Reverse)"));
85
a->setProperty("isConfigurationAction", true);
86
a->setText(i18n("Walk Through Windows (Reverse)"));
87
a->setGlobalShortcut(KShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Backtab));
88
a = qobject_cast<KAction*>(m_actionCollection->addAction("Walk Through Windows Alternative"));
89
a->setProperty("isConfigurationAction", true);
90
a->setText(i18n("Walk Through Windows Alternative"));
91
a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
92
a = qobject_cast<KAction*>(m_actionCollection->addAction("Walk Through Windows Alternative (Reverse)"));
93
a->setProperty("isConfigurationAction", true);
94
a->setText(i18n("Walk Through Windows Alternative (Reverse)"));
95
a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut);
96
m_editor->addCollection(m_actionCollection, i18n("Navigation"));
97
layout->addWidget(m_editor);
100
// search the effect names
101
// TODO: way to recognize if a effect is not found
102
KServiceTypeTrader* trader = KServiceTypeTrader::self();
103
KService::List services;
105
QString presentwindows;
108
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_boxswitch'");
109
if (!services.isEmpty())
110
boxswitch = services.first()->name();
111
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_presentwindows'");
112
if (!services.isEmpty())
113
presentwindows = services.first()->name();
114
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_coverswitch'");
115
if (!services.isEmpty())
116
coverswitch = services.first()->name();
117
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_flipswitch'");
118
if (!services.isEmpty())
119
flipswitch = services.first()->name();
121
m_primaryTabBoxUi->effectCombo->addItem(i18n("No Effect"));
122
m_primaryTabBoxUi->effectCombo->addItem(boxswitch);
123
m_primaryTabBoxUi->effectCombo->addItem(presentwindows);
124
m_primaryTabBoxUi->effectCombo->addItem(coverswitch);
125
m_primaryTabBoxUi->effectCombo->addItem(flipswitch);
127
m_alternativeTabBoxUi->effectCombo->addItem(i18n("No Effect"));
128
m_alternativeTabBoxUi->effectCombo->addItem(boxswitch);
129
m_alternativeTabBoxUi->effectCombo->addItem(presentwindows);
130
m_alternativeTabBoxUi->effectCombo->addItem(coverswitch);
131
m_alternativeTabBoxUi->effectCombo->addItem(flipswitch);
133
// effect config and info button
134
m_primaryTabBoxUi->effectInfoButton->setIcon(KIcon("dialog-information"));
135
m_primaryTabBoxUi->effectConfigButton->setIcon(KIcon("configure"));
136
m_alternativeTabBoxUi->effectInfoButton->setIcon(KIcon("dialog-information"));
137
m_alternativeTabBoxUi->effectConfigButton->setIcon(KIcon("configure"));
140
connect(m_primaryTabBoxUi->listModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
141
connect(m_primaryTabBoxUi->switchingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
142
connect(m_primaryTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
144
connect(m_primaryTabBoxUi->showOutlineCheck, SIGNAL(stateChanged(int)), this, SLOT(changed()));
145
connect(m_primaryTabBoxUi->showTabBox, SIGNAL(toggled(bool)), this, SLOT(changed()));
146
connect(m_primaryTabBoxUi->highlightWindowCheck, SIGNAL(stateChanged(int)), this, SLOT(changed()));
147
connect(m_primaryTabBoxUi->showDesktopBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
148
// combo boxes alternative
149
connect(m_alternativeTabBoxUi->listModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
150
connect(m_alternativeTabBoxUi->switchingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
151
connect(m_alternativeTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
152
// check boxes alternative
153
connect(m_alternativeTabBoxUi->showOutlineCheck, SIGNAL(stateChanged(int)), this, SLOT(changed()));
154
connect(m_alternativeTabBoxUi->showTabBox, SIGNAL(toggled(bool)), this, SLOT(changed()));
155
connect(m_alternativeTabBoxUi->highlightWindowCheck, SIGNAL(stateChanged(int)), this, SLOT(changed()));
156
connect(m_alternativeTabBoxUi->showDesktopBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
159
connect(m_primaryTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEffectSelectionChanged(int)));
160
connect(m_primaryTabBoxUi->effectInfoButton, SIGNAL(clicked(bool)), this, SLOT(slotAboutEffectClicked()));
161
connect(m_primaryTabBoxUi->effectConfigButton, SIGNAL(clicked(bool)), this, SLOT(slotConfigureEffectClicked()));
163
connect(m_primaryTabBoxUi->layoutConfigButton, SIGNAL(clicked(bool)), this, SLOT(slotConfigureLayoutClicked()));
165
// effects alternative
166
connect(m_alternativeTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEffectSelectionChangedAlternative(int)));
167
connect(m_alternativeTabBoxUi->effectInfoButton, SIGNAL(clicked(bool)), this, SLOT(slotAboutEffectClickedAlternative()));
168
connect(m_alternativeTabBoxUi->effectConfigButton, SIGNAL(clicked(bool)), this, SLOT(slotConfigureEffectClickedAlternative()));
170
connect(m_alternativeTabBoxUi->layoutConfigButton, SIGNAL(clicked(bool)), this, SLOT(slotConfigureLayoutClickedAlternative()));
172
// check focus policy - we don't offer configs for unreasonable focus policies
173
KConfigGroup config(m_config, "Windows");
174
QString policy = config.readEntry("FocusPolicy", "ClickToFocus");
175
if ((policy == "FocusUnderMouse") || (policy == "FocusStrictlyUnderMouse")) {
176
tabWidget->setEnabled(false);
182
KWinTabBoxConfig::~KWinTabBoxConfig()
186
void KWinTabBoxConfig::load()
190
KConfigGroup config(m_config, "TabBox");
191
KConfigGroup alternativeConfig(m_config, "TabBoxAlternative");
192
loadConfig(config, m_tabBoxConfig);
193
loadConfig(alternativeConfig, m_tabBoxAlternativeConfig);
196
updateUiFromConfig(m_primaryTabBoxUi, m_tabBoxConfig);
197
updateUiFromConfig(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig);
200
// Set current option to "none" if no plugin is activated.
201
m_primaryTabBoxUi->effectCombo->setCurrentIndex(0);
202
m_alternativeTabBoxUi->effectCombo->setCurrentIndex(0);
203
KConfigGroup effectconfig(m_config, "Plugins");
204
KConfigGroup boxswitchconfig(m_config, "Effect-BoxSwitch");
205
if (effectEnabled("boxswitch", effectconfig)) {
206
if (boxswitchconfig.readEntry("TabBox", true))
207
m_primaryTabBoxUi->effectCombo->setCurrentIndex(1);
208
if (boxswitchconfig.readEntry("TabBoxAlternative", false))
209
m_alternativeTabBoxUi->effectCombo->setCurrentIndex(1);
211
KConfigGroup presentwindowsconfig(m_config, "Effect-PresentWindows");
212
if (effectEnabled("presentwindows", effectconfig)) {
213
if (presentwindowsconfig.readEntry("TabBox", false))
214
m_primaryTabBoxUi->effectCombo->setCurrentIndex(2);
215
if (presentwindowsconfig.readEntry("TabBoxAlternative", false))
216
m_alternativeTabBoxUi->effectCombo->setCurrentIndex(2);
218
KConfigGroup coverswitchconfig(m_config, "Effect-CoverSwitch");
219
if (effectEnabled("coverswitch", effectconfig)) {
220
if (coverswitchconfig.readEntry("TabBox", false))
221
m_primaryTabBoxUi->effectCombo->setCurrentIndex(3);
222
if (coverswitchconfig.readEntry("TabBoxAlternative", false))
223
m_alternativeTabBoxUi->effectCombo->setCurrentIndex(3);
225
KConfigGroup flipswitchconfig(m_config, "Effect-FlipSwitch");
226
if (effectEnabled("flipswitch", effectconfig)) {
227
if (flipswitchconfig.readEntry("TabBox", false))
228
m_primaryTabBoxUi->effectCombo->setCurrentIndex(4);
229
if (flipswitchconfig.readEntry("TabBoxAlternative", false))
230
m_alternativeTabBoxUi->effectCombo->setCurrentIndex(4);
232
slotEffectSelectionChanged(m_primaryTabBoxUi->effectCombo->currentIndex());
233
slotEffectSelectionChangedAlternative(m_alternativeTabBoxUi->effectCombo->currentIndex());
238
void KWinTabBoxConfig::loadConfig(const KConfigGroup& config, KWin::TabBox::TabBoxConfig& tabBoxConfig)
240
tabBoxConfig.setClientListMode(TabBox::TabBoxConfig::ClientListMode(
241
config.readEntry<int>("ListMode", TabBox::TabBoxConfig::defaultListMode())));
242
tabBoxConfig.setClientSwitchingMode(TabBox::TabBoxConfig::ClientSwitchingMode(
243
config.readEntry<int>("SwitchingMode", TabBox::TabBoxConfig::defaultSwitchingMode())));
244
tabBoxConfig.setLayout(TabBox::TabBoxConfig::LayoutMode(
245
config.readEntry<int>("LayoutMode", TabBox::TabBoxConfig::defaultLayoutMode())));
246
tabBoxConfig.setSelectedItemViewPosition(TabBox::TabBoxConfig::SelectedItemViewPosition(
247
config.readEntry<int>("SelectedItem", TabBox::TabBoxConfig::defaultSelectedItemViewPosition())));
248
tabBoxConfig.setShowDesktop(config.readEntry<bool>("ShowDesktop",
249
TabBox::TabBoxConfig::defaultShowDesktop()));
251
tabBoxConfig.setShowOutline(config.readEntry<bool>("ShowOutline",
252
TabBox::TabBoxConfig::defaultShowOutline()));
253
tabBoxConfig.setShowTabBox(config.readEntry<bool>("ShowTabBox",
254
TabBox::TabBoxConfig::defaultShowTabBox()));
255
tabBoxConfig.setHighlightWindows(config.readEntry<bool>("HighlightWindows",
256
TabBox::TabBoxConfig::defaultHighlightWindow()));
258
tabBoxConfig.setMinWidth(config.readEntry<int>("MinWidth",
259
TabBox::TabBoxConfig::defaultMinWidth()));
260
tabBoxConfig.setMinHeight(config.readEntry<int>("MinHeight",
261
TabBox::TabBoxConfig::defaultMinHeight()));
263
tabBoxConfig.setLayoutName(config.readEntry<QString>("LayoutName", TabBox::TabBoxConfig::defaultLayoutName()));
264
tabBoxConfig.setSelectedItemLayoutName(config.readEntry<QString>("SelectedLayoutName", TabBox::TabBoxConfig::defaultSelectedItemLayoutName()));
267
void KWinTabBoxConfig::saveConfig(KConfigGroup& config, const KWin::TabBox::TabBoxConfig& tabBoxConfig)
270
config.writeEntry("ListMode", int(tabBoxConfig.clientListMode()));
271
config.writeEntry("SwitchingMode", int(tabBoxConfig.clientSwitchingMode()));
272
config.writeEntry("LayoutMode", int(tabBoxConfig.layout()));
273
config.writeEntry("SelectedItem", int(tabBoxConfig.selectedItemViewPosition()));
274
config.writeEntry("LayoutName", tabBoxConfig.layoutName());
275
config.writeEntry("SelectedLayoutName", tabBoxConfig.selectedItemLayoutName());
276
config.writeEntry("ShowDesktop", tabBoxConfig.isShowDesktop());
279
config.writeEntry("ShowOutline", tabBoxConfig.isShowOutline());
280
config.writeEntry("ShowTabBox", tabBoxConfig.isShowTabBox());
281
config.writeEntry("HighlightWindows", tabBoxConfig.isHighlightWindows());
284
config.writeEntry("MinWidth", tabBoxConfig.minWidth());
285
config.writeEntry("MinHeight", tabBoxConfig.minHeight());
289
void KWinTabBoxConfig::save()
292
KConfigGroup config(m_config, "TabBox");
295
updateConfigFromUi(m_primaryTabBoxUi, m_tabBoxConfig);
296
updateConfigFromUi(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig);
297
saveConfig(config, m_tabBoxConfig);
298
config = KConfigGroup(m_config, "TabBoxAlternative");
299
saveConfig(config, m_tabBoxAlternativeConfig);
302
bool boxSwitch = false;
303
bool presentWindowSwitching = false;
304
bool coverSwitch = false;
305
bool flipSwitch = false;
306
bool boxSwitchAlternative = false;
307
bool presentWindowSwitchingAlternative = false;
308
bool coverSwitchAlternative = false;
309
bool flipSwitchAlternative = false;
310
switch(m_primaryTabBoxUi->effectCombo->currentIndex()) {
315
presentWindowSwitching = true;
326
switch(m_alternativeTabBoxUi->effectCombo->currentIndex()) {
328
boxSwitchAlternative = true;
331
presentWindowSwitchingAlternative = true;
334
coverSwitchAlternative = true;
337
flipSwitchAlternative = true;
342
// activate effects if not active
343
KConfigGroup effectconfig(m_config, "Plugins");
344
if (boxSwitch || boxSwitchAlternative)
345
effectconfig.writeEntry("kwin4_effect_boxswitchEnabled", true);
346
if (presentWindowSwitching || presentWindowSwitchingAlternative)
347
effectconfig.writeEntry("kwin4_effect_presentwindowsEnabled", true);
348
if (coverSwitch || coverSwitchAlternative)
349
effectconfig.writeEntry("kwin4_effect_coverswitchEnabled", true);
350
if (flipSwitch || flipSwitchAlternative)
351
effectconfig.writeEntry("kwin4_effect_flipswitchEnabled", true);
353
KConfigGroup boxswitchconfig(m_config, "Effect-BoxSwitch");
354
boxswitchconfig.writeEntry("TabBox", boxSwitch);
355
boxswitchconfig.writeEntry("TabBoxAlternative", boxSwitchAlternative);
356
boxswitchconfig.sync();
357
KConfigGroup presentwindowsconfig(m_config, "Effect-PresentWindows");
358
presentwindowsconfig.writeEntry("TabBox", presentWindowSwitching);
359
presentwindowsconfig.writeEntry("TabBoxAlternative", presentWindowSwitchingAlternative);
360
presentwindowsconfig.sync();
361
KConfigGroup coverswitchconfig(m_config, "Effect-CoverSwitch");
362
coverswitchconfig.writeEntry("TabBox", coverSwitch);
363
coverswitchconfig.writeEntry("TabBoxAlternative", coverSwitchAlternative);
364
coverswitchconfig.sync();
365
KConfigGroup flipswitchconfig(m_config, "Effect-FlipSwitch");
366
flipswitchconfig.writeEntry("TabBox", flipSwitch);
367
flipswitchconfig.writeEntry("TabBoxAlternative", flipSwitchAlternative);
368
flipswitchconfig.sync();
373
QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
374
QDBusConnection::sessionBus().send(message);
379
void KWinTabBoxConfig::defaults()
382
m_primaryTabBoxUi->listModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultListMode());
383
m_primaryTabBoxUi->switchingModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultSwitchingMode());
386
m_primaryTabBoxUi->showOutlineCheck->setChecked(TabBox::TabBoxConfig::defaultShowOutline());
387
m_primaryTabBoxUi->showTabBox->setChecked(TabBox::TabBoxConfig::defaultShowTabBox());
388
m_primaryTabBoxUi->highlightWindowCheck->setChecked(TabBox::TabBoxConfig::defaultHighlightWindow());
389
m_primaryTabBoxUi->showDesktopBox->setChecked(TabBox::TabBoxConfig::defaultShowDesktop());
392
m_primaryTabBoxUi->effectCombo->setCurrentIndex(1);
396
m_alternativeTabBoxUi->listModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultListMode());
397
m_alternativeTabBoxUi->switchingModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultSwitchingMode());
400
m_alternativeTabBoxUi->showOutlineCheck->setChecked(TabBox::TabBoxConfig::defaultShowOutline());
401
m_alternativeTabBoxUi->showTabBox->setChecked(TabBox::TabBoxConfig::defaultShowTabBox());
402
m_alternativeTabBoxUi->highlightWindowCheck->setChecked(TabBox::TabBoxConfig::defaultHighlightWindow());
403
m_alternativeTabBoxUi->showDesktopBox->setChecked(TabBox::TabBoxConfig::defaultShowDesktop());
406
m_alternativeTabBoxUi->effectCombo->setCurrentIndex(0);
408
m_editor->allDefault();
413
bool KWinTabBoxConfig::effectEnabled(const QString& effect, const KConfigGroup& cfg) const
415
KService::List services = KServiceTypeTrader::self()->query(
416
"KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + '\'');
417
if (services.isEmpty())
419
QVariant v = services.first()->property("X-KDE-PluginInfo-EnabledByDefault");
420
return cfg.readEntry("kwin4_effect_" + effect + "Enabled", v.toBool());
423
void KWinTabBoxConfig::updateUiFromConfig(KWinTabBoxConfigForm* ui, const KWin::TabBox::TabBoxConfig& config)
426
ui->listModeCombo->setCurrentIndex(config.clientListMode());
427
ui->switchingModeCombo->setCurrentIndex(config.clientSwitchingMode());
430
ui->showOutlineCheck->setChecked(config.isShowOutline());
431
ui->showTabBox->setChecked(config.isShowTabBox());
432
ui->highlightWindowCheck->setChecked(config.isHighlightWindows());
433
ui->showDesktopBox->setChecked(config.isShowDesktop());
436
void KWinTabBoxConfig::updateConfigFromUi(const KWin::KWinTabBoxConfigForm* ui, TabBox::TabBoxConfig& config)
438
config.setClientListMode(TabBox::TabBoxConfig::ClientListMode(ui->listModeCombo->currentIndex()));
439
config.setClientSwitchingMode(TabBox::TabBoxConfig::ClientSwitchingMode(ui->switchingModeCombo->currentIndex()));
441
config.setShowOutline(ui->showOutlineCheck->isChecked());
442
config.setShowTabBox(ui->showTabBox->isChecked());
443
config.setHighlightWindows(ui->highlightWindowCheck->isChecked());
444
config.setShowDesktop(ui->showDesktopBox->isChecked());
447
void KWinTabBoxConfig::slotEffectSelectionChanged(int index)
449
effectSelectionChanged(m_primaryTabBoxUi, index);
452
void KWinTabBoxConfig::slotEffectSelectionChangedAlternative(int index)
454
effectSelectionChanged(m_alternativeTabBoxUi, index);
457
void KWinTabBoxConfig::effectSelectionChanged(KWinTabBoxConfigForm* ui, int index)
459
bool enabled = false;
462
ui->effectInfoButton->setEnabled(enabled);
463
ui->effectConfigButton->setEnabled(enabled);
466
void KWinTabBoxConfig::slotAboutEffectClicked()
468
aboutEffectClicked(m_primaryTabBoxUi);
471
void KWinTabBoxConfig::slotAboutEffectClickedAlternative()
473
aboutEffectClicked(m_alternativeTabBoxUi);
476
void KWinTabBoxConfig::aboutEffectClicked(KWinTabBoxConfigForm* ui)
478
KServiceTypeTrader* trader = KServiceTypeTrader::self();
479
KService::List services;
481
switch(ui->effectCombo->currentIndex()) {
483
effect = "boxswitch";
486
effect = "presentwindows";
489
effect = "coverswitch";
492
effect = "flipswitch";
497
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + '\'');
498
if (services.isEmpty())
500
KPluginInfo pluginInfo(services.first());
502
const QString name = pluginInfo.name();
503
const QString comment = pluginInfo.comment();
504
const QString author = pluginInfo.author();
505
const QString email = pluginInfo.email();
506
const QString website = pluginInfo.website();
507
const QString version = pluginInfo.version();
508
const QString license = pluginInfo.license();
509
const QString icon = pluginInfo.icon();
511
KAboutData aboutData(name.toUtf8(), name.toUtf8(), ki18n(name.toUtf8()), version.toUtf8(), ki18n(comment.toUtf8()), KAboutLicense::byKeyword(license).key(), ki18n(QByteArray()), ki18n(QByteArray()), website.toLatin1());
512
aboutData.setProgramIconName(icon);
513
const QStringList authors = author.split(',');
514
const QStringList emails = email.split(',');
516
if (authors.count() == emails.count()) {
517
foreach (const QString & author, authors) {
518
if (!author.isEmpty()) {
519
aboutData.addAuthor(ki18n(author.toUtf8()), ki18n(QByteArray()), emails[i].toUtf8(), 0);
524
QPointer< KAboutApplicationDialog > aboutPlugin = new KAboutApplicationDialog(&aboutData, this);
529
void KWinTabBoxConfig::slotConfigureEffectClicked()
531
configureEffectClicked(m_primaryTabBoxUi);
534
void KWinTabBoxConfig::slotConfigureEffectClickedAlternative()
536
configureEffectClicked(m_alternativeTabBoxUi);
539
void KWinTabBoxConfig::configureEffectClicked(KWinTabBoxConfigForm* ui)
542
switch(ui->effectCombo->currentIndex()) {
544
effect = "boxswitch_config";
547
effect = "presentwindows_config";
550
effect = "coverswitch_config";
553
effect = "flipswitch_config";
558
KCModuleProxy* proxy = new KCModuleProxy(effect);
559
QPointer< KDialog > configDialog = new KDialog(this);
560
configDialog->setWindowTitle(ui->effectCombo->currentText());
561
configDialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Default);
562
connect(configDialog, SIGNAL(defaultClicked()), proxy, SLOT(defaults()));
564
QWidget *showWidget = new QWidget(configDialog);
565
QVBoxLayout *layout = new QVBoxLayout;
566
showWidget->setLayout(layout);
567
layout->addWidget(proxy);
568
layout->insertSpacing(-1, KDialog::marginHint());
569
configDialog->setMainWidget(showWidget);
571
if (configDialog->exec() == QDialog::Accepted) {
579
void KWinTabBoxConfig::slotConfigureLayoutClicked()
581
QPointer<KDialog> dialog = new KDialog(this);
582
dialog->setCaption(i18n("Configure Layout"));
583
dialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Default);
584
connect(dialog, SIGNAL(okClicked()), this, SLOT(slotLayoutChanged()));
586
m_configForm = new TabBox::LayoutConfig(dialog);
587
m_configForm->setConfig(m_tabBoxConfig);
588
dialog->setMainWidget(m_configForm);
594
void KWinTabBoxConfig::slotLayoutChanged()
596
m_tabBoxConfig = m_configForm->config();
600
void KWinTabBoxConfig::slotConfigureLayoutClickedAlternative()
602
QPointer<KDialog> dialog = new KDialog(this);
603
dialog->setCaption(i18n("Configure Layout"));
604
dialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Default);
605
connect(dialog, SIGNAL(okClicked()), this, SLOT(slotLayoutChangedAlternative()));
607
m_configForm = new TabBox::LayoutConfig(dialog);
608
m_configForm->setConfig(m_tabBoxAlternativeConfig);
609
dialog->setMainWidget(m_configForm);
615
void KWinTabBoxConfig::slotLayoutChangedAlternative()
617
m_tabBoxAlternativeConfig = m_configForm->config();