From 905c1f8f9df4234feb068b910a8f6a84bc5d31b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 29 Oct 2014 09:54:05 +0100 Subject: [PATCH] [tabbox/qml] Default desktop switcher moved to look and feel package REVIEW: 120884 --- tabbox/qml/CMakeLists.txt | 2 - .../desktops/informative/contents/ui/main.qml | 200 ------------------ .../qml/desktops/informative/metadata.desktop | 105 --------- tabbox/tabboxhandler.cpp | 12 +- 4 files changed, 4 insertions(+), 315 deletions(-) delete mode 100644 tabbox/qml/desktops/informative/contents/ui/main.qml delete mode 100644 tabbox/qml/desktops/informative/metadata.desktop diff --git a/tabbox/qml/CMakeLists.txt b/tabbox/qml/CMakeLists.txt index 469648de81..e6979e357c 100644 --- a/tabbox/qml/CMakeLists.txt +++ b/tabbox/qml/CMakeLists.txt @@ -1,7 +1,5 @@ # packages -install( DIRECTORY desktops/informative DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/desktoptabbox ) install( DIRECTORY desktops/previews DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/desktoptabbox ) # service files -install( FILES desktops/informative/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_desktop_switcher_informative.desktop ) install( FILES desktops/previews/metadata.desktop DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} RENAME kwin4_desktop_switcher_previews.desktop ) diff --git a/tabbox/qml/desktops/informative/contents/ui/main.qml b/tabbox/qml/desktops/informative/contents/ui/main.qml deleted file mode 100644 index 54179e6b3d..0000000000 --- a/tabbox/qml/desktops/informative/contents/ui/main.qml +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************** - KWin - the KDE window manager - This file is part of the KDE project. - -Copyright (C) 2012 Martin Gräßlin - -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 . -*********************************************************************/ -import QtQuick 2.0 -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.kquickcontrolsaddons 2.0 -import org.kde.kwin 2.0 as KWin - -KWin.Switcher { - id: tabBox - currentIndex: listView.currentIndex - property bool allDesktops: true - property int textMargin: 2 - - PlasmaCore.Dialog { - id: dialog - location: PlasmaCore.Types.Floating - visible: tabBox.visible - flags: Qt.X11BypassWindowManagerHint - x: tabBox.screenGeometry.x + tabBox.screenGeometry.width * 0.5 - dialogMainItem.width * 0.5 - y: tabBox.screenGeometry.y + tabBox.screenGeometry.height * 0.5 - dialogMainItem.height * 0.5 - - mainItem: Item { - id: dialogMainItem - property int optimalWidth: listView.maxRowWidth - property int optimalHeight: listView.rowHeight * listView.count + clientArea.height + 4 - property bool canStretchX: true - property bool canStretchY: false - width: Math.min(Math.max(tabBox.screenGeometry.width * 0.2, optimalWidth), tabBox.screenGeometry.width * 0.8) - height: Math.min(optimalHeight, tabBox.screenGeometry.height * 0.8) - - // just to get the margin sizes - PlasmaCore.FrameSvgItem { - id: hoverItem - imagePath: "widgets/viewitem" - prefix: "hover" - visible: false - } - - // delegate - Component { - id: listDelegate - Item { - id: delegateItem - width: listView.width - height: listView.rowHeight - QIconItem { - id: iconElement - icon: "user-desktop" - width: 32 - height: 32 - anchors { - topMargin: (listView.rowHeight - 32) / 2 - left: parent.left - top: parent.top - leftMargin: hoverItem.margins.left - } - } - Text { - id: captionItem - horizontalAlignment: Text.AlignHCenter - text: display - font.bold: true - color: theme.textColor - elide: Text.ElideMiddle - anchors { - left: iconElement.right - right: parent.right - top: parent.top - topMargin: tabBox.textMargin + hoverItem.margins.top - rightMargin: hoverItem.margins.right - leftMargin: tabBox.textMargin - } - } - MouseArea { - anchors.fill: parent - onClicked: { - listView.currentIndex = index; - } - } - } - } - ListView { - function calculateMaxRowWidth() { - var width = 0; - var textElement = Qt.createQmlObject( - 'import QtQuick 2.0;' - + 'Text {\n' - + ' text: "' + tabBox.model.longestCaption() + '"\n' - + ' font.bold: true\n' - + ' visible: false\n' - + '}', - listView, "calculateMaxRowWidth"); - width = Math.max(textElement.width, width); - textElement.destroy(); - return width + 32 + hoverItem.margins.right + hoverItem.margins.left; - } - /** - * Calculates the height of one row based on the text height and icon size. - * @return Row height - **/ - function calcRowHeight() { - var textElement = Qt.createQmlObject( - 'import QtQuick 2.0;' - + 'Text {\n' - + ' text: "Some Text"\n' - + ' font.bold: true\n' - + ' visible: false\n' - + '}', - listView, "calcRowHeight"); - var height = textElement.height; - textElement.destroy(); - // icon size or two text elements and margins and hoverItem margins - return Math.max(32, height + tabBox.textMargin * 2 + hoverItem.margins.top + hoverItem.margins.bottom); - } - id: listView - model: tabBox.model - // the maximum text width + icon item width (32 + 4 margin) + margins for hover item - property int maxRowWidth: calculateMaxRowWidth() - property int rowHeight: calcRowHeight() - anchors { - top: parent.top - left: parent.left - right: parent.right - bottom: clientArea.top - bottomMargin: clientArea.topMargin - } - clip: true - delegate: listDelegate - highlight: PlasmaCore.FrameSvgItem { - id: highlightItem - imagePath: "widgets/viewitem" - prefix: "hover" - width: listView.width - } - highlightMoveDuration: 250 - boundsBehavior: Flickable.StopAtBounds - Connections { - target: tabBox - onCurrentIndexChanged: {listView.currentIndex = tabBox.currentIndex;} - } - } - Component { - id: clientIconDelegate - QIconItem { - icon: model.icon - width: 16 - height: 16 - } - } - Item { - id: clientArea - VisualDataModel { - property alias desktopIndex: listView.currentIndex - id: desktopClientModel - model: tabBox.model - delegate: clientIconDelegate - onDesktopIndexChanged: { - desktopClientModel.rootIndex = desktopClientModel.parentModelIndex(); - desktopClientModel.rootIndex = desktopClientModel.modelIndex(desktopClientModel.desktopIndex); - } - } - ListView { - id: iconsListView - model: desktopClientModel - clip: true - orientation: ListView.Horizontal - spacing: 4 - anchors { - fill: parent - leftMargin: 34 - } - } - height: 18 - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - topMargin: 2 - } - } - } - } -} diff --git a/tabbox/qml/desktops/informative/metadata.desktop b/tabbox/qml/desktops/informative/metadata.desktop deleted file mode 100644 index a1495d58bc..0000000000 --- a/tabbox/qml/desktops/informative/metadata.desktop +++ /dev/null @@ -1,105 +0,0 @@ -[Desktop Entry] -Name=Informative -Name[bs]=informativan -Name[ca]=Informativa -Name[ca@valencia]=Informativa -Name[cs]=Informativní -Name[da]=Informativt -Name[de]=Informativ -Name[el]=Ενημερωτικό -Name[en_GB]=Informative -Name[es]=Informativo -Name[et]=Informatiivne -Name[eu]=Informatzailea -Name[fi]=Informatiivinen -Name[fr]=Informatif -Name[ga]=Faisnéiseach -Name[gl]=Informativo -Name[he]=מלא מידע -Name[hu]=Informatív -Name[ia]=Informative -Name[id]=Informatif -Name[it]=Informativo -Name[kk]=Мәліметті -Name[km]=ព័ត៌មាន -Name[ko]=정보성 -Name[lt]=Informatyvus -Name[mr]=माहितीजनक -Name[nb]=Informativ -Name[nds]=Informeren -Name[nl]=Informatief -Name[pa]=ਜਾਣਕਾਰੀ -Name[pl]=Informacyjny -Name[pt]=Informativa -Name[pt_BR]=Informativo -Name[ro]=Informativ -Name[ru]=Подробный -Name[sk]=Informatívne -Name[sl]=Podrobno -Name[sr]=Информативно -Name[sr@ijekavian]=Информативно -Name[sr@ijekavianlatin]=Informativno -Name[sr@latin]=Informativno -Name[sv]=Informativ -Name[tr]=Bilgilendirici -Name[ug]=مول ئۇچۇرلۇق -Name[uk]=Інформативне -Name[vi]=Thông tin -Name[x-test]=xxInformativexx -Name[zh_CN]=信息 -Name[zh_TW]=資訊提供 -Comment=An informative desktop switcher layout -Comment[bs]=Izgled informativnog prebacivača radnih površina -Comment[ca]=Una disposició informativa del commutador d'escriptoris -Comment[ca@valencia]=Una disposició informativa del commutador d'escriptoris -Comment[cs]=Informativní rozvržení přepínače oken -Comment[da]=Et informativt layout til skrivebordskift -Comment[de]=Ein ausführliches Fensterwechsler-Layout -Comment[el]=Ενημερωτική εναλλαγή επιφάνειας εργασίας -Comment[en_GB]=An informative desktop switcher layout -Comment[es]=Un esquema informativo del cambiador de escritorios -Comment[eu]=Mahaigain-aldatzaile diseinu informatibo bat -Comment[fi]=Informatiivinen työpöydänvalitsimen asettelu -Comment[fr]=Une disposition du sélecteur informative de bureaux -Comment[gl]=Unha disposición informativa do selector de escritorios -Comment[hu]=Egy informatív asztalváltó elrendezés -Comment[ia]=Un disposition de commutator de criptorio informative -Comment[id]=Tata letak pengganti desktop yang informatif -Comment[it]=Una disposizione informativa dello scambiafinestre -Comment[kk]=Ақпаратты үстел ауыстырғышының қалыпы -Comment[ko]=정보가 있는 데스크톱 전환기 레이아웃 -Comment[lt]=Informatyvus darbastalio perjungimo išdėstymas -Comment[nb]=En kompakt utforming av skrivebordsbytter -Comment[nds]=En informeren Finsterwessel-Utsehn -Comment[nl]=Een informatieve indeling van de bureaubladwisselaar -Comment[pa]=ਜਾਣਕਾਰੀ ਭਰਪੂਰ ਡੈਸਕਟਾਪ ਸਵਿੱਚਰ ਲੇਆਉਟ -Comment[pl]=Informacyjny układ przełączania pulpitów -Comment[pt]=Uma disposição informativa de mudança de ecrãs -Comment[pt_BR]=Uma leiaute informativo do seletor de área de trabalho -Comment[ru]=Информативный переключатель рабочих столов -Comment[sk]=Informatívne rozloženie prepínača okien -Comment[sl]=Podroben razpored preklapljanja med okni -Comment[sr]=Информативни распоред мењача површи -Comment[sr@ijekavian]=Информативни распоред мењача површи -Comment[sr@ijekavianlatin]=Informativni raspored menjača površi -Comment[sr@latin]=Informativni raspored menjača površi -Comment[sv]=En informativ layout för skrivbordsbyte -Comment[tr]=Etkili bir pencere değiştirme düzeni -Comment[uk]=Інформативне компонування засобу перемикання стільниць -Comment[x-test]=xxAn informative desktop switcher layoutxx -Comment[zh_CN]=一个信息全面的桌面切换器布局 -Comment[zh_TW]=有較多資訊的桌面切換器佈局 -Icon=preferences-system-desktop-switcher-informative - -X-Plasma-API=declarativeappletscript -X-Plasma-MainScript=ui/main.qml - -X-KDE-PluginInfo-Author=Martin Gräßlin -X-KDE-PluginInfo-Email=mgraesslin@kde.org -X-KDE-PluginInfo-Name=informative -X-KDE-PluginInfo-Version=1.0 - -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-ServiceTypes=KWin/DesktopSwitcher -Type=Service diff --git a/tabbox/tabboxhandler.cpp b/tabbox/tabboxhandler.cpp index f2c8af21e2..6a1b4b22c4 100644 --- a/tabbox/tabboxhandler.cpp +++ b/tabbox/tabboxhandler.cpp @@ -231,15 +231,11 @@ void TabBoxHandlerPrivate::endHighlightWindows(bool abort) #ifndef KWIN_UNIT_TEST QObject *TabBoxHandlerPrivate::createSwitcherItem(bool desktopMode) { - QString file; // first try look'n'feel package - if (desktopMode) { - file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral("plasma/look-and-feel/%1/contents/desktopswitcher/DesktopSwitcher.qml").arg(config.layoutName())); - } else { - file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, - QStringLiteral("plasma/look-and-feel/%1/contents/windowswitcher/WindowSwitcher.qml").arg(config.layoutName())); - } + QString file = QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral("plasma/look-and-feel/%1/contents/%2") + .arg(config.layoutName()) + .arg(desktopMode ? QStringLiteral("desktopswitcher/DesktopSwitcher.qml") : QStringLiteral("windowswitcher/WindowSwitcher.qml"))); if (file.isNull()) { auto findSwitcher = [this, desktopMode] { QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(config.layoutName());