1
/********************************************************************
2
KWin - the KDE window manager
3
This file is part of the KDE project.
5
Copyright (C) 2007 Rivo Laks <rivolaks@hot.ee>
6
Copyright (C) 2010 Sebastian Sauer <sebsauer@kdab.com>
8
This program is free software; you can redistribute it and/or modify
9
it under the terms of the GNU General Public License as published by
10
the Free Software Foundation; either version 2 of the License, or
11
(at your option) any later version.
13
This program is distributed in the hope that it will be useful,
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License
19
along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*********************************************************************/
22
#include "zoom_config.h"
24
#include <kwineffects.h>
28
#include <KActionCollection>
30
#include <KShortcutsEditor>
32
#include <QVBoxLayout>
37
KWIN_EFFECT_CONFIG_FACTORY
39
ZoomEffectConfigForm::ZoomEffectConfigForm(QWidget* parent) : QWidget(parent)
44
ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) :
45
KCModule(EffectFactory::componentData(), parent, args)
47
m_ui = new ZoomEffectConfigForm(this);
49
QVBoxLayout* layout = new QVBoxLayout(this);
50
layout->addWidget(m_ui);
52
connect(m_ui->zoomStepsSpinBox, SIGNAL(valueChanged(double)), this, SLOT(changed()));
53
connect(m_ui->mousePointerComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
54
connect(m_ui->mouseTrackingComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
55
connect(m_ui->focusTrackingCheckBox, SIGNAL(toggled(bool)), this, SLOT(changed()));
56
connect(m_ui->followFocusCheckBox, SIGNAL(toggled(bool)), this, SLOT(changed()));
57
connect(m_ui->editor, SIGNAL(keyChange()), this, SLOT(changed()));
59
// Shortcut config. The shortcut belongs to the component "kwin"!
60
KActionCollection *actionCollection = new KActionCollection(this, KComponentData("kwin"));
61
actionCollection->setConfigGroup("Zoom");
62
actionCollection->setConfigGlobal(true);
65
a = static_cast< KAction* >(actionCollection->addAction(KStandardAction::ZoomIn));
66
a->setProperty("isConfigurationAction", true);
67
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Equal));
69
a = static_cast< KAction* >(actionCollection->addAction(KStandardAction::ZoomOut));
70
a->setProperty("isConfigurationAction", true);
71
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus));
73
a = static_cast< KAction* >(actionCollection->addAction(KStandardAction::ActualSize));
74
a->setProperty("isConfigurationAction", true);
75
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
77
a = static_cast< KAction* >(actionCollection->addAction("MoveZoomLeft"));
78
a->setIcon(KIcon("go-previous"));
79
a->setText(i18n("Move Left"));
80
a->setProperty("isConfigurationAction", true);
81
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Left));
83
a = static_cast< KAction* >(actionCollection->addAction("MoveZoomRight"));
84
a->setIcon(KIcon("go-next"));
85
a->setText(i18n("Move Right"));
86
a->setProperty("isConfigurationAction", true);
87
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Right));
89
a = static_cast< KAction* >(actionCollection->addAction("MoveZoomUp"));
90
a->setIcon(KIcon("go-up"));
91
a->setText(i18n("Move Up"));
92
a->setProperty("isConfigurationAction", true);
93
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Up));
95
a = static_cast< KAction* >(actionCollection->addAction("MoveZoomDown"));
96
a->setIcon(KIcon("go-down"));
97
a->setText(i18n("Move Down"));
98
a->setProperty("isConfigurationAction", true);
99
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Down));
101
a = static_cast< KAction* >(actionCollection->addAction("MoveMouseToFocus"));
102
a->setIcon(KIcon("view-restore"));
103
a->setText(i18n("Move Mouse to Focus"));
104
a->setProperty("isConfigurationAction", true);
105
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_F5));
107
a = static_cast< KAction* >(actionCollection->addAction("MoveMouseToCenter"));
108
a->setIcon(KIcon("view-restore"));
109
a->setText(i18n("Move Mouse to Center"));
110
a->setProperty("isConfigurationAction", true);
111
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_F6));
113
m_ui->editor->addCollection(actionCollection);
117
ZoomEffectConfig::~ZoomEffectConfig()
119
// Undo (only) unsaved changes to global key shortcuts
120
m_ui->editor->undoChanges();
123
void ZoomEffectConfig::load()
126
KConfigGroup conf = EffectsHandler::effectConfig("Zoom");
127
m_ui->zoomStepsSpinBox->setValue(conf.readEntry("ZoomFactor", 1.2));
128
m_ui->mousePointerComboBox->setCurrentIndex(conf.readEntry("MousePointer", 0));
129
m_ui->mouseTrackingComboBox->setCurrentIndex(conf.readEntry("MouseTracking", 0));
130
m_ui->focusTrackingCheckBox->setChecked(conf.readEntry("EnableFocusTracking", false));
131
m_ui->followFocusCheckBox->setChecked(conf.readEntry("EnableFollowFocus", true));
135
void ZoomEffectConfig::save()
138
KConfigGroup conf = EffectsHandler::effectConfig("Zoom");
139
conf.writeEntry("ZoomFactor", m_ui->zoomStepsSpinBox->value());
140
conf.writeEntry("MousePointer", m_ui->mousePointerComboBox->currentIndex());
141
conf.writeEntry("MouseTracking", m_ui->mouseTrackingComboBox->currentIndex());
142
conf.writeEntry("EnableFocusTracking", m_ui->focusTrackingCheckBox->isChecked());
143
conf.writeEntry("EnableFollowFocus", m_ui->followFocusCheckBox->isChecked());
144
m_ui->editor->save(); // undo() will restore to this state from now on
147
EffectsHandler::sendReloadMessage("zoom");
150
void ZoomEffectConfig::defaults()
152
m_ui->zoomStepsSpinBox->setValue(1.25);
153
m_ui->mousePointerComboBox->setCurrentIndex(0);
154
m_ui->mouseTrackingComboBox->setCurrentIndex(0);
155
m_ui->focusTrackingCheckBox->setChecked(false);
156
m_ui->followFocusCheckBox->setChecked(true);
157
m_ui->editor->allDefault();
163
#include "zoom_config.moc"