/**************************************************************************** Copyright (C) 2012-2013 by Eike Hein <hein@kde.org> ** ** 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, write to the ** Free Software Foundation, Inc., ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . ****************************************************************************/import QtQuick 2.0import QtQuick.Layouts 1.1import org.kde.plasma.plasmoid 2.0import org.kde.plasma.core 2.0 as PlasmaCoreimport org.kde.plasma.private.taskmanager 0.1 as TaskManagerimport "../code/layout.js" as LayoutManagerimport "../code/tools.js" as TaskToolsItem {id: tasksanchors.fill: parentproperty bool vertical: (plasmoid.formFactor == PlasmaCore.Types.Vertical)Plasmoid.preferredRepresentation: Plasmoid.fullRepresentationLayout.fillWidth: trueLayout.fillHeight:trueLayout.minimumWidth: tasks.vertical ? 0 : LayoutManager.preferredMinWidth()Layout.minimumHeight: !tasks.vertical ? 0 : LayoutManager.preferredMinHeight()//BEGIN TODO: this is not precise enough: launchers are smaller than full tasksLayout.preferredWidth: tasks.vertical ? units.gridUnit * 10 : Math.min(taskList.columns, taskList.children.length) * units.gridUnit * 10;Layout.preferredHeight: tasks.vertical ? Math.min(taskList.rows, taskList.children.length) * units.gridUnit * 2 : units.gridUnit * 2;//END TODOproperty Item dragSource: nullsignal activateItem(int id, bool toggle)signal activateWindow(int winId)signal itemContextMenu(Item item, QtObject configAction)signal itemHovered(int id, bool hovered)signal itemMove(int id, int newIndex)signal itemGeometryChanged(Item item, int id)signal presentWindows(int groupParentId)onWidthChanged: {taskList.width = LayoutManager.layoutWidth();if (plasmoid.configuration.forceStripes) {taskList.height = LayoutManager.layoutHeight();}}onHeightChanged: {if (plasmoid.configuration.forceStripes) {taskList.width = LayoutManager.layoutWidth();}taskList.height = LayoutManager.layoutHeight();}TaskManager.Backend {id: backendtaskManagerItem: taskshighlightWindows: plasmoid.configuration.highlightWindowsgroupingStrategy: plasmoid.configuration.groupingStrategysortingStrategy: plasmoid.configuration.sortingStrategyonLaunchersChanged: plasmoid.configuration.launchers = launchersComponent.onCompleted: {launchers = plasmoid.configuration.launchers;}}Timer {id: iconGeometryTimerinterval: 500repeat: falseonTriggered: {TaskTools.publishIconGeometries(taskList.children);}}Connections {target: plasmoidonLocationChanged: {// This is on a timer because the panel may not have// settled into position yet when the location prop-// erty updates.iconGeometryTimer.start();}}Connections {target: plasmoid.configurationonLaunchersChanged: backend.launchers = plasmoid.configuration.launchers}Binding {target: backend.groupManagerproperty: "screenGeometry"value: plasmoid.screenGeometry}Binding {target: backend.groupManagerproperty: "onlyGroupWhenFull"value: plasmoid.configuration.onlyGroupWhenFull}Binding {target: backend.groupManagerproperty: "fullLimit"value: LayoutManager.optimumCapacity(width, height) + 1}Binding {target: backend.groupManagerproperty: "showOnlyCurrentScreen"value: plasmoid.configuration.showOnlyCurrentScreen}Binding {target: backend.groupManagerproperty: "showOnlyCurrentDesktop"value: plasmoid.configuration.showOnlyCurrentDesktop}Binding {target: backend.groupManagerproperty: "showOnlyCurrentActivity"value: plasmoid.configuration.showOnlyCurrentActivity}Binding {target: backend.groupManagerproperty: "showOnlyMinimized"value: plasmoid.configuration.showOnlyMinimized}TaskManager.DragHelper { id: dragHelper }PlasmaCore.FrameSvgItem {id: taskFramevisible: false;imagePath: "widgets/tasks";prefix: "normal"}PlasmaCore.Svg {id: taskSvgimagePath: "widgets/tasks"}MouseHandler {id: mouseHandleranchors.fill: parenttarget: taskList}VisualDataModel {id: visualModelmodel: backend.tasksModeldelegate: Task {}}ToolTipDelegate {id: toolTipDelegate}TaskList {id: taskListanchors {left: parent.lefttop: parent.top}onWidthChanged: LayoutManager.layout(taskRepeater)onHeightChanged: LayoutManager.layout(taskRepeater)flow: tasks.vertical ? Flow.TopToBottom : Flow.LeftToRightonAnimatingChanged: {if (!animating) {TaskTools.publishIconGeometries(children);}}Repeater {id: taskRepeatermodel: visualModelonCountChanged: {taskList.width = LayoutManager.layoutWidth();taskList.height = LayoutManager.layoutHeight();LayoutManager.layout(taskRepeater);}function modelWasReset() {LayoutManager.layout(taskRepeater);}Component.onCompleted: {backend.tasksModel.modelReset.connect(modelWasReset);}}}GroupDialog { id: groupDialog }function hasLauncher(url) {return backend.groupManager.launcherExists(url);}function addLauncher(url) {backend.groupManager.addLauncher(url);}function updateStatus(demandsAttention) {if (demandsAttention) {plasmoid.status = PlasmaCore.Types.NeedsAttentionStatus;} else if (!backend.anyTaskNeedsAttention) {plasmoid.status = PlasmaCore.Types.PassiveStatus;}}function resetDragSource() {dragSource = null;}Component.onCompleted: {tasks.activateItem.connect(backend.activateItem);tasks.activateWindow.connect(backend.activateWindow);tasks.itemContextMenu.connect(backend.itemContextMenu);tasks.itemHovered.connect(backend.itemHovered);tasks.itemMove.connect(backend.itemMove);tasks.itemGeometryChanged.connect(backend.itemGeometryChanged);tasks.presentWindows.connect(backend.presentWindows);dragHelper.dropped.connect(resetDragSource);}}