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: 2012 Filip Wieladek <wattos@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "mouseclick_config.h"
0010 
0011 #include <config-kwin.h>
0012 
0013 // KConfigSkeleton
0014 #include "mouseclickconfig.h"
0015 #include <kwineffects_interface.h>
0016 
0017 #include <QAction>
0018 
0019 #include <KActionCollection>
0020 #include <KGlobalAccel>
0021 #include <KLocalizedString>
0022 #include <KPluginFactory>
0023 
0024 #include <QWidget>
0025 
0026 K_PLUGIN_CLASS(KWin::MouseClickEffectConfig)
0027 
0028 namespace KWin
0029 {
0030 
0031 MouseClickEffectConfig::MouseClickEffectConfig(QObject *parent, const KPluginMetaData &data)
0032     : KCModule(parent, data)
0033 {
0034     m_ui.setupUi(widget());
0035 
0036     connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
0037 
0038     // Shortcut config. The shortcut belongs to the component "kwin"!
0039     m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
0040     m_actionCollection->setComponentDisplayName(i18n("KWin"));
0041 
0042     QAction *a = m_actionCollection->addAction(QStringLiteral("ToggleMouseClick"));
0043     a->setText(i18n("Toggle Mouse Click Effect"));
0044     a->setProperty("isConfigurationAction", true);
0045     KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Asterisk));
0046     KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::Key_Asterisk));
0047 
0048     m_ui.editor->addCollection(m_actionCollection);
0049 
0050     MouseClickConfig::instance(KWIN_CONFIG);
0051     addConfig(MouseClickConfig::self(), widget());
0052 }
0053 
0054 void MouseClickEffectConfig::save()
0055 {
0056     KCModule::save();
0057     m_ui.editor->save(); // undo() will restore to this state from now on
0058     OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
0059                                          QStringLiteral("/Effects"),
0060                                          QDBusConnection::sessionBus());
0061     interface.reconfigureEffect(QStringLiteral("mouseclick"));
0062 }
0063 
0064 } // namespace
0065 
0066 #include "mouseclick_config.moc"
0067 
0068 #include "moc_mouseclick_config.cpp"