diff --git a/containments/desktop/package/contents/ui/main.qml b/containments/desktop/package/contents/ui/main.qml index 3f80f3df5..b0b08c458 100644 --- a/containments/desktop/package/contents/ui/main.qml +++ b/containments/desktop/package/contents/ui/main.qml @@ -1,412 +1,412 @@ /*************************************************************************** * Copyright (C) 2011-2013 Sebastian Kügler * * Copyright (C) 2011-2019 Marco Martin * * Copyright (C) 2014-2015 by 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 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.10 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.draganddrop 2.0 as DragDrop import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons import org.kde.private.desktopcontainment.desktop 0.1 as Desktop import org.kde.private.desktopcontainment.folder 0.1 as Folder import org.kde.plasma.private.containmentlayoutmanager 1.0 as ContainmentLayoutManager import "code/FolderTools.js" as FolderTools FolderViewDropArea { id: root objectName: isFolder ? "folder" : "desktop" width: isPopup ? undefined : preferredWidth(false) // Initial size when adding to e.g. desktop. height: isPopup ? undefined : preferredHeight(false) // Initial size when adding to e.g. desktop. Layout.minimumWidth: preferredWidth(!isPopup) Layout.minimumHeight: preferredHeight(!isPopup) Layout.preferredWidth: preferredWidth(false) Layout.preferredHeight: preferredHeight(false) Layout.maximumWidth: isPopup ? preferredWidth(false) : -1 Layout.maximumHeight: isPopup ? preferredHeight(false) : -1 Plasmoid.switchWidth: { // Support expanding into the full representation only on vertical panels. if (isPopup && plasmoid.formFactor === PlasmaCore.Types.Vertical) { return units.iconSizeHints.panel; } return 0; } Plasmoid.switchHeight: { // Support expanding into the full representation only on vertical panels. if (isPopup && plasmoid.formFactor === PlasmaCore.Types.Vertical) { return units.iconSizeHints.panel; } return 0; } LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true property bool isFolder: (plasmoid.pluginName === "org.kde.plasma.folder") property bool isContainment: ("containmentType" in plasmoid) property bool isPopup: (plasmoid.location !== PlasmaCore.Types.Floating) property bool useListViewMode: isPopup && plasmoid.configuration.viewMode === 0 property Component appletAppearanceComponent property Item toolBox property int handleDelay: 800 property real haloOpacity: 0.5 property int iconSize: units.iconSizes.small property int iconWidth: iconSize property int iconHeight: iconWidth readonly property int hoverActivateDelay: 750 // Magic number that matches Dolphin's auto-expand folders delay. preventStealing: true // Plasmoid.title is set by a Binding {} in FolderViewLayer Plasmoid.toolTipSubText: "" Plasmoid.icon: (!plasmoid.configuration.useCustomIcon && folderViewLayer.ready) ? folderViewLayer.view.model.iconName : plasmoid.configuration.icon Plasmoid.compactRepresentation: (isFolder && !isContainment) ? compactRepresentation : null Plasmoid.associatedApplicationUrls: folderViewLayer.ready ? folderViewLayer.model.resolvedUrl : null onIconHeightChanged: updateGridSize() anchors { leftMargin: (isContainment && plasmoid.availableScreenRect) ? plasmoid.availableScreenRect.x : 0 topMargin: (isContainment && plasmoid.availableScreenRect) ? plasmoid.availableScreenRect.y : 0 rightMargin: (isContainment && plasmoid.availableScreenRect) && parent ? parent.width - (plasmoid.availableScreenRect.x + plasmoid.availableScreenRect.width) : 0 bottomMargin: (isContainment && plasmoid.availableScreenRect) && parent ? parent.height - (plasmoid.availableScreenRect.y + plasmoid.availableScreenRect.height) : 0 } Behavior on anchors.topMargin { NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutQuad } } Behavior on anchors.leftMargin { NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutQuad } } Behavior on anchors.rightMargin { NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutQuad } } Behavior on anchors.bottomMargin { NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutQuad } } function updateGridSize() { appletsLayout.cellWidth = root.iconWidth + toolBoxSvg.elementSize("left").width + toolBoxSvg.elementSize("right").width appletsLayout.cellHeight = root.iconHeight + toolBoxSvg.elementSize("top").height + toolBoxSvg.elementSize("bottom").height; appletsLayout.defaultItemWidth = appletsLayout.cellWidth * 6; appletsLayout.defaultItemHeight = appletsLayout.cellHeight * 6; } function addLauncher(desktopUrl) { if (!isFolder) { return; } folderViewLayer.view.linkHere(desktopUrl); } function preferredWidth(minimum) { if (isContainment || !folderViewLayer.ready) { return -1; } else if (useListViewMode) { return (minimum ? folderViewLayer.view.cellHeight * 4 : units.gridUnit * 16); } return (folderViewLayer.view.cellWidth * (minimum ? 1 : 3)) + (units.largeSpacing * 2); } function preferredHeight(minimum) { if (isContainment || !folderViewLayer.ready) { return -1; } else if (useListViewMode) { var height = (folderViewLayer.view.cellHeight * (minimum ? 1 : 15)) + units.smallSpacing; } else { var height = (folderViewLayer.view.cellHeight * (minimum ? 1 : 2)) + units.largeSpacing } if (plasmoid.configuration.labelMode !== 0) { height += folderViewLayer.item.labelHeight; } return height; } function isDrag(fromX, fromY, toX, toY) { var length = Math.abs(fromX - toX) + Math.abs(fromY - toY); return length >= Qt.styleHints.startDragDistance; } onFocusChanged: { if (focus && isFolder) { folderViewLayer.item.forceActiveFocus(); } } onDragEnter: { if (isContainment && plasmoid.immutable && !(isFolder && FolderTools.isFileDrag(event))) { event.ignore(); } // Don't allow any drops while listing. if (isFolder && folderViewLayer.view.status === Folder.FolderModel.Listing) { event.ignore(); } // Firefox tabs are regular drags. Since all of our drop handling is asynchronous // we would accept this drop and have Firefox not spawn a new window. (Bug 337711) if (event.mimeData.formats.indexOf("application/x-moz-tabbrowser-tab") > -1) { event.ignore(); } } onDragMove: { // TODO: We should reject drag moves onto file items that don't accept drops // (cf. QAbstractItemModel::flags() here, but DeclarativeDropArea currently // is currently incapable of rejecting drag events. // Trigger autoscroll. if (isFolder && FolderTools.isFileDrag(event)) { handleDragMove(folderViewLayer.view, mapToItem(folderViewLayer.view, event.x, event.y)); } else if (isContainment) { appletsLayout.showPlaceHolderAt( Qt.rect(event.x - appletsLayout.minimumItemWidth / 2, event.y - appletsLayout.minimumItemHeight / 2, appletsLayout.minimumItemWidth, appletsLayout.minimumItemHeight) ); } } onDragLeave: { // Cancel autoscroll. if (isFolder) { handleDragEnd(folderViewLayer.view); } if (isContainment) { appletsLayout.hidePlaceHolder(); } } onDrop: { if (isFolder && FolderTools.isFileDrag(event)) { handleDragEnd(folderViewLayer.view); folderViewLayer.view.drop(root, event, mapToItem(folderViewLayer.view, event.x, event.y)); } else if (isContainment) { plasmoid.processMimeData(event.mimeData, event.x - appletsLayout.placeHolder.width / 2, event.y - appletsLayout.placeHolder.height / 2); event.accept(event.proposedAction); appletsLayout.hidePlaceHolder(); } } Component { id: compactRepresentation CompactRepresentation { folderView: folderViewLayer.view } } Connections { target: plasmoid ignoreUnknownSignals: true onImmutableChanged: { if (root.isContainment && !plasmoid.immutable) { pressToMoveHelp.show(); } } } Connections { target: plasmoid.configuration onPressToMoveChanged: { if (plasmoid.configuration.pressToMove && plasmoid.configuration.pressToMoveHelp && !plasmoid.immutable) { pressToMoveHelp.show(); } } } Binding { target: toolBox property: "visible" value: plasmoid.configuration.showToolbox } Desktop.InfoNotification { id: pressToMoveHelp enabled: plasmoid.configuration.pressToMove && plasmoid.configuration.pressToMoveHelp iconName: "plasma" titleText: i18n("Widgets unlocked") text: i18n("You can press and hold widgets to move them and reveal their handles.") acknowledgeActionText: i18n("Got it") onAcknowledged: { plasmoid.configuration.pressToMoveHelp = false; } } PlasmaCore.FrameSvgItem { id : highlightItemSvg visible: false imagePath: isPopup ? "widgets/viewitem" : "" prefix: "hover" } PlasmaCore.FrameSvgItem { id : listItemSvg visible: false imagePath: isPopup ? "widgets/viewitem" : "" prefix: "normal" } PlasmaCore.Svg { id: toolBoxSvg imagePath: "widgets/toolbox" property int rightBorder: elementSize("right").width property int topBorder: elementSize("top").height property int bottomBorder: elementSize("bottom").height property int leftBorder: elementSize("left").width } // Can be removed? KQuickControlsAddons.EventGenerator { id: eventGenerator } Connections { target: plasmoid ignoreUnknownSignals: true onEditModeChanged: appletsLayout.editMode = plasmoid.editMode } ContainmentLayoutManager.AppletsLayout { id: appletsLayout anchors.fill: parent // NOTE: use plasmoid.availableScreenRect and not own width and height as they are updated not atomically configKey: plasmoid.availableScreenRect.width > plasmoid.availableScreenRect.height ? "ItemGeometriesHorizontal" : "ItemGeometriesVertical" containment: plasmoid editModeCondition: plasmoid.immutable ? ContainmentLayoutManager.AppletsLayout.Locked - : ContainmentLayoutManager.AppletsLayout.Manual + : ContainmentLayoutManager.AppletsLayout.AfterPressAndHold // Sets the containment in edit mode when we go in edit mode as well onEditModeChanged: plasmoid.editMode = editMode minimumItemWidth: units.gridUnit * 3 minimumItemHeight: minimumItemWidth cellWidth: units.iconSizes.small cellHeight: cellWidth appletContainerComponent: ContainmentLayoutManager.BasicAppletContainer { id: appletContainer editModeCondition: plasmoid.immutable ? ContainmentLayoutManager.ItemContainer.Locked : (plasmoid.configuration.pressToMove ? ContainmentLayoutManager.ItemContainer.AfterPressAndHold : ContainmentLayoutManager.ItemContainer.AfterMouseOver) configOverlayComponent: ConfigOverlay {} onUserDrag: { var pos = mapToItem(root.parent, dragCenter.x, dragCenter.y); var newCont = plasmoid.containmentAt(pos.x, pos.y); if (newCont && newCont !== plasmoid) { var newPos = newCont.mapFromApplet(plasmoid, pos.x, pos.y); newCont.addApplet(appletContainer.applet, newPos.x, newPos.y); appletsLayout.hidePlaceHolder(); } } } placeHolder: ContainmentLayoutManager.PlaceHolder {} Loader { id: folderViewLayer anchors.fill: parent property bool ready: status == Loader.Ready property Item view: item ? item.view : null property QtObject model: item ? item.model : null focus: true active: isFolder asynchronous: false source: "FolderViewLayer.qml" onFocusChanged: { if (!focus && model) { model.clearSelection(); } } Connections { target: folderViewLayer.view // `FolderViewDropArea` is not a FocusScope. We need to forward manually. onPressed: { folderViewLayer.forceActiveFocus(); } } } } Component.onCompleted: { if (!isContainment) { return; } // Customize the icon and text to improve discoverability plasmoid.setAction("configure", i18n("Configure Desktop..."), "preferences-desktop-wallpaper") // WORKAROUND: that's the only place where we can inject a sensible size. // if root has width defined, it will override the value we set before // the component completes root.width = plasmoid.width; updateGridSize(); } } diff --git a/containments/panel/contents/ui/main.qml b/containments/panel/contents/ui/main.qml index cc263f208..8e78c04fe 100644 --- a/containments/panel/contents/ui/main.qml +++ b/containments/panel/contents/ui/main.qml @@ -1,444 +1,444 @@ /* * Copyright 2013 Marco Martin * * 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 2.010-1301, USA. */ import QtQuick 2.1 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.kquickcontrolsaddons 2.0 import org.kde.draganddrop 2.0 as DragDrop import "LayoutManager.js" as LayoutManager DragDrop.DropArea { id: root width: 640 height: 48 //BEGIN properties Layout.minimumWidth: fixedWidth > 0 ? fixedWidth : (currentLayout.Layout.minimumWidth + (isHorizontal && toolBox ? toolBox.width : 0)) Layout.maximumWidth: fixedWidth > 0 ? fixedWidth : (currentLayout.Layout.maximumWidth + (isHorizontal && toolBox ? toolBox.width : 0)) Layout.preferredWidth: fixedWidth > 0 ? fixedWidth : (currentLayout.Layout.preferredWidth + (isHorizontal && toolBox ? toolBox.width : 0)) Layout.minimumHeight: fixedHeight > 0 ? fixedHeight : (currentLayout.Layout.minimumHeight + (!isHorizontal && toolBox ? toolBox.height : 0)) Layout.maximumHeight: fixedHeight > 0 ? fixedHeight : (currentLayout.Layout.maximumHeight + (!isHorizontal && toolBox ? toolBox.height : 0)) Layout.preferredHeight: fixedHeight > 0 ? fixedHeight : (currentLayout.Layout.preferredHeight + (!isHorizontal && toolBox? toolBox.height : 0)) property Item toolBox property var layoutManager: LayoutManager property Item dragOverlay property bool isHorizontal: plasmoid.formFactor !== PlasmaCore.Types.Vertical property int fixedWidth: 0 property int fixedHeight: 0 //END properties //BEGIN functions function addApplet(applet, x, y) { // don't show applet if it chooses to be hidden but still make it // accessible in the panelcontroller // Due to the nature of how "visible" propagates in QML, we need to // explicitly set it on the container (so the Layout ignores it) // as well as the applet (so it reliably knows about), otherwise it can // happen that an applet erroneously thinks it's visible, or suddenly // starts thinking that way on teardown (virtual desktop pager) // leading to crashes var visibleBinding = Qt.binding(function() { return applet.status !== PlasmaCore.Types.HiddenStatus || (!plasmoid.immutable && plasmoid.userConfiguring); }) var container = appletContainerComponent.createObject(root, { applet: applet, visible: visibleBinding }); applet.parent = container; applet.anchors.fill = container; applet.visible = visibleBinding; // Is there a DND placeholder? Replace it! if (dndSpacer.parent === currentLayout) { LayoutManager.insertBefore(dndSpacer, container); dndSpacer.parent = root; return; // If the provided position is valid, use it. } else if (x >= 0 && y >= 0) { var index = LayoutManager.insertAtCoordinates(container, x , y); // Fall through to determining an appropriate insert position. } else { var before = lastSpacer; container.animationsEnabled = false; // Insert icons to the left of whatever is at the center (usually a Task Manager), // if it exists. // FIXME TODO: This is a real-world fix to produce a sensible initial position for // launcher icons added by launcher menu applets. The basic approach has been used // since Plasma 1. However, "add launcher to X" is a generic-enough concept and // frequent-enough occurrence that we'd like to abstract it further in the future // and get rid of the ugliness of parties external to the containment adding applets // of a specific type, and the containment caring about the applet type. In a better // system the containment would be informed of requested launchers, and determine by // itself what it wants to do with that information. if (!startupTimer.running && applet.pluginName === "org.kde.plasma.icon") { var middle = currentLayout.childAt(root.width / 2, root.height / 2); if (middle) { before = middle; } // lastSpacer is here, enqueue before it. } LayoutManager.insertBefore(before, container); //event compress the enable of animations startupTimer.restart(); } } function checkLastSpacer() { var flexibleFound = false; for (var i = 0; i < currentLayout.children.length; ++i) { var applet = currentLayout.children[i].applet; if (!applet) { continue; } if (!applet.visible || !applet.Layout) { continue; } if ((root.isHorizontal && applet.Layout.fillWidth) || (!root.isHorizontal && applet.Layout.fillHeight)) { flexibleFound = true; break } } lastSpacer.visible= !flexibleFound; } //END functions //BEGIN connections Component.onCompleted: { currentLayout.isLayoutHorizontal = isHorizontal LayoutManager.plasmoid = plasmoid; LayoutManager.root = root; LayoutManager.layout = currentLayout; LayoutManager.lastSpacer = lastSpacer; LayoutManager.restore(); containmentSizeSyncTimer.restart(); plasmoid.action("configure").visible = Qt.binding(function() { return !plasmoid.immutable; }); plasmoid.action("configure").enabled = Qt.binding(function() { return !plasmoid.immutable; }); } onDragEnter: { if (plasmoid.immutable) { event.ignore(); return; } //during drag operations we disable panel auto resize if (root.isHorizontal) { root.fixedWidth = root.width } else { root.fixedHeight = root.height } LayoutManager.insertAtCoordinates(dndSpacer, event.x, event.y) } onDragMove: { LayoutManager.insertAtCoordinates(dndSpacer, event.x, event.y) } onDragLeave: { dndSpacer.parent = root; root.fixedWidth = 0; root.fixedHeight = 0; } onDrop: { plasmoid.processMimeData(event.mimeData, event.x, event.y); event.accept(event.proposedAction); root.fixedWidth = 0; root.fixedHeight = 0; containmentSizeSyncTimer.restart(); } Containment.onAppletAdded: { addApplet(applet, x, y); checkLastSpacer(); LayoutManager.save(); } Containment.onAppletRemoved: { LayoutManager.removeApplet(applet); checkLastSpacer(); LayoutManager.save(); } Plasmoid.onUserConfiguringChanged: { if (plasmoid.immutable) { if (dragOverlay) { dragOverlay.destroy(); } return; } if (plasmoid.userConfiguring) { for (var i = 0; i < plasmoid.applets.length; ++i) { plasmoid.applets[i].expanded = false; } if (!dragOverlay) { var component = Qt.createComponent("ConfigOverlay.qml"); if (component.status === Component.Ready) { dragOverlay = component.createObject(root); } else { console.log("Could not create ConfigOverlay:", component.errorString()); } component.destroy(); } else { dragOverlay.visible = true; } } else { dragOverlay.destroy(); } } Plasmoid.onFormFactorChanged: containmentSizeSyncTimer.restart(); - Plasmoid.onImmutableChanged: containmentSizeSyncTimer.restart(); + Containment.onEditModeChanged: containmentSizeSyncTimer.restart(); onToolBoxChanged: { containmentSizeSyncTimer.restart(); if (startupTimer.running) { startupTimer.restart(); } } //END connections //BEGIN components Component { id: appletContainerComponent // This loader conditionally manages the BusyIndicator, it's not // loading the applet. The applet becomes a regular child item. Loader { id: container visible: false property bool animationsEnabled: true //when the applet moves caused by its resize, don't animate. //this is completely heuristic, but looks way less "jumpy" property bool movingForResize: false Layout.fillWidth: applet && applet.Layout.fillWidth Layout.onFillWidthChanged: { if (plasmoid.formFactor !== PlasmaCore.Types.Vertical) { checkLastSpacer(); } } Layout.fillHeight: applet && applet.Layout.fillHeight Layout.onFillHeightChanged: { if (plasmoid.formFactor === PlasmaCore.Types.Vertical) { checkLastSpacer(); } } Layout.minimumWidth: (currentLayout.isLayoutHorizontal ? (applet && applet.Layout.minimumWidth > 0 ? applet.Layout.minimumWidth : root.height) : root.width) Layout.minimumHeight: (!currentLayout.isLayoutHorizontal ? (applet && applet.Layout.minimumHeight > 0 ? applet.Layout.minimumHeight : root.width) : root.height) Layout.preferredWidth: (currentLayout.isLayoutHorizontal ? (applet && applet.Layout.preferredWidth > 0 ? applet.Layout.preferredWidth : root.height) : root.width) Layout.preferredHeight: (!currentLayout.isLayoutHorizontal ? (applet && applet.Layout.preferredHeight > 0 ? applet.Layout.preferredHeight : root.width) : root.height) Layout.maximumWidth: (currentLayout.isLayoutHorizontal ? (applet && applet.Layout.maximumWidth > 0 ? applet.Layout.maximumWidth : (Layout.fillWidth ? root.width : root.height)) : root.height) Layout.maximumHeight: (!currentLayout.isLayoutHorizontal ? (applet && applet.Layout.maximumHeight > 0 ? applet.Layout.maximumHeight : (Layout.fillHeight ? root.height : root.width)) : root.width) property int oldX: x property int oldY: y property Item applet onAppletChanged: { if (!applet) { destroy(); } } active: applet && applet.busy sourceComponent: PlasmaComponents.BusyIndicator {} Layout.onMinimumWidthChanged: movingForResize = true; Layout.onMinimumHeightChanged: movingForResize = true; Layout.onMaximumWidthChanged: movingForResize = true; Layout.onMaximumHeightChanged: movingForResize = true; onXChanged: { if (movingForResize) { movingForResize = false; return; } if (!animationsEnabled) { startupTimer.restart(); return; } translation.x = oldX - x translation.y = oldY - y translAnim.running = true oldX = x oldY = y } onYChanged: { if (movingForResize) { movingForResize = false; return; } if (!animationsEnabled) { startupTimer.restart(); return; } translation.x = oldX - x translation.y = oldY - y translAnim.running = true oldX = x oldY = y } transform: Translate { id: translation } NumberAnimation { id: translAnim duration: units.longDuration easing.type: Easing.InOutQuad target: translation properties: "x,y" to: 0 } } } //END components //BEGIN UI elements Item { id: lastSpacer parent: currentLayout Layout.fillWidth: true Layout.fillHeight: true } Item { id: dndSpacer Layout.preferredWidth: width Layout.preferredHeight: height width: (plasmoid.formFactor === PlasmaCore.Types.Vertical) ? currentLayout.width : theme.mSize(theme.defaultFont).width * 10 height: (plasmoid.formFactor === PlasmaCore.Types.Vertical) ? theme.mSize(theme.defaultFont).width * 10 : currentLayout.height } // while the user is moving the applet when configuring the panel, the applet is reparented // here so it can be moved freely; previously it was reparented to "root" but this one does not // take into account the toolbox (which is left-of) the layout in right-to-left languages Item { id: moveAppletLayer anchors.fill: currentLayout } GridLayout { id: currentLayout property bool isLayoutHorizontal rowSpacing: units.smallSpacing columnSpacing: units.smallSpacing Layout.preferredWidth: { var width = 0; for (var i = 0, length = currentLayout.children.length; i < length; ++i) { var item = currentLayout.children[i]; if (item.Layout) { width += Math.max(item.Layout.minimumWidth, item.Layout.preferredWidth); } } return width; } Layout.preferredHeight: { var height = 0; for (var i = 0, length = currentLayout.children.length; i < length; ++i) { var item = currentLayout.children[i]; if (item.Layout) { height += Math.max(item.Layout.minimumHeight, item.Layout.preferredHeight); } } return height; } rows: 1 columns: 1 //when horizontal layout top-to-bottom, this way it will obey our limit of one row and actually lay out left to right flow: isHorizontal ? GridLayout.TopToBottom : GridLayout.LeftToRight layoutDirection: Qt.application.layoutDirection } onWidthChanged: { containmentSizeSyncTimer.restart() if (startupTimer.running) { startupTimer.restart(); } } onHeightChanged: { containmentSizeSyncTimer.restart() if (startupTimer.running) { startupTimer.restart(); } } Timer { id: containmentSizeSyncTimer interval: 150 onTriggered: { dndSpacer.parent = root; - currentLayout.x = (isHorizontal && toolBox && Qt.application.layoutDirection === Qt.RightToLeft && !plasmoid.immutable) ? toolBox.width : 0; + currentLayout.x = (isHorizontal && toolBox && Qt.application.layoutDirection === Qt.RightToLeft && plasmoid.editMode) ? toolBox.width : 0; currentLayout.y = 0 - currentLayout.width = root.width - (isHorizontal && toolBox && !plasmoid.immutable ? toolBox.width : 0) - currentLayout.height = root.height - (!isHorizontal && toolBox && !plasmoid.immutable ? toolBox.height : 0) + currentLayout.width = root.width - (isHorizontal && toolBox && plasmoid.editMode ? toolBox.width : 0) + currentLayout.height = root.height - (!isHorizontal && toolBox && plasmoid.editMode ? toolBox.height : 0) currentLayout.isLayoutHorizontal = isHorizontal } } //FIXME: I don't see other ways at the moment a way to see when the UI is REALLY ready Timer { id: startupTimer interval: 4000 onTriggered: { for (var i = 0; i < currentLayout.children.length; ++i) { var item = currentLayout.children[i]; if (item.hasOwnProperty("animationsEnabled")) { item.animationsEnabled = true; } } } } //END UI elements } diff --git a/toolboxes/desktoptoolbox/contents/ui/ToolBoxButton.qml b/toolboxes/desktoptoolbox/contents/ui/ToolBoxButton.qml index 8d3ed4e56..238d1ce7c 100644 --- a/toolboxes/desktoptoolbox/contents/ui/ToolBoxButton.qml +++ b/toolboxes/desktoptoolbox/contents/ui/ToolBoxButton.qml @@ -1,309 +1,279 @@ /*************************************************************************** * Copyright 2012,2015 by Sebastian Kügler * * Copyright 2015 by Kai Uwe Broulik * * * * 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.4 +import QtQuick.Layouts 1.4 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons import org.kde.plasma.plasmoid 2.0 Item { id: toolBoxButton - property string text: main.Plasmoid.activityName === i18n("Default") ? i18n("Desktop Toolbox") : i18n("Desktop Toolbox — %1 Activity", main.Plasmoid.activityName) - property bool isCorner: !buttonMouse.dragging && - ((state == "topleft") || (state == "topright") || - (state == "bottomright") || (state == "bottomleft")) property bool isHorizontal: (state != "left" && state != "right") rotation: switch(state) { case "left": return -90; case "right": return 90; default: return 0; } transform: Translate { - x: state == "left" ? Math.round(-width/2 + height/2) : state == "right" ? + Math.round(width/2 - height/2) : 0 + x: state == "left" ? Math.round(-width/2 + height/2) - (plasmoid.editMode ? 0: height) + : state == "right" ? + Math.round(width/2 - height/2) + (plasmoid.editMode ? 0 : height) + : 0 + + y: plasmoid.editMode ? 0 + : state == "top" ? -height + : state == "bottom" ? height + : 0 Behavior on x { NumberAnimation { - duration: units.shortDuration * 3; - easing.type: Easing.InOutExpo; + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + Behavior on y { + NumberAnimation { + duration: units.longDuration + easing.type: Easing.InOutQuad } } } transformOrigin: Item.Center + opacity: plasmoid.editMode + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + enabled: visible + } Behavior on rotation { NumberAnimation { duration: units.shortDuration * 3; easing.type: Easing.InOutExpo; } enabled: visible } Behavior on x { NumberAnimation { duration: units.shortDuration * 3; easing.type: Easing.InOutExpo; } enabled: visible } Behavior on y { NumberAnimation { duration: units.shortDuration * 3; easing.type: Easing.InOutExpo; } enabled: visible } clip: backgroundFrameWidthAnimation.running width: backgroundFrame.width + backgroundFrame.width % 2 height: backgroundFrame.height + backgroundFrame.height % 2 //x and y default to 0, so top left would be correct //If the position is anything else it will updated via onXChanged during initialization state: "topleft" onXChanged: stateTimer.restart() onYChanged: stateTimer.restart() Timer { id: stateTimer interval: 100 onTriggered: updateState() } function updateState() { var container = main; //print(" w: " + container.width +"x"+container.height+" : "+x+"/"+y+" tbw: " + toolBoxButton.width); var x = toolBoxButton.x - main.x; var y = toolBoxButton.y - main.y; var cornerSnap = iconWidth - if (x < cornerSnap && y < cornerSnap) { - toolBoxButton.state = "topleft"; - } else if (container.width - x - buttonLayout.width < cornerSnap && y < cornerSnap) { - toolBoxButton.state = "topright"; - } else if (container.width - x - buttonLayout.width < cornerSnap && container.height - y - buttonLayout.width < cornerSnap) { - toolBoxButton.state = "bottomright"; - } else if (x < cornerSnap && container.height - y - buttonLayout.width < cornerSnap) { - toolBoxButton.state = "bottomleft"; //top diagonal half - } else if (x > (y * (container.width/container.height))) { + if (x > (y * (container.width/container.height))) { //Top edge if (container.width - x > y ) { toolBoxButton.state = "top"; //right edge } else { //toolBoxButton.transformOrigin = Item.BottomRight toolBoxButton.state = "right"; } //bottom diagonal half } else { //Left edge if (container.height - y > x ) { //toolBoxButton.transformOrigin = Item.TopLeft toolBoxButton.state = "left"; //Bottom edge } else { toolBoxButton.state = "bottom"; } } if (!buttonMouse.pressed) { main.placeToolBox(toolBoxButton.state); } stateTimer.running = false; } PlasmaCore.FrameSvgItem { id: backgroundFrame anchors { left: parent.left top: parent.top } imagePath: "widgets/translucentbackground" - opacity: buttonMouse.containsMouse || (toolBoxLoader.item && toolBoxLoader.item.visible) ? 1.0 : 0.4 - width: Math.round((isCorner ? buttonLayout.height : buttonLayout.width) + margins.horizontal) + width: Math.round(buttonLayout.width + margins.horizontal) height: Math.round(buttonLayout.height + margins.vertical) Behavior on width { NumberAnimation { id: backgroundFrameWidthAnimation duration: units.longDuration; easing.type: Easing.InOutQuad; } } Behavior on opacity { NumberAnimation { duration: units.longDuration; } } } - Row { - id: buttonLayout - anchors.centerIn: parent - height: Math.max(toolBoxIcon.height, fontMetrics.height) - spacing: units.smallSpacing - - Behavior on x { - NumberAnimation { - duration: units.longDuration; - easing.type: Easing.InOutQuad; - } - } - - PlasmaCore.SvgItem { - id: toolBoxIcon - svg: PlasmaCore.Svg { - id: iconSvg - imagePath: "widgets/configuration-icons" - onRepaintNeeded: toolBoxIcon.elementId = iconSvg.hasElement("menu") ? "menu" : "configure" - } - elementId: iconSvg.hasElement("menu") ? "menu" : "configure" - anchors.verticalCenter: parent.verticalCenter - width: iconSize - height: iconSize - opacity: buttonMouse.containsMouse || (toolBoxLoader.item && toolBoxLoader.item.visible) ? 1 : 0.5 - rotation: isHorizontal ? 0 : -90; - transformOrigin: Item.Center - Behavior on opacity { - NumberAnimation { - duration: units.longDuration; - easing.type: Easing.InOutExpo; - } - } - } - - PlasmaComponents.Label { - id: activityName - anchors.verticalCenter: parent.verticalCenter - opacity: isCorner ? 0 : 1 - text: toolBoxButton.text - visible: opacity - Behavior on opacity { - //only have this animation when going from hidden -> shown - enabled: activityName.opacity == 0 - - SequentialAnimation { - //pause to allow the toolbox frame to resize - //otherwise we see the text overflow the box - //whilst that animates - PauseAnimation { - duration: units.longDuration - } - NumberAnimation { - duration: units.shortDuration - easing.type: Easing.InOutExpo - } - } - } - } - - FontMetrics { - id: fontMetrics - font: activityName.font - } - } - MouseArea { id: buttonMouse property QtObject container: main property int pressedX property int pressedY property bool dragging: false - anchors { - fill: parent - margins: -10 - } + anchors.fill: parent drag { + filterChildren: true target: main.Plasmoid.immutable ? undefined : toolBoxButton minimumX: 0 - maximumX: container.width - toolBoxIcon.width + maximumX: container.width - toolBoxButton.width minimumY: 0 - maximumY: container.height - toolBoxIcon.height + maximumY: container.height - toolBoxButton.height } hoverEnabled: true onPressed: { pressedX = toolBoxButton.x pressedY = toolBoxButton.y } onPositionChanged: { if (pressed && (Math.abs(toolBoxButton.x - pressedX) > iconSize || Math.abs(toolBoxButton.y - pressedY) > iconSize)) { dragging = true; } } - onClicked: { - // the dialog auto-closes on losing focus - main.open = !main.dialogWasVisible - plasmoid.focus = true; - } + onReleased: { main.Plasmoid.configuration.ToolBoxButtonState = toolBoxButton.state; main.Plasmoid.configuration.ToolBoxButtonX = toolBoxButton.x; main.Plasmoid.configuration.ToolBoxButtonY = toolBoxButton.y; //print("Saved coordinates for ToolBox in config: " + toolBoxButton.x + ", " +toolBoxButton.x); if (dragging) { main.placeToolBox(); } dragging = false; stateTimer.stop(); updateState(); } onCanceled: dragging = false; + + RowLayout { + id: buttonLayout + anchors.centerIn: parent + spacing: units.smallSpacing + + + PlasmaComponents3.ToolButton { + property QtObject qAction: plasmoid.action("add widgets") + text: qAction.text + icon.name: "list-add" + icon.height: units.iconSizes.smallMedium + onClicked: qAction.trigger() + } + PlasmaComponents3.ToolButton { + property QtObject qAction: plasmoid.globalAction("manage activities") + text: qAction.text + icon.name: "activities" + icon.height: units.iconSizes.smallMedium + onClicked: qAction.trigger() + } + PlasmaComponents3.ToolButton { + property QtObject qAction: plasmoid.action("lock widgets") + text: qAction.text + icon.name: "lock" + icon.height: units.iconSizes.smallMedium + onClicked: qAction.trigger() + } + PlasmaComponents3.ToolButton { + property QtObject qAction: plasmoid.action("configure") + text: qAction.text + icon.name: "preferences-desktop-wallpaper" + icon.height: units.iconSizes.smallMedium + onClicked: qAction.trigger() + } + PlasmaComponents3.ToolButton { + icon.name: "window-close" + icon.height: units.iconSizes.smallMedium + onClicked: plasmoid.editMode = false + PlasmaComponents3.ToolTip { + text: i18n("Close Edit Mode") + } + } + } } states: [ - State { - name: "topleft" - }, State { name: "top" }, - State { - name: "topright" - }, State { name: "right" }, - State { - name: "bottomright" - }, State { name: "bottom" }, - State { - name: "bottomleft" - }, State { name: "left" } ] } diff --git a/toolboxes/desktoptoolbox/contents/ui/ToolBoxItem.qml b/toolboxes/desktoptoolbox/contents/ui/ToolBoxItem.qml deleted file mode 100644 index c0ca5c1ea..000000000 --- a/toolboxes/desktoptoolbox/contents/ui/ToolBoxItem.qml +++ /dev/null @@ -1,158 +0,0 @@ -/*************************************************************************** - * Copyright 2012 by Sebastian Kügler * - * Copyright 2015 by Kai Uwe Broulik * - * * - * 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.0 -import QtQuick.Layouts 1.1 - -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.components 2.0 as PlasmaComponents - -ListView { - id: menu - width: units.gridUnit * 14 - height: contentHeight - - currentIndex: -1 - focus: true - keyNavigationWraps: true - - onVisibleChanged: currentIndex = -1 - - // needs to be on released, otherwise Dashboard hides because it already gained focus - // because of the dialog closing right on the key *press* event - Keys.onReleased: { - if (event.key === Qt.Key_Escape) { - main.open = false - event.accepted = true - } - } - - Keys.onPressed: { - if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { - if (currentIndex >= 0) { - if (model[currentIndex].operation) { - performOperation(model[currentIndex].operation) - } else { - model[currentIndex].trigger() - } - } - main.open = false - event.accepted = true - } - } - - function performOperation(what) { - var service = dataEngine.serviceForSource("PowerDevil"); - var operation = service.operationDescription(what); - return service.startOperationCall(operation); - } - - highlightMoveDuration: 0 - highlightResizeDuration: 0 - highlight: PlasmaComponents.Highlight { } - - PlasmaCore.DataSource { - id: dataEngine - engine: "powermanagement" - connectedSources: ["PowerDevil", "Sleep States"] - } - - model: { - var model = [] - var actions = plasmoid.actions - for (var i = 0, j = actions.length; i < j; ++i) { - var action = actions[i] - if (action && action.visible && action.text !== "") { - model.push(action) - } - } - - if (dataEngine.data["Sleep States"].LockScreen) { - model.push({ - text: i18nd("plasma_toolbox_org.kde.desktoptoolbox", "Lock Screen"), - icon: "system-lock-screen", - visible: true, - enabled: true, - operation: "lockScreen" - }) - } - - if (dataEngine.data["Sleep States"].Logout) { - model.push({ - text: i18nd("plasma_toolbox_org.kde.desktoptoolbox", "Leave"), - icon: "system-log-out", - visible: true, - enabled: true, - operation: "requestShutDown" // cannot put function() into a model :( - }) - } - - return model - } - - delegate: MouseArea { - width: menu.width - height: labelRow.implicitHeight + units.smallSpacing * 2 - hoverEnabled: true - enabled: modelData.enabled - opacity: modelData.enabled ? 1 : 0.5 - - onEntered: menu.currentIndex = index - onExited: menu.currentIndex = -1 - - onClicked: { - main.open = false - if (modelData.operation) { - performOperation(modelData.operation) - } else { - modelData.trigger() - } - } - - Accessible.role: Accessible.MenuItem - Accessible.name: textLabel.text - - RowLayout { - id: labelRow - anchors { - left: parent.left - right: parent.right - margins: units.smallSpacing - verticalCenter: parent.verticalCenter - } - spacing: units.smallSpacing - - PlasmaCore.IconItem { - implicitWidth: units.iconSizes.smallMedium - implicitHeight: implicitWidth - source: modelData.icon - Accessible.ignored: true - } - - PlasmaComponents.Label { - id: textLabel - Layout.fillWidth: true - text: modelData.text.replace("&", "") // hack to get rid of keyboard accelerator hints - elide: Text.ElideRight - Accessible.ignored: true - } - } - } -} diff --git a/toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml b/toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml index c27229341..be6ccc0a0 100644 --- a/toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml +++ b/toolboxes/desktoptoolbox/contents/ui/ToolBoxRoot.qml @@ -1,202 +1,116 @@ /* * Copyright 2011 Sebastian Kügler * Copyright 2011 Marco Martin * Copyright 2015 Kai Uwe Broulik * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 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 Library General Public License for more details * * You should have received a copy of the GNU Library 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.2 import QtQuick.Window 2.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddons import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.plasmoid 2.0 Item { id: main objectName: "org.kde.desktoptoolbox" z: 999 anchors.fill: parent Connections { target: plasmoid onAvailableScreenRegionChanged: placeToolBoxTimer.restart(); } - //FIXME: this timer shouldn't exist, but unfortunately when the focus passes - //from the desktop to the dialog or vice versa, the event is not atomic - //and ends up with neither of those having focus, hiding the dialog when - //it shouldn't - Timer { - id: hideDialogTimer - interval: 0 - //NOTE: it's checking activeFocusItem instead of active as active doesn't correctly signal its change - property bool desktopOrDialogFocus: main.Window.activeFocusItem !== null || (toolBoxLoader.item && toolBoxLoader.item.activeFocusItem !== null) - onDesktopOrDialogFocusChanged: { - if (!desktopOrDialogFocus) { - hideDialogTimer.restart(); - } - - } - onTriggered: { - if (!desktopOrDialogFocus) { - open = false; - } - } - } - signal minimumWidthChanged signal minimumHeightChanged signal maximumWidthChanged signal maximumHeightChanged signal preferredWidthChanged signal preferredHeightChanged property int iconSize: units.iconSizes.small property int iconWidth: units.iconSizes.smallMedium property int iconHeight: iconWidth property bool dialogWasVisible: false property bool open: false - onOpenChanged: { - plasmoid.editMode = open - if (open) { - plasmoid.contextualActionsAboutToShow(); - - toolBoxLoader.active = true; - toolBoxLoader.item.visible = true; - } else { - toolBoxLoader.item.visible = false; - } - } onWidthChanged: placeToolBoxTimer.restart(); onHeightChanged: placeToolBoxTimer.restart(); LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft) LayoutMirroring.childrenInherit: true - onVisibleChanged: { - if (!visible && toolBoxLoader.item) { - toolBoxLoader.item.visible = false - } - } - ToolBoxButton { id: toolBoxButton visible: false Component.onCompleted: { placeToolBox(plasmoid.configuration.ToolBoxButtonState); toolBoxButton.visible = true } } Timer { id: placeToolBoxTimer interval: 100 repeat: false running: false onTriggered: { placeToolBox(plasmoid.configuration.ToolBoxButtonState); } } - Loader { - id: toolBoxLoader - active: false - sourceComponent: PlasmaCore.Dialog { - id: dialog - flags: Qt.WindowStaysOnTopHint - location: PlasmaCore.Types.Floating - visualParent: toolBoxButton - // hideOnWindowDeactivate: true - mainItem: ToolBoxItem { - LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft - LayoutMirroring.childrenInherit: true - - Timer { - id: visibleTimer - interval: 300 - onTriggered: main.dialogWasVisible = dialog.visible - } - } - onVisibleChanged: visibleTimer.restart(); - } - } - function placeToolBox(ts) { // if nothing has been setup yet, determine default position based on layout direction if (!ts) { - if (Qt.application.layoutDirection === Qt.RightToLeft) { - placeToolBox("topleft"); - } else { - placeToolBox("topright"); - } + placeToolBox("top"); return; } var tx = Plasmoid.configuration.ToolBoxButtonX var ty = Plasmoid.configuration.ToolBoxButtonY var pos; switch (ts) { case "top": ty = main.y; pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.width, toolBoxButton.height); break; case "left": tx = main.x; pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.width, toolBoxButton.height); break; case "right": tx = main.width + main.x - toolBoxButton.width; pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.width, toolBoxButton.height); break; case "bottom": - ty = main.height + main.y - toolBoxButton.height; - pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.width, toolBoxButton.height); - break; - case "topleft": - tx = main.x; - ty = main.y; - pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.height, toolBoxButton.height); - break; - case "topright": - tx = main.width + main.x - toolBoxButton.height; - ty = main.y; - pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.height, toolBoxButton.height); - break; - case "bottomleft": - tx = main.x; - ty = main.height + main.y - toolBoxButton.height; - pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.height, toolBoxButton.height); - break; - case "bottomright": default: - tx = main.width + main.x - toolBoxButton.height; ty = main.height + main.y - toolBoxButton.height; - pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.height, toolBoxButton.height); + pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxButton.width, toolBoxButton.height); break; } //print("XXXY Setting toolbox to: " + ts + " " + tx + "x" + ty + " screen: " + main.width+ "x" + main.height+""); toolBoxButton.x = pos.x; toolBoxButton.y = pos.y; } } diff --git a/toolboxes/paneltoolbox/contents/ui/main.qml b/toolboxes/paneltoolbox/contents/ui/main.qml index daaca6319..6eed96eac 100644 --- a/toolboxes/paneltoolbox/contents/ui/main.qml +++ b/toolboxes/paneltoolbox/contents/ui/main.qml @@ -1,93 +1,93 @@ /* * Copyright 2011 Sebastian Kügler * Copyright 2013 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 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 Library General Public License for more details * * You should have received a copy of the GNU Library 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.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.plasmoid 2.0 Item { id: main width: isVertical ? units.iconSizes.medium : units.iconSizes.smallMedium + units.smallSpacing * 2 height: isVertical ? units.iconSizes.smallMedium + units.smallSpacing * 2 : units.iconSizes.medium property bool isVertical: plasmoid.formFactor === 3 - opacity: plasmoid.immutable ? 0 : (mouseArea.containsMouse || plasmoid.userConfiguring ? 1 : 0.5) + opacity: plasmoid.editMode ? (mouseArea.containsMouse || plasmoid.userConfiguring ? 1 : 0.5) : 0 z: 999 Behavior on opacity { NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutExpo; } } LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft) anchors { left: undefined top: undefined right: isVertical || !parent ? undefined : parent.right bottom: isVertical && parent ? parent.bottom : undefined verticalCenter: isVertical || !parent ? undefined : parent.verticalCenter horizontalCenter: isVertical && parent ? parent.horizontalCenter : undefined } PlasmaCore.SvgItem { id: toolBoxIcon svg: PlasmaCore.Svg { id: iconSvg imagePath: "widgets/configuration-icons" } elementId: "configure" anchors.centerIn: mouseArea width: units.iconSizes.small height: width } Connections { target: plasmoid onUserConfiguringChanged: { plasmoid.editMode = plasmoid.userConfiguring; if (plasmoid.userConfiguring) { toolTipArea.hideToolTip(); } } } MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: enabled enabled: !plasmoid.immutable onClicked: { main.Plasmoid.action("configure").trigger() } PlasmaCore.ToolTipArea { id: toolTipArea anchors.fill: parent mainText: i18nd("plasma_toolbox_org.kde.paneltoolbox", "Configure Panel...") icon: "configure" enabled: mouseArea.containsMouse } } }