From c8927395ab3b169eee0438fe99f9f060b33b275b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Mon, 9 Apr 2012 18:59:26 +0200 Subject: [PATCH] rework kcmtabbox BUG: 297639 FIXED-IN:4.9 REVIEW: 104525 --- kcmkwin/kwintabbox/CMakeLists.txt | 2 +- .../{layoutconfig.cpp => layoutpreview.cpp} | 114 +- .../{layoutconfig.h => layoutpreview.h} | 39 +- kcmkwin/kwintabbox/main.cpp | 690 +++++------ kcmkwin/kwintabbox/main.h | 28 +- kcmkwin/kwintabbox/main.ui | 1020 +++++++++++------ kcmkwin/kwintabbox/qml/main.qml | 96 +- 7 files changed, 1009 insertions(+), 980 deletions(-) rename kcmkwin/kwintabbox/{layoutconfig.cpp => layoutpreview.cpp} (63%) rename kcmkwin/kwintabbox/{layoutconfig.h => layoutpreview.h} (67%) diff --git a/kcmkwin/kwintabbox/CMakeLists.txt b/kcmkwin/kwintabbox/CMakeLists.txt index 15f6dc87bb..25c80ea8cf 100644 --- a/kcmkwin/kwintabbox/CMakeLists.txt +++ b/kcmkwin/kwintabbox/CMakeLists.txt @@ -6,7 +6,7 @@ ADD_DEFINITIONS(-DTABBOX_KCM) set(kcm_kwintabbox_PART_SRCS main.cpp - layoutconfig.cpp + layoutpreview.cpp thumbnailitem.cpp ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/tabbox/clientmodel.cpp ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/tabbox/declarative.cpp diff --git a/kcmkwin/kwintabbox/layoutconfig.cpp b/kcmkwin/kwintabbox/layoutpreview.cpp similarity index 63% rename from kcmkwin/kwintabbox/layoutconfig.cpp rename to kcmkwin/kwintabbox/layoutpreview.cpp index b2a426685a..9ada2ad81c 100644 --- a/kcmkwin/kwintabbox/layoutconfig.cpp +++ b/kcmkwin/kwintabbox/layoutpreview.cpp @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ // own -#include "layoutconfig.h" +#include "layoutpreview.h" #include "thumbnailitem.h" #include #include @@ -31,9 +31,9 @@ along with this program. If not, see . #include #include #include -#include +// #include #include -#include +// #include #include namespace KWin @@ -41,15 +41,15 @@ namespace KWin namespace TabBox { -LayoutConfig::LayoutConfig(QWidget* parent) +LayoutPreview::LayoutPreview(QWidget* parent) : QDeclarativeView(parent) - , m_layoutsModels(new LayoutModel(this)) { - setAttribute(Qt::WA_TranslucentBackground); +// setAttribute(Qt::WA_TranslucentBackground); + setAutoFillBackground(false); QPalette pal = palette(); pal.setColor(backgroundRole(), Qt::transparent); setPalette(pal); - setMinimumSize(QSize(500, 500)); + setMinimumSize(QSize(480, 300)); setResizeMode(QDeclarativeView::SizeRootObjectToView); foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) { engine()->addImportPath(importPath); @@ -65,34 +65,19 @@ LayoutConfig::LayoutConfig(QWidget* parent) kdeclarative.setupBindings(); qmlRegisterType("org.kde.kwin", 0, 1, "ThumbnailItem"); rootContext()->setContextProperty("clientModel", model); - rootContext()->setContextProperty("layoutModel", m_layoutsModels); + rootContext()->setContextProperty("sourcePath", QString()); + rootContext()->setContextProperty("name", QString()); setSource(KStandardDirs::locate("data", "kwin/kcm_kwintabbox/main.qml")); } -LayoutConfig::~LayoutConfig() +LayoutPreview::~LayoutPreview() { } -void LayoutConfig::setLayout(const QString &layoutName) +void LayoutPreview::setLayout(const QString &path, const QString &name) { - const QModelIndex index = m_layoutsModels->indexForLayoutName(layoutName); - const int row = (index.isValid()) ? index.row() : -1; - if (QObject *item = rootObject()->findChild("view")) { - item->setProperty("currentIndex", row); - } -} - -QString LayoutConfig::selectedLayout() const -{ - int row = 0; - if (QObject *item = rootObject()->findChild("view")) { - row = item->property("currentIndex").toInt(); - } - const QModelIndex index = m_layoutsModels->index(row); - if (!index.isValid()) { - return QString(); - } - return m_layoutsModels->data(index, Qt::UserRole+2).toString(); + rootContext()->setContextProperty("sourcePath", path); + rootContext()->setContextProperty("name", name); } TabBoxImageProvider::TabBoxImageProvider(QAbstractListModel* model) @@ -194,79 +179,6 @@ int ExampleClientModel::rowCount(const QModelIndex &parent) const return m_nameList.size(); } -LayoutModel::LayoutModel(QObject *parent) - : QAbstractListModel(parent) -{ - QHash roles; - roles[Qt::UserRole] = "name"; - roles[Qt::UserRole+1] = "sourcePath"; - setRoleNames(roles); - init(); -} - -LayoutModel::~LayoutModel() -{ -} - -void LayoutModel::init() -{ - KService::List offers = KServiceTypeTrader::self()->query("KWin/WindowSwitcher"); - 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(); - const QString scriptFile = KStandardDirs::locate("data", "kwin/tabbox/" + pluginName + "/contents/" + scriptName); - if (scriptFile.isNull()) { - continue; - } - m_nameList << service->name(); - m_pathList << scriptFile; - m_layoutList << pluginName; - } -} - -QVariant LayoutModel::data (const QModelIndex& index, int role) const -{ - if (!index.isValid()) { - return QVariant(); - } - switch (role) { - case Qt::DisplayRole: - case Qt::UserRole: - return m_nameList.at(index.row()); - case Qt::UserRole + 1: - return m_pathList.at(index.row()); - case Qt::UserRole + 2: - return m_layoutList.at(index.row()); - } - return QVariant(); -} - -int LayoutModel::rowCount (const QModelIndex& parent) const -{ - Q_UNUSED(parent) - return m_nameList.size(); -} - -QModelIndex LayoutModel::indexForLayoutName(const QString &name) const -{ - // fallback for default - QString normalizedName = name.toLower().replace(' ', '_'); - if (name == "Default" || name.isEmpty()) { - normalizedName = "informative"; - } - for (int i=0; i. *********************************************************************/ -#ifndef KWIN_TABBOX_LAYOUTCONFIG_H -#define KWIN_TABBOX_LAYOUTCONFIG_H +#ifndef KWIN_TABBOX_LAYOUTPREVIEW_H +#define KWIN_TABBOX_LAYOUTPREVIEW_H #include #include @@ -30,20 +30,14 @@ namespace KWin namespace TabBox { -class LayoutModel; - -class LayoutConfig : public QDeclarativeView +class LayoutPreview : public QDeclarativeView { Q_OBJECT public: - LayoutConfig(QWidget *parent = NULL); - virtual ~LayoutConfig(); + LayoutPreview(QWidget *parent = NULL); + virtual ~LayoutPreview(); - void setLayout(const QString &layoutName); - QString selectedLayout() const; - -private: - LayoutModel *m_layoutsModels; + void setLayout(const QString &path, const QString &name); }; class TabBoxImageProvider : public QDeclarativeImageProvider @@ -70,26 +64,7 @@ private: QStringList m_nameList; }; -class LayoutModel : public QAbstractListModel -{ - Q_OBJECT -public: - LayoutModel(QObject *parent = NULL); - virtual ~LayoutModel(); - - virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - - QModelIndex indexForLayoutName(const QString &name) const; - -private: - void init(); - QStringList m_nameList; - QStringList m_pathList; - QStringList m_layoutList; -}; - } // namespace TabBox } // namespace KWin -#endif // KWIN_TABBOX_LAYOUTCONFIG_H +#endif // KWIN_TABBOX_LAYOUTPREVIEW_H diff --git a/kcmkwin/kwintabbox/main.cpp b/kcmkwin/kwintabbox/main.cpp index bb705dbfc9..719a527b5d 100644 --- a/kcmkwin/kwintabbox/main.cpp +++ b/kcmkwin/kwintabbox/main.cpp @@ -21,13 +21,14 @@ along with this program. If not, see . // Qt #include +#include #include // KDE -#include #include #include #include +//#include #include #include #include @@ -35,10 +36,11 @@ along with this program. If not, see . #include #include #include +#include // own #include "tabboxconfig.h" -#include "layoutconfig.h" +#include "layoutpreview.h" K_PLUGIN_FACTORY(KWinTabBoxConfigFactory, registerPlugin();) K_EXPORT_PLUGIN(KWinTabBoxConfigFactory("kcm_kwintabbox")) @@ -46,6 +48,8 @@ K_EXPORT_PLUGIN(KWinTabBoxConfigFactory("kcm_kwintabbox")) namespace KWin { +using namespace TabBox; + KWinTabBoxConfigForm::KWinTabBoxConfigForm(QWidget* parent) : QWidget(parent) { @@ -55,13 +59,12 @@ KWinTabBoxConfigForm::KWinTabBoxConfigForm(QWidget* parent) KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args) : KCModule(KWinTabBoxConfigFactory::componentData(), parent, args) , m_config(KSharedConfig::openConfig("kwinrc")) + , m_layoutPreview(NULL) { KGlobal::locale()->insertCatalog("kwin_effects"); KTabWidget* tabWidget = new KTabWidget(this); m_primaryTabBoxUi = new KWinTabBoxConfigForm(tabWidget); m_alternativeTabBoxUi = new KWinTabBoxConfigForm(tabWidget); - m_alternativeTabBoxUi->description->setText( - i18n("These settings are used by the \"Walk Through Windows Alternative\" actions.")); tabWidget->addTab(m_primaryTabBoxUi, i18n("Main")); tabWidget->addTab(m_alternativeTabBoxUi, i18n("Alternative")); QVBoxLayout* layout = new QVBoxLayout(this); @@ -69,49 +72,36 @@ KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args) infoLabel->setText(i18n("Focus policy settings limit the functionality of navigating through windows."), KTitleWidget::InfoMessage); infoLabel->setPixmap(KTitleWidget::InfoMessage, KTitleWidget::ImageLeft); - layout->addWidget(infoLabel); - layout->addWidget(tabWidget); + layout->addWidget(infoLabel,0); + layout->addWidget(tabWidget,1); + setLayout(layout); + +#define ADD_SHORTCUT(_NAME_, _CUT_, _BTN_) \ + a = qobject_cast(m_actionCollection->addAction(_NAME_));\ + a->setProperty("isConfigurationAction", true);\ + _BTN_->setProperty("shortcutAction", _NAME_);\ + a->setText(i18n(_NAME_));\ + a->setGlobalShortcut(KShortcut(_CUT_)); \ + connect(_BTN_, SIGNAL(keySequenceChanged(QKeySequence)), SLOT(shortcutChanged(QKeySequence))) - m_editor = new KShortcutsEditor(m_primaryTabBoxUi, KShortcutsEditor::GlobalAction); // Shortcut config. The shortcut belongs to the component "kwin"! m_actionCollection = new KActionCollection(this, KComponentData("kwin")); m_actionCollection->setConfigGroup("Navigation"); m_actionCollection->setConfigGlobal(true); - KAction* a = qobject_cast(m_actionCollection->addAction("Walk Through Windows")); - a->setProperty("isConfigurationAction", true); - a->setText(i18n("Walk Through Windows")); - a->setGlobalShortcut(KShortcut(Qt::ALT + Qt::Key_Tab)); - a = qobject_cast(m_actionCollection->addAction("Walk Through Windows (Reverse)")); - a->setProperty("isConfigurationAction", true); - a->setText(i18n("Walk Through Windows (Reverse)")); - a->setGlobalShortcut(KShortcut(Qt::ALT + Qt::SHIFT + Qt::Key_Backtab)); - a = qobject_cast(m_actionCollection->addAction("Walk Through Windows Alternative")); - a->setProperty("isConfigurationAction", true); - a->setText(i18n("Walk Through Windows Alternative")); - a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut); - a = qobject_cast(m_actionCollection->addAction("Walk Through Windows Alternative (Reverse)")); - a->setProperty("isConfigurationAction", true); - a->setText(i18n("Walk Through Windows Alternative (Reverse)")); - a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut); - a = qobject_cast(m_actionCollection->addAction("Walk Through Windows of Current Application")); - a->setProperty("isConfigurationAction", true); - a->setText(i18n("Walk Through Windows of Current Application")); - a->setGlobalShortcut(KShortcut(Qt::ALT + Qt::Key_QuoteLeft)); - a = qobject_cast(m_actionCollection->addAction("Walk Through Windows of Current Application (Reverse)")); - a->setProperty("isConfigurationAction", true); - a->setText(i18n("Walk Through Windows of Current Application (Reverse)")); - a->setGlobalShortcut(KShortcut(Qt::ALT + Qt::Key_AsciiTilde)); - a = qobject_cast(m_actionCollection->addAction("Walk Through Windows of Current Application Alternative")); - a->setProperty("isConfigurationAction", true); - a->setText(i18n("Walk Through Windows of Current Application Alternative")); - a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut); - a = qobject_cast(m_actionCollection->addAction("Walk Through Windows of Current Application Alternative (Reverse)")); - a->setProperty("isConfigurationAction", true); - a->setText(i18n("Walk Through Windows of Current Application Alternative (Reverse)")); - a->setGlobalShortcut(KShortcut(), KAction::ActiveShortcut); - m_editor->addCollection(m_actionCollection, i18n("Navigation")); - layout->addWidget(m_editor); - setLayout(layout); + KAction* a; + 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); + ADD_SHORTCUT("Walk Through Windows Alternative", , m_alternativeTabBoxUi->scAll); + ADD_SHORTCUT("Walk Through Windows Alternative (Reverse)", ,m_alternativeTabBoxUi->scAllReverse); + 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); + ADD_SHORTCUT("Walk Through Windows of Current Application Alternative", , m_alternativeTabBoxUi->scCurrent); + ADD_SHORTCUT("Walk Through Windows of Current Application Alternative (Reverse)", , + m_alternativeTabBoxUi->scCurrentReverse); +#undef ADD_SHORTCUT // search the effect names // TODO: way to recognize if a effect is not found @@ -126,58 +116,70 @@ KWinTabBoxConfig::KWinTabBoxConfig(QWidget* parent, const QVariantList& args) if (!services.isEmpty()) flipswitch = services.first()->name(); - m_primaryTabBoxUi->effectCombo->addItem(i18nc("ComboBox item for window switcher based on layouts instead of a desktop effect", - "Layout based switcher")); - m_primaryTabBoxUi->effectCombo->addItem(coverswitch); - m_primaryTabBoxUi->effectCombo->addItem(flipswitch); + 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(); + const QString scriptFile = KStandardDirs::locate("data", "kwin/tabbox/" + pluginName + "/contents/" + scriptName); + if (scriptFile.isNull()) { + continue; + } - m_alternativeTabBoxUi->effectCombo->addItem(i18nc("ComboBox item for window switcher based on layouts instead of a desktop effect", - "Layout based switcher")); - m_alternativeTabBoxUi->effectCombo->addItem(coverswitch); - m_alternativeTabBoxUi->effectCombo->addItem(flipswitch); + layoutNames << service->name(); + layoutPlugins << pluginName; + layoutPaths << scriptFile; + } - // effect config and info button - m_primaryTabBoxUi->effectInfoButton->setIcon(KIcon("dialog-information")); - m_primaryTabBoxUi->effectConfigButton->setIcon(KIcon("configure")); - m_alternativeTabBoxUi->effectInfoButton->setIcon(KIcon("dialog-information")); - m_alternativeTabBoxUi->effectConfigButton->setIcon(KIcon("configure")); + KWinTabBoxConfigForm *ui[2] = { m_primaryTabBoxUi, m_alternativeTabBoxUi }; + for (int i = 0; i < 2; ++i) { + 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); + } - // combo boxes - connect(m_primaryTabBoxUi->desktopModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->activitiesModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->applicationsModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->minimizedModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->showDesktopModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->multiScreenModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->switchingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - // check boxes - connect(m_primaryTabBoxUi->showOutlineCheck, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->showTabBox, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_primaryTabBoxUi->highlightWindowCheck, SIGNAL(stateChanged(int)), this, SLOT(changed())); - // combo boxes alternative - connect(m_alternativeTabBoxUi->desktopModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->activitiesModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->applicationsModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->minimizedModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->showDesktopModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->multiScreenModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->switchingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changed())); - // check boxes alternative - connect(m_alternativeTabBoxUi->showOutlineCheck, SIGNAL(stateChanged(int)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->showTabBox, SIGNAL(toggled(bool)), this, SLOT(changed())); - connect(m_alternativeTabBoxUi->highlightWindowCheck, SIGNAL(stateChanged(int)), this, SLOT(changed())); + ui[i]->effectConfigButton->setIcon(KIcon("view-preview")); - // effects - connect(m_primaryTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEffectSelectionChanged(int))); - connect(m_primaryTabBoxUi->effectInfoButton, SIGNAL(clicked(bool)), this, SLOT(slotAboutEffectClicked())); - connect(m_primaryTabBoxUi->effectConfigButton, SIGNAL(clicked(bool)), this, SLOT(slotConfigureEffectClicked())); + connect(ui[i]->highlightWindowCheck, SIGNAL(clicked(bool)), SLOT(changed())); + connect(ui[i]->showOutlineCheck, 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())); - // effects alternative - connect(m_alternativeTabBoxUi->effectCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotEffectSelectionChangedAlternative(int))); - connect(m_alternativeTabBoxUi->effectInfoButton, SIGNAL(clicked(bool)), this, SLOT(slotAboutEffectClickedAlternative())); - connect(m_alternativeTabBoxUi->effectConfigButton, SIGNAL(clicked(bool)), this, SLOT(slotConfigureEffectClickedAlternative())); + 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())); + } + + 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())); + } // check focus policy - we don't offer configs for unreasonable focus policies KConfigGroup config(m_config, "Windows"); @@ -197,73 +199,65 @@ void KWinTabBoxConfig::load() { KCModule::load(); - KConfigGroup config(m_config, "TabBox"); - KConfigGroup alternativeConfig(m_config, "TabBoxAlternative"); - loadConfig(config, m_tabBoxConfig); - loadConfig(alternativeConfig, m_tabBoxAlternativeConfig); + const QString group[2] = { "TabBox", "TabBoxAlternative" }; + KWinTabBoxConfigForm* ui[2] = { m_primaryTabBoxUi, m_alternativeTabBoxUi }; + TabBoxConfig *tabBoxConfig[2] = { &m_tabBoxConfig, &m_tabBoxAlternativeConfig }; - // sync to ui - updateUiFromConfig(m_primaryTabBoxUi, m_tabBoxConfig); - updateUiFromConfig(m_alternativeTabBoxUi, m_tabBoxAlternativeConfig); + for (int i = 0; i < 2; ++i) { + KConfigGroup config(m_config, group[i]); + loadConfig(config, *(tabBoxConfig[i])); - // effects - // Set current option to "none" if no plugin is activated. - m_primaryTabBoxUi->effectCombo->setCurrentIndex(Layout); - m_alternativeTabBoxUi->effectCombo->setCurrentIndex(Layout); - KConfigGroup effectconfig(m_config, "Plugins"); - KConfigGroup coverswitchconfig(m_config, "Effect-CoverSwitch"); - if (effectEnabled("coverswitch", effectconfig)) { - if (coverswitchconfig.readEntry("TabBox", false)) - m_primaryTabBoxUi->effectCombo->setCurrentIndex(CoverSwitch); - if (coverswitchconfig.readEntry("TabBoxAlternative", false)) - m_alternativeTabBoxUi->effectCombo->setCurrentIndex(CoverSwitch); + 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;\ + if (KAction *a = qobject_cast(m_actionCollection->action(action)))\ + ui[i]->_BTN_->setKeySequence(a->globalShortcut().primary()) + LOAD_SHORTCUT(scAll); + LOAD_SHORTCUT(scAllReverse); + LOAD_SHORTCUT(scCurrent); + LOAD_SHORTCUT(scCurrentReverse); +#undef LOAD_SHORTCUT } - KConfigGroup flipswitchconfig(m_config, "Effect-FlipSwitch"); - if (effectEnabled("flipswitch", effectconfig)) { - if (flipswitchconfig.readEntry("TabBox", false)) - m_primaryTabBoxUi->effectCombo->setCurrentIndex(FlipSwitch); - if (flipswitchconfig.readEntry("TabBoxAlternative", false)) - m_alternativeTabBoxUi->effectCombo->setCurrentIndex(FlipSwitch); - } - slotEffectSelectionChanged(m_primaryTabBoxUi->effectCombo->currentIndex()); - slotEffectSelectionChangedAlternative(m_alternativeTabBoxUi->effectCombo->currentIndex()); - emit changed(false); } void KWinTabBoxConfig::loadConfig(const KConfigGroup& config, KWin::TabBox::TabBoxConfig& tabBoxConfig) { - tabBoxConfig.setClientDesktopMode(TabBox::TabBoxConfig::ClientDesktopMode( - config.readEntry("DesktopMode", TabBox::TabBoxConfig::defaultDesktopMode()))); - tabBoxConfig.setClientActivitiesMode(TabBox::TabBoxConfig::ClientActivitiesMode( - config.readEntry("ActivitiesMode", TabBox::TabBoxConfig::defaultActivitiesMode()))); - tabBoxConfig.setClientApplicationsMode(TabBox::TabBoxConfig::ClientApplicationsMode( - config.readEntry("ApplicationsMode", TabBox::TabBoxConfig::defaultApplicationsMode()))); - tabBoxConfig.setClientMinimizedMode(TabBox::TabBoxConfig::ClientMinimizedMode( - config.readEntry("MinimizedMode", TabBox::TabBoxConfig::defaultMinimizedMode()))); - tabBoxConfig.setShowDesktopMode(TabBox::TabBoxConfig::ShowDesktopMode( - config.readEntry("ShowDesktopMode", TabBox::TabBoxConfig::defaultShowDesktopMode()))); - tabBoxConfig.setClientMultiScreenMode(TabBox::TabBoxConfig::ClientMultiScreenMode( - config.readEntry("MultiScreenMode", TabBox::TabBoxConfig::defaultMultiScreenMode()))); - tabBoxConfig.setClientSwitchingMode(TabBox::TabBoxConfig::ClientSwitchingMode( - config.readEntry("SwitchingMode", TabBox::TabBoxConfig::defaultSwitchingMode()))); - tabBoxConfig.setLayout(TabBox::TabBoxConfig::LayoutMode( - config.readEntry("LayoutMode", TabBox::TabBoxConfig::defaultLayoutMode()))); + tabBoxConfig.setClientDesktopMode(TabBoxConfig::ClientDesktopMode( + config.readEntry("DesktopMode", TabBoxConfig::defaultDesktopMode()))); + tabBoxConfig.setClientActivitiesMode(TabBoxConfig::ClientActivitiesMode( + config.readEntry("ActivitiesMode", TabBoxConfig::defaultActivitiesMode()))); + tabBoxConfig.setClientApplicationsMode(TabBoxConfig::ClientApplicationsMode( + config.readEntry("ApplicationsMode", TabBoxConfig::defaultApplicationsMode()))); + tabBoxConfig.setClientMinimizedMode(TabBoxConfig::ClientMinimizedMode( + config.readEntry("MinimizedMode", TabBoxConfig::defaultMinimizedMode()))); + tabBoxConfig.setShowDesktopMode(TabBoxConfig::ShowDesktopMode( + config.readEntry("ShowDesktopMode", TabBoxConfig::defaultShowDesktopMode()))); + tabBoxConfig.setClientMultiScreenMode(TabBoxConfig::ClientMultiScreenMode( + config.readEntry("MultiScreenMode", TabBoxConfig::defaultMultiScreenMode()))); + tabBoxConfig.setClientSwitchingMode(TabBoxConfig::ClientSwitchingMode( + config.readEntry("SwitchingMode", TabBoxConfig::defaultSwitchingMode()))); + tabBoxConfig.setLayout(TabBoxConfig::LayoutMode( + config.readEntry("LayoutMode", TabBoxConfig::defaultLayoutMode()))); - tabBoxConfig.setShowOutline(config.readEntry("ShowOutline", - TabBox::TabBoxConfig::defaultShowOutline())); - tabBoxConfig.setShowTabBox(config.readEntry("ShowTabBox", - TabBox::TabBoxConfig::defaultShowTabBox())); - tabBoxConfig.setHighlightWindows(config.readEntry("HighlightWindows", - TabBox::TabBoxConfig::defaultHighlightWindow())); + tabBoxConfig.setShowOutline(config.readEntry("ShowOutline", TabBoxConfig::defaultShowOutline())); + tabBoxConfig.setShowTabBox(config.readEntry("ShowTabBox", TabBoxConfig::defaultShowTabBox())); + tabBoxConfig.setHighlightWindows(config.readEntry("HighlightWindows", TabBoxConfig::defaultHighlightWindow())); - tabBoxConfig.setMinWidth(config.readEntry("MinWidth", - TabBox::TabBoxConfig::defaultMinWidth())); - tabBoxConfig.setMinHeight(config.readEntry("MinHeight", - TabBox::TabBoxConfig::defaultMinHeight())); + tabBoxConfig.setMinWidth(config.readEntry("MinWidth", TabBoxConfig::defaultMinWidth())); + tabBoxConfig.setMinHeight(config.readEntry("MinHeight", TabBoxConfig::defaultMinHeight())); - tabBoxConfig.setLayoutName(config.readEntry("LayoutName", TabBox::TabBoxConfig::defaultLayoutName())); - tabBoxConfig.setSelectedItemLayoutName(config.readEntry("SelectedLayoutName", TabBox::TabBoxConfig::defaultSelectedItemLayoutName())); + tabBoxConfig.setLayoutName(config.readEntry("LayoutName", TabBoxConfig::defaultLayoutName())); + tabBoxConfig.setSelectedItemLayoutName(config.readEntry("SelectedLayoutName", TabBoxConfig::defaultSelectedItemLayoutName())); } void KWinTabBoxConfig::saveConfig(KConfigGroup& config, const KWin::TabBox::TabBoxConfig& tabBoxConfig) @@ -306,37 +300,17 @@ void KWinTabBoxConfig::save() // effects bool highlightWindows = m_primaryTabBoxUi->highlightWindowCheck->isChecked() || m_alternativeTabBoxUi->highlightWindowCheck->isChecked(); - bool presentWindowSwitching = false; - bool coverSwitch = false; - bool flipSwitch = false; - bool presentWindowSwitchingAlternative = false; - bool coverSwitchAlternative = false; - bool flipSwitchAlternative = false; - switch(m_primaryTabBoxUi->effectCombo->currentIndex()) { - case CoverSwitch: - coverSwitch = true; - break; - case FlipSwitch: - flipSwitch = true; - break; - default: - break; // nothing - } - switch(m_alternativeTabBoxUi->effectCombo->currentIndex()) { - case CoverSwitch: - coverSwitchAlternative = true; - break; - case FlipSwitch: - flipSwitchAlternative = true; - break; - default: - break; // nothing - } + 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; // activate effects if not active KConfigGroup effectconfig(m_config, "Plugins"); - if (presentWindowSwitching || presentWindowSwitchingAlternative) - effectconfig.writeEntry("kwin4_effect_presentwindowsEnabled", true); if (coverSwitch || coverSwitchAlternative) effectconfig.writeEntry("kwin4_effect_coverswitchEnabled", true); if (flipSwitch || flipSwitchAlternative) @@ -353,8 +327,6 @@ void KWinTabBoxConfig::save() flipswitchconfig.writeEntry("TabBoxAlternative", flipSwitchAlternative); flipswitchconfig.sync(); - m_editor->save(); - // Reload KWin. QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); QDBusConnection::sessionBus().send(message); @@ -364,43 +336,54 @@ void KWinTabBoxConfig::save() void KWinTabBoxConfig::defaults() { - // combo boxes - m_primaryTabBoxUi->desktopModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultDesktopMode()); - m_primaryTabBoxUi->activitiesModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultActivitiesMode()); - m_primaryTabBoxUi->applicationsModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultApplicationsMode()); - m_primaryTabBoxUi->minimizedModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultMinimizedMode()); - m_primaryTabBoxUi->showDesktopModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultShowDesktopMode()); - m_primaryTabBoxUi->multiScreenModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultMultiScreenMode()); - m_primaryTabBoxUi->switchingModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultSwitchingMode()); + 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(filterApplication, Applications, !=, AllWindowsAllApplications); +// CONFIGURE(currentApplication, Applications, ==, AllWindowsCurrentApplication); + CONFIGURE(oneAppWindow, Applications, ==, OneWindowPerApplication); + CONFIGURE(filterMinimization, Minimized, !=, IgnoreMinimizedStatus); + CONFIGURE(visibleWindows, Minimized, ==, ExcludeMinimizedClients); + CONFIGURE(hiddenWindows, Minimized, ==, OnlyMinimizedClients); - // checkboxes - m_primaryTabBoxUi->showOutlineCheck->setChecked(TabBox::TabBoxConfig::defaultShowOutline()); - m_primaryTabBoxUi->showTabBox->setChecked(TabBox::TabBoxConfig::defaultShowTabBox()); - m_primaryTabBoxUi->highlightWindowCheck->setChecked(TabBox::TabBoxConfig::defaultHighlightWindow()); + ui[i]->switchingModeCombo->setCurrentIndex(TabBoxConfig::defaultSwitchingMode()); - // effects - m_primaryTabBoxUi->effectCombo->setCurrentIndex(1); - - // alternative - // combo boxes - m_alternativeTabBoxUi->desktopModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultDesktopMode()); - m_alternativeTabBoxUi->activitiesModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultActivitiesMode()); - m_alternativeTabBoxUi->applicationsModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultApplicationsMode()); - m_alternativeTabBoxUi->minimizedModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultMinimizedMode()); - m_alternativeTabBoxUi->showDesktopModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultShowDesktopMode()); - m_alternativeTabBoxUi->multiScreenModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultMultiScreenMode()); - m_alternativeTabBoxUi->switchingModeCombo->setCurrentIndex(TabBox::TabBoxConfig::defaultSwitchingMode()); - - // checkboxes - m_alternativeTabBoxUi->showOutlineCheck->setChecked(TabBox::TabBoxConfig::defaultShowOutline()); - m_alternativeTabBoxUi->showTabBox->setChecked(TabBox::TabBoxConfig::defaultShowTabBox()); - m_alternativeTabBoxUi->highlightWindowCheck->setChecked(TabBox::TabBoxConfig::defaultHighlightWindow()); - - // effects - m_alternativeTabBoxUi->effectCombo->setCurrentIndex(Layout); - - m_editor->allDefault(); + // checkboxes + ui[i]->showOutlineCheck->setChecked(TabBoxConfig::defaultShowOutline()); + 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")); + } + QString action; +#define RESET_SHORTCUT(_BTN_, _CUT_) \ + action = _BTN_->property("shortcutAction").toString(); \ + if (KAction *a = qobject_cast(m_actionCollection->action(action))) \ + a->setGlobalShortcut(KShortcut(_CUT_), KAction::ActiveShortcut, KAction::NoAutoloading) + RESET_SHORTCUT(m_primaryTabBoxUi->scAll, Qt::ALT + Qt::Key_Tab); + RESET_SHORTCUT(m_primaryTabBoxUi->scAllReverse, Qt::ALT + Qt::SHIFT + Qt::Key_Backtab); + RESET_SHORTCUT(m_alternativeTabBoxUi->scAll, ); + RESET_SHORTCUT(m_alternativeTabBoxUi->scAllReverse, ); + RESET_SHORTCUT(m_primaryTabBoxUi->scCurrent, Qt::ALT + Qt::Key_QuoteLeft); + RESET_SHORTCUT(m_primaryTabBoxUi->scCurrentReverse, Qt::ALT + Qt::Key_AsciiTilde); + RESET_SHORTCUT(m_alternativeTabBoxUi->scCurrent, ); + RESET_SHORTCUT(m_alternativeTabBoxUi->scCurrentReverse, ); + m_actionCollection->writeSettings(); +#undef RESET_SHORTCUT emit changed(true); } @@ -416,203 +399,146 @@ bool KWinTabBoxConfig::effectEnabled(const QString& effect, const KConfigGroup& void KWinTabBoxConfig::updateUiFromConfig(KWinTabBoxConfigForm* ui, const KWin::TabBox::TabBoxConfig& config) { - // combo boxes - ui->desktopModeCombo->setCurrentIndex(config.clientDesktopMode()); - ui->activitiesModeCombo->setCurrentIndex(config.clientActivitiesMode()); - ui->applicationsModeCombo->setCurrentIndex(config.clientApplicationsMode()); - ui->minimizedModeCombo->setCurrentIndex(config.clientMinimizedMode()); - ui->showDesktopModeCombo->setCurrentIndex(config.showDesktopMode()); - ui->multiScreenModeCombo->setCurrentIndex(config.clientMultiScreenMode()); +#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(filterApplication, clientApplications, !=, AllWindowsAllApplications); +// CONFIGURE(currentApplication, clientApplications, ==, AllWindowsCurrentApplication); + CONFIGURE(oneAppWindow, clientApplications, ==, OneWindowPerApplication); + CONFIGURE(filterMinimization, clientMinimized, !=, IgnoreMinimizedStatus); + CONFIGURE(visibleWindows, clientMinimized, ==, ExcludeMinimizedClients); + CONFIGURE(hiddenWindows, clientMinimized, ==, OnlyMinimizedClients); + ui->switchingModeCombo->setCurrentIndex(config.clientSwitchingMode()); // check boxes ui->showOutlineCheck->setChecked(config.isShowOutline()); ui->showTabBox->setChecked(config.isShowTabBox()); ui->highlightWindowCheck->setChecked(config.isHighlightWindows()); + ui->effectCombo->setCurrentIndex(ui->effectCombo->findData(config.layoutName())); + CONFIGURE(showDesktop, showDesktop, ==, ShowDesktopClient); +#undef CONFIGURE } void KWinTabBoxConfig::updateConfigFromUi(const KWin::KWinTabBoxConfigForm* ui, TabBox::TabBoxConfig& config) { - config.setClientDesktopMode(TabBox::TabBoxConfig::ClientDesktopMode(ui->desktopModeCombo->currentIndex())); - config.setClientActivitiesMode(TabBox::TabBoxConfig::ClientActivitiesMode(ui->activitiesModeCombo->currentIndex())); - config.setClientApplicationsMode(TabBox::TabBoxConfig::ClientApplicationsMode(ui->applicationsModeCombo->currentIndex())); - config.setClientMinimizedMode(TabBox::TabBoxConfig::ClientMinimizedMode(ui->minimizedModeCombo->currentIndex())); - config.setShowDesktopMode(TabBox::TabBoxConfig::ShowDesktopMode(ui->showDesktopModeCombo->currentIndex())); - config.setClientMultiScreenMode(TabBox::TabBoxConfig::ClientMultiScreenMode(ui->multiScreenModeCombo->currentIndex())); - config.setClientSwitchingMode(TabBox::TabBoxConfig::ClientSwitchingMode(ui->switchingModeCombo->currentIndex())); + 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); +// if (ui->filterApplication->isChecked()) + config.setClientApplicationsMode(ui->oneAppWindow->isChecked() ? TabBoxConfig::OneWindowPerApplication : TabBoxConfig::AllWindowsAllApplications/*AllWindowsCurrentApplication*/); +// else +// config.setClientApplicationsMode(TabBoxConfig::AllWindowsAllApplications); + 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())); config.setShowOutline(ui->showOutlineCheck->isChecked()); config.setShowTabBox(ui->showTabBox->isChecked()); config.setHighlightWindows(ui->highlightWindowCheck->isChecked()); -} - -void KWinTabBoxConfig::slotEffectSelectionChanged(int index) -{ - effectSelectionChanged(m_primaryTabBoxUi, index); -} - -void KWinTabBoxConfig::slotEffectSelectionChangedAlternative(int index) -{ - effectSelectionChanged(m_alternativeTabBoxUi, index); -} - -void KWinTabBoxConfig::effectSelectionChanged(KWinTabBoxConfigForm* ui, int index) -{ - bool enabled = false; - if (index > 0) - enabled = true; - ui->effectInfoButton->setEnabled(enabled); -} - -void KWinTabBoxConfig::slotAboutEffectClicked() -{ - aboutEffectClicked(m_primaryTabBoxUi); -} - -void KWinTabBoxConfig::slotAboutEffectClickedAlternative() -{ - aboutEffectClicked(m_alternativeTabBoxUi); -} - -void KWinTabBoxConfig::aboutEffectClicked(KWinTabBoxConfigForm* ui) -{ - KServiceTypeTrader* trader = KServiceTypeTrader::self(); - KService::List services; - QString effect; - switch(ui->effectCombo->currentIndex()) { - case CoverSwitch: - effect = "coverswitch"; - break; - case FlipSwitch: - effect = "flipswitch"; - break; - default: - return; + if (ui->effectCombo->currentIndex() >= Layout) { + config.setLayoutName(ui->effectCombo->itemData(ui->effectCombo->currentIndex()).toString()); } - services = trader->query("KWin/Effect", "[X-KDE-PluginInfo-Name] == 'kwin4_effect_" + effect + '\''); - if (services.isEmpty()) + config.setShowDesktopMode(ui->showDesktop->isChecked() ? TabBoxConfig::ShowDesktopClient : TabBoxConfig::DoNotShowDesktopClient); +} + +#define CHECK_CURRENT_TABBOX_UI \ + Q_ASSERT(sender());\ + KWinTabBoxConfigForm *ui = 0;\ + QObject *dad = sender();\ + while (!ui && (dad = dad->parent()))\ + ui = qobject_cast(dad);\ + Q_ASSERT(ui); + +void KWinTabBoxConfig::effectSelectionChanged(int index) +{ + CHECK_CURRENT_TABBOX_UI + ui->effectConfigButton->setIcon(KIcon(index < Layout ? "configure" : "view-preview")); + if (!ui->showTabBox->isChecked()) return; - KPluginInfo pluginInfo(services.first()); + ui->highlightWindowCheck->setEnabled(index >= Layout); + ui->showOutlineCheck->setEnabled(index >= Layout); + if (m_layoutPreview && m_layoutPreview->isVisible()) { + if (index < Layout) + m_layoutPreview->hide(); + else + m_layoutPreview->setLayout(ui->effectCombo->itemData(index, Qt::UserRole+1).toString(), ui->effectCombo->itemText(index)); + } +} - const QString name = pluginInfo.name(); - const QString comment = pluginInfo.comment(); - const QString author = pluginInfo.author(); - const QString email = pluginInfo.email(); - const QString website = pluginInfo.website(); - const QString version = pluginInfo.version(); - const QString license = pluginInfo.license(); - const QString icon = pluginInfo.icon(); +void KWinTabBoxConfig::tabBoxToggled(bool on) { + CHECK_CURRENT_TABBOX_UI + on = !on || ui->effectCombo->currentIndex() >= Layout; + ui->highlightWindowCheck->setEnabled(on); + ui->showOutlineCheck->setEnabled(on); + emit changed(); +} - KAboutData aboutData(name.toUtf8(), name.toUtf8(), ki18n(name.toUtf8()), version.toUtf8(), ki18n(comment.toUtf8()), KAboutLicense::byKeyword(license).key(), ki18n(QByteArray()), ki18n(QByteArray()), website.toLatin1()); - aboutData.setProgramIconName(icon); - const QStringList authors = author.split(','); - const QStringList emails = email.split(','); - int i = 0; - if (authors.count() == emails.count()) { - foreach (const QString & author, authors) { - if (!author.isEmpty()) { - aboutData.addAuthor(ki18n(author.toUtf8()), ki18n(QByteArray()), emails[i].toUtf8(), 0); - } - i++; +void KWinTabBoxConfig::configureEffectClicked() +{ + CHECK_CURRENT_TABBOX_UI + + const int effect = ui->effectCombo->currentIndex(); + if (effect >= Layout) { + if (!m_layoutPreview) { + m_layoutPreview = new LayoutPreview(this); + m_layoutPreview->setWindowTitle(i18n("Tabbox layout preview")); + m_layoutPreview->setWindowFlags(Qt::Dialog); } - } - QPointer< KAboutApplicationDialog > aboutPlugin = new KAboutApplicationDialog(&aboutData, this); - aboutPlugin->exec(); - delete aboutPlugin; -} - -void KWinTabBoxConfig::slotConfigureEffectClicked() -{ - if (m_primaryTabBoxUi->effectCombo->currentIndex() == Layout) { - slotConfigureLayoutClicked(); - return; - } - configureEffectClicked(m_primaryTabBoxUi); -} - -void KWinTabBoxConfig::slotConfigureEffectClickedAlternative() -{ - if (m_alternativeTabBoxUi->effectCombo->currentIndex() == Layout) { - slotConfigureLayoutClickedAlternative(); - return; - } - configureEffectClicked(m_alternativeTabBoxUi); -} - -void KWinTabBoxConfig::configureEffectClicked(KWinTabBoxConfigForm* ui) -{ - QString effect; - switch(ui->effectCombo->currentIndex()) { - case CoverSwitch: - effect = "coverswitch_config"; - break; - case FlipSwitch: - effect = "flipswitch_config"; - break; - default: - return; - } - KCModuleProxy* proxy = new KCModuleProxy(effect); - QPointer< KDialog > configDialog = new KDialog(this); - configDialog->setWindowTitle(ui->effectCombo->currentText()); - configDialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Default); - connect(configDialog, SIGNAL(defaultClicked()), proxy, SLOT(defaults())); - - QWidget *showWidget = new QWidget(configDialog); - QVBoxLayout *layout = new QVBoxLayout; - showWidget->setLayout(layout); - layout->addWidget(proxy); - layout->insertSpacing(-1, KDialog::marginHint()); - configDialog->setMainWidget(showWidget); - - if (configDialog->exec() == QDialog::Accepted) { - proxy->save(); + m_layoutPreview->setLayout(ui->effectCombo->itemData(effect, Qt::UserRole+1).toString(), ui->effectCombo->itemText(effect)); + m_layoutPreview->show(); } else { - proxy->load(); + QPointer< KDialog > configDialog = new KDialog(this); + configDialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Default); + configDialog->setWindowTitle(ui->effectCombo->currentText()); + 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); + layout->insertSpacing(-1, KDialog::marginHint()); + configDialog->setMainWidget(showWidget); + + if (configDialog->exec() == QDialog::Accepted) { + proxy->save(); + } else { + proxy->load(); + } + delete configDialog; } - delete configDialog; } -void KWinTabBoxConfig::slotConfigureLayoutClicked() +void KWinTabBoxConfig::shortcutChanged(const QKeySequence &seq) { - QPointer dialog = new KDialog(this); - dialog->setCaption(i18n("Configure Layout")); - dialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Default); - connect(dialog, SIGNAL(okClicked()), this, SLOT(slotLayoutChanged())); - - m_configForm = new TabBox::LayoutConfig(dialog); - m_configForm->setLayout(m_tabBoxConfig.layoutName()); - dialog->setMainWidget(m_configForm); - - dialog->exec(); - delete dialog; -} - -void KWinTabBoxConfig::slotLayoutChanged() -{ - m_tabBoxConfig.setLayoutName(m_configForm->selectedLayout()); - emit changed(true); -} - -void KWinTabBoxConfig::slotConfigureLayoutClickedAlternative() -{ - QPointer dialog = new KDialog(this); - dialog->setCaption(i18n("Configure Layout")); - dialog->setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Default); - connect(dialog, SIGNAL(okClicked()), this, SLOT(slotLayoutChangedAlternative())); - - m_configForm = new TabBox::LayoutConfig(dialog); - m_configForm->setLayout(m_tabBoxAlternativeConfig.layoutName()); - dialog->setMainWidget(m_configForm); - - dialog->exec(); - delete dialog; -} - -void KWinTabBoxConfig::slotLayoutChangedAlternative() -{ - m_tabBoxAlternativeConfig.setLayoutName(m_configForm->selectedLayout()); - emit changed(true); + QString action; + if (sender()) + action = sender()->property("shortcutAction").toString(); + if (action.isEmpty()) + return; + if (KAction *a = qobject_cast(m_actionCollection->action(action))) + a->setGlobalShortcut(KShortcut(seq), KAction::ActiveShortcut, KAction::NoAutoloading); + m_actionCollection->writeSettings(); } } // namespace diff --git a/kcmkwin/kwintabbox/main.h b/kcmkwin/kwintabbox/main.h index b1e57e6609..df84af69a5 100644 --- a/kcmkwin/kwintabbox/main.h +++ b/kcmkwin/kwintabbox/main.h @@ -35,7 +35,7 @@ namespace KWin namespace TabBox { -class LayoutConfig; +class LayoutPreview; } @@ -62,31 +62,21 @@ public slots: virtual void defaults(); private slots: - void slotEffectSelectionChanged(int index); - void slotAboutEffectClicked(); - void slotConfigureEffectClicked(); - void slotConfigureLayoutClicked(); - void slotLayoutChanged(); - void slotEffectSelectionChangedAlternative(int index); - void slotAboutEffectClickedAlternative(); - void slotConfigureEffectClickedAlternative(); - void slotConfigureLayoutClickedAlternative(); - void slotLayoutChangedAlternative(); - + void effectSelectionChanged(int index); + void configureEffectClicked(); + void tabBoxToggled(bool on); + void shortcutChanged(const QKeySequence &seq); private: void updateUiFromConfig(KWinTabBoxConfigForm* ui, const TabBox::TabBoxConfig& config); void updateConfigFromUi(const KWinTabBoxConfigForm* ui, TabBox::TabBoxConfig& config); void loadConfig(const KConfigGroup& config, KWin::TabBox::TabBoxConfig& tabBoxConfig); void saveConfig(KConfigGroup& config, const KWin::TabBox::TabBoxConfig& tabBoxConfig); - void effectSelectionChanged(KWinTabBoxConfigForm* ui, int index); - void aboutEffectClicked(KWinTabBoxConfigForm* ui); - void configureEffectClicked(KWinTabBoxConfigForm* ui); private: enum Mode { - Layout = 0, - CoverSwitch = 1, - FlipSwitch = 2 + CoverSwitch = 0, + FlipSwitch = 1, + Layout = 2 }; KWinTabBoxConfigForm* m_primaryTabBoxUi; KWinTabBoxConfigForm* m_alternativeTabBoxUi; @@ -95,7 +85,7 @@ private: KShortcutsEditor* m_editor; TabBox::TabBoxConfig m_tabBoxConfig; TabBox::TabBoxConfig m_tabBoxAlternativeConfig; - TabBox::LayoutConfig* m_configForm; + TabBox::LayoutPreview *m_layoutPreview; bool effectEnabled(const QString& effect, const KConfigGroup& cfg) const; }; diff --git a/kcmkwin/kwintabbox/main.ui b/kcmkwin/kwintabbox/main.ui index d83d532ca3..8ae9d848ea 100644 --- a/kcmkwin/kwintabbox/main.ui +++ b/kcmkwin/kwintabbox/main.ui @@ -6,370 +6,25 @@ 0 0 - 541 - 305 + 621 + 398 - - - - - These settings are used by the "Walk Through Windows" actions. - - - - - - - - - Desktop: - - - desktopModeCombo - - - - - - - - 0 - 0 - - - - - Windows from all desktops - - - - - Windows from current desktop only - - - - - Exclude windows from current desktop - - - - - - - - Activities: - - - activitiesModeCombo - - - - - - - - 0 - 0 - - - - - Windows from all activities - - - - - Windows from current activity only - - - - - Exclude windows from current activity - - - - - - - - Applications: - - - applicationsModeCombo - - - - - - - - 0 - 0 - - - - - All windows from all applications - - - - - Only one window per application - - - - - All windows of the current application only - - - - - - - - Minimized: - - - minimizedModeCombo - - - - - - - - 0 - 0 - - - - - Ignore status - - - - - Exclude minimized windows - - - - - Minimized windows only - - - - - - - - Show desktop: - - - showDesktopModeCombo - - - - - - - - 0 - 0 - - - - - Do not show desktop - - - - - Show desktop to minimize all windows - - - - - - - - Multi screen: - - - multiScreenModeCombo - - - - - - - - 0 - 0 - - - - - Ignore - - - - - Only windows from current screen - - - - - Exclude windows from current screen - - - - - - - - Sort order: - - - switchingModeCombo - - - - - - - - 0 - 0 - - - - - Recently used - - - - - Stacking order - - - - - - - - + + + - Qt::Horizontal + Qt::Vertical - - - - - - The currently selected window will be highlighted by fading out all other windows. This option requires desktop effects to be active. + + + 20 + 40 + - - Highlight selected window - - + - - - - Show outline of selected window - - - - - - - - - Effect: - - - effectCombo - - - - - - - - - - 0 - 0 - - - - The effect to replace the list window when desktop effects are active. - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - Qt::Horizontal - - - - - - - - - Display list while switching - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - + Qt::Vertical @@ -377,7 +32,555 @@ 20 - 5 + 40 + + + + + + + + Filter windows by + + + true + + + + + + Virtual desktops + + + false + + + + + + + false + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 24 + 20 + + + + + + + + Current desktop + + + + + + + All other desktops + + + + + + + + + + Activities + + + false + + + + + + + false + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 24 + 20 + + + + + + + + Current activity + + + + + + + All other activities + + + + + + + + + + Screens + + + false + + + + + + + false + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 24 + 20 + + + + + + + + Current screen + + + + + + + All other screens + + + + + + + + + + Minimization + + + false + + + + + + + false + + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 24 + 20 + + + + + + + + Visible windows + + + + + + + Hidden windows + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Content + + + true + + + + + + Include "Show Desktop" icon + + + + + + + + 0 + 0 + + + + + Recently used + + + + + Stacking order + + + + + + + + Only one window per application + + + false + + + + + + + Sort order: + + + switchingModeCombo + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Shortcuts + + + true + + + + + + Forward + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Horizontal + + + + + + + + 75 + true + + + + All windows + + + Qt::AlignCenter + + + + + + + Reverse + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Forward + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Reverse + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + KKeySequenceWidget::GlobalShortcuts + + + + + + + KKeySequenceWidget::GlobalShortcuts + + + + + + + + 75 + true + + + + Current application + + + Qt::AlignCenter + + + + + + + KKeySequenceWidget::GlobalShortcuts + + + + + + + KKeySequenceWidget::GlobalShortcuts + + + + + + + + + + Qt::Vertical + + + + + + + Visualization + + + true + + + + + + + 0 + + + + + + 0 + 0 + + + + The effect to replace the list window when desktop effects are active. + + + + + + + + 0 + 0 + + + + + + + + + + + + + + true + + + + + + + Outline selected window + + + + + + + The currently selected window will be highlighted by fading out all other windows. This option requires desktop effects to be active. + + + Show selected window + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 40 + 20 @@ -386,50 +589,105 @@ - KTitleWidget + KKeySequenceWidget QWidget -
ktitlewidget.h
-
- - KPushButton - QPushButton -
kpushbutton.h
+
kkeysequencewidget.h
KComboBox QComboBox
kcombobox.h
+ + KPushButton + QPushButton +
kpushbutton.h
+
- desktopModeCombo - activitiesModeCombo - applicationsModeCombo - minimizedModeCombo - showDesktopModeCombo - multiScreenModeCombo - switchingModeCombo highlightWindowCheck showOutlineCheck - effectCombo effectConfigButton - effectInfoButton - showTabBox + filterDesktops toggled(bool) - layoutConfigButton + desktopFilter setEnabled(bool) - 81 - 211 + 109 + 298 - 295 - 216 + 392 + 298 + + + + + filterActivities + toggled(bool) + activityFilter + setEnabled(bool) + + + 111 + 325 + + + 392 + 325 + + + + + filterScreens + toggled(bool) + screenFilter + setEnabled(bool) + + + 123 + 352 + + + 392 + 352 + + + + + filterMinimization + toggled(bool) + minimizationFilter + setEnabled(bool) + + + 126 + 379 + + + 392 + 379 + + + + + showTabBox + toggled(bool) + widget_6 + setEnabled(bool) + + + 45 + 106 + + + 230 + 108 diff --git a/kcmkwin/kwintabbox/qml/main.qml b/kcmkwin/kwintabbox/qml/main.qml index 8858e208c9..7f55ff9b7f 100644 --- a/kcmkwin/kwintabbox/qml/main.qml +++ b/kcmkwin/kwintabbox/qml/main.qml @@ -18,74 +18,42 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ import QtQuick 1.0 -import org.kde.plasma.components 0.1 as PlasmaComponents + Item { - id: container - GridView { - property int lastMousePosX - property int lastMousePosY - id: view - objectName: "view" - model: layoutModel - cellWidth: Math.max(100, (container.width % 2 == 0 ? container.width : (container.width - 1)) / 2.0) - cellHeight: Math.max(100, container.height / (count % 2 == 0 ? count : (count+1)) * 2) - anchors.fill: parent - delegate: itemDelegate - highlight: PlasmaComponents.Highlight { - width: view.cellWidth - height: view.cellHeight - hover: true - } - MouseArea { - hoverEnabled: true - anchors.fill: parent - onPositionChanged: { - view.lastMousePosX = mouse.x; - view.lastMousePosY = mouse.y; + id : preview + Loader { + property int screenWidth : preview.width + property int screenHeight : preview.height + property bool allDesktops: true + width: preview.width + height: preview.height - textElement.height + source: sourcePath + anchors.centerIn: parent + onLoaded: { + if (item.allDesktops != undefined) { + item.allDesktops = allDesktops; } - onClicked: { - view.currentIndex = view.indexAt(mouse.x, mouse.y); + if (item.setModel) { + item.setModel(clientModel); } + if (item.screenWidth != undefined) { + item.screenWidth = screenWidth; + } + if (item.screenHeight != undefined) { + item.screenHeight = screenHeight; + } + item.width = preview.width; + item.height = preview.height - textElement.height; } } - Component { - id: itemDelegate - Item { - width: view.cellWidth - height: view.cellHeight - Loader { - property int screenWidth : container.width - property int screenHeight : container.height - property bool allDesktops: true - width: { - if (item.canStretchX) { - return Math.min(Math.max(item.optimalWidth, view.cellWidth), view.cellWidth) - } else { - return Math.min(item.optimalWidth, view.cellWidth); - } - } - height: Math.min(item.optimalHeight, view.cellHeight) - source: sourcePath - anchors.centerIn: parent - onLoaded: { - if (item.allDesktops != undefined) { - item.allDesktops = allDesktops; - } - if (item.setModel) { - item.setModel(clientModel); - } - } - } - Text { - id: textElement - font.bold: true - text: name - anchors { - horizontalCenter: parent.horizontalCenter - bottom: parent.bottom - } - visible: view.indexAt(view.lastMousePosX, view.lastMousePosY) == index - } + Text { + id: textElement + font.bold: true + text: name + anchors { + horizontalCenter: parent.horizontalCenter + bottom: parent.bottom } + visible: true } -} +} \ No newline at end of file