File indexing completed on 2024-11-10 04:57:11

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 "thumbnailaside_config.h"
0010 
0011 #include <config-kwin.h>
0012 
0013 // KConfigSkeleton
0014 #include "thumbnailasideconfig.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 <QVBoxLayout>
0026 #include <QWidget>
0027 
0028 K_PLUGIN_CLASS(KWin::ThumbnailAsideEffectConfig)
0029 
0030 namespace KWin
0031 {
0032 ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QObject *parent, const KPluginMetaData &data)
0033     : KCModule(parent, data)
0034 {
0035     m_ui.setupUi(widget());
0036 
0037     connect(m_ui.editor, &KShortcutsEditor::keyChange, this, &KCModule::markAsChanged);
0038 
0039     ThumbnailAsideConfig::instance(KWIN_CONFIG);
0040     addConfig(ThumbnailAsideConfig::self(), widget());
0041 
0042     // Shortcut config. The shortcut belongs to the component "kwin"!
0043     m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
0044 
0045     m_actionCollection->setComponentDisplayName(i18n("KWin"));
0046     m_actionCollection->setConfigGroup(QStringLiteral("ThumbnailAside"));
0047     m_actionCollection->setConfigGlobal(true);
0048 
0049     QAction *a = m_actionCollection->addAction(QStringLiteral("ToggleCurrentThumbnail"));
0050     a->setText(i18n("Toggle Thumbnail for Current Window"));
0051     a->setProperty("isConfigurationAction", true);
0052     KGlobalAccel::self()->setDefaultShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_T));
0053     KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << (Qt::META | Qt::CTRL | Qt::Key_T));
0054 
0055     m_ui.editor->addCollection(m_actionCollection);
0056 }
0057 
0058 void ThumbnailAsideEffectConfig::save()
0059 {
0060     KCModule::save();
0061     m_ui.editor->save();
0062     OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
0063                                          QStringLiteral("/Effects"),
0064                                          QDBusConnection::sessionBus());
0065     interface.reconfigureEffect(QStringLiteral("thumbnailaside"));
0066 }
0067 
0068 } // namespace
0069 
0070 #include "thumbnailaside_config.moc"
0071 
0072 #include "moc_thumbnailaside_config.cpp"