2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2008 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2009 Lucas Murray <lmurray@undefinedfire.com>
|
|
|
|
SPDX-FileCopyrightText: 2020 Cyril Rossi <cyril.rossi@enioka.com>
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
#include "main.h"
|
2014-04-04 08:45:16 +00:00
|
|
|
#include <effect_builtins.h>
|
2014-05-15 06:34:04 +00:00
|
|
|
#include <kwin_effects_interface.h>
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2014-03-17 15:24:10 +00:00
|
|
|
#include <KAboutData>
|
|
|
|
#include <KConfigGroup>
|
2014-03-18 10:06:56 +00:00
|
|
|
#include <KLocalizedString>
|
2009-02-27 15:40:53 +00:00
|
|
|
#include <KPluginFactory>
|
2016-10-07 14:20:14 +00:00
|
|
|
#include <KPackage/Package>
|
|
|
|
#include <KPackage/PackageLoader>
|
2018-06-05 10:52:57 +00:00
|
|
|
#include <QtDBus>
|
2020-03-05 17:03:00 +00:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#include "kwinscreenedgeconfigform.h"
|
|
|
|
#include "kwinscreenedgesettings.h"
|
|
|
|
#include "kwinscreenedgescriptsettings.h"
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin<KWin::KWinScreenEdgesConfig>();)
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget *parent, const QVariantList &args)
|
2013-09-29 08:24:35 +00:00
|
|
|
: KCModule(parent, args)
|
2020-03-05 17:03:00 +00:00
|
|
|
, m_form(new KWinScreenEdgesConfigForm(this))
|
2011-01-30 14:34:42 +00:00
|
|
|
, m_config(KSharedConfig::openConfig("kwinrc"))
|
2020-03-05 17:03:00 +00:00
|
|
|
, m_settings(new KWinScreenEdgeSettings(this))
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-03-05 17:03:00 +00:00
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
|
|
layout->addWidget(m_form);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
addConfig(m_settings, m_form);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
monitorInit();
|
2013-08-16 17:38:26 +00:00
|
|
|
|
2020-08-04 08:11:27 +00:00
|
|
|
connect(this, &KWinScreenEdgesConfig::defaultsIndicatorsVisibleChanged, m_form, &KWinScreenEdgesConfigForm::setDefaultsIndicatorsVisible);
|
2020-03-05 17:03:00 +00:00
|
|
|
connect(m_form, &KWinScreenEdgesConfigForm::saveNeededChanged, this, &KWinScreenEdgesConfig::unmanagedWidgetChangeState);
|
|
|
|
connect(m_form, &KWinScreenEdgesConfigForm::defaultChanged, this, &KWinScreenEdgesConfig::unmanagedWidgetDefaultState);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
KWinScreenEdgesConfig::~KWinScreenEdgesConfig()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::load()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-27 15:40:53 +00:00
|
|
|
KCModule::load();
|
2020-03-05 17:03:00 +00:00
|
|
|
m_settings->load();
|
|
|
|
for (KWinScreenEdgeScriptSettings *setting : qAsConst(m_scriptSettings)) {
|
|
|
|
setting->load();
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
monitorLoadSettings();
|
|
|
|
monitorLoadDefaultSettings();
|
|
|
|
m_form->setElectricBorderCornerRatio(m_settings->electricBorderCornerRatio());
|
|
|
|
m_form->setDefaultElectricBorderCornerRatio(m_settings->defaultElectricBorderCornerRatioValue());
|
|
|
|
m_form->reload();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::save()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-03-05 17:03:00 +00:00
|
|
|
monitorSaveSettings();
|
|
|
|
m_settings->setElectricBorderCornerRatio(m_form->electricBorderCornerRatio());
|
|
|
|
m_settings->save();
|
|
|
|
for (KWinScreenEdgeScriptSettings *setting : qAsConst(m_scriptSettings)) {
|
|
|
|
setting->save();
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
// Reload saved settings to ScreenEdge UI
|
|
|
|
monitorLoadSettings();
|
|
|
|
m_form->setElectricBorderCornerRatio(m_settings->electricBorderCornerRatio());
|
|
|
|
m_form->reload();
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Reload KWin.
|
2011-01-30 14:34:42 +00:00
|
|
|
QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
2014-05-15 06:34:04 +00:00
|
|
|
// and reconfigure the effects
|
|
|
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
|
|
|
QStringLiteral("/Effects"),
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::PresentWindows));
|
|
|
|
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::DesktopGrid));
|
|
|
|
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::Cube));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
KCModule::save();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::defaults()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->setDefaults();
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
KCModule::defaults();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
void KWinScreenEdgesConfig::showEvent(QShowEvent *e)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
KCModule::showEvent(e);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
monitorShowEvent();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Copied from kcmkwin/kwincompositing/main.cpp
|
2020-03-05 17:03:00 +00:00
|
|
|
bool KWinScreenEdgesConfig::effectEnabled(const BuiltInEffect &effect, const KConfigGroup &cfg) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2014-04-04 09:49:31 +00:00
|
|
|
return cfg.readEntry(BuiltInEffects::nameForEffect(effect) + "Enabled", BuiltInEffects::enabledByDefault(effect));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Monitor
|
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::monitorInit()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorAddItem(i18n("No Action"));
|
|
|
|
m_form->monitorAddItem(i18n("Show Desktop"));
|
|
|
|
m_form->monitorAddItem(i18n("Lock Screen"));
|
|
|
|
m_form->monitorAddItem(i18n("Show KRunner"));
|
|
|
|
m_form->monitorAddItem(i18n("Activity Manager"));
|
|
|
|
m_form->monitorAddItem(i18n("Application Launcher"));
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2014-04-04 08:45:16 +00:00
|
|
|
// Add the effects
|
|
|
|
const QString presentWindowsName = BuiltInEffects::effectData(BuiltInEffect::PresentWindows).displayName;
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorAddItem(i18n("%1 - All Desktops", presentWindowsName));
|
|
|
|
m_form->monitorAddItem(i18n("%1 - Current Desktop", presentWindowsName));
|
|
|
|
m_form->monitorAddItem(i18n("%1 - Current Application", presentWindowsName));
|
|
|
|
m_form->monitorAddItem(BuiltInEffects::effectData(BuiltInEffect::DesktopGrid).displayName);
|
2014-04-04 08:45:16 +00:00
|
|
|
const QString cubeName = BuiltInEffects::effectData(BuiltInEffect::Cube).displayName;
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorAddItem(i18n("%1 - Cube", cubeName));
|
|
|
|
m_form->monitorAddItem(i18n("%1 - Cylinder", cubeName));
|
|
|
|
m_form->monitorAddItem(i18n("%1 - Sphere", cubeName));
|
2013-03-08 19:17:55 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorAddItem(i18n("Toggle window switching"));
|
|
|
|
m_form->monitorAddItem(i18n("Toggle alternative window switching"));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2016-10-07 14:20:14 +00:00
|
|
|
const QString scriptFolder = QStringLiteral("kwin/scripts/");
|
|
|
|
const auto scripts = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder);
|
|
|
|
|
|
|
|
KConfigGroup config(m_config, "Plugins");
|
|
|
|
for (const KPluginMetaData &script: scripts) {
|
|
|
|
if (script.value(QStringLiteral("X-KWin-Border-Activate")) != QLatin1String("true")) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!config.readEntry(script.pluginId() + QStringLiteral("Enabled"), script.isEnabledByDefault())) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
m_scripts << script.pluginId();
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorAddItem(script.name());
|
|
|
|
m_scriptSettings[script.pluginId()] = new KWinScreenEdgeScriptSettings(script.pluginId(), this);
|
2016-10-07 14:20:14 +00:00
|
|
|
}
|
|
|
|
|
2009-02-27 15:40:53 +00:00
|
|
|
monitorShowEvent();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorLoadSettings()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-28 08:33:16 +00:00
|
|
|
// Load ElectricBorderActions
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(ElectricTop, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->top()));
|
|
|
|
m_form->monitorChangeEdge(ElectricTopRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->topRight()));
|
|
|
|
m_form->monitorChangeEdge(ElectricRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->right()));
|
|
|
|
m_form->monitorChangeEdge(ElectricBottomRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->bottomRight()));
|
|
|
|
m_form->monitorChangeEdge(ElectricBottom, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->bottom()));
|
|
|
|
m_form->monitorChangeEdge(ElectricBottomLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->bottomLeft()));
|
|
|
|
m_form->monitorChangeEdge(ElectricLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->left()));
|
|
|
|
m_form->monitorChangeEdge(ElectricTopLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->topLeft()));
|
2009-02-28 08:33:16 +00:00
|
|
|
|
|
|
|
// Load effect-specific actions:
|
|
|
|
|
2009-03-29 12:57:20 +00:00
|
|
|
// PresentWindows BorderActivateAll
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(m_settings->borderActivateAll(), PresentWindowsAll);
|
|
|
|
|
2009-03-29 12:57:20 +00:00
|
|
|
// PresentWindows BorderActivate
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(m_settings->borderActivatePresentWindows(), PresentWindowsCurrent);
|
|
|
|
|
2011-12-24 19:26:01 +00:00
|
|
|
// PresentWindows BorderActivateClass
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(m_settings->borderActivateClass(), PresentWindowsClass);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Desktop Grid
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(m_settings->borderActivateDesktopGrid(), DesktopGrid);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Desktop Cube
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(m_settings->borderActivateCube(), Cube);
|
|
|
|
m_form->monitorChangeEdge(m_settings->borderActivateCylinder(), Cylinder);
|
|
|
|
m_form->monitorChangeEdge(m_settings->borderActivateSphere(), Sphere);
|
2009-07-21 10:18:48 +00:00
|
|
|
|
2013-03-08 19:17:55 +00:00
|
|
|
// TabBox
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(m_settings->borderActivateTabBox(), TabBox);
|
2013-03-08 19:17:55 +00:00
|
|
|
// Alternative TabBox
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(m_settings->borderAlternativeActivate(), TabBoxAlternative);
|
2016-10-07 14:20:14 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
// Scripts
|
|
|
|
for (int i = 0; i < m_scripts.size(); i++) {
|
2016-10-07 14:20:14 +00:00
|
|
|
int index = EffectCount + i;
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorChangeEdge(m_scriptSettings[m_scripts[i]]->borderActivate(), index);
|
2016-10-07 14:20:14 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorLoadDefaultSettings()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-03-05 17:03:00 +00:00
|
|
|
// Load ElectricBorderActions
|
|
|
|
m_form->monitorChangeDefaultEdge(ElectricTop, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultTopValue()));
|
|
|
|
m_form->monitorChangeDefaultEdge(ElectricTopRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultTopRightValue()));
|
|
|
|
m_form->monitorChangeDefaultEdge(ElectricRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultRightValue()));
|
|
|
|
m_form->monitorChangeDefaultEdge(ElectricBottomRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultBottomRightValue()));
|
|
|
|
m_form->monitorChangeDefaultEdge(ElectricBottom, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultBottomValue()));
|
|
|
|
m_form->monitorChangeDefaultEdge(ElectricBottomLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultBottomLeftValue()));
|
|
|
|
m_form->monitorChangeDefaultEdge(ElectricLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultLeftValue()));
|
|
|
|
m_form->monitorChangeDefaultEdge(ElectricTopLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultTopLeftValue()));
|
|
|
|
|
|
|
|
// Load effect-specific actions:
|
|
|
|
|
|
|
|
// PresentWindows BorderActivateAll
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderActivateAllValue(), PresentWindowsAll);
|
|
|
|
|
|
|
|
// PresentWindows BorderActivate
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderActivatePresentWindowsValue(), PresentWindowsCurrent);
|
|
|
|
|
|
|
|
// PresentWindows BorderActivateClass
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderActivateClassValue(), PresentWindowsClass);
|
|
|
|
|
|
|
|
// Desktop Grid
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderActivateDesktopGridValue(), DesktopGrid);
|
|
|
|
|
|
|
|
// Desktop Cube
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderActivateCubeValue(), Cube);
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderActivateCylinderValue(), Cylinder);
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderActivateSphereValue(), Sphere);
|
|
|
|
|
|
|
|
// TabBox
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderActivateTabBoxValue(), TabBox);
|
|
|
|
// Alternative TabBox
|
|
|
|
m_form->monitorChangeDefaultEdge(m_settings->defaultBorderAlternativeActivateValue(), TabBoxAlternative);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-28 08:33:16 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorSaveSettings()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-28 08:33:16 +00:00
|
|
|
// Save ElectricBorderActions
|
2020-03-05 17:03:00 +00:00
|
|
|
m_settings->setTop(KWinScreenEdgesConfig::electricBorderActionToString(m_form->selectedEdgeItem(ElectricTop)));
|
|
|
|
m_settings->setTopRight(KWinScreenEdgesConfig::electricBorderActionToString(m_form->selectedEdgeItem(ElectricTopRight)));
|
|
|
|
m_settings->setRight(KWinScreenEdgesConfig::electricBorderActionToString(m_form->selectedEdgeItem(ElectricRight)));
|
|
|
|
m_settings->setBottomRight(KWinScreenEdgesConfig::electricBorderActionToString(m_form->selectedEdgeItem(ElectricBottomRight)));
|
|
|
|
m_settings->setBottom(KWinScreenEdgesConfig::electricBorderActionToString(m_form->selectedEdgeItem(ElectricBottom)));
|
|
|
|
m_settings->setBottomLeft(KWinScreenEdgesConfig::electricBorderActionToString(m_form->selectedEdgeItem(ElectricBottomLeft)));
|
|
|
|
m_settings->setLeft(KWinScreenEdgesConfig::electricBorderActionToString(m_form->selectedEdgeItem(ElectricLeft)));
|
|
|
|
m_settings->setTopLeft(KWinScreenEdgesConfig::electricBorderActionToString(m_form->selectedEdgeItem(ElectricTopLeft)));
|
2009-02-28 08:33:16 +00:00
|
|
|
|
|
|
|
// Save effect-specific actions:
|
|
|
|
|
2009-02-27 15:40:53 +00:00
|
|
|
// Present Windows
|
2020-03-05 17:03:00 +00:00
|
|
|
m_settings->setBorderActivateAll(m_form->monitorCheckEffectHasEdge(PresentWindowsAll));
|
|
|
|
m_settings->setBorderActivatePresentWindows(m_form->monitorCheckEffectHasEdge(PresentWindowsCurrent));
|
|
|
|
m_settings->setBorderActivateClass(m_form->monitorCheckEffectHasEdge(PresentWindowsClass));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Desktop Grid
|
2020-03-05 17:03:00 +00:00
|
|
|
m_settings->setBorderActivateDesktopGrid(m_form->monitorCheckEffectHasEdge(DesktopGrid));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Desktop Cube
|
2020-03-05 17:03:00 +00:00
|
|
|
m_settings->setBorderActivateCube(m_form->monitorCheckEffectHasEdge(Cube));
|
|
|
|
m_settings->setBorderActivateCylinder(m_form->monitorCheckEffectHasEdge(Cylinder));
|
|
|
|
m_settings->setBorderActivateSphere(m_form->monitorCheckEffectHasEdge(Sphere));
|
2009-07-21 10:18:48 +00:00
|
|
|
|
2013-03-08 19:17:55 +00:00
|
|
|
// TabBox
|
2020-03-05 17:03:00 +00:00
|
|
|
m_settings->setBorderActivateTabBox(m_form->monitorCheckEffectHasEdge(TabBox));
|
|
|
|
m_settings->setBorderAlternativeActivate(m_form->monitorCheckEffectHasEdge(TabBoxAlternative));
|
2016-10-07 14:20:14 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
// Scripts
|
|
|
|
for (int i = 0; i < m_scripts.size(); i++) {
|
2016-10-07 14:20:14 +00:00
|
|
|
int index = EffectCount + i;
|
2020-03-05 17:03:00 +00:00
|
|
|
m_scriptSettings[m_scripts[i]]->setBorderActivate(m_form->monitorCheckEffectHasEdge(index));
|
2016-10-07 14:20:14 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::monitorShowEvent()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-27 15:40:53 +00:00
|
|
|
// Check if they are enabled
|
2014-12-01 15:38:16 +00:00
|
|
|
KConfigGroup config(m_config, "Plugins");
|
|
|
|
|
|
|
|
// Present Windows
|
|
|
|
bool enabled = effectEnabled(BuiltInEffect::PresentWindows, config);
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorItemSetEnabled(PresentWindowsCurrent, enabled);
|
|
|
|
m_form->monitorItemSetEnabled(PresentWindowsAll, enabled);
|
2014-12-01 15:38:16 +00:00
|
|
|
|
|
|
|
// Desktop Grid
|
|
|
|
enabled = effectEnabled(BuiltInEffect::DesktopGrid, config);
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorItemSetEnabled(DesktopGrid, enabled);
|
2014-12-01 15:38:16 +00:00
|
|
|
|
|
|
|
// Desktop Cube
|
|
|
|
enabled = effectEnabled(BuiltInEffect::Cube, config);
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorItemSetEnabled(Cube, enabled);
|
|
|
|
m_form->monitorItemSetEnabled(Cylinder, enabled);
|
|
|
|
m_form->monitorItemSetEnabled(Sphere, enabled);
|
2013-03-08 19:17:55 +00:00
|
|
|
// tabbox, depends on reasonable focus policy.
|
|
|
|
KConfigGroup config2(m_config, "Windows");
|
|
|
|
QString focusPolicy = config2.readEntry("FocusPolicy", QString());
|
|
|
|
bool reasonable = focusPolicy != "FocusStrictlyUnderMouse" && focusPolicy != "FocusUnderMouse";
|
2020-03-05 17:03:00 +00:00
|
|
|
m_form->monitorItemSetEnabled(TabBox, reasonable);
|
|
|
|
m_form->monitorItemSetEnabled(TabBoxAlternative, reasonable);
|
KCM KWinScreenEdges disable widgets if is immutable
Summary:
Same as D28507
Disable screen edge modification, but allow the user to open an edge context menu and see the settings.
To set an edge immutable, just add `[$i]` right after the entry in `ElectricBorders` group, although the edges settings are shared between some `[Effect-something]` group under the key `BorderActivateSomething`.
Since one entry like `BorderActivateSomething` lists all edges that use this effect, it doesn't make sense to set it immutable.
Test Plan:
In `kwinrc`, set the `ElectricBorders` and/or `Windows` group immutable or any entry.
```
[ElectricBorders]
BottomLeft[$i]=None
Left=None
Right=None
Top[$i]=None
[Windows][$i]
ElectricBorderCornerRatio=0.29
ElectricBorderDelay=300
ElectricBorderMaximize=false
ElectricBorderTiling=true
ElectricBorders=2
```
Reviewers: ervin, bport, meven, zzag, #kwin, mart
Reviewed By: ervin, zzag, #kwin, mart
Subscribers: kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D28508
2020-04-02 09:28:14 +00:00
|
|
|
|
|
|
|
// Disable Edge if ElectricBorders group entries are immutable
|
|
|
|
m_form->monitorEnableEdge(ElectricTop, !m_settings->isTopImmutable());
|
|
|
|
m_form->monitorEnableEdge(ElectricTopRight, !m_settings->isTopRightImmutable());
|
|
|
|
m_form->monitorEnableEdge(ElectricRight, !m_settings->isRightImmutable());
|
|
|
|
m_form->monitorEnableEdge(ElectricBottomRight, !m_settings->isBottomRightImmutable());
|
|
|
|
m_form->monitorEnableEdge(ElectricBottom, !m_settings->isBottomImmutable());
|
|
|
|
m_form->monitorEnableEdge(ElectricBottomLeft, !m_settings->isBottomLeftImmutable());
|
|
|
|
m_form->monitorEnableEdge(ElectricLeft, !m_settings->isLeftImmutable());
|
|
|
|
m_form->monitorEnableEdge(ElectricTopLeft, !m_settings->isTopLeftImmutable());
|
|
|
|
|
|
|
|
// Disable ElectricBorderCornerRatio if entry is immutable
|
|
|
|
m_form->setElectricBorderCornerRatioEnabled(!m_settings->isElectricBorderCornerRatioImmutable());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
ElectricBorderAction KWinScreenEdgesConfig::electricBorderActionFromString(const QString &string)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-03-05 17:03:00 +00:00
|
|
|
QString lowerName = string.toLower();
|
|
|
|
if (lowerName == QStringLiteral("showdesktop")) {
|
|
|
|
return ElectricActionShowDesktop;
|
2009-02-27 15:40:53 +00:00
|
|
|
}
|
2020-03-05 17:03:00 +00:00
|
|
|
if (lowerName == QStringLiteral("lockscreen")) {
|
|
|
|
return ElectricActionLockScreen;
|
2009-02-27 15:40:53 +00:00
|
|
|
}
|
2020-03-05 17:03:00 +00:00
|
|
|
if (lowerName == QStringLiteral("krunner")) {
|
|
|
|
return ElectricActionKRunner;
|
|
|
|
}
|
|
|
|
if (lowerName == QStringLiteral("activitymanager")) {
|
|
|
|
return ElectricActionActivityManager;
|
|
|
|
}
|
|
|
|
if (lowerName == QStringLiteral("applicationlauncher")) {
|
|
|
|
return ElectricActionApplicationLauncher;
|
|
|
|
}
|
|
|
|
return ElectricActionNone;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
QString KWinScreenEdgesConfig::electricBorderActionToString(int action)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-03-05 17:03:00 +00:00
|
|
|
switch (action) {
|
|
|
|
case 1:
|
|
|
|
return QStringLiteral("ShowDesktop");
|
|
|
|
case 2:
|
|
|
|
return QStringLiteral("LockScreen");
|
|
|
|
case 3:
|
|
|
|
return QStringLiteral("KRunner");
|
|
|
|
case 4:
|
|
|
|
return QStringLiteral("ActivityManager");
|
|
|
|
case 5:
|
|
|
|
return QStringLiteral("ApplicationLauncher");
|
|
|
|
default:
|
|
|
|
return QStringLiteral("None");
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "main.moc"
|