File indexing completed on 2024-11-10 04:57:03
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2007 Christian Nitschkowski <christian.nitschkowski@kdemail.net> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "magnifier_config.h" 0010 0011 #include <config-kwin.h> 0012 0013 // KConfigSkeleton 0014 #include "magnifierconfig.h" 0015 #include <kwineffects_interface.h> 0016 0017 #include <QAction> 0018 0019 #include <KActionCollection> 0020 #include <KGlobalAccel> 0021 #include <KLocalizedString> 0022 #include <KPluginFactory> 0023 #include <kconfiggroup.h> 0024 0025 #include <QDebug> 0026 #include <QVBoxLayout> 0027 #include <QWidget> 0028 0029 K_PLUGIN_CLASS(KWin::MagnifierEffectConfig) 0030 0031 namespace KWin 0032 { 0033 MagnifierEffectConfig::MagnifierEffectConfig(QObject *parent, const KPluginMetaData &data) 0034 : KCModule(parent, data) 0035 { 0036 m_ui.setupUi(widget()); 0037 0038 MagnifierConfig::instance(KWIN_CONFIG); 0039 addConfig(MagnifierConfig::self(), widget()); 0040 0041 connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged); 0042 0043 // Shortcut config. The shortcut belongs to the component "kwin"! 0044 m_actionCollection = new KActionCollection(this, QStringLiteral("kwin")); 0045 0046 m_actionCollection->setComponentDisplayName(i18n("KWin")); 0047 m_actionCollection->setConfigGroup(QStringLiteral("Magnifier")); 0048 m_actionCollection->setConfigGlobal(true); 0049 0050 QAction *a; 0051 a = m_actionCollection->addAction(KStandardAction::ZoomIn); 0052 a->setProperty("isConfigurationAction", true); 0053 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Plus) << (Qt::META | Qt::Key_Equal)); 0054 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Plus) << (Qt::META | Qt::Key_Equal)); 0055 0056 a = m_actionCollection->addAction(KStandardAction::ZoomOut); 0057 a->setProperty("isConfigurationAction", true); 0058 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Minus)); 0059 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Minus)); 0060 0061 a = m_actionCollection->addAction(KStandardAction::ActualSize); 0062 a->setProperty("isConfigurationAction", true); 0063 KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_0)); 0064 KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_0)); 0065 0066 m_ui.editor->addCollection(m_actionCollection); 0067 } 0068 0069 void MagnifierEffectConfig::save() 0070 { 0071 qDebug() << "Saving config of Magnifier"; 0072 0073 m_ui.editor->save(); // undo() will restore to this state from now on 0074 KCModule::save(); 0075 OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), 0076 QStringLiteral("/Effects"), 0077 QDBusConnection::sessionBus()); 0078 interface.reconfigureEffect(QStringLiteral("magnifier")); 0079 } 0080 0081 void MagnifierEffectConfig::defaults() 0082 { 0083 m_ui.editor->allDefault(); 0084 KCModule::defaults(); 0085 } 0086 0087 } // namespace 0088 0089 #include "magnifier_config.moc" 0090 0091 #include "moc_magnifier_config.cpp"