/* Copyright (C) 2011 Martin Gräßlin Copyright (C) 2012 Gregor Taetzner Copyright (C) 2012 Marco Martin Copyright (C) 2013 David Edmundson Copyright (C) 2015 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 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid import org.kde.plasma.core as PlasmaCore import org.kde.plasma.components as PlasmaComponents import org.kde.plasma.extras as PlasmaExtras import org.kde.kquickcontrolsaddons import org.kde.plasma.private.kicker 0.1 as Kicker PlasmoidItem { id: kickoff readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge || plasmoid.location === PlasmaCore.Types.RightEdge || plasmoid.location === PlasmaCore.Types.BottomEdge || plasmoid.location === PlasmaCore.Types.LeftEdge) readonly property bool vertical: (plasmoid.formFactor === PlasmaCore.Types.Vertical) Plasmoid.switchWidth: PlasmaCore.Units.gridUnit * 20 Plasmoid.switchHeight: PlasmaCore.Units.gridUnit * 30 Plasmoid.fullRepresentation: FullRepresentation {} Plasmoid.icon: plasmoid.configuration.icon Plasmoid.compactRepresentation: MouseArea { id: compactRoot Layout.minimumWidth: { if (!inPanel) { return PlasmaCore.Units.iconSizeHints.panel; } if (vertical) { return -1; } else { return Math.min(PlasmaCore.Units.iconSizeHints.panel, parent.height) * buttonIcon.aspectRatio; } } Layout.minimumHeight: { if (!inPanel) { return PlasmaCore.Units.iconSizeHints.panel; } if (vertical) { return Math.min(PlasmaCore.Units.iconSizeHints.panel, parent.width) * buttonIcon.aspectRatio; } else { return -1; } } Layout.maximumWidth: { if (!inPanel) { return -1; } if (vertical) { return PlasmaCore.Units.iconSizeHints.panel; } else { return Math.min(PlasmaCore.Units.iconSizeHints.panel, parent.height) * buttonIcon.aspectRatio; } } Layout.maximumHeight: { if (!inPanel) { return -1; } if (vertical) { return Math.min(PlasmaCore.Units.iconSizeHints.panel, parent.width) * buttonIcon.aspectRatio; } else { return PlasmaCore.Units.iconSizeHints.panel; } } hoverEnabled: true onClicked: plasmoid.expanded = !plasmoid.expanded DropArea { id: compactDragArea anchors.fill: parent } Timer { id: expandOnDragTimer interval: 250 running: compactDragArea.containsDrag onTriggered: plasmoid.expanded = true } PlasmaCore.IconItem { id: buttonIcon readonly property double aspectRatio: (vertical ? implicitHeight / implicitWidth : implicitWidth / implicitHeight) anchors.fill: parent source: plasmoid.icon active: parent.containsMouse || compactDragArea.containsDrag smooth: true roundToIconSize: aspectRatio === 1 } } property Item dragSource: null Kicker.ProcessRunner { id: processRunner; } function action_menuedit() { processRunner.runMenuEditor(); } Component.onCompleted: { if (plasmoid.hasOwnProperty("activationTogglesExpanded")) { plasmoid.activationTogglesExpanded = true } if (plasmoid.immutability !== PlasmaCore.Types.SystemImmutable) { plasmoid.setAction("menuedit", i18n("Edit Applications..."), "kmenuedit"); } } } // root