Warning, /multimedia/amarok/src/context/context_qml_package/contents/ui/toolbar/AppletToolbarAppletItem.qml is written in an unsupported language. File is not indexed.

0001 /****************************************************************************************
0002  * Copyright (c) 2017 Malte Veerman <malte.veerman@gmail.com>                           *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 import QtQuick 2.6
0018 import QtQuick.Controls 2.0
0019 import QtQuick.Layouts 1.3
0020 import org.kde.kirigami 2.0 as Kirigami
0021 
0022 
0023 MouseArea {
0024     id: root
0025 
0026     property alias name: label.text
0027     property string appletId
0028     property var toolbar
0029     property var flickable
0030     property bool configEnabled: !!toolbar ? toolbar.configEnabled : false
0031     property bool held: false
0032 
0033     height: held ? toolbar.height : toolbar.height - Kirigami.Units.smallSpacing
0034     anchors.verticalCenter: parent.verticalCenter
0035     implicitWidth: label.implicitWidth + Kirigami.Units.smallSpacing * 2
0036 
0037     acceptedButtons: Qt.LeftButton
0038     hoverEnabled: true
0039     drag.target: held ? content : undefined
0040     drag.axis: Drag.XAxis
0041     cursorShape: configEnabled ? held ? Qt.ClosedHandCursor : Qt.PointingHandCursor : Qt.ArrowCursor
0042 
0043     onPressAndHold: if (configEnabled) held = true
0044     onReleased: held = false
0045     onPressed: if (!configEnabled) flickable.scrollToApplet(appletId)
0046     onImplicitWidthChanged: toolbar.resizeApplets()
0047 
0048     DropArea {
0049         anchors {
0050             fill: parent
0051             leftMargin: Kirigami.Units.smallSpacing
0052             rightMargin: Kirigami.Units.smallSpacing
0053         }
0054 
0055         onEntered: {
0056             AppletProxyModel.setAppletPlace(drag.source.appletId, AppletProxyModel.appletPlace(root.appletId));
0057         }
0058     }
0059 
0060     Rectangle {
0061         id: content
0062 
0063         readonly property string appletId: root.appletId
0064 
0065         border.width: 1
0066         color: root.pressed ? palette.highlight : palette.button
0067         border.color: root.containsMouse ? palette.highlight : palette.buttonText
0068         radius: Kirigami.Units.smallSpacing / 2
0069         anchors {
0070             horizontalCenter: root.horizontalCenter
0071             verticalCenter: root.verticalCenter
0072         }
0073         width: root.width
0074         height: root.height
0075 
0076         Drag.active: root.held
0077         Drag.source: root
0078         Drag.hotSpot.x: width / 2
0079         Drag.hotSpot.y: height / 2
0080 
0081         states: State {
0082             when: root.held
0083 
0084             ParentChange {
0085                 target: content
0086                 parent: contextRoot
0087             }
0088             AnchorChanges {
0089                 target: content
0090                 anchors {
0091                     horizontalCenter: undefined
0092                     verticalCenter: undefined
0093                 }
0094             }
0095         }
0096 
0097         Label {
0098             id: label
0099 
0100             anchors {
0101                 fill: parent
0102                 leftMargin: Kirigami.Units.smallSpacing
0103                 rightMargin: Kirigami.Units.smallSpacing
0104             }
0105 
0106             horizontalAlignment: Text.AlignHCenter
0107             verticalAlignment: Text.AlignVCenter
0108             clip: true
0109         }
0110     }
0111 
0112     SystemPalette {
0113         id: palette
0114     }
0115 }