/** Copyright 2011 Sebastian KΓΌgler <sebas@kde.org>* Copyright 2011 Marco Martin <mart@kde.org>* Copyright 2015 Kai Uwe Broulik <kde@privat.broulik.de>** 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.0import org.kde.plasma.core 2.0 as PlasmaCoreimport org.kde.plasma.components 2.0 as PlasmaComponentsimport org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddonsimport org.kde.plasma.extras 2.0 as PlasmaExtrasimport org.kde.plasma.plasmoid 2.0Item {id: mainobjectName: "org.kde.desktoptoolbox"z: 999anchors.fill: parentConnections {target: plasmoidonAvailableScreenRegionChanged: placeToolBoxTimer.restart();}signal minimumWidthChangedsignal minimumHeightChangedsignal maximumWidthChangedsignal maximumHeightChangedsignal preferredWidthChangedsignal preferredHeightChangedproperty int iconSize: units.iconSizes.smallproperty int iconWidth: units.iconSizes.smallMediumproperty int iconHeight: iconWidthproperty bool dialogWasVisible: falseonWidthChanged: placeToolBoxTimer.restart();onHeightChanged: placeToolBoxTimer.restart();LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft)LayoutMirroring.childrenInherit: trueToolBoxButton {id: toolBoxButtonvisible: falseComponent.onCompleted: {placeToolBox(plasmoid.configuration.ToolBoxButtonState);toolBoxButton.visible = true}}Timer {id: placeToolBoxTimerinterval: 100repeat: falserunning: falseonTriggered: {placeToolBox(plasmoid.configuration.ToolBoxButtonState);}}Loader {id: toolBoxLoaderactive: falsesourceComponent: PlasmaCore.Dialog {flags: Qt.WindowStaysOnTopHintlocation: PlasmaCore.Types.FloatingvisualParent: toolBoxButtonhideOnWindowDeactivate: truemainItem: ToolBoxItem {id: dialogTimer {id: visibleTimerinterval: 300onTriggered: main.dialogWasVisible = dialog.visible}}onVisibleChanged: visibleTimer.restart();}}function placeToolBox(ts) {var tx = Plasmoid.configuration.ToolBoxButtonXvar ty = Plasmoid.configuration.ToolBoxButtonYvar 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);break;}//print("XXXY Setting toolbox to: " + ts + " " + tx + "x" + ty + " screen: " + main.width+ "x" + main.height+"");toolBoxButton.x = pos.x;toolBoxButton.y = pos.y;}}