File indexing completed on 2024-11-10 04:57:13
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2007 Rivo Laks <rivolaks@hot.ee> 0006 SPDX-FileCopyrightText: 2010 Sebastian Sauer <sebsauer@kdab.com> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 #include "zoom_config.h" 0011 0012 #include <config-kwin.h> 0013 0014 // KConfigSkeleton 0015 #include "zoomconfig.h" 0016 #include <kwineffects_interface.h> 0017 0018 #include <QAction> 0019 0020 #include <KActionCollection> 0021 #include <KGlobalAccel> 0022 #include <KLocalizedString> 0023 #include <KPluginFactory> 0024 0025 #include <QVBoxLayout> 0026 0027 K_PLUGIN_CLASS(KWin::ZoomEffectConfig) 0028 0029 namespace KWin 0030 { 0031 ZoomEffectConfig::ZoomEffectConfig(QObject *parent, const KPluginMetaData &data) 0032 : KCModule(parent, data) 0033 { 0034 ZoomConfig::instance(KWIN_CONFIG); 0035 m_ui.setupUi(widget()); 0036 0037 addConfig(ZoomConfig::self(), widget()); 0038 0039 connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged); 0040 0041 #if !HAVE_ACCESSIBILITY 0042 m_ui.kcfg_EnableFocusTracking->setVisible(false); 0043 m_ui.kcfg_EnableTextCaretTracking->setVisible(false); 0044 #endif 0045 0046 // Shortcut config. The shortcut belongs to the component "kwin"! 0047 KActionCollection *actionCollection = new KActionCollection(this, QStringLiteral("kwin")); 0048 actionCollection->setComponentDisplayName(i18n("KWin")); 0049 actionCollection->setConfigGroup(QStringLiteral("Zoom")); 0050 actionCollection->setConfigGlobal(true); 0051 0052 QAction *a; 0053 a = actionCollection->addAction(KStandardAction::ZoomIn); 0054 a->setProperty("isConfigurationAction", true); 0055 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Plus) << (Qt::META | Qt::Key_Equal)); 0056 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Plus) << (Qt::META | Qt::Key_Equal)); 0057 0058 a = actionCollection->addAction(KStandardAction::ZoomOut); 0059 a->setProperty("isConfigurationAction", true); 0060 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Minus)); 0061 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Minus)); 0062 0063 a = actionCollection->addAction(KStandardAction::ActualSize); 0064 a->setProperty("isConfigurationAction", true); 0065 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_0)); 0066 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_0)); 0067 0068 a = actionCollection->addAction(QStringLiteral("MoveZoomLeft")); 0069 a->setIcon(QIcon::fromTheme(QStringLiteral("go-previous"))); 0070 a->setText(i18n("Move Left")); 0071 a->setProperty("isConfigurationAction", true); 0072 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_Left)); 0073 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_Left)); 0074 0075 a = actionCollection->addAction(QStringLiteral("MoveZoomRight")); 0076 a->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); 0077 a->setText(i18n("Move Right")); 0078 a->setProperty("isConfigurationAction", true); 0079 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_Right)); 0080 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_Right)); 0081 0082 a = actionCollection->addAction(QStringLiteral("MoveZoomUp")); 0083 a->setIcon(QIcon::fromTheme(QStringLiteral("go-up"))); 0084 a->setText(i18n("Move Up")); 0085 a->setProperty("isConfigurationAction", true); 0086 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_Up)); 0087 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_Up)); 0088 0089 a = actionCollection->addAction(QStringLiteral("MoveZoomDown")); 0090 a->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); 0091 a->setText(i18n("Move Down")); 0092 a->setProperty("isConfigurationAction", true); 0093 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_Down)); 0094 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_Down)); 0095 0096 a = actionCollection->addAction(QStringLiteral("MoveMouseToFocus")); 0097 a->setIcon(QIcon::fromTheme(QStringLiteral("view-restore"))); 0098 a->setText(i18n("Move Mouse to Focus")); 0099 a->setProperty("isConfigurationAction", true); 0100 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_F5)); 0101 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_F5)); 0102 0103 a = actionCollection->addAction(QStringLiteral("MoveMouseToCenter")); 0104 a->setIcon(QIcon::fromTheme(QStringLiteral("view-restore"))); 0105 a->setText(i18n("Move Mouse to Center")); 0106 a->setProperty("isConfigurationAction", true); 0107 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_F6)); 0108 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_F6)); 0109 0110 m_ui.editor->addCollection(actionCollection); 0111 } 0112 0113 void ZoomEffectConfig::save() 0114 { 0115 m_ui.editor->save(); // undo() will restore to this state from now on 0116 KCModule::save(); 0117 OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), 0118 QStringLiteral("/Effects"), 0119 QDBusConnection::sessionBus()); 0120 interface.reconfigureEffect(QStringLiteral("zoom")); 0121 } 0122 0123 } // namespace 0124 0125 #include "zoom_config.moc" 0126 0127 #include "moc_zoom_config.cpp"