diff --git a/applets/window-list/contents/ui/Menu.qml b/applets/window-list/contents/ui/Menu.qml deleted file mode 100644 --- a/applets/window-list/contents/ui/Menu.qml +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2013 Heena Mahour - * - * 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.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.extras 2.0 as PlasmaExtras - -PlasmaExtras.ScrollArea { - id: menu - - property alias model: menuListView.model - property alias section: menuListView.section - property int iconSize: units.iconSizes.small - property bool showDesktop: true - signal itemSelected(int id) - signal executeJob(string jobName, int id) - signal setOnDesktop(int id, int desktop) - - ListView { - id: menuListView - anchors.top: menu.top - anchors.left: menu.left - anchors.bottom: menu.bottom - focus: true - section.property: desktop - section.criteria: ViewSection.FullString - spacing:0 - - section.delegate: PlasmaComponents.Highlight { - hover: menu.focus - width: menu.width - height: sectionDelegateLabel.height + marginHints.top + marginHints.bottom - - PlasmaComponents.Label { - id: sectionDelegateLabel - text: section > 0 ? i18nc("%1 is the name of the desktop", "Desktop %1") : i18n("On all desktops") - anchors.centerIn: parent - } - } - - highlight: PlasmaComponents.Highlight { - hover: false - width: menuListView.width - } - - delegate: TaskDelegate { - id: menuItemDelegate - width: menuListView.width - nameLabel: DisplayRole - desktop: Desktop - icon: DecorationRole - active: Active - iconSize: menu.iconSize - showDesktop: menu.showDesktop - onClicked: menu.itemSelected(Id); - onExecuteJob: menu.executeJob(jobName, Id); - onSetOnDesktop: menu.setOnDesktop(Id, desktop); - onActiveChanged: { - if (active) { - menuListView.currentIndex = index - } - } - } - } -} diff --git a/applets/window-list/contents/ui/TaskDelegate.qml b/applets/window-list/contents/ui/TaskDelegate.qml deleted file mode 100644 --- a/applets/window-list/contents/ui/TaskDelegate.qml +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2013 Heena Mahour - * - * 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.components 2.0 as PlasmaComponents -import org.kde.kquickcontrolsaddons 2.0 -import org.kde.plasma.core 2.0 as PlasmaCore - -Item { - id: menuItem - width: parent.width - height: Math.max(iconItem.height, label.height) + highlightItem.marginHints.top + highlightItem.marginHints.bottom - - signal clicked() - signal entered() - signal executeJob(string jobName) - signal setOnDesktop(int desktop) - property alias nameLabel: label.text - property int desktop - property alias icon: iconItem.source - property alias label: label.text - property bool active: false - property int iconSize: units.iconSizes.small - property bool showDesktop: true - property variant desktopItems: [] - - PlasmaCore.IconItem { - id: iconItem - - width: menuItem.iconSize - height: width - - anchors { - verticalCenter: parent.verticalCenter - left: parent.left - leftMargin: highlightItem.marginHints.left - } - } - - PlasmaComponents.Label { - id: label - - height: implicitHeight - anchors { - left: iconItem.right - leftMargin: highlightItem.marginHints.left - right: parent.right - verticalCenter: parent.verticalCenter - } - - font.italic: (minimized == true) ? true : false - - elide: Text.ElideRight - } - - MouseArea { - id:root_item - anchors.fill: parent - hoverEnabled: true - - onClicked: { - menuItem.clicked(); - } - - onEntered:{ - highlightItem.trackingItem = menuItem - highlightItem.width = menuItem.width - highlightItem.height = menuItem.height - menuItem.entered(); - highlight = true - } - - onExited: { - highlight = false - } - } -} - diff --git a/applets/window-list/contents/ui/main.qml b/applets/window-list/contents/ui/main.qml --- a/applets/window-list/contents/ui/main.qml +++ b/applets/window-list/contents/ui/main.qml @@ -1,5 +1,5 @@ /* - * Copyright 2013 Heena Mahour + * Copyright 2016 Eike Hein * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -16,151 +16,272 @@ */ import QtQuick 2.0 import QtQuick.Layouts 1.1 + import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras +import org.kde.taskmanager 0.1 as TaskManager +import org.kde.kwindowsystem 1.0 as KWindowSystem + + +Item { + id: root -MouseArea { - id: main - anchors.fill: parent Layout.minimumWidth: units.gridUnit * 12 Layout.minimumHeight: units.gridUnit * 12 + Plasmoid.switchWidth: units.gridUnit * 11 Plasmoid.switchHeight: units.gridUnit * 11 - //property alias data: tasksSource.data; - property variant desktopList: [] - property int iconSize: units.iconSizes.smallMedium - property bool showDesktop: true - property bool highlight: false - - PlasmaComponents.Highlight { - id: highlightItem - - property Item trackingItem - onTrackingItemChanged: { - if (trackingItem) { - y = trackingItem.mapToItem(main, 0, 0).y - } - } - hover: true - width: windowListMenu.width - x: 0 - y: 0 - height: trackingItem.height - visible: true - opacity: highlight ? 1 : 0 - - Behavior on opacity { - NumberAnimation { - duration: units.longDuration - easing.type: Easing.InOutQuad - } - } - Behavior on y { - NumberAnimation { - duration: units.longDuration - easing.type: Easing.InOutQuad - } - } - } - Connections { - target: windowListMenu.flickableItem - onContentYChanged: { - highlightItem.trackingItem = null - } + Plasmoid.icon: "preferences-system-windows" + Plasmoid.toolTipMainText: i18n("Window List") + Plasmoid.toolTipSubText: i18n("Show list of opened windows") + + property int itemHeight: Math.ceil((Math.max(theme.mSize(theme.defaultFont).height, units.iconSizes.small) + + Math.max(highlightItemSvg.margins.top + highlightItemSvg.margins.bottom, + listItemSvg.margins.top + listItemSvg.margins.bottom)) / 2) * 2 + + TaskManager.TasksModel { + id: tasksModel + + sortMode: TaskManager.TasksModel.SortVirtualDesktop + groupMode: TaskManager.TasksModel.GroupDisabled } + TaskManager.VirtualDesktopInfo { + id: virtualDesktopInfo + } - function performOperation(op) { - var service =tasksSource.serviceForSource(""); - var operation = service.operationDescription(op); - service.startOperationCall(operation); + KWindowSystem.KWindowSystem { + id: windowSystem } - function executeJob(operationName, id) { - var service = tasksSource.serviceForSource("tasks"); - var operation = service.operationDescription(operationName); -operation.Id = id; - service.startOperationCall(operation); + PlasmaCore.FrameSvgItem { + id : highlightItemSvg + + visible: false + + imagePath: "widgets/viewitem" + prefix: "hover" } - function setOnDesktop(id, desktop) { - var service = tasksSource.serviceForSource("tasks"); - var operation = service.operationDescription("toDesktop"); -operation.Id = id; - operation.desktop = desktop; - service.startOperationCall(operation); + PlasmaCore.FrameSvgItem { + id : listItemSvg + + visible: false + + imagePath: "widgets/viewitem" + prefix: "normal" } - Component.onCompleted: { - var toolTipData = new Object; - toolTipData["image"] = "preferences-system-window"; - toolTipData["mainText"] = i18n("Window List"); - toolTipData["subText"] = i18n("Show list of opened windows"); - plasmoid.popupIconToolTip = toolTipData; - plasmoid.popupIcon = QIcon("preferences-system-windows"); + Connections { + target: plasmoid + + onExpandedChanged: { + if (!expanded) { + windowListView.currentIndex = 0; + } + } } - PlasmaCore.DataSource { - id: tasksSource - engine: "tasks" - onSourceAdded: { - connectSource(source); + PlasmaExtras.ScrollArea { + anchors.fill: parent + + focus: true + + onFocusChanged: { + if (!focus) { + windowListView.currentIndex = -1; + } } - connectedSources: "tasks" - Component.onCompleted: { - print("connected"); - connectSource("virtualDesktops"); - main.desktopList = tasksSource.data["virtualDesktops"]["names"]; - print(models.tasks) + + ListView { + id: windowListView + + property bool overflowing: (visibleArea.heightRatio < 1.0) + property var pinTopItem: null + property var pinBottomItem: null + + focus: true + + model: tasksModel + + boundsBehavior: Flickable.StopAtBounds + snapMode: ListView.SnapToItem + spacing: 0 + keyNavigationWraps: true + + highlight: PlasmaComponents.Highlight {} + highlightMoveDuration: 0 + + onOverflowingChanged: { + if (!overflowing) { + pinTopItem = null; + pinBottomItem = null; + } + } + + onContentYChanged: { + pinTopItem = contentItem.childAt(0, contentY); + pinBottomItem = contentItem.childAt(0, contentY + windowPin.height); + } + + section.property: virtualDesktopInfo.numberOfDesktops ? "VirtualDesktop" : undefined + section.criteria: ViewSection.FullString + section.delegate: PlasmaComponents.Label { + height: root.itemHeight + width: root.width + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + textFormat: Text.PlainText + wrapMode: Text.NoWrap + elide: Text.ElideRight + + text: { + if (section > 0) { + return virtualDesktopInfo.desktopNames[section - 1]; + } + + return i18n("On all desktops"); + } + } + + delegate: MouseArea { + id: item + + height: root.itemHeight + width: windowListView.overflowing ? ListView.view.width - units.smallSpacing : ListView.view.width + + property bool underPin: (item == windowListView.pinTopItem || item == windowListView.pinBottomItem) + + Accessible.role: Accessible.MenuItem + Accessible.name: label.text + + hoverEnabled: true + + onClicked: tasksModel.requestActivate(tasksModel.makeModelIndex(index)) + + onContainsMouseChanged: { + if (containsMouse) { + windowListView.focus = true; + windowListView.currentIndex = index; + } + } + + Row { + anchors.left: parent.left + anchors.leftMargin: highlightItemSvg.margins.left + anchors.right: parent.right + anchors.rightMargin: highlightItemSvg.margins.right + + height: parent.height + + spacing: units.smallSpacing * 2 + + LayoutMirroring.enabled: (Qt.application.layoutDirection == Qt.RightToLeft) + + PlasmaCore.IconItem { + id: icon + + anchors.verticalCenter: parent.verticalCenter + + width: visible ? units.iconSizes.small : 0 + height: width + + usesPlasmaTheme: false + + source: model.decoration + } + + PlasmaComponents.Label { + id: label + + width: (parent.width - icon.width - parent.spacing - (underPin ? root.width - windowPin.x : 0)) + height: parent.height + + verticalAlignment: Text.AlignVCenter + + textFormat: Text.PlainText + wrapMode: Text.NoWrap + elide: Text.ElideRight + + text: model.display + } + } + + Keys.onTabPressed: windowPin.focus = true + Keys.onBacktabPressed: windowPin.focus = true + + Keys.onPressed: { + if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) { + event.accepted = true; + + tasksModel.requestActivate(tasksModel.makeModelIndex(index)) + + if (!windowPin.checked) { + plasmoid.expanded = false; + } + } + } + } } } - Column { - id: col - - PlasmaComponents.Highlight { - hover: menu.focus - width: windowListMenu.width - height: actions.height + marginHints.top + marginHints.bottom - PlasmaComponents.Label { - id: actions - text: i18n("Actions") - anchors.centerIn: parent + PlasmaComponents.ToolButton { + id: windowPin + + anchors.top: parent.top + anchors.right: parent.right + anchors.rightMargin: windowListView.overflowing ? units.gridUnit : 0 + + width: Math.round(units.gridUnit * 1.25) + height: width + + iconSource: "window-pin" + + checkable: true + onCheckedChanged: plasmoid.hideOnWindowDeactivate = !checked + + Keys.onTabPressed: { + if (windowListView.count) { + windowListView.currentIndex = 0; + windowListView.forceActiveFocus(); } } - TaskDelegate { - nameLabel: i18n("Unclutter Windows") - onClicked: performOperation("unclutter") + Keys.onBacktabPressed: cascadeButton.focus = true + + Keys.onUpPressed: { + if (windowListView.count) { + windowListView.currentIndex = (windowListView.count - 1); + windowListView.forceActiveFocus(); + } } - TaskDelegate { - nameLabel : i18n("Cascade Windows") - onClicked: performOperation("cascade") + Keys.onDownPressed: { + if (windowListView.count) { + windowListView.currentIndex = 0; + windowListView.forceActiveFocus(); + } } - } - Menu { - id: windowListMenu - anchors { - top: col.bottom - left: parent.left - right: parent.right - bottom: parent.bottom + Keys.onLeftPressed: { + if (windowListView.count) { + windowListView.currentIndex = 0; + windowListView.forceActiveFocus(); + } } - model: tasksSource.models.tasks - section.property: "desktop" - section.criteria: ViewSection.FullString - iconSize: main.iconSize - showDesktop: main.showDesktop - onItemSelected: main.executeJob("activate", id); - onExecuteJob: main.executeJob(jobName, id); - onSetOnDesktop: main.setOnDesktop(id, desktop); + Keys.onRightPressed: { + if (windowListView.count) { + windowListView.currentIndex = 0; + windowListView.forceActiveFocus(); + } + } } } diff --git a/applets/window-list/metadata.desktop b/applets/window-list/metadata.desktop --- a/applets/window-list/metadata.desktop +++ b/applets/window-list/metadata.desktop @@ -118,11 +118,11 @@ Type=Service X-KDE-ParentApp= -X-KDE-PluginInfo-Author=Heena -X-KDE-PluginInfo-Email=heena393@gmail.com +X-KDE-PluginInfo-Author=Eike Hein +X-KDE-PluginInfo-Email=hein@kde.org X-KDE-PluginInfo-License=GPL X-KDE-PluginInfo-Name=org.kde.plasma.windowlist -X-KDE-PluginInfo-Version=1.0 +X-KDE-PluginInfo-Version=2.0 X-KDE-PluginInfo-Website=plasma.kde.org X-KDE-ServiceTypes=Plasma/Applet,Plasma/PopupApplet X-Plasma-API=declarativeappletscript