Warning, /multimedia/amarok/src/context/qml_plugin/Applet.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.4 0018 import QtQuick.Dialogs 1.2 0019 import org.kde.kirigami 2.0 as Kirigami 0020 0021 0022 Rectangle { 0023 id: root 0024 0025 default property alias contents: content.data 0026 property alias title: header.title 0027 property string name: "Nameless Applet" 0028 property string appletId 0029 property url iconSource 0030 property bool collapsed: false 0031 property bool configEnabled: false 0032 property real spacing: Kirigami.Units.smallSpacing 0033 property real padding: spacing 0034 property real contentHeight: content.childrenRect.height 0035 property Dialog configDialog: null 0036 readonly property AppletHeader appletHeader: header 0037 readonly property SystemPalette palette: palette 0038 0039 radius: Kirigami.Units.smallSpacing 0040 border.width: 2 0041 border.color: palette.mid 0042 color: "transparent" 0043 clip: true 0044 height: content.height + header.height + 2 * padding + !collapsed * spacing 0045 0046 function imageUrl(filename) { 0047 return AppletModel.imageUrl(root.appletId, filename); 0048 } 0049 0050 onCollapsedChanged: AppletModel.setAppletCollapsed(appletId, collapsed) 0051 onContentHeightChanged: AppletModel.setAppletContentHeight(appletId, contentHeight) 0052 0053 AppletHeader { 0054 id: header 0055 0056 title: root.name 0057 iconSource: root.iconSource 0058 } 0059 0060 Item { 0061 id: content 0062 0063 anchors { 0064 top: header.bottom 0065 left: root.left 0066 right: root.right 0067 topMargin: root.spacing 0068 leftMargin: root.padding 0069 rightMargin: root.padding 0070 } 0071 0072 height: root.collapsed ? 0 : root.contentHeight 0073 clip: true 0074 0075 Behavior on height { 0076 enabled: !resizeMouseArea.pressed 0077 NumberAnimation { duration: 350 } 0078 } 0079 } 0080 0081 MouseArea { 0082 id: resizeMouseArea 0083 0084 anchors { 0085 bottom: parent.bottom 0086 left: parent.left 0087 right: parent.right 0088 } 0089 height: root.padding 0090 enabled: root.configEnabled 0091 cursorShape: enabled ? Qt.SizeVerCursor : Qt.ArrowCursor 0092 acceptedButtons: Qt.LeftButton 0093 preventStealing: true 0094 onMouseYChanged: { 0095 if(pressed) { 0096 root.contentHeight = Math.max(Kirigami.Units.largeSpacing, root.contentHeight + mouseY); 0097 } 0098 } 0099 } 0100 0101 SystemPalette { 0102 id: palette 0103 } 0104 }