2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2009 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2020 Cyril Rossi <cyril.rossi@enioka.com>
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2009-09-13 11:36:45 +00:00
|
|
|
#include "main.h"
|
2014-04-04 09:03:45 +00:00
|
|
|
#include <effect_builtins.h>
|
2014-05-22 13:36:17 +00:00
|
|
|
#include <kwin_effects_interface.h>
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// Qt
|
2018-06-05 10:52:57 +00:00
|
|
|
#include <QtDBus>
|
2013-12-05 19:22:31 +00:00
|
|
|
#include <QDialogButtonBox>
|
2018-10-31 04:33:45 +00:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QSpacerItem>
|
2020-02-21 16:52:31 +00:00
|
|
|
#include <QTabWidget>
|
2013-08-03 20:34:58 +00:00
|
|
|
#include <QStandardPaths>
|
2013-09-30 13:13:14 +00:00
|
|
|
#include <QPointer>
|
2020-02-21 16:52:31 +00:00
|
|
|
#include <QStandardItemModel>
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// KDE
|
|
|
|
#include <KCModuleProxy>
|
2014-03-18 10:51:35 +00:00
|
|
|
#include <KLocalizedString>
|
2009-09-13 11:36:45 +00:00
|
|
|
#include <KPluginFactory>
|
2014-04-04 09:03:45 +00:00
|
|
|
#include <KPluginTrader>
|
2009-09-13 11:36:45 +00:00
|
|
|
#include <KTitleWidget>
|
|
|
|
#include <KServiceTypeTrader>
|
2014-01-15 19:32:40 +00:00
|
|
|
#include <KNewStuff3/KNS3/DownloadDialog>
|
2014-10-31 11:53:42 +00:00
|
|
|
// Plasma
|
2016-12-26 16:41:06 +00:00
|
|
|
#include <KPackage/Package>
|
|
|
|
#include <KPackage/PackageLoader>
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// own
|
2020-02-21 16:52:31 +00:00
|
|
|
#include "kwintabboxconfigform.h"
|
2012-04-09 16:59:26 +00:00
|
|
|
#include "layoutpreview.h"
|
2020-02-07 11:03:34 +00:00
|
|
|
#include "kwintabboxsettings.h"
|
|
|
|
#include "kwinswitcheffectsettings.h"
|
|
|
|
#include "kwinpluginssettings.h"
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
K_PLUGIN_FACTORY(KWinTabBoxConfigFactory, registerPlugin<KWin::KWinTabBoxConfig>();)
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
using namespace TabBox;
|
|
|
|
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args)
|
2013-09-30 13:11:07 +00:00
|
|
|
: KCModule(parent, args)
|
2011-01-30 14:34:42 +00:00
|
|
|
, m_config(KSharedConfig::openConfig("kwinrc"))
|
2020-02-07 11:03:34 +00:00
|
|
|
, m_tabBoxConfig(new TabBoxSettings(QStringLiteral("TabBox"), this))
|
|
|
|
, m_tabBoxAlternativeConfig(new TabBoxSettings(QStringLiteral("TabBoxAlternative"), this))
|
|
|
|
, m_coverSwitchConfig(new SwitchEffectSettings(QStringLiteral("Effect-CoverSwitch"), this))
|
|
|
|
, m_flipSwitchConfig(new SwitchEffectSettings(QStringLiteral("Effect-FlipSwitch"), this))
|
|
|
|
, m_pluginsConfig(new PluginsSettings(this))
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2013-12-05 19:22:31 +00:00
|
|
|
QTabWidget* tabWidget = new QTabWidget(this);
|
2020-02-21 16:52:31 +00:00
|
|
|
m_primaryTabBoxUi = new KWinTabBoxConfigForm(KWinTabBoxConfigForm::TabboxType::Main, tabWidget);
|
|
|
|
m_alternativeTabBoxUi = new KWinTabBoxConfigForm(KWinTabBoxConfigForm::TabboxType::Alternative, tabWidget);
|
2011-01-30 14:34:42 +00:00
|
|
|
tabWidget->addTab(m_primaryTabBoxUi, i18n("Main"));
|
|
|
|
tabWidget->addTab(m_alternativeTabBoxUi, i18n("Alternative"));
|
2018-10-31 04:33:45 +00:00
|
|
|
|
|
|
|
QPushButton* ghnsButton = new QPushButton(QIcon::fromTheme(QStringLiteral("get-hot-new-stuff")), i18n("Get New Task Switchers..."));
|
|
|
|
connect(ghnsButton, SIGNAL(clicked(bool)), SLOT(slotGHNS()));
|
|
|
|
|
|
|
|
QHBoxLayout* buttonBar = new QHBoxLayout();
|
|
|
|
QSpacerItem* buttonBarSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
|
buttonBar->addItem(buttonBarSpacer);
|
|
|
|
buttonBar->addWidget(ghnsButton);
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
KTitleWidget* infoLabel = new KTitleWidget(tabWidget);
|
|
|
|
infoLabel->setText(i18n("Focus policy settings limit the functionality of navigating through windows."),
|
|
|
|
KTitleWidget::InfoMessage);
|
|
|
|
infoLabel->setPixmap(KTitleWidget::InfoMessage, KTitleWidget::ImageLeft);
|
2012-04-09 16:59:26 +00:00
|
|
|
layout->addWidget(infoLabel,0);
|
|
|
|
layout->addWidget(tabWidget,1);
|
2018-10-31 04:33:45 +00:00
|
|
|
layout->addLayout(buttonBar);
|
2012-04-09 16:59:26 +00:00
|
|
|
setLayout(layout);
|
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
addConfig(m_tabBoxConfig, m_primaryTabBoxUi);
|
|
|
|
addConfig(m_tabBoxAlternativeConfig, m_alternativeTabBoxUi);
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-04-01 14:34:01 +00:00
|
|
|
createConnections(m_primaryTabBoxUi);
|
|
|
|
createConnections(m_alternativeTabBoxUi);
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
initLayoutLists();
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// check focus policy - we don't offer configs for unreasonable focus policies
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup config(m_config, "Windows");
|
|
|
|
QString policy = config.readEntry("FocusPolicy", "ClickToFocus");
|
|
|
|
if ((policy == "FocusUnderMouse") || (policy == "FocusStrictlyUnderMouse")) {
|
|
|
|
tabWidget->setEnabled(false);
|
2009-09-13 11:36:45 +00:00
|
|
|
infoLabel->show();
|
2020-02-07 11:03:34 +00:00
|
|
|
} else {
|
2009-09-13 11:36:45 +00:00
|
|
|
infoLabel->hide();
|
2020-02-07 11:03:34 +00:00
|
|
|
}
|
2020-04-01 14:34:01 +00:00
|
|
|
|
|
|
|
setEnabledUi(m_primaryTabBoxUi, m_tabBoxConfig);
|
|
|
|
setEnabledUi(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
KWinTabBoxConfig::~KWinTabBoxConfig()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2016-12-26 16:41:06 +00:00
|
|
|
static QList<KPackage::Package> availableLnFPackages()
|
2014-10-31 11:53:42 +00:00
|
|
|
{
|
2016-12-26 16:41:06 +00:00
|
|
|
QList<KPackage::Package> packages;
|
2014-10-31 11:53:42 +00:00
|
|
|
QStringList paths;
|
|
|
|
const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
|
|
|
|
|
|
|
|
for (const QString &path : dataPaths) {
|
2015-11-05 14:14:06 +00:00
|
|
|
QDir dir(path + QLatin1String("/plasma/look-and-feel"));
|
2014-10-31 11:53:42 +00:00
|
|
|
paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &p = paths;
|
|
|
|
for (const QString &path : p) {
|
2016-12-26 16:41:06 +00:00
|
|
|
KPackage::Package pkg = KPackage::PackageLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel"));
|
2014-10-31 11:53:42 +00:00
|
|
|
pkg.setPath(path);
|
2016-12-26 16:41:06 +00:00
|
|
|
pkg.setFallbackPackage(KPackage::Package());
|
2014-10-31 11:53:42 +00:00
|
|
|
if (!pkg.filePath("defaults").isEmpty()) {
|
|
|
|
KSharedConfigPtr conf = KSharedConfig::openConfig(pkg.filePath("defaults"));
|
|
|
|
KConfigGroup cg = KConfigGroup(conf, "kwinrc");
|
|
|
|
cg = KConfigGroup(&cg, "WindowSwitcher");
|
|
|
|
if (!cg.readEntry("LayoutName", QString()).isEmpty()) {
|
|
|
|
packages << pkg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return packages;
|
|
|
|
}
|
|
|
|
|
2012-05-09 16:43:32 +00:00
|
|
|
void KWinTabBoxConfig::initLayoutLists()
|
|
|
|
{
|
|
|
|
// search the effect names
|
2020-02-21 16:52:31 +00:00
|
|
|
m_coverSwitch = BuiltInEffects::effectData(BuiltInEffect::CoverSwitch).name;
|
|
|
|
m_flipSwitch = BuiltInEffects::effectData(BuiltInEffect::FlipSwitch).name;
|
2012-05-09 16:43:32 +00:00
|
|
|
|
use proper packagestructures
Summary:
as the plasmapkg2 utility is dead, scripts and tabboxes couldn't
be installed anymore, as plasmapkg2 was launched with an hardcoded
package type (and had a bunch of custom code for it)
and no packagestructure for the relevant package types existed.
the port of scripts and tabboxes to kpackage in kwin is quite
incomplete and somewhat strange (given the fact that was started by
looking manually for the file as it couldn't link to libplasma)
this makes things a bit better as now scripts and tabboxes have an actual
package structure, making it installable by kpackagetool5.
in the future, the port should be completed and replace all the manual lookup
of files with package::filePath as it should work now given that valid
structures exist
BUG:374766
Test Plan:
tabbox plugins and kwin scripts can be installed from knewstuff
again and can be successfully loaded
Reviewers: #plasma, graesslin, subdiff
Reviewed By: #plasma, graesslin
Subscribers: graesslin, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D4202
2017-01-19 17:13:01 +00:00
|
|
|
QList<KPluginMetaData> offers = KPackage::PackageLoader::self()->listPackages("KWin/WindowSwitcher");
|
2012-05-09 16:43:32 +00:00
|
|
|
QStringList layoutNames, layoutPlugins, layoutPaths;
|
2014-10-31 11:53:42 +00:00
|
|
|
|
|
|
|
const auto lnfPackages = availableLnFPackages();
|
|
|
|
for (const auto &package : lnfPackages) {
|
|
|
|
const auto &metaData = package.metadata();
|
|
|
|
layoutNames << metaData.name();
|
2016-12-26 16:41:06 +00:00
|
|
|
layoutPlugins << metaData.pluginId();
|
2014-10-31 11:53:42 +00:00
|
|
|
layoutPaths << package.filePath("windowswitcher", QStringLiteral("WindowSwitcher.qml"));
|
|
|
|
}
|
|
|
|
|
use proper packagestructures
Summary:
as the plasmapkg2 utility is dead, scripts and tabboxes couldn't
be installed anymore, as plasmapkg2 was launched with an hardcoded
package type (and had a bunch of custom code for it)
and no packagestructure for the relevant package types existed.
the port of scripts and tabboxes to kpackage in kwin is quite
incomplete and somewhat strange (given the fact that was started by
looking manually for the file as it couldn't link to libplasma)
this makes things a bit better as now scripts and tabboxes have an actual
package structure, making it installable by kpackagetool5.
in the future, the port should be completed and replace all the manual lookup
of files with package::filePath as it should work now given that valid
structures exist
BUG:374766
Test Plan:
tabbox plugins and kwin scripts can be installed from knewstuff
again and can be successfully loaded
Reviewers: #plasma, graesslin, subdiff
Reviewed By: #plasma, graesslin
Subscribers: graesslin, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D4202
2017-01-19 17:13:01 +00:00
|
|
|
for (const auto &offer : offers) {
|
|
|
|
const QString pluginName = offer.pluginId();
|
|
|
|
if (offer.value("X-Plasma-API") != "declarativeappletscript") {
|
2012-05-09 16:43:32 +00:00
|
|
|
continue;
|
|
|
|
}
|
use proper packagestructures
Summary:
as the plasmapkg2 utility is dead, scripts and tabboxes couldn't
be installed anymore, as plasmapkg2 was launched with an hardcoded
package type (and had a bunch of custom code for it)
and no packagestructure for the relevant package types existed.
the port of scripts and tabboxes to kpackage in kwin is quite
incomplete and somewhat strange (given the fact that was started by
looking manually for the file as it couldn't link to libplasma)
this makes things a bit better as now scripts and tabboxes have an actual
package structure, making it installable by kpackagetool5.
in the future, the port should be completed and replace all the manual lookup
of files with package::filePath as it should work now given that valid
structures exist
BUG:374766
Test Plan:
tabbox plugins and kwin scripts can be installed from knewstuff
again and can be successfully loaded
Reviewers: #plasma, graesslin, subdiff
Reviewed By: #plasma, graesslin
Subscribers: graesslin, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D4202
2017-01-19 17:13:01 +00:00
|
|
|
//we don't have a proper servicetype
|
|
|
|
if (offer.value("X-KWin-Exclude-Listing") == QStringLiteral("true")) {
|
2012-05-09 16:43:32 +00:00
|
|
|
continue;
|
|
|
|
}
|
use proper packagestructures
Summary:
as the plasmapkg2 utility is dead, scripts and tabboxes couldn't
be installed anymore, as plasmapkg2 was launched with an hardcoded
package type (and had a bunch of custom code for it)
and no packagestructure for the relevant package types existed.
the port of scripts and tabboxes to kpackage in kwin is quite
incomplete and somewhat strange (given the fact that was started by
looking manually for the file as it couldn't link to libplasma)
this makes things a bit better as now scripts and tabboxes have an actual
package structure, making it installable by kpackagetool5.
in the future, the port should be completed and replace all the manual lookup
of files with package::filePath as it should work now given that valid
structures exist
BUG:374766
Test Plan:
tabbox plugins and kwin scripts can be installed from knewstuff
again and can be successfully loaded
Reviewers: #plasma, graesslin, subdiff
Reviewed By: #plasma, graesslin
Subscribers: graesslin, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D4202
2017-01-19 17:13:01 +00:00
|
|
|
const QString scriptName = offer.value("X-Plasma-MainScript");
|
2013-08-03 20:34:58 +00:00
|
|
|
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
2015-11-05 14:14:06 +00:00
|
|
|
QLatin1String("kwin/tabbox/") + pluginName + QLatin1String("/contents/")
|
2013-08-03 20:34:58 +00:00
|
|
|
+ scriptName);
|
2012-05-09 16:43:32 +00:00
|
|
|
if (scriptFile.isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
use proper packagestructures
Summary:
as the plasmapkg2 utility is dead, scripts and tabboxes couldn't
be installed anymore, as plasmapkg2 was launched with an hardcoded
package type (and had a bunch of custom code for it)
and no packagestructure for the relevant package types existed.
the port of scripts and tabboxes to kpackage in kwin is quite
incomplete and somewhat strange (given the fact that was started by
looking manually for the file as it couldn't link to libplasma)
this makes things a bit better as now scripts and tabboxes have an actual
package structure, making it installable by kpackagetool5.
in the future, the port should be completed and replace all the manual lookup
of files with package::filePath as it should work now given that valid
structures exist
BUG:374766
Test Plan:
tabbox plugins and kwin scripts can be installed from knewstuff
again and can be successfully loaded
Reviewers: #plasma, graesslin, subdiff
Reviewed By: #plasma, graesslin
Subscribers: graesslin, plasma-devel, kwin, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D4202
2017-01-19 17:13:01 +00:00
|
|
|
layoutNames << offer.name();
|
2012-05-09 16:43:32 +00:00
|
|
|
layoutPlugins << pluginName;
|
|
|
|
layoutPaths << scriptFile;
|
|
|
|
}
|
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
|
2012-05-09 16:43:32 +00:00
|
|
|
KWinTabBoxConfigForm *ui[2] = { m_primaryTabBoxUi, m_alternativeTabBoxUi };
|
|
|
|
for (int i=0; i<2; ++i) {
|
2020-02-21 16:52:31 +00:00
|
|
|
QStandardItemModel *model = new QStandardItemModel;
|
|
|
|
|
|
|
|
QStandardItem *coverItem = new QStandardItem(BuiltInEffects::effectData(BuiltInEffect::CoverSwitch).displayName);
|
|
|
|
coverItem->setData(m_coverSwitch, Qt::UserRole);
|
|
|
|
coverItem->setData(false, KWinTabBoxConfigForm::AddonEffect);
|
|
|
|
model->appendRow(coverItem);
|
|
|
|
|
|
|
|
QStandardItem *flipItem = new QStandardItem(BuiltInEffects::effectData(BuiltInEffect::FlipSwitch).displayName);
|
|
|
|
flipItem->setData(m_flipSwitch, Qt::UserRole);
|
|
|
|
flipItem->setData(false, KWinTabBoxConfigForm::AddonEffect);
|
|
|
|
model->appendRow(flipItem);
|
|
|
|
|
2012-05-09 16:43:32 +00:00
|
|
|
for (int j = 0; j < layoutNames.count(); ++j) {
|
2020-02-21 16:52:31 +00:00
|
|
|
QStandardItem *item = new QStandardItem(layoutNames[j]);
|
|
|
|
item->setData(layoutPlugins[j], Qt::UserRole);
|
|
|
|
item->setData(layoutPaths[j], KWinTabBoxConfigForm::LayoutPath);
|
|
|
|
item->setData(true, KWinTabBoxConfigForm::AddonEffect);
|
|
|
|
model->appendRow(item);
|
2012-05-09 16:43:32 +00:00
|
|
|
}
|
2020-02-21 16:52:31 +00:00
|
|
|
model->sort(0);
|
|
|
|
ui[i]->setEffectComboModel(model);
|
2012-05-09 16:43:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-01 14:34:01 +00:00
|
|
|
void KWinTabBoxConfig::setEnabledUi(KWinTabBoxConfigForm *form, const TabBoxSettings *config)
|
|
|
|
{
|
|
|
|
form->setHighlightWindowsEnabled(!config->isHighlightWindowsImmutable());
|
|
|
|
form->setFilterScreenEnabled(!config->isMultiScreenModeImmutable());
|
|
|
|
form->setFilterDesktopEnabled(!config->isDesktopModeImmutable());
|
|
|
|
form->setFilterActivitiesEnabled(!config->isActivitiesModeImmutable());
|
|
|
|
form->setFilterMinimizationEnabled(!config->isMinimizedModeImmutable());
|
|
|
|
form->setApplicationModeEnabled(!config->isApplicationsModeImmutable());
|
|
|
|
form->setShowDesktopModeEnabled(!config->isShowDesktopModeImmutable());
|
|
|
|
form->setSwitchingModeEnabled(!config->isSwitchingModeImmutable());
|
|
|
|
form->setLayoutNameEnabled(!config->isLayoutNameImmutable());
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinTabBoxConfig::createConnections(KWinTabBoxConfigForm *form)
|
2020-02-21 16:52:31 +00:00
|
|
|
{
|
|
|
|
connect(form, SIGNAL(effectConfigButtonClicked()), this, SLOT(configureEffectClicked()));
|
|
|
|
|
|
|
|
connect(form, SIGNAL(filterScreenChanged(int)), this, SLOT(updateUnmanagedState()));
|
|
|
|
connect(form, SIGNAL(filterDesktopChanged(int)), this, SLOT(updateUnmanagedState()));
|
|
|
|
connect(form, SIGNAL(filterActivitiesChanged(int)), this, SLOT(updateUnmanagedState()));
|
|
|
|
connect(form, SIGNAL(filterMinimizationChanged(int)), this, SLOT(updateUnmanagedState()));
|
|
|
|
connect(form, SIGNAL(applicationModeChanged(int)), this, SLOT(updateUnmanagedState()));
|
|
|
|
connect(form, SIGNAL(showDesktopModeChanged(int)), this, SLOT(updateUnmanagedState()));
|
|
|
|
connect(form, SIGNAL(switchingModeChanged(int)), this, SLOT(updateUnmanagedState()));
|
|
|
|
connect(form, SIGNAL(layoutNameChanged(QString)), this, SLOT(updateUnmanagedState()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinTabBoxConfig::updateUnmanagedState()
|
|
|
|
{
|
|
|
|
bool isNeedSave = false;
|
|
|
|
isNeedSave |= updateUnmanagedIsNeedSave(m_primaryTabBoxUi, m_tabBoxConfig);
|
|
|
|
isNeedSave |= updateUnmanagedIsNeedSave(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig);
|
|
|
|
|
|
|
|
unmanagedWidgetChangeState(isNeedSave);
|
|
|
|
|
|
|
|
bool isDefault = true;
|
|
|
|
isDefault &= updateUnmanagedIsDefault(m_primaryTabBoxUi, m_tabBoxConfig);
|
|
|
|
isDefault &= updateUnmanagedIsDefault(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig);
|
|
|
|
|
|
|
|
unmanagedWidgetDefaultState(isDefault);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KWinTabBoxConfig::updateUnmanagedIsNeedSave(const KWinTabBoxConfigForm *form, const TabBoxSettings *config)
|
|
|
|
{
|
|
|
|
bool isNeedSave = false;
|
|
|
|
isNeedSave |= form->filterScreen() != config->multiScreenMode();
|
|
|
|
isNeedSave |= form->filterDesktop() != config->desktopMode();
|
|
|
|
isNeedSave |= form->filterActivities() != config->activitiesMode();
|
|
|
|
isNeedSave |= form->filterMinimization() != config->minimizedMode();
|
|
|
|
isNeedSave |= form->applicationMode() != config->applicationsMode();
|
|
|
|
isNeedSave |= form->showDesktopMode() != config->showDesktopMode();
|
|
|
|
isNeedSave |= form->switchingMode() != config->switchingMode();
|
|
|
|
isNeedSave |= form->layoutName() != config->layoutName();
|
|
|
|
|
|
|
|
return isNeedSave;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KWinTabBoxConfig::updateUnmanagedIsDefault(const KWinTabBoxConfigForm *form, const TabBoxSettings *config)
|
|
|
|
{
|
|
|
|
bool isDefault = true;
|
|
|
|
isDefault &= form->filterScreen() == config->defaultMultiScreenModeValue();
|
|
|
|
isDefault &= form->filterDesktop() == config->defaultDesktopModeValue();
|
|
|
|
isDefault &= form->filterActivities() == config->defaultActivitiesModeValue();
|
|
|
|
isDefault &= form->filterMinimization() == config->defaultMinimizedModeValue();
|
|
|
|
isDefault &= form->applicationMode() == config->defaultApplicationsModeValue();
|
|
|
|
isDefault &= form->showDesktopMode() == config->defaultShowDesktopModeValue();
|
|
|
|
isDefault &= form->switchingMode() == config->defaultSwitchingModeValue();
|
|
|
|
isDefault &= form->layoutName() == config->defaultLayoutNameValue();
|
|
|
|
|
|
|
|
return isDefault;
|
|
|
|
}
|
|
|
|
|
2009-09-13 11:36:45 +00:00
|
|
|
void KWinTabBoxConfig::load()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-09-13 11:36:45 +00:00
|
|
|
KCModule::load();
|
|
|
|
|
2020-02-07 11:03:34 +00:00
|
|
|
m_tabBoxConfig->load();
|
|
|
|
m_tabBoxAlternativeConfig->load();
|
2012-04-09 16:59:26 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
updateUiFromConfig(m_primaryTabBoxUi, m_tabBoxConfig);
|
|
|
|
updateUiFromConfig(m_alternativeTabBoxUi , m_tabBoxAlternativeConfig);
|
|
|
|
|
2020-02-07 11:03:34 +00:00
|
|
|
m_coverSwitchConfig->load();
|
|
|
|
m_flipSwitchConfig->load();
|
|
|
|
|
|
|
|
m_pluginsConfig->load();
|
2012-04-09 16:59:26 +00:00
|
|
|
|
2020-02-07 11:03:34 +00:00
|
|
|
if (m_pluginsConfig->coverswitchEnabled()) {
|
|
|
|
if (m_coverSwitchConfig->tabBox()) {
|
2020-02-21 16:52:31 +00:00
|
|
|
m_primaryTabBoxUi->setLayoutName(m_coverSwitch);
|
2020-02-07 11:03:34 +00:00
|
|
|
}
|
|
|
|
if (m_coverSwitchConfig->tabBoxAlternative()) {
|
2020-02-21 16:52:31 +00:00
|
|
|
m_alternativeTabBoxUi->setLayoutName(m_coverSwitch);
|
2020-02-07 11:03:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (m_pluginsConfig->flipswitchEnabled()) {
|
|
|
|
if (m_flipSwitchConfig->tabBox()) {
|
2020-02-21 16:52:31 +00:00
|
|
|
m_primaryTabBoxUi->setLayoutName(m_flipSwitch);
|
2020-02-07 11:03:34 +00:00
|
|
|
}
|
|
|
|
if (m_flipSwitchConfig->tabBoxAlternative()) {
|
2020-02-21 16:52:31 +00:00
|
|
|
m_alternativeTabBoxUi->setLayoutName(m_flipSwitch);
|
2020-02-07 11:03:34 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-09 16:59:26 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
m_primaryTabBoxUi->loadShortcuts();
|
|
|
|
m_alternativeTabBoxUi->loadShortcuts();
|
|
|
|
|
|
|
|
updateUnmanagedState();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
2009-09-13 11:36:45 +00:00
|
|
|
void KWinTabBoxConfig::save()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-09-13 11:36:45 +00:00
|
|
|
// effects
|
2020-02-21 16:52:31 +00:00
|
|
|
const bool highlightWindows = m_primaryTabBoxUi->highlightWindows() || m_alternativeTabBoxUi->highlightWindows();
|
|
|
|
const bool coverSwitch = m_primaryTabBoxUi->showTabBox()
|
|
|
|
&& m_primaryTabBoxUi->effectComboCurrentData().toString() == m_coverSwitch;
|
|
|
|
const bool flipSwitch = m_primaryTabBoxUi->showTabBox()
|
|
|
|
&& m_primaryTabBoxUi->effectComboCurrentData().toString() == m_flipSwitch;
|
|
|
|
const bool coverSwitchAlternative = m_alternativeTabBoxUi->showTabBox()
|
|
|
|
&& m_alternativeTabBoxUi->effectComboCurrentData().toString() == m_coverSwitch;
|
|
|
|
const bool flipSwitchAlternative = m_alternativeTabBoxUi->showTabBox()
|
|
|
|
&& m_alternativeTabBoxUi->effectComboCurrentData().toString() == m_flipSwitch;
|
2011-12-07 13:44:30 +00:00
|
|
|
|
2009-09-13 11:36:45 +00:00
|
|
|
// activate effects if not active
|
2020-02-07 11:03:34 +00:00
|
|
|
if (coverSwitch || coverSwitchAlternative) {
|
|
|
|
m_pluginsConfig->setCoverswitchEnabled(true);
|
|
|
|
}
|
|
|
|
if (flipSwitch || flipSwitchAlternative) {
|
|
|
|
m_pluginsConfig->setFlipswitchEnabled(true);
|
|
|
|
}
|
|
|
|
if (highlightWindows) {
|
|
|
|
m_pluginsConfig->setHighlightwindowEnabled(true);
|
|
|
|
}
|
|
|
|
m_pluginsConfig->save();
|
|
|
|
|
|
|
|
m_coverSwitchConfig->setTabBox(coverSwitch);
|
|
|
|
m_coverSwitchConfig->setTabBoxAlternative(coverSwitchAlternative);
|
|
|
|
m_coverSwitchConfig->save();
|
|
|
|
|
|
|
|
m_flipSwitchConfig->setTabBox(flipSwitch);
|
|
|
|
m_flipSwitchConfig->setTabBoxAlternative(flipSwitchAlternative);
|
|
|
|
m_flipSwitchConfig->save();
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
updateConfigFromUi(m_primaryTabBoxUi, m_tabBoxConfig);
|
|
|
|
updateConfigFromUi(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig);
|
|
|
|
|
|
|
|
m_tabBoxConfig->save();
|
|
|
|
m_tabBoxAlternativeConfig->save();
|
|
|
|
|
|
|
|
KCModule::save();
|
|
|
|
updateUnmanagedState();
|
|
|
|
|
2009-09-13 11:36:45 +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-22 13:36:17 +00:00
|
|
|
// and reconfigure the effects
|
|
|
|
OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"),
|
|
|
|
QStringLiteral("/Effects"),
|
|
|
|
QDBusConnection::sessionBus());
|
|
|
|
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::CoverSwitch));
|
|
|
|
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::FlipSwitch));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
void KWinTabBoxConfig::defaults()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-02-07 11:03:34 +00:00
|
|
|
m_coverSwitchConfig->setDefaults();
|
|
|
|
m_flipSwitchConfig->setDefaults();
|
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
updateUiFromDefaultConfig(m_primaryTabBoxUi, m_tabBoxConfig);
|
|
|
|
updateUiFromDefaultConfig(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig);
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
m_primaryTabBoxUi->resetShortcuts();
|
|
|
|
m_alternativeTabBoxUi->resetShortcuts();
|
|
|
|
|
|
|
|
KCModule::defaults();
|
|
|
|
updateUnmanagedState();
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
void KWinTabBoxConfig::updateUiFromConfig(KWinTabBoxConfigForm *form, const KWin::TabBox::TabBoxSettings *config)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-02-21 16:52:31 +00:00
|
|
|
form->setFilterScreen(static_cast<TabBoxConfig::ClientMultiScreenMode>(config->multiScreenMode()));
|
|
|
|
form->setFilterDesktop(static_cast<TabBoxConfig::ClientDesktopMode>(config->desktopMode()));
|
|
|
|
form->setFilterActivities(static_cast<TabBoxConfig::ClientActivitiesMode>(config->activitiesMode()));
|
|
|
|
form->setFilterMinimization(static_cast<TabBoxConfig::ClientMinimizedMode>(config->minimizedMode()));
|
|
|
|
form->setApplicationMode(static_cast<TabBoxConfig::ClientApplicationsMode>(config->applicationsMode()));
|
|
|
|
form->setShowDesktopMode(static_cast<TabBoxConfig::ShowDesktopMode>(config->showDesktopMode()));
|
|
|
|
form->setSwitchingModeChanged(static_cast<TabBoxConfig::ClientSwitchingMode>(config->switchingMode()));
|
|
|
|
form->setLayoutName(config->layoutName());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
void KWinTabBoxConfig::updateConfigFromUi(const KWinTabBoxConfigForm *form, TabBoxSettings *config)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-02-21 16:52:31 +00:00
|
|
|
config->setMultiScreenMode(form->filterScreen());
|
|
|
|
config->setDesktopMode(form->filterDesktop());
|
|
|
|
config->setActivitiesMode(form->filterActivities());
|
|
|
|
config->setMinimizedMode(form->filterMinimization());
|
|
|
|
config->setApplicationsMode(form->applicationMode());
|
|
|
|
config->setShowDesktopMode(form->showDesktopMode());
|
|
|
|
config->setSwitchingMode(form->switchingMode());
|
|
|
|
config->setLayoutName(form->layoutName());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
void KWinTabBoxConfig::updateUiFromDefaultConfig(KWinTabBoxConfigForm *form, const KWin::TabBox::TabBoxSettings *config)
|
2020-02-07 11:03:34 +00:00
|
|
|
{
|
2020-02-21 16:52:31 +00:00
|
|
|
form->setFilterScreen(static_cast<TabBoxConfig::ClientMultiScreenMode>(config->defaultMultiScreenModeValue()));
|
|
|
|
form->setFilterDesktop(static_cast<TabBoxConfig::ClientDesktopMode>(config->defaultDesktopModeValue()));
|
|
|
|
form->setFilterActivities(static_cast<TabBoxConfig::ClientActivitiesMode>(config->defaultActivitiesModeValue()));
|
|
|
|
form->setFilterMinimization(static_cast<TabBoxConfig::ClientMinimizedMode>(config->defaultMinimizedModeValue()));
|
|
|
|
form->setApplicationMode(static_cast<TabBoxConfig::ClientApplicationsMode>(config->defaultApplicationsModeValue()));
|
|
|
|
form->setShowDesktopMode(static_cast<TabBoxConfig::ShowDesktopMode>(config->defaultShowDesktopModeValue()));
|
|
|
|
form->setSwitchingModeChanged(static_cast<TabBoxConfig::ClientSwitchingMode>(config->defaultSwitchingModeValue()));
|
|
|
|
form->setLayoutName(config->defaultLayoutNameValue());
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
void KWinTabBoxConfig::configureEffectClicked()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2020-02-21 16:52:31 +00:00
|
|
|
auto form = qobject_cast<KWinTabBoxConfigForm *>(sender());
|
|
|
|
Q_ASSERT(form);
|
2012-04-09 16:59:26 +00:00
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
if (form->effectComboCurrentData(KWinTabBoxConfigForm::AddonEffect).toBool()) {
|
|
|
|
// Show the preview for addon effect
|
|
|
|
new LayoutPreview(form->effectComboCurrentData(KWinTabBoxConfigForm::LayoutPath).toString(), this);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2020-02-21 16:52:31 +00:00
|
|
|
// For builtin effect, display a configuration dialog
|
2013-12-05 19:22:31 +00:00
|
|
|
QPointer<QDialog> configDialog = new QDialog(this);
|
|
|
|
configDialog->setLayout(new QVBoxLayout);
|
2020-02-21 16:52:31 +00:00
|
|
|
configDialog->setWindowTitle(form->effectComboCurrentData(Qt::DisplayRole).toString());
|
2013-12-05 19:22:31 +00:00
|
|
|
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel|QDialogButtonBox::RestoreDefaults, configDialog);
|
|
|
|
connect(buttonBox, SIGNAL(accepted()), configDialog, SLOT(accept()));
|
|
|
|
connect(buttonBox, SIGNAL(rejected()), configDialog, SLOT(reject()));
|
|
|
|
|
2020-02-21 16:52:31 +00:00
|
|
|
const QString name = form->effectComboCurrentData().toString();
|
2014-04-28 12:06:18 +00:00
|
|
|
KCModule *kcm = KPluginTrader::createInstanceFromQuery<KCModule>(QStringLiteral("kwin/effects/configs/"), QString(),
|
2015-03-04 23:44:47 +00:00
|
|
|
QStringLiteral("'%1' in [X-KDE-ParentComponents]").arg(name),
|
2020-02-21 16:52:31 +00:00
|
|
|
configDialog);
|
2014-04-04 09:03:45 +00:00
|
|
|
if (!kcm) {
|
|
|
|
delete configDialog;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
connect(buttonBox->button(QDialogButtonBox::RestoreDefaults), &QPushButton::clicked, kcm, &KCModule::defaults);
|
2012-04-09 16:59:26 +00:00
|
|
|
|
|
|
|
QWidget *showWidget = new QWidget(configDialog);
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
showWidget->setLayout(layout);
|
2014-04-04 09:03:45 +00:00
|
|
|
layout->addWidget(kcm);
|
2013-12-05 19:22:31 +00:00
|
|
|
configDialog->layout()->addWidget(showWidget);
|
|
|
|
configDialog->layout()->addWidget(buttonBox);
|
2012-04-09 16:59:26 +00:00
|
|
|
|
|
|
|
if (configDialog->exec() == QDialog::Accepted) {
|
2014-04-04 09:03:45 +00:00
|
|
|
kcm->save();
|
2012-04-09 16:59:26 +00:00
|
|
|
} else {
|
2014-04-04 09:03:45 +00:00
|
|
|
kcm->load();
|
2012-04-09 16:59:26 +00:00
|
|
|
}
|
|
|
|
delete configDialog;
|
2009-09-13 11:36:45 +00:00
|
|
|
}
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2012-05-09 16:43:32 +00:00
|
|
|
void KWinTabBoxConfig::slotGHNS()
|
|
|
|
{
|
|
|
|
QPointer<KNS3::DownloadDialog> downloadDialog = new KNS3::DownloadDialog("kwinswitcher.knsrc", this);
|
2013-09-30 13:07:49 +00:00
|
|
|
if (downloadDialog->exec() == QDialog::Accepted) {
|
2012-05-09 16:43:32 +00:00
|
|
|
if (!downloadDialog->changedEntries().isEmpty()) {
|
|
|
|
initLayoutLists();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
delete downloadDialog;
|
|
|
|
}
|
|
|
|
|
2009-09-13 11:36:45 +00:00
|
|
|
} // namespace
|
2013-09-30 13:13:14 +00:00
|
|
|
|
|
|
|
#include "main.moc"
|