/*SPDX-FileCopyrightText: 2011 Sebastian KΓΌgler <sebas@kde.org>SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org>SPDX-FileCopyrightText: 2015 Kai Uwe Broulik <kde@privat.broulik.de>SPDX-License-Identifier: LGPL-2.0-or-later*/import QtQuick 2.2import QtQuick.Window 2.2import org.kde.plasma.core 2.0 as PlasmaCoreimport 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: parentproperty Item toolBoxContentConnections {target: plasmoidfunction onAvailableScreenRegionChanged() {placeToolBoxTimer.restart();}}property int iconSize: PlasmaCore.Units.iconSizes.smallproperty int iconWidth: PlasmaCore.Units.iconSizes.smallMediumproperty int iconHeight: iconWidthproperty bool dialogWasVisible: falseproperty bool open: falseonWidthChanged: placeToolBoxTimer.restart();onHeightChanged: placeToolBoxTimer.restart();LayoutMirroring.enabled: (Qt.application.layoutDirection === Qt.RightToLeft)LayoutMirroring.childrenInherit: truePlasmoid.onEditModeChanged: {if (!Plasmoid.editMode) {toolBoxContent.exitAnimation.start();return;}const component = Qt.createComponent(Qt.resolvedUrl("./ToolBoxContent.qml"), main);toolBoxContent = component.createObject(main);component.destroy();placeToolBox(Plasmoid.configuration.ToolBoxButtonState);toolBoxContent.enterAnimation.start();}Timer {id: placeToolBoxTimerinterval: 100repeat: falserunning: falseonTriggered: {placeToolBox(plasmoid.configuration.ToolBoxButtonState);}}function placeToolBox(ts) {if (!main.toolBoxContent) {return;}// if nothing has been setup yet, determine default position based on layout directionif (!ts) {placeToolBox("topcenter");return;}var tx = Plasmoid.configuration.ToolBoxButtonXvar ty = Plasmoid.configuration.ToolBoxButtonYvar pos;switch (ts) {case "top":ty = main.y;pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxContent.width, toolBoxContent.height);break;case "bottom":ty = main.height + main.y - toolBoxContent.height;pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxContent.width, toolBoxContent.height);break;case "bottomcenter":tx = main.width / 2 - toolBoxContent.width / 2;ty = main.height + main.y - toolBoxContent.height;pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxContent.width, toolBoxContent.height);break;case "topcenter":default:tx = main.width / 2 - toolBoxContent.width / 2;ty = main.y;pos = plasmoid.adjustToAvailableScreenRegion(tx, ty, toolBoxContent.width, toolBoxContent.height);break;}//print("XXXY Setting toolbox to: " + ts + " " + tx + "x" + ty + " screen: " + main.width+ "x" + main.height+"");toolBoxContent.x = pos.x;toolBoxContent.y = pos.y;}}