/*SPDX-FileCopyrightText: 2014-2020 Ivan Cukic <ivan.cukic(at)kde.org>SPDX-License-Identifier: GPL-2.0-or-later*/import QtQuickimport org.kde.plasma.components as PlasmaComponentsimport org.kde.plasma.extras as PlasmaExtrasimport org.kde.plasma.activityswitcher as ActivitySwitcherimport org.kde.kirigami as Kirigamiimport org.kde.kcmutils // KCMLauncherimport "static.js" as SItem {id: rootproperty int innerPadding : Kirigami.Units.gridUnitproperty bool current : falseproperty bool selected : falseproperty alias title : title.textproperty alias icon : icon.sourceproperty alias hasWindows : hasWindowsIndicator.visiblez : current ? 10 :selected ? 5 : 0property string activityId : ""property string background : ""onBackgroundChanged: if (background[0] !== '#') {// We have a proper wallpaper, hurroo!backgroundColor.visible = false;} else {// We have only a colorbackgroundColor.color = background;backgroundColor.visible = true;}signal clickedwidth : 200height : width * 9.0 / 16.0Item {anchors {fill: parent}// Background until we get something realRectangle {id: backgroundColoranchors.fill: parent// This is intentional - while waiting for the wallpaper,// we are showing a semi-transparent black backgroundcolor: "black"opacity: root.selected ? .8 : .5}Image {id: backgroundWallpaperanchors.fill: parentvisible: !backgroundColor.visiblefillMode: Image.PreserveAspectCropsource: "image://wallpaperthumbnail/" + root.background// We ask for a square so that wallpapers narrower than// the 16:9 card still cover it without being upscaled.sourceSize: Qt.size(width, width)}// Title and the iconRectangle {id: shadewidth: parent.heightheight: parent.widthanchors.centerIn: parentrotation: 90gradient: Gradient {GradientStop { position: 1.0; color: "black" }GradientStop { position: 0.0; color: "transparent" }}opacity : root.selected ? 0.5 : 1.0}Rectangle {id: currentActivityHighlightvisible: root.currentborder.width: root.current ? Kirigami.Units.smallSpacing : 0border.color: Kirigami.Theme.highlightColorz: 10anchors {fill: parent// Hide the rounding error on the bottom of the rectanglebottomMargin: -1}color: "transparent"}Item {id: titleBaranchors {top : parent.topleft : parent.leftright : parent.rightleftMargin : 2 * Kirigami.Units.smallSpacing + 2topMargin : 2 * Kirigami.Units.smallSpacing}PlasmaExtras.ShadowedLabel {id: titlecolor : "white"elide : Text.ElideRightvisible : shade.visiblefont.bold : trueanchors {top : parent.topleft : parent.leftright : icon.left}}PlasmaExtras.ShadowedLabel {id: descriptioncolor : "white"elide : Text.ElideRighttext : model.descriptionanchors {top : title.bottomleft : parent.leftright : icon.left}}Kirigami.Icon {id: iconwidth : Kirigami.Units.iconSizes.mediumheight : widthanchors {right : parent.rightrightMargin : 2 * Kirigami.Units.smallSpacing}}}Column {id: statsBarheight: childrenRect.height + Kirigami.Units.smallSpacinganchors {bottom : controlBar.topleft : parent.leftright : parent.rightleftMargin : 2 * Kirigami.Units.smallSpacing + 2rightMargin : 2 * Kirigami.Units.smallSpacingbottomMargin : Kirigami.Units.smallSpacing}Kirigami.Icon {id : hasWindowsIndicatorsource : "window-duplicate"width : 16height : widthopacity : .6visible : false}PlasmaExtras.ShadowedLabel {id: lastUsedDatecolor : "white"elide : Text.ElideRighttext: root.current ?i18ndc("plasma_shell_org.kde.plasma.desktop", "@info:status currently active activity", "Currently being used") :model.lastTimeUsedString}}Rectangle {id: dropHighlightvisible: moveDropAction.isHovered || copyDropAction.isHoveredonVisibleChanged: {ActivitySwitcher.Backend.setDropMode(visible);if (visible) {root.state = "dropAreasShown";} else {root.state = "plain";}}anchors {fill: parenttopMargin: icon.height + 3 * Kirigami.Units.smallSpacing}opacity: .75color: Kirigami.Theme.backgroundColor}TaskDropArea {id: moveDropActionanchors {right: parent.horizontalCenterleft: parent.lefttop: parent.topbottom: parent.bottom}topPadding: icon.height + 3 * Kirigami.Units.smallSpacingactionVisible: dropHighlight.visibleactionTitle: i18ndc("plasma_shell_org.kde.plasma.desktop", "@action shows when dragging file over item", "Move to\nthis activity")onTaskDropped: mimeData => {ActivitySwitcher.Backend.dropMove(mimeData, root.activityId);}onClicked: {root.clicked();}onEntered: {S.showActivityItemActionsBar(root);}visible: ActivitySwitcher.Backend.dropEnabled}TaskDropArea {id: copyDropActiontopPadding: icon.height + 3 * Kirigami.Units.smallSpacingactionVisible: dropHighlight.visibleanchors {right: parent.rightleft: parent.horizontalCentertop: parent.topbottom: parent.bottom}actionTitle: i18ndc("plasma_shell_org.kde.plasma.desktop", "@action shows when dragging file over item", "Show also\nin this activity")onTaskDropped: mimeData => {ActivitySwitcher.Backend.dropCopy(mimeData, root.activityId);}onClicked: {root.clicked();}onEntered: {S.showActivityItemActionsBar(root);}visible: ActivitySwitcher.Backend.dropEnabled}// ControlsItem {id: controlBarheight: root.state == "showingControls" ?(configButton.height + 4 * Kirigami.Units.smallSpacing) :0Behavior on height {NumberAnimation {duration: Kirigami.Units.longDuration}}Behavior on opacity {NumberAnimation {duration: Kirigami.Units.shortDuration}}clip: trueanchors {bottom : parent.bottomleft : parent.leftright : parent.right}Rectangle {anchors {fill: parentmargins: - 2 * Kirigami.Units.smallSpacing}opacity: .75color: Kirigami.Theme.backgroundColor}PlasmaComponents.Button {id: configButtonicon.name: "configure"text: i18ndc("plasma_shell_org.kde.plasma.desktop", "@action:button tooltip only, opens kcm showing the indicated activity", "Configure Activity “%1”", root.title)display: PlasmaComponents.AbstractButton.IconOnlyPlasmaComponents.ToolTip.delay: Kirigami.Units.toolTipDelayPlasmaComponents.ToolTip.visible: hovered || visualFocusPlasmaComponents.ToolTip.text: textonClicked: KCMLauncher.openSystemSettings("kcm_activities", root.activityId);anchors {left : parent.lefttop : parent.topleftMargin : 2 * Kirigami.Units.smallSpacing + 2topMargin : 2 * Kirigami.Units.smallSpacing}}}}states: [State {name: "plain"PropertyChanges { shade.visible: true }PropertyChanges { controlBar.opacity: 0 }},State {name: "showingControls"PropertyChanges { shade.visible: true }PropertyChanges { controlBar.opacity: 1 }},State {name: "dropAreasShown"// PropertyChanges { shade.visible: false }PropertyChanges { statsBar.visible: false }PropertyChanges { controlBar.opacity: 0 }}]transitions: [Transition {NumberAnimation {properties : "opacity"duration : Kirigami.Units.shortDuration}}]}