2009-02-27 15:40:53 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
2013-03-12 12:17:53 +00:00
|
|
|
Copyright (C) 2008 Martin Gräßlin <mgraesslin@kde.org>
|
2009-02-27 15:40:53 +00:00
|
|
|
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#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>
|
|
|
|
#include <KPluginInfo>
|
2018-06-05 10:52:57 +00:00
|
|
|
#include <QtDBus>
|
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
|
|
|
|
{
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWinScreenEdgesConfigForm::KWinScreenEdgesConfigForm(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args)
|
2013-09-29 08:24:35 +00:00
|
|
|
: KCModule(parent, args)
|
2011-01-30 14:34:42 +00:00
|
|
|
, m_config(KSharedConfig::openConfig("kwinrc"))
|
|
|
|
{
|
|
|
|
m_ui = new KWinScreenEdgesConfigForm(this);
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
layout->addWidget(m_ui);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
monitorInit();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
connect(m_ui->monitor, SIGNAL(changed()), this, SLOT(changed()));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
connect(m_ui->desktopSwitchCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed()));
|
2013-08-16 17:38:26 +00:00
|
|
|
connect(m_ui->activationDelaySpin, SIGNAL(valueChanged(int)), this, SLOT(sanitizeCooldown()));
|
2011-01-30 14:34:42 +00:00
|
|
|
connect(m_ui->activationDelaySpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->triggerCooldownSpin, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->quickMaximizeBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
|
|
|
connect(m_ui->quickTileBox, SIGNAL(stateChanged(int)), this, SLOT(changed()));
|
2013-03-23 20:38:33 +00:00
|
|
|
connect(m_ui->electricBorderCornerRatio, SIGNAL(valueChanged(int)), this, SLOT(changed()));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Visual feedback of action group conflicts
|
2011-01-30 14:34:42 +00:00
|
|
|
connect(m_ui->desktopSwitchCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(groupChanged()));
|
|
|
|
connect(m_ui->quickMaximizeBox, SIGNAL(stateChanged(int)), this, SLOT(groupChanged()));
|
|
|
|
connect(m_ui->quickTileBox, SIGNAL(stateChanged(int)), this, SLOT(groupChanged()));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
load();
|
2013-08-16 17:38:26 +00:00
|
|
|
|
|
|
|
sanitizeCooldown();
|
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::groupChanged()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-27 15:40:53 +00:00
|
|
|
// Monitor conflicts
|
|
|
|
bool hide = false;
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_ui->desktopSwitchCombo->currentIndex() == 2)
|
2009-02-27 15:40:53 +00:00
|
|
|
hide = true;
|
2011-01-30 14:34:42 +00:00
|
|
|
monitorHideEdge(ElectricTop, hide);
|
|
|
|
monitorHideEdge(ElectricRight, hide);
|
|
|
|
monitorHideEdge(ElectricBottom, hide);
|
|
|
|
monitorHideEdge(ElectricLeft, hide);
|
|
|
|
}
|
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();
|
|
|
|
|
|
|
|
monitorLoad();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup config(m_config, "Windows");
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
m_ui->desktopSwitchCombo->setCurrentIndex(config.readEntry("ElectricBorders", 0));
|
|
|
|
m_ui->activationDelaySpin->setValue(config.readEntry("ElectricBorderDelay", 150));
|
|
|
|
m_ui->triggerCooldownSpin->setValue(config.readEntry("ElectricBorderCooldown", 350));
|
|
|
|
m_ui->quickMaximizeBox->setChecked(config.readEntry("ElectricBorderMaximize", true));
|
|
|
|
m_ui->quickTileBox->setChecked(config.readEntry("ElectricBorderTiling", true));
|
2013-03-23 20:38:33 +00:00
|
|
|
m_ui->electricBorderCornerRatio->setValue(qRound(config.readEntry("ElectricBorderCornerRatio", 0.25)*100));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
emit changed(false);
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::save()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-27 15:40:53 +00:00
|
|
|
KCModule::save();
|
|
|
|
|
|
|
|
monitorSave();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup config(m_config, "Windows");
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
config.writeEntry("ElectricBorders", m_ui->desktopSwitchCombo->currentIndex());
|
|
|
|
config.writeEntry("ElectricBorderDelay", m_ui->activationDelaySpin->value());
|
|
|
|
config.writeEntry("ElectricBorderCooldown", m_ui->triggerCooldownSpin->value());
|
|
|
|
config.writeEntry("ElectricBorderMaximize", m_ui->quickMaximizeBox->isChecked());
|
|
|
|
config.writeEntry("ElectricBorderTiling", m_ui->quickTileBox->isChecked());
|
2013-03-23 20:38:33 +00:00
|
|
|
config.writeEntry("ElectricBorderCornerRatio", m_ui->electricBorderCornerRatio->value()/100.0);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
config.sync();
|
|
|
|
|
|
|
|
// 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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
emit changed(false);
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::defaults()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-27 15:40:53 +00:00
|
|
|
monitorDefaults();
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
m_ui->desktopSwitchCombo->setCurrentIndex(0);
|
|
|
|
m_ui->activationDelaySpin->setValue(150);
|
|
|
|
m_ui->triggerCooldownSpin->setValue(350);
|
|
|
|
m_ui->quickMaximizeBox->setChecked(true);
|
|
|
|
m_ui->quickTileBox->setChecked(true);
|
2013-03-23 20:38:33 +00:00
|
|
|
m_ui->electricBorderCornerRatio->setValue(25);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
emit changed(true);
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinScreenEdgesConfig::showEvent(QShowEvent* e)
|
|
|
|
{
|
|
|
|
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
|
|
|
|
2013-08-16 17:38:26 +00:00
|
|
|
void KWinScreenEdgesConfig::sanitizeCooldown()
|
|
|
|
{
|
|
|
|
m_ui->triggerCooldownSpin->setMinimum(m_ui->activationDelaySpin->value() + 50);
|
|
|
|
}
|
|
|
|
|
2009-02-27 15:40:53 +00:00
|
|
|
// Copied from kcmkwin/kwincompositing/main.cpp
|
2014-04-04 08:45:16 +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
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorAddItem(const QString& item)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
m_ui->monitor->addEdgeItem(i, item);
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorItemSetEnabled(int index, bool enabled)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
m_ui->monitor->setEdgeItemEnabled(i, index, enabled);
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::monitorInit()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
monitorAddItem(i18n("No Action"));
|
|
|
|
monitorAddItem(i18n("Show Desktop"));
|
|
|
|
monitorAddItem(i18n("Lock Screen"));
|
2019-05-22 14:19:46 +00:00
|
|
|
monitorAddItem(i18n("Show KRunner"));
|
2016-04-07 19:07:41 +00:00
|
|
|
monitorAddItem(i18n("Activity Manager"));
|
2016-08-10 13:07:54 +00:00
|
|
|
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;
|
|
|
|
monitorAddItem(i18n("%1 - All Desktops", presentWindowsName));
|
|
|
|
monitorAddItem(i18n("%1 - Current Desktop", presentWindowsName));
|
|
|
|
monitorAddItem(i18n("%1 - Current Application", presentWindowsName));
|
|
|
|
monitorAddItem(BuiltInEffects::effectData(BuiltInEffect::DesktopGrid).displayName);
|
|
|
|
const QString cubeName = BuiltInEffects::effectData(BuiltInEffect::Cube).displayName;
|
|
|
|
monitorAddItem(i18n("%1 - Cube", cubeName));
|
|
|
|
monitorAddItem(i18n("%1 - Cylinder", cubeName));
|
|
|
|
monitorAddItem(i18n("%1 - Sphere", cubeName));
|
2013-03-08 19:17:55 +00:00
|
|
|
|
|
|
|
monitorAddItem(i18n("Toggle window switching"));
|
|
|
|
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();
|
|
|
|
monitorAddItem(script.name());
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorLoadAction(ElectricBorder edge, const QString& configName)
|
|
|
|
{
|
|
|
|
KConfigGroup config(m_config, "ElectricBorders");
|
|
|
|
QString lowerName = config.readEntry(configName, "None").toLower();
|
2015-10-19 13:39:52 +00:00
|
|
|
if (lowerName == "showdesktop") monitorChangeEdge(edge, int(ElectricActionShowDesktop));
|
2011-01-30 14:34:42 +00:00
|
|
|
else if (lowerName == "lockscreen") monitorChangeEdge(edge, int(ElectricActionLockScreen));
|
2016-04-07 19:07:41 +00:00
|
|
|
else if (lowerName == "krunner") monitorChangeEdge(edge, int(ElectricActionKRunner));
|
|
|
|
else if (lowerName == "activitymanager") monitorChangeEdge(edge, int(ElectricActionActivityManager));
|
2016-08-10 13:07:54 +00:00
|
|
|
else if (lowerName == "applicationlauncher") monitorChangeEdge(edge, int(ElectricActionApplicationLauncher));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-28 08:33:16 +00:00
|
|
|
|
2009-02-27 15:40:53 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorLoad()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-28 08:33:16 +00:00
|
|
|
// Load ElectricBorderActions
|
2011-01-30 14:34:42 +00:00
|
|
|
monitorLoadAction(ElectricTop, "Top");
|
|
|
|
monitorLoadAction(ElectricTopRight, "TopRight");
|
|
|
|
monitorLoadAction(ElectricRight, "Right");
|
|
|
|
monitorLoadAction(ElectricBottomRight, "BottomRight");
|
|
|
|
monitorLoadAction(ElectricBottom, "Bottom");
|
|
|
|
monitorLoadAction(ElectricBottomLeft, "BottomLeft");
|
|
|
|
monitorLoadAction(ElectricLeft, "Left");
|
|
|
|
monitorLoadAction(ElectricTopLeft, "TopLeft");
|
2009-02-28 08:33:16 +00:00
|
|
|
|
|
|
|
// Load effect-specific actions:
|
|
|
|
|
2009-02-27 15:40:53 +00:00
|
|
|
// Present Windows
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup presentWindowsConfig(m_config, "Effect-PresentWindows");
|
2009-03-29 12:57:20 +00:00
|
|
|
QList<int> list = QList<int>();
|
|
|
|
// PresentWindows BorderActivateAll
|
2011-01-30 14:34:42 +00:00
|
|
|
list.append(int(ElectricTopLeft));
|
|
|
|
list = presentWindowsConfig.readEntry("BorderActivateAll", list);
|
|
|
|
foreach (int i, list) {
|
|
|
|
monitorChangeEdge(ElectricBorder(i), int(PresentWindowsAll));
|
|
|
|
}
|
2009-03-29 12:57:20 +00:00
|
|
|
// PresentWindows BorderActivate
|
|
|
|
list.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
list.append(int(ElectricNone));
|
|
|
|
list = presentWindowsConfig.readEntry("BorderActivate", list);
|
|
|
|
foreach (int i, list) {
|
|
|
|
monitorChangeEdge(ElectricBorder(i), int(PresentWindowsCurrent));
|
|
|
|
}
|
2011-12-24 19:26:01 +00:00
|
|
|
// PresentWindows BorderActivateClass
|
|
|
|
list.clear();
|
|
|
|
list.append(int(ElectricNone));
|
|
|
|
list = presentWindowsConfig.readEntry("BorderActivateClass", list);
|
|
|
|
foreach (int i, list) {
|
|
|
|
monitorChangeEdge(ElectricBorder(i), int(PresentWindowsClass));
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Desktop Grid
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup gridConfig(m_config, "Effect-DesktopGrid");
|
2009-03-29 12:57:20 +00:00
|
|
|
list.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
list.append(int(ElectricNone));
|
|
|
|
list = gridConfig.readEntry("BorderActivate", list);
|
|
|
|
foreach (int i, list) {
|
|
|
|
monitorChangeEdge(ElectricBorder(i), int(DesktopGrid));
|
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Desktop Cube
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup cubeConfig(m_config, "Effect-Cube");
|
2009-03-29 12:57:20 +00:00
|
|
|
list.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
list.append(int(ElectricNone));
|
|
|
|
list = cubeConfig.readEntry("BorderActivate", list);
|
|
|
|
foreach (int i, list) {
|
|
|
|
monitorChangeEdge(ElectricBorder(i), int(Cube));
|
|
|
|
}
|
2009-03-29 12:57:20 +00:00
|
|
|
list.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
list.append(int(ElectricNone));
|
|
|
|
list = cubeConfig.readEntry("BorderActivateCylinder", list);
|
|
|
|
foreach (int i, list) {
|
|
|
|
monitorChangeEdge(ElectricBorder(i), int(Cylinder));
|
|
|
|
}
|
2009-03-29 12:57:20 +00:00
|
|
|
list.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
list.append(int(ElectricNone));
|
|
|
|
list = cubeConfig.readEntry("BorderActivateSphere", list);
|
|
|
|
foreach (int i, list) {
|
|
|
|
monitorChangeEdge(ElectricBorder(i), int(Sphere));
|
|
|
|
}
|
2009-07-21 10:18:48 +00:00
|
|
|
|
2013-03-08 19:17:55 +00:00
|
|
|
// TabBox
|
|
|
|
KConfigGroup tabBoxConfig(m_config, "TabBox");
|
2009-07-21 10:18:48 +00:00
|
|
|
list.clear();
|
2013-03-08 19:17:55 +00:00
|
|
|
// TabBox
|
2011-01-30 14:34:42 +00:00
|
|
|
list.append(int(ElectricNone));
|
2013-03-08 19:17:55 +00:00
|
|
|
list = tabBoxConfig.readEntry("BorderActivate", list);
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (int i, list) {
|
2013-03-08 19:17:55 +00:00
|
|
|
monitorChangeEdge(ElectricBorder(i), int(TabBox));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2013-03-08 19:17:55 +00:00
|
|
|
// Alternative TabBox
|
2009-07-21 10:18:48 +00:00
|
|
|
list.clear();
|
2011-01-30 14:34:42 +00:00
|
|
|
list.append(int(ElectricNone));
|
2013-03-08 19:17:55 +00:00
|
|
|
list = tabBoxConfig.readEntry("BorderAlternativeActivate", list);
|
2011-01-30 14:34:42 +00:00
|
|
|
foreach (int i, list) {
|
2013-03-08 19:17:55 +00:00
|
|
|
monitorChangeEdge(ElectricBorder(i), int(TabBoxAlternative));
|
2009-02-27 15:40:53 +00:00
|
|
|
}
|
2016-10-07 14:20:14 +00:00
|
|
|
|
|
|
|
for (int i=0; i < m_scripts.size(); i++) {
|
|
|
|
int index = EffectCount + i;
|
|
|
|
KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]);
|
|
|
|
list.append(int(ElectricNone));
|
|
|
|
list = scriptConfig.readEntry("BorderActivate", list);
|
|
|
|
for (int i: list) {
|
|
|
|
monitorChangeEdge(ElectricBorder(i), index);
|
|
|
|
}
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorSaveAction(int edge, const QString& configName)
|
|
|
|
{
|
|
|
|
KConfigGroup config(m_config, "ElectricBorders");
|
|
|
|
int item = m_ui->monitor->selectedEdgeItem(edge);
|
2015-10-19 13:39:52 +00:00
|
|
|
if (item == 1)
|
2011-01-30 14:34:42 +00:00
|
|
|
config.writeEntry(configName, "ShowDesktop");
|
2015-10-19 13:39:52 +00:00
|
|
|
else if (item == 2)
|
2011-01-30 14:34:42 +00:00
|
|
|
config.writeEntry(configName, "LockScreen");
|
2016-04-07 19:07:41 +00:00
|
|
|
else if (item == 3)
|
|
|
|
config.writeEntry(configName, "KRunner");
|
|
|
|
else if (item == 4)
|
|
|
|
config.writeEntry(configName, "ActivityManager");
|
2016-08-10 13:07:54 +00:00
|
|
|
else if (item == 5)
|
|
|
|
config.writeEntry(configName, "ApplicationLauncher");
|
2009-02-28 08:33:16 +00:00
|
|
|
else // Anything else
|
2011-01-30 14:34:42 +00:00
|
|
|
config.writeEntry(configName, "None");
|
|
|
|
}
|
2009-02-28 08:33:16 +00:00
|
|
|
|
2009-02-27 15:40:53 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorSave()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-28 08:33:16 +00:00
|
|
|
// Save ElectricBorderActions
|
2011-01-30 14:34:42 +00:00
|
|
|
monitorSaveAction(int(Monitor::Top), "Top");
|
|
|
|
monitorSaveAction(int(Monitor::TopRight), "TopRight");
|
|
|
|
monitorSaveAction(int(Monitor::Right), "Right");
|
|
|
|
monitorSaveAction(int(Monitor::BottomRight), "BottomRight");
|
|
|
|
monitorSaveAction(int(Monitor::Bottom), "Bottom");
|
|
|
|
monitorSaveAction(int(Monitor::BottomLeft), "BottomLeft");
|
|
|
|
monitorSaveAction(int(Monitor::Left), "Left");
|
|
|
|
monitorSaveAction(int(Monitor::TopLeft), "TopLeft");
|
2009-02-28 08:33:16 +00:00
|
|
|
|
|
|
|
// Save effect-specific actions:
|
|
|
|
|
2009-02-27 15:40:53 +00:00
|
|
|
// Present Windows
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup presentWindowsConfig(m_config, "Effect-PresentWindows");
|
|
|
|
presentWindowsConfig.writeEntry("BorderActivateAll",
|
|
|
|
monitorCheckEffectHasEdge(int(PresentWindowsAll)));
|
|
|
|
presentWindowsConfig.writeEntry("BorderActivate",
|
|
|
|
monitorCheckEffectHasEdge(int(PresentWindowsCurrent)));
|
2011-12-24 19:26:01 +00:00
|
|
|
presentWindowsConfig.writeEntry("BorderActivateClass",
|
|
|
|
monitorCheckEffectHasEdge(int(PresentWindowsClass)));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Desktop Grid
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup gridConfig(m_config, "Effect-DesktopGrid");
|
|
|
|
gridConfig.writeEntry("BorderActivate",
|
|
|
|
monitorCheckEffectHasEdge(int(DesktopGrid)));
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Desktop Cube
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup cubeConfig(m_config, "Effect-Cube");
|
|
|
|
cubeConfig.writeEntry("BorderActivate",
|
|
|
|
monitorCheckEffectHasEdge(int(Cube)));
|
|
|
|
cubeConfig.writeEntry("BorderActivateCylinder",
|
|
|
|
monitorCheckEffectHasEdge(int(Cylinder)));
|
|
|
|
cubeConfig.writeEntry("BorderActivateSphere",
|
|
|
|
monitorCheckEffectHasEdge(int(Sphere)));
|
2009-07-21 10:18:48 +00:00
|
|
|
|
2013-03-08 19:17:55 +00:00
|
|
|
// TabBox
|
|
|
|
KConfigGroup tabBoxConfig(m_config, "TabBox");
|
|
|
|
tabBoxConfig.writeEntry("BorderActivate",
|
|
|
|
monitorCheckEffectHasEdge(int(TabBox)));
|
|
|
|
tabBoxConfig.writeEntry("BorderAlternativeActivate",
|
|
|
|
monitorCheckEffectHasEdge(int(TabBoxAlternative)));
|
2016-10-07 14:20:14 +00:00
|
|
|
|
|
|
|
for (int i=0; i < m_scripts.size(); i++) {
|
|
|
|
int index = EffectCount + i;
|
|
|
|
KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]);
|
|
|
|
scriptConfig.writeEntry("BorderActivate",
|
|
|
|
monitorCheckEffectHasEdge(index));
|
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
void KWinScreenEdgesConfig::monitorDefaults()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-02-27 15:40:53 +00:00
|
|
|
// Clear all edges
|
2011-01-30 14:34:42 +00:00
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
m_ui->monitor->selectEdgeItem(i, 0);
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
// Present windows = Top-left
|
2011-01-30 14:34:42 +00:00
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::TopLeft), int(PresentWindowsAll));
|
|
|
|
}
|
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);
|
|
|
|
monitorItemSetEnabled(int(PresentWindowsCurrent), enabled);
|
|
|
|
monitorItemSetEnabled(int(PresentWindowsAll), enabled);
|
|
|
|
|
|
|
|
// Desktop Grid
|
|
|
|
enabled = effectEnabled(BuiltInEffect::DesktopGrid, config);
|
|
|
|
monitorItemSetEnabled(int(DesktopGrid), enabled);
|
|
|
|
|
|
|
|
// Desktop Cube
|
|
|
|
enabled = effectEnabled(BuiltInEffect::Cube, config);
|
|
|
|
monitorItemSetEnabled(int(Cube), enabled);
|
|
|
|
monitorItemSetEnabled(int(Cylinder), enabled);
|
|
|
|
monitorItemSetEnabled(int(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";
|
|
|
|
monitorItemSetEnabled(int(TabBox), reasonable);
|
|
|
|
monitorItemSetEnabled(int(TabBoxAlternative), reasonable);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorChangeEdge(ElectricBorder border, int index)
|
|
|
|
{
|
|
|
|
switch(border) {
|
|
|
|
case ElectricTop:
|
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::Top), index);
|
|
|
|
break;
|
|
|
|
case ElectricTopRight:
|
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::TopRight), index);
|
|
|
|
break;
|
|
|
|
case ElectricRight:
|
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::Right), index);
|
|
|
|
break;
|
|
|
|
case ElectricBottomRight:
|
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::BottomRight), index);
|
|
|
|
break;
|
|
|
|
case ElectricBottom:
|
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::Bottom), index);
|
|
|
|
break;
|
|
|
|
case ElectricBottomLeft:
|
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::BottomLeft), index);
|
|
|
|
break;
|
|
|
|
case ElectricLeft:
|
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::Left), index);
|
|
|
|
break;
|
|
|
|
case ElectricTopLeft:
|
|
|
|
m_ui->monitor->selectEdgeItem(int(Monitor::TopLeft), index);
|
|
|
|
break;
|
|
|
|
default: // Nothing
|
|
|
|
break;
|
2009-02-27 15:40:53 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinScreenEdgesConfig::monitorHideEdge(ElectricBorder border, bool hidden)
|
|
|
|
{
|
|
|
|
switch(border) {
|
|
|
|
case ElectricTop:
|
|
|
|
m_ui->monitor->setEdgeHidden(int(Monitor::Top), hidden);
|
|
|
|
break;
|
|
|
|
case ElectricTopRight:
|
|
|
|
m_ui->monitor->setEdgeHidden(int(Monitor::TopRight), hidden);
|
|
|
|
break;
|
|
|
|
case ElectricRight:
|
|
|
|
m_ui->monitor->setEdgeHidden(int(Monitor::Right), hidden);
|
|
|
|
break;
|
|
|
|
case ElectricBottomRight:
|
|
|
|
m_ui->monitor->setEdgeHidden(int(Monitor::BottomRight), hidden);
|
|
|
|
break;
|
|
|
|
case ElectricBottom:
|
|
|
|
m_ui->monitor->setEdgeHidden(int(Monitor::Bottom), hidden);
|
|
|
|
break;
|
|
|
|
case ElectricBottomLeft:
|
|
|
|
m_ui->monitor->setEdgeHidden(int(Monitor::BottomLeft), hidden);
|
|
|
|
break;
|
|
|
|
case ElectricLeft:
|
|
|
|
m_ui->monitor->setEdgeHidden(int(Monitor::Left), hidden);
|
|
|
|
break;
|
|
|
|
case ElectricTopLeft:
|
|
|
|
m_ui->monitor->setEdgeHidden(int(Monitor::TopLeft), hidden);
|
|
|
|
break;
|
|
|
|
default: // Nothing
|
|
|
|
break;
|
2009-02-27 15:40:53 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QList<int> KWinScreenEdgesConfig::monitorCheckEffectHasEdge(int index) const
|
|
|
|
{
|
2009-03-29 12:57:20 +00:00
|
|
|
QList<int> list = QList<int>();
|
2011-01-30 14:34:42 +00:00
|
|
|
if (m_ui->monitor->selectedEdgeItem(int(Monitor::Top)) == index)
|
|
|
|
list.append(int(ElectricTop));
|
|
|
|
if (m_ui->monitor->selectedEdgeItem(int(Monitor::TopRight)) == index)
|
|
|
|
list.append(int(ElectricTopRight));
|
|
|
|
if (m_ui->monitor->selectedEdgeItem(int(Monitor::Right)) == index)
|
|
|
|
list.append(int(ElectricRight));
|
|
|
|
if (m_ui->monitor->selectedEdgeItem(int(Monitor::BottomRight)) == index)
|
|
|
|
list.append(int(ElectricBottomRight));
|
|
|
|
if (m_ui->monitor->selectedEdgeItem(int(Monitor::Bottom)) == index)
|
|
|
|
list.append(int(ElectricBottom));
|
|
|
|
if (m_ui->monitor->selectedEdgeItem(int(Monitor::BottomLeft)) == index)
|
|
|
|
list.append(int(ElectricBottomLeft));
|
|
|
|
if (m_ui->monitor->selectedEdgeItem(int(Monitor::Left)) == index)
|
|
|
|
list.append(int(ElectricLeft));
|
|
|
|
if (m_ui->monitor->selectedEdgeItem(int(Monitor::TopLeft)) == index)
|
|
|
|
list.append(int(ElectricTopLeft));
|
|
|
|
|
|
|
|
if (list.isEmpty())
|
|
|
|
list.append(int(ElectricNone));
|
2009-03-29 12:57:20 +00:00
|
|
|
return list;
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-02-27 15:40:53 +00:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
#include "main.moc"
|