kwin/src/effects/overview/kcm/overvieweffectkcm.cpp
Vlad Zahorodnii 6132329c2c Add Overview effect
This effect is meant to be as a replacement for the present windows and
the desktop grid effect. It is written using QML.

So far, this effect implements only the basic features of the present
windows effect. Desktop management features will be added later.

CCBUG: 295775
CCBUG: 303438
2021-08-19 06:30:55 +00:00

79 lines
2.3 KiB
C++

/*
SPDX-FileCopyrightText: 2021 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "overvieweffectkcm.h"
#include "overviewconfig.h"
#include <config-kwin.h>
#include <kwineffects_interface.h>
#include <KAboutData>
#include <KActionCollection>
#include <KGlobalAccel>
#include <KLocalizedString>
#include <KPluginFactory>
#include <QAction>
K_PLUGIN_FACTORY_WITH_JSON(OverviewEffectConfigFactory,
"overvieweffectkcm.json",
registerPlugin<KWin::OverviewEffectConfig>();)
namespace KWin
{
OverviewEffectConfig::OverviewEffectConfig(QWidget *parent, const QVariantList &args)
: KCModule(parent, args)
{
ui.setupUi(this);
OverviewConfig::instance(KWIN_CONFIG);
addConfig(OverviewConfig::self(), this);
auto actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
actionCollection->setComponentDisplayName(i18n("KWin"));
actionCollection->setConfigGroup(QStringLiteral("Overview"));
actionCollection->setConfigGlobal(true);
const QKeySequence defaultToggleShortcut = Qt::CTRL + Qt::META + Qt::Key_D;
QAction *toggleAction = actionCollection->addAction(QStringLiteral("Overview"));
toggleAction->setText(i18n("Toggle Overview"));
toggleAction->setProperty("isConfigurationAction", true);
KGlobalAccel::self()->setDefaultShortcut(toggleAction, {defaultToggleShortcut});
KGlobalAccel::self()->setShortcut(toggleAction, {defaultToggleShortcut});
ui.shortcutsEditor->addCollection(actionCollection);
connect(ui.shortcutsEditor, &KShortcutsEditor::keyChange, this, &OverviewEffectConfig::markAsChanged);
load();
}
OverviewEffectConfig::~OverviewEffectConfig()
{
// If save() is called, undo() has no effect.
ui.shortcutsEditor->undo();
}
void OverviewEffectConfig::save()
{
KCModule::save();
ui.shortcutsEditor->save();
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
QStringLiteral("/Effects"),
QDBusConnection::sessionBus());
interface.reconfigureEffect(QStringLiteral("overview"));
}
void OverviewEffectConfig::defaults()
{
ui.shortcutsEditor->allDefault();
KCModule::defaults();
}
} // namespace KWin
#include "overvieweffectkcm.moc"