2009-09-13 11:36:45 +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) 2009 Martin Gräßlin <mgraesslin@kde.org>
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
// Qt
|
|
|
|
#include <QtDBus/QtDBus>
|
2012-04-09 16:59:26 +00:00
|
|
|
#include <QDesktopWidget>
|
2009-09-13 11:36:45 +00:00
|
|
|
#include <QVBoxLayout>
|
2013-12-05 19:22:31 +00:00
|
|
|
#include <QDialogButtonBox>
|
2013-08-03 20:34:58 +00:00
|
|
|
#include <QStandardPaths>
|
2013-09-30 13:13:14 +00:00
|
|
|
#include <QPointer>
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// KDE
|
|
|
|
#include <KActionCollection>
|
|
|
|
#include <KCModuleProxy>
|
2013-09-30 13:07:49 +00:00
|
|
|
#include <KGlobalAccel>
|
2012-04-09 16:59:26 +00:00
|
|
|
//#include <KLocalizedString>
|
2009-09-13 11:36:45 +00:00
|
|
|
#include <KPluginFactory>
|
|
|
|
#include <KPluginInfo>
|
|
|
|
#include <KPluginLoader>
|
|
|
|
#include <KTabWidget>
|
|
|
|
#include <KTitleWidget>
|
|
|
|
#include <KServiceTypeTrader>
|
|
|
|
#include <KShortcutsEditor>
|
2012-05-09 16:43:32 +00:00
|
|
|
#include <KNS3/DownloadDialog>
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// own
|
|
|
|
#include "tabboxconfig.h"
|
2012-04-09 16:59:26 +00:00
|
|
|
#include "layoutpreview.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;
|
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
KWinTabBoxConfigForm::KWinTabBoxConfigForm(QWidget* parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
}
|
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"))
|
|
|
|
{
|
2013-12-05 19:22:31 +00:00
|
|
|
QTabWidget* tabWidget = new QTabWidget(this);
|
2011-01-30 14:34:42 +00:00
|
|
|
m_primaryTabBoxUi = new KWinTabBoxConfigForm(tabWidget);
|
|
|
|
m_alternativeTabBoxUi = new KWinTabBoxConfigForm(tabWidget);
|
|
|
|
tabWidget->addTab(m_primaryTabBoxUi, i18n("Main"));
|
|
|
|
tabWidget->addTab(m_alternativeTabBoxUi, i18n("Alternative"));
|
|
|
|
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);
|
|
|
|
setLayout(layout);
|
|
|
|
|
|
|
|
#define ADD_SHORTCUT(_NAME_, _CUT_, _BTN_) \
|
2013-09-30 13:07:49 +00:00
|
|
|
a = m_actionCollection->addAction(_NAME_);\
|
2012-04-09 16:59:26 +00:00
|
|
|
a->setProperty("isConfigurationAction", true);\
|
|
|
|
_BTN_->setProperty("shortcutAction", _NAME_);\
|
|
|
|
a->setText(i18n(_NAME_));\
|
2013-09-30 13:07:49 +00:00
|
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << _CUT_); \
|
2012-04-09 16:59:26 +00:00
|
|
|
connect(_BTN_, SIGNAL(keySequenceChanged(QKeySequence)), SLOT(shortcutChanged(QKeySequence)))
|
2011-01-30 14:34:42 +00:00
|
|
|
|
2009-09-13 11:36:45 +00:00
|
|
|
// Shortcut config. The shortcut belongs to the component "kwin"!
|
2013-09-30 13:07:49 +00:00
|
|
|
m_actionCollection = new KActionCollection(this, QStringLiteral("kwin"));
|
2011-01-30 14:34:42 +00:00
|
|
|
m_actionCollection->setConfigGroup("Navigation");
|
|
|
|
m_actionCollection->setConfigGlobal(true);
|
2013-09-30 13:07:49 +00:00
|
|
|
QAction* a;
|
2012-04-09 16:59:26 +00:00
|
|
|
ADD_SHORTCUT("Walk Through Windows", Qt::ALT + Qt::Key_Tab, m_primaryTabBoxUi->scAll);
|
|
|
|
ADD_SHORTCUT("Walk Through Windows (Reverse)", Qt::ALT + Qt::SHIFT + Qt::Key_Backtab,
|
|
|
|
m_primaryTabBoxUi->scAllReverse);
|
2013-09-30 13:07:49 +00:00
|
|
|
ADD_SHORTCUT("Walk Through Windows Alternative", QKeySequence(), m_alternativeTabBoxUi->scAll);
|
|
|
|
ADD_SHORTCUT("Walk Through Windows Alternative (Reverse)", QKeySequence(), m_alternativeTabBoxUi->scAllReverse);
|
2012-04-09 16:59:26 +00:00
|
|
|
ADD_SHORTCUT("Walk Through Windows of Current Application", Qt::ALT + Qt::Key_QuoteLeft,
|
|
|
|
m_primaryTabBoxUi->scCurrent);
|
|
|
|
ADD_SHORTCUT("Walk Through Windows of Current Application (Reverse)", Qt::ALT + Qt::Key_AsciiTilde,
|
|
|
|
m_primaryTabBoxUi->scCurrentReverse);
|
2013-09-30 13:07:49 +00:00
|
|
|
ADD_SHORTCUT("Walk Through Windows of Current Application Alternative", QKeySequence(), m_alternativeTabBoxUi->scCurrent);
|
|
|
|
ADD_SHORTCUT("Walk Through Windows of Current Application Alternative (Reverse)", QKeySequence(),
|
2012-04-09 16:59:26 +00:00
|
|
|
m_alternativeTabBoxUi->scCurrentReverse);
|
|
|
|
#undef ADD_SHORTCUT
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2012-05-09 16:43:32 +00:00
|
|
|
initLayoutLists();
|
2012-04-09 16:59:26 +00:00
|
|
|
KWinTabBoxConfigForm *ui[2] = { m_primaryTabBoxUi, m_alternativeTabBoxUi };
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
2013-09-30 13:09:07 +00:00
|
|
|
ui[i]->effectConfigButton->setIcon(QIcon::fromTheme("view-preview"));
|
|
|
|
ui[i]->ghns->setIcon(QIcon::fromTheme("get-hot-new-stuff"));
|
2012-05-09 16:43:32 +00:00
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
connect(ui[i]->highlightWindowCheck, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->showTabBox, SIGNAL(clicked(bool)), SLOT(tabBoxToggled(bool)));
|
|
|
|
connect(ui[i]->effectCombo, SIGNAL(currentIndexChanged(int)), SLOT(changed()));
|
|
|
|
connect(ui[i]->effectCombo, SIGNAL(currentIndexChanged(int)), SLOT(effectSelectionChanged(int)));
|
|
|
|
connect(ui[i]->effectConfigButton, SIGNAL(clicked(bool)), SLOT(configureEffectClicked()));
|
|
|
|
|
|
|
|
connect(ui[i]->switchingModeCombo, SIGNAL(currentIndexChanged(int)), SLOT(changed()));
|
|
|
|
connect(ui[i]->showDesktop, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
|
|
|
|
connect(ui[i]->filterDesktops, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->currentDesktop, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->otherDesktops, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
|
|
|
|
connect(ui[i]->filterActivities, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->currentActivity, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->otherActivities, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
|
|
|
|
connect(ui[i]->filterScreens, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
if (QApplication::desktop()->screenCount() < 2) {
|
|
|
|
ui[i]->filterScreens->hide();
|
|
|
|
ui[i]->screenFilter->hide();
|
|
|
|
} else {
|
|
|
|
connect(ui[i]->currentScreen, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->otherScreens, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
connect(ui[i]->oneAppWindow, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->filterMinimization, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->visibleWindows, SIGNAL(clicked(bool)), SLOT(changed()));
|
|
|
|
connect(ui[i]->hiddenWindows, SIGNAL(clicked(bool)), SLOT(changed()));
|
2012-05-09 16:43:32 +00:00
|
|
|
connect(ui[i]->ghns, SIGNAL(clicked(bool)), SLOT(slotGHNS()));
|
2012-04-09 16:59:26 +00:00
|
|
|
}
|
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();
|
2011-01-30 14:34:42 +00:00
|
|
|
} else
|
2009-09-13 11:36:45 +00:00
|
|
|
infoLabel->hide();
|
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
|
|
|
|
2012-05-09 16:43:32 +00:00
|
|
|
void KWinTabBoxConfig::initLayoutLists()
|
|
|
|
{
|
|
|
|
// search the effect names
|
|
|
|
// TODO: way to recognize if a effect is not found
|
|
|
|
KServiceTypeTrader* trader = KServiceTypeTrader::self();
|
|
|
|
KService::List services;
|
|
|
|
QString coverswitch;
|
|
|
|
QString flipswitch;
|
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_coverswitch'");
|
|
|
|
if (!services.isEmpty())
|
|
|
|
coverswitch = services.first()->name();
|
|
|
|
services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_flipswitch'");
|
|
|
|
if (!services.isEmpty())
|
|
|
|
flipswitch = services.first()->name();
|
|
|
|
|
|
|
|
KService::List offers = trader->query("KWin/WindowSwitcher");
|
|
|
|
QStringList layoutNames, layoutPlugins, layoutPaths;
|
|
|
|
foreach (KService::Ptr service, offers) {
|
|
|
|
const QString pluginName = service->property("X-KDE-PluginInfo-Name").toString();
|
|
|
|
if (service->property("X-Plasma-API").toString() != "declarativeappletscript") {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (service->property("X-KWin-Exclude-Listing").toBool()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
const QString scriptName = service->property("X-Plasma-MainScript").toString();
|
2013-08-03 20:34:58 +00:00
|
|
|
const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
|
|
|
|
"kwin/tabbox/" + pluginName + "/contents/"
|
|
|
|
+ scriptName);
|
2012-05-09 16:43:32 +00:00
|
|
|
if (scriptFile.isNull()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
layoutNames << service->name();
|
|
|
|
layoutPlugins << pluginName;
|
|
|
|
layoutPaths << scriptFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
KWinTabBoxConfigForm *ui[2] = { m_primaryTabBoxUi, m_alternativeTabBoxUi };
|
|
|
|
for (int i=0; i<2; ++i) {
|
|
|
|
int index = ui[i]->effectCombo->currentIndex();
|
|
|
|
QVariant data = ui[i]->effectCombo->itemData(index);
|
|
|
|
ui[i]->effectCombo->clear();
|
|
|
|
ui[i]->effectCombo->addItem(coverswitch);
|
|
|
|
ui[i]->effectCombo->addItem(flipswitch);
|
|
|
|
for (int j = 0; j < layoutNames.count(); ++j) {
|
|
|
|
ui[i]->effectCombo->addItem(layoutNames[j], layoutPlugins[j]);
|
|
|
|
ui[i]->effectCombo->setItemData(ui[i]->effectCombo->count() - 1, layoutPaths[j], Qt::UserRole+1);
|
|
|
|
}
|
|
|
|
if (data.isValid()) {
|
|
|
|
ui[i]->effectCombo->setCurrentIndex(ui[i]->effectCombo->findData(data));
|
|
|
|
} else if (index != -1) {
|
|
|
|
ui[i]->effectCombo->setCurrentIndex(index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
const QString group[2] = { "TabBox", "TabBoxAlternative" };
|
|
|
|
KWinTabBoxConfigForm* ui[2] = { m_primaryTabBoxUi, m_alternativeTabBoxUi };
|
|
|
|
TabBoxConfig *tabBoxConfig[2] = { &m_tabBoxConfig, &m_tabBoxAlternativeConfig };
|
|
|
|
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
KConfigGroup config(m_config, group[i]);
|
|
|
|
loadConfig(config, *(tabBoxConfig[i]));
|
|
|
|
|
|
|
|
updateUiFromConfig(ui[i], *(tabBoxConfig[i]));
|
|
|
|
|
|
|
|
KConfigGroup effectconfig(m_config, "Plugins");
|
|
|
|
if (effectEnabled("coverswitch", effectconfig) && KConfigGroup(m_config, "Effect-CoverSwitch").readEntry(group[i], false))
|
|
|
|
ui[i]->effectCombo->setCurrentIndex(CoverSwitch);
|
|
|
|
else if (effectEnabled("flipswitch", effectconfig) && KConfigGroup(m_config, "Effect-FlipSwitch").readEntry(group[i], false))
|
|
|
|
ui[i]->effectCombo->setCurrentIndex(FlipSwitch);
|
|
|
|
|
|
|
|
QString action;
|
|
|
|
#define LOAD_SHORTCUT(_BTN_)\
|
|
|
|
action = ui[i]->_BTN_->property("shortcutAction").toString();\
|
|
|
|
qDebug() << "load shortcut for " << action;\
|
2013-09-30 13:07:49 +00:00
|
|
|
if (QAction *a = m_actionCollection->action(action)) { \
|
|
|
|
auto shortcuts = KGlobalAccel::self()->shortcut(a); \
|
|
|
|
if (!shortcuts.isEmpty()) \
|
|
|
|
ui[i]->_BTN_->setKeySequence(shortcuts.first()); \
|
|
|
|
}
|
2012-04-09 16:59:26 +00:00
|
|
|
LOAD_SHORTCUT(scAll);
|
|
|
|
LOAD_SHORTCUT(scAllReverse);
|
|
|
|
LOAD_SHORTCUT(scCurrent);
|
|
|
|
LOAD_SHORTCUT(scCurrentReverse);
|
|
|
|
#undef LOAD_SHORTCUT
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
emit changed(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinTabBoxConfig::loadConfig(const KConfigGroup& config, KWin::TabBox::TabBoxConfig& tabBoxConfig)
|
|
|
|
{
|
2012-04-09 16:59:26 +00:00
|
|
|
tabBoxConfig.setClientDesktopMode(TabBoxConfig::ClientDesktopMode(
|
|
|
|
config.readEntry<int>("DesktopMode", TabBoxConfig::defaultDesktopMode())));
|
|
|
|
tabBoxConfig.setClientActivitiesMode(TabBoxConfig::ClientActivitiesMode(
|
|
|
|
config.readEntry<int>("ActivitiesMode", TabBoxConfig::defaultActivitiesMode())));
|
|
|
|
tabBoxConfig.setClientApplicationsMode(TabBoxConfig::ClientApplicationsMode(
|
|
|
|
config.readEntry<int>("ApplicationsMode", TabBoxConfig::defaultApplicationsMode())));
|
|
|
|
tabBoxConfig.setClientMinimizedMode(TabBoxConfig::ClientMinimizedMode(
|
|
|
|
config.readEntry<int>("MinimizedMode", TabBoxConfig::defaultMinimizedMode())));
|
|
|
|
tabBoxConfig.setShowDesktopMode(TabBoxConfig::ShowDesktopMode(
|
|
|
|
config.readEntry<int>("ShowDesktopMode", TabBoxConfig::defaultShowDesktopMode())));
|
|
|
|
tabBoxConfig.setClientMultiScreenMode(TabBoxConfig::ClientMultiScreenMode(
|
|
|
|
config.readEntry<int>("MultiScreenMode", TabBoxConfig::defaultMultiScreenMode())));
|
|
|
|
tabBoxConfig.setClientSwitchingMode(TabBoxConfig::ClientSwitchingMode(
|
|
|
|
config.readEntry<int>("SwitchingMode", TabBoxConfig::defaultSwitchingMode())));
|
|
|
|
|
|
|
|
tabBoxConfig.setShowTabBox(config.readEntry<bool>("ShowTabBox", TabBoxConfig::defaultShowTabBox()));
|
|
|
|
tabBoxConfig.setHighlightWindows(config.readEntry<bool>("HighlightWindows", TabBoxConfig::defaultHighlightWindow()));
|
|
|
|
|
|
|
|
tabBoxConfig.setLayoutName(config.readEntry<QString>("LayoutName", TabBoxConfig::defaultLayoutName()));
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KWinTabBoxConfig::saveConfig(KConfigGroup& config, const KWin::TabBox::TabBoxConfig& tabBoxConfig)
|
|
|
|
{
|
2009-09-13 11:36:45 +00:00
|
|
|
// combo boxes
|
2012-03-04 18:24:13 +00:00
|
|
|
config.writeEntry("DesktopMode", int(tabBoxConfig.clientDesktopMode()));
|
|
|
|
config.writeEntry("ActivitiesMode", int(tabBoxConfig.clientActivitiesMode()));
|
|
|
|
config.writeEntry("ApplicationsMode", int(tabBoxConfig.clientApplicationsMode()));
|
2012-01-26 23:25:32 +00:00
|
|
|
config.writeEntry("MinimizedMode", int(tabBoxConfig.clientMinimizedMode()));
|
2012-03-04 18:24:13 +00:00
|
|
|
config.writeEntry("ShowDesktopMode", int(tabBoxConfig.showDesktopMode()));
|
|
|
|
config.writeEntry("MultiScreenMode", int(tabBoxConfig.clientMultiScreenMode()));
|
|
|
|
config.writeEntry("SwitchingMode", int(tabBoxConfig.clientSwitchingMode()));
|
2011-01-30 14:34:42 +00:00
|
|
|
config.writeEntry("LayoutName", tabBoxConfig.layoutName());
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// check boxes
|
2011-01-30 14:34:42 +00:00
|
|
|
config.writeEntry("ShowTabBox", tabBoxConfig.isShowTabBox());
|
|
|
|
config.writeEntry("HighlightWindows", tabBoxConfig.isHighlightWindows());
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
config.sync();
|
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
|
|
|
KCModule::save();
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup config(m_config, "TabBox");
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// sync ui to config
|
2011-01-30 14:34:42 +00:00
|
|
|
updateConfigFromUi(m_primaryTabBoxUi, m_tabBoxConfig);
|
|
|
|
updateConfigFromUi(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig);
|
|
|
|
saveConfig(config, m_tabBoxConfig);
|
|
|
|
config = KConfigGroup(m_config, "TabBoxAlternative");
|
|
|
|
saveConfig(config, m_tabBoxAlternativeConfig);
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// effects
|
2011-12-07 13:44:30 +00:00
|
|
|
bool highlightWindows = m_primaryTabBoxUi->highlightWindowCheck->isChecked() ||
|
|
|
|
m_alternativeTabBoxUi->highlightWindowCheck->isChecked();
|
2012-04-09 16:59:26 +00:00
|
|
|
const bool coverSwitch = m_primaryTabBoxUi->showTabBox->isChecked() &&
|
|
|
|
m_primaryTabBoxUi->effectCombo->currentIndex() == CoverSwitch;
|
|
|
|
const bool flipSwitch = m_primaryTabBoxUi->showTabBox->isChecked() &&
|
|
|
|
m_primaryTabBoxUi->effectCombo->currentIndex() == FlipSwitch;
|
|
|
|
const bool coverSwitchAlternative = m_alternativeTabBoxUi->showTabBox->isChecked() &&
|
|
|
|
m_alternativeTabBoxUi->effectCombo->currentIndex() == CoverSwitch;
|
|
|
|
const bool flipSwitchAlternative = m_alternativeTabBoxUi->showTabBox->isChecked() &&
|
|
|
|
m_alternativeTabBoxUi->effectCombo->currentIndex() == FlipSwitch;
|
2011-12-07 13:44:30 +00:00
|
|
|
|
2009-09-13 11:36:45 +00:00
|
|
|
// activate effects if not active
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup effectconfig(m_config, "Plugins");
|
|
|
|
if (coverSwitch || coverSwitchAlternative)
|
2009-09-13 11:36:45 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_coverswitchEnabled", true);
|
2011-01-30 14:34:42 +00:00
|
|
|
if (flipSwitch || flipSwitchAlternative)
|
2009-09-13 11:36:45 +00:00
|
|
|
effectconfig.writeEntry("kwin4_effect_flipswitchEnabled", true);
|
2011-12-07 13:44:30 +00:00
|
|
|
if (highlightWindows)
|
|
|
|
effectconfig.writeEntry("kwin4_effect_highlightwindowEnabled", true);
|
2009-09-13 11:36:45 +00:00
|
|
|
effectconfig.sync();
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup coverswitchconfig(m_config, "Effect-CoverSwitch");
|
|
|
|
coverswitchconfig.writeEntry("TabBox", coverSwitch);
|
|
|
|
coverswitchconfig.writeEntry("TabBoxAlternative", coverSwitchAlternative);
|
2009-09-13 11:36:45 +00:00
|
|
|
coverswitchconfig.sync();
|
2011-01-30 14:34:42 +00:00
|
|
|
KConfigGroup flipswitchconfig(m_config, "Effect-FlipSwitch");
|
|
|
|
flipswitchconfig.writeEntry("TabBox", flipSwitch);
|
|
|
|
flipswitchconfig.writeEntry("TabBoxAlternative", flipSwitchAlternative);
|
2009-09-13 11:36:45 +00:00
|
|
|
flipswitchconfig.sync();
|
|
|
|
|
|
|
|
// Reload KWin.
|
2011-01-30 14:34:42 +00:00
|
|
|
QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
emit changed(false);
|
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
void KWinTabBoxConfig::defaults()
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-04-09 16:59:26 +00:00
|
|
|
const KWinTabBoxConfigForm* ui[2] = { m_primaryTabBoxUi, m_alternativeTabBoxUi};
|
|
|
|
for (int i = 0; i < 2; ++i) {
|
|
|
|
// combo boxes
|
|
|
|
#define CONFIGURE(SETTING, MODE, IS, VALUE) \
|
|
|
|
ui[i]->SETTING->setChecked(TabBoxConfig::default##MODE##Mode() IS TabBoxConfig::VALUE)
|
|
|
|
CONFIGURE(filterDesktops, Desktop, !=, AllDesktopsClients);
|
|
|
|
CONFIGURE(currentDesktop, Desktop, ==, OnlyCurrentDesktopClients);
|
|
|
|
CONFIGURE(otherDesktops, Desktop, ==, ExcludeCurrentDesktopClients);
|
|
|
|
CONFIGURE(filterActivities, Activities, !=, AllActivitiesClients);
|
|
|
|
CONFIGURE(currentActivity, Activities, ==, OnlyCurrentActivityClients);
|
|
|
|
CONFIGURE(otherActivities, Activities, ==, ExcludeCurrentActivityClients);
|
|
|
|
CONFIGURE(filterScreens, MultiScreen, !=, IgnoreMultiScreen);
|
|
|
|
CONFIGURE(currentScreen, MultiScreen, ==, OnlyCurrentScreenClients);
|
|
|
|
CONFIGURE(otherScreens, MultiScreen, ==, ExcludeCurrentScreenClients);
|
|
|
|
CONFIGURE(oneAppWindow, Applications, ==, OneWindowPerApplication);
|
|
|
|
CONFIGURE(filterMinimization, Minimized, !=, IgnoreMinimizedStatus);
|
|
|
|
CONFIGURE(visibleWindows, Minimized, ==, ExcludeMinimizedClients);
|
|
|
|
CONFIGURE(hiddenWindows, Minimized, ==, OnlyMinimizedClients);
|
|
|
|
|
|
|
|
ui[i]->switchingModeCombo->setCurrentIndex(TabBoxConfig::defaultSwitchingMode());
|
|
|
|
|
|
|
|
// checkboxes
|
|
|
|
ui[i]->showTabBox->setChecked(TabBoxConfig::defaultShowTabBox());
|
|
|
|
ui[i]->highlightWindowCheck->setChecked(TabBoxConfig::defaultHighlightWindow());
|
|
|
|
CONFIGURE(showDesktop, ShowDesktop, ==, ShowDesktopClient);
|
|
|
|
#undef CONFIGURE
|
|
|
|
// effects
|
|
|
|
ui[i]->effectCombo->setCurrentIndex(ui[i]->effectCombo->findData("thumbnails"));
|
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
QString action;
|
2013-09-30 13:07:49 +00:00
|
|
|
auto RESET_SHORTCUT = [this](KKeySequenceWidget *widget, const QKeySequence &sequence = QKeySequence()) {
|
|
|
|
const QString action = widget->property("shortcutAction").toString();
|
|
|
|
QAction *a = m_actionCollection->action(action);
|
|
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << sequence, KGlobalAccel::NoAutoloading);
|
|
|
|
};
|
2012-04-09 16:59:26 +00:00
|
|
|
RESET_SHORTCUT(m_primaryTabBoxUi->scAll, Qt::ALT + Qt::Key_Tab);
|
|
|
|
RESET_SHORTCUT(m_primaryTabBoxUi->scAllReverse, Qt::ALT + Qt::SHIFT + Qt::Key_Backtab);
|
2013-09-30 13:07:49 +00:00
|
|
|
RESET_SHORTCUT(m_alternativeTabBoxUi->scAll);
|
|
|
|
RESET_SHORTCUT(m_alternativeTabBoxUi->scAllReverse);
|
2012-04-09 16:59:26 +00:00
|
|
|
RESET_SHORTCUT(m_primaryTabBoxUi->scCurrent, Qt::ALT + Qt::Key_QuoteLeft);
|
|
|
|
RESET_SHORTCUT(m_primaryTabBoxUi->scCurrentReverse, Qt::ALT + Qt::Key_AsciiTilde);
|
2013-09-30 13:07:49 +00:00
|
|
|
RESET_SHORTCUT(m_alternativeTabBoxUi->scCurrent);
|
|
|
|
RESET_SHORTCUT(m_alternativeTabBoxUi->scCurrentReverse);
|
2012-04-09 16:59:26 +00:00
|
|
|
m_actionCollection->writeSettings();
|
2011-01-30 14:34:42 +00:00
|
|
|
emit changed(true);
|
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
bool KWinTabBoxConfig::effectEnabled(const QString& effect, const KConfigGroup& cfg) const
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2009-09-13 11:36:45 +00:00
|
|
|
KService::List services = KServiceTypeTrader::self()->query(
|
2011-01-30 14:34:42 +00:00
|
|
|
"KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + '\'');
|
|
|
|
if (services.isEmpty())
|
2009-09-13 11:36:45 +00:00
|
|
|
return false;
|
2011-01-30 14:34:42 +00:00
|
|
|
QVariant v = services.first()->property("X-KDE-PluginInfo-EnabledByDefault");
|
|
|
|
return cfg.readEntry("kwin4_effect_" + effect + "Enabled", v.toBool());
|
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinTabBoxConfig::updateUiFromConfig(KWinTabBoxConfigForm* ui, const KWin::TabBox::TabBoxConfig& config)
|
|
|
|
{
|
2012-04-09 16:59:26 +00:00
|
|
|
#define CONFIGURE(SETTING, MODE, IS, VALUE) ui->SETTING->setChecked(config.MODE##Mode() IS TabBoxConfig::VALUE)
|
|
|
|
CONFIGURE(filterDesktops, clientDesktop, !=, AllDesktopsClients);
|
|
|
|
CONFIGURE(currentDesktop, clientDesktop, ==, OnlyCurrentDesktopClients);
|
|
|
|
CONFIGURE(otherDesktops, clientDesktop, ==, ExcludeCurrentDesktopClients);
|
|
|
|
CONFIGURE(filterActivities, clientActivities, !=, AllActivitiesClients);
|
|
|
|
CONFIGURE(currentActivity, clientActivities, ==, OnlyCurrentActivityClients);
|
|
|
|
CONFIGURE(otherActivities, clientActivities, ==, ExcludeCurrentActivityClients);
|
|
|
|
CONFIGURE(filterScreens, clientMultiScreen, !=, IgnoreMultiScreen);
|
|
|
|
CONFIGURE(currentScreen, clientMultiScreen, ==, OnlyCurrentScreenClients);
|
|
|
|
CONFIGURE(otherScreens, clientMultiScreen, ==, ExcludeCurrentScreenClients);
|
|
|
|
CONFIGURE(oneAppWindow, clientApplications, ==, OneWindowPerApplication);
|
|
|
|
CONFIGURE(filterMinimization, clientMinimized, !=, IgnoreMinimizedStatus);
|
|
|
|
CONFIGURE(visibleWindows, clientMinimized, ==, ExcludeMinimizedClients);
|
|
|
|
CONFIGURE(hiddenWindows, clientMinimized, ==, OnlyMinimizedClients);
|
|
|
|
|
2012-03-04 18:24:13 +00:00
|
|
|
ui->switchingModeCombo->setCurrentIndex(config.clientSwitchingMode());
|
2009-09-13 11:36:45 +00:00
|
|
|
|
|
|
|
// check boxes
|
2011-01-30 14:34:42 +00:00
|
|
|
ui->showTabBox->setChecked(config.isShowTabBox());
|
|
|
|
ui->highlightWindowCheck->setChecked(config.isHighlightWindows());
|
2012-04-09 16:59:26 +00:00
|
|
|
ui->effectCombo->setCurrentIndex(ui->effectCombo->findData(config.layoutName()));
|
|
|
|
CONFIGURE(showDesktop, showDesktop, ==, ShowDesktopClient);
|
|
|
|
#undef CONFIGURE
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
void KWinTabBoxConfig::updateConfigFromUi(const KWin::KWinTabBoxConfigForm* ui, TabBox::TabBoxConfig& config)
|
|
|
|
{
|
2012-04-09 16:59:26 +00:00
|
|
|
if (ui->filterDesktops->isChecked())
|
|
|
|
config.setClientDesktopMode(ui->currentDesktop->isChecked() ? TabBoxConfig::OnlyCurrentDesktopClients : TabBoxConfig::ExcludeCurrentDesktopClients);
|
|
|
|
else
|
|
|
|
config.setClientDesktopMode(TabBoxConfig::AllDesktopsClients);
|
|
|
|
if (ui->filterActivities->isChecked())
|
|
|
|
config.setClientActivitiesMode(ui->currentActivity->isChecked() ? TabBoxConfig::OnlyCurrentActivityClients : TabBoxConfig::ExcludeCurrentActivityClients);
|
|
|
|
else
|
|
|
|
config.setClientActivitiesMode(TabBoxConfig::AllActivitiesClients);
|
|
|
|
if (ui->filterScreens->isChecked())
|
|
|
|
config.setClientMultiScreenMode(ui->currentScreen->isChecked() ? TabBoxConfig::OnlyCurrentScreenClients : TabBoxConfig::ExcludeCurrentScreenClients);
|
|
|
|
else
|
|
|
|
config.setClientMultiScreenMode(TabBoxConfig::IgnoreMultiScreen);
|
2012-05-17 17:35:01 +00:00
|
|
|
config.setClientApplicationsMode(ui->oneAppWindow->isChecked() ? TabBoxConfig::OneWindowPerApplication : TabBoxConfig::AllWindowsAllApplications);
|
2012-04-09 16:59:26 +00:00
|
|
|
if (ui->filterMinimization->isChecked())
|
|
|
|
config.setClientMinimizedMode(ui->visibleWindows->isChecked() ? TabBoxConfig::ExcludeMinimizedClients : TabBoxConfig::OnlyMinimizedClients);
|
|
|
|
else
|
|
|
|
config.setClientMinimizedMode(TabBoxConfig::IgnoreMinimizedStatus);
|
|
|
|
|
|
|
|
config.setClientSwitchingMode(TabBoxConfig::ClientSwitchingMode(ui->switchingModeCombo->currentIndex()));
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2011-01-30 14:34:42 +00:00
|
|
|
config.setShowTabBox(ui->showTabBox->isChecked());
|
|
|
|
config.setHighlightWindows(ui->highlightWindowCheck->isChecked());
|
2012-04-09 16:59:26 +00:00
|
|
|
if (ui->effectCombo->currentIndex() >= Layout) {
|
|
|
|
config.setLayoutName(ui->effectCombo->itemData(ui->effectCombo->currentIndex()).toString());
|
|
|
|
}
|
|
|
|
config.setShowDesktopMode(ui->showDesktop->isChecked() ? TabBoxConfig::ShowDesktopClient : TabBoxConfig::DoNotShowDesktopClient);
|
2011-01-30 14:34:42 +00:00
|
|
|
}
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
#define CHECK_CURRENT_TABBOX_UI \
|
|
|
|
Q_ASSERT(sender());\
|
|
|
|
KWinTabBoxConfigForm *ui = 0;\
|
|
|
|
QObject *dad = sender();\
|
|
|
|
while (!ui && (dad = dad->parent()))\
|
|
|
|
ui = qobject_cast<KWinTabBoxConfigForm*>(dad);\
|
|
|
|
Q_ASSERT(ui);
|
2009-09-13 11:36:45 +00:00
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
void KWinTabBoxConfig::effectSelectionChanged(int index)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-04-09 16:59:26 +00:00
|
|
|
CHECK_CURRENT_TABBOX_UI
|
2013-09-30 13:09:07 +00:00
|
|
|
ui->effectConfigButton->setIcon(QIcon::fromTheme(index < Layout ? "configure" : "view-preview"));
|
2012-04-09 16:59:26 +00:00
|
|
|
if (!ui->showTabBox->isChecked())
|
2011-01-30 14:34:42 +00:00
|
|
|
return;
|
2012-04-09 16:59:26 +00:00
|
|
|
ui->highlightWindowCheck->setEnabled(index >= Layout);
|
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::tabBoxToggled(bool on) {
|
|
|
|
CHECK_CURRENT_TABBOX_UI
|
|
|
|
on = !on || ui->effectCombo->currentIndex() >= Layout;
|
|
|
|
ui->highlightWindowCheck->setEnabled(on);
|
|
|
|
emit changed();
|
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
|
|
|
{
|
2012-04-09 16:59:26 +00:00
|
|
|
CHECK_CURRENT_TABBOX_UI
|
|
|
|
|
|
|
|
const int effect = ui->effectCombo->currentIndex();
|
|
|
|
if (effect >= Layout) {
|
2013-12-12 10:13:11 +00:00
|
|
|
// TODO: here we need to show the preview
|
|
|
|
new LayoutPreview(ui->effectCombo->itemData(effect, Qt::UserRole+1).toString(), this);
|
2011-01-30 14:34:42 +00:00
|
|
|
} else {
|
2013-12-05 19:22:31 +00:00
|
|
|
QPointer<QDialog> configDialog = new QDialog(this);
|
|
|
|
configDialog->setLayout(new QVBoxLayout);
|
2012-04-09 16:59:26 +00:00
|
|
|
configDialog->setWindowTitle(ui->effectCombo->currentText());
|
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()));
|
|
|
|
|
2012-04-09 16:59:26 +00:00
|
|
|
KCModuleProxy* proxy = new KCModuleProxy(effect == CoverSwitch ? "coverswitch_config" : "flipswitch_config");
|
|
|
|
connect(configDialog, SIGNAL(defaultClicked()), proxy, SLOT(defaults()));
|
|
|
|
|
|
|
|
QWidget *showWidget = new QWidget(configDialog);
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
showWidget->setLayout(layout);
|
|
|
|
layout->addWidget(proxy);
|
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) {
|
|
|
|
proxy->save();
|
|
|
|
} else {
|
|
|
|
proxy->load();
|
|
|
|
}
|
|
|
|
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-04-09 16:59:26 +00:00
|
|
|
void KWinTabBoxConfig::shortcutChanged(const QKeySequence &seq)
|
2011-01-30 14:34:42 +00:00
|
|
|
{
|
2012-04-09 16:59:26 +00:00
|
|
|
QString action;
|
|
|
|
if (sender())
|
|
|
|
action = sender()->property("shortcutAction").toString();
|
|
|
|
if (action.isEmpty())
|
|
|
|
return;
|
2013-09-30 13:07:49 +00:00
|
|
|
QAction *a = m_actionCollection->action(action);
|
|
|
|
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << seq, KGlobalAccel::NoAutoloading);
|
2012-04-09 16:59:26 +00:00
|
|
|
m_actionCollection->writeSettings();
|
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"
|