Warning, /multimedia/amarok/src/context/context_qml_package/contents/ui/main.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.Controls 2.0
0019 import QtQuick.Layouts 1.2
0020 import QtQml.Models 2.2
0021 import org.kde.kirigami 2.0 as Kirigami
0022 import "toolbar"
0023 
0024 Item {
0025     id: root
0026 
0027     Component.onCompleted: Context.debug("Context created")
0028 
0029     ColumnLayout {
0030         anchors.fill: parent
0031 
0032         Flickable {
0033             id: appletFlickable
0034 
0035             signal scrollToApplet(string id)
0036 
0037             Layout.alignment: Qt.AlignTop
0038             Layout.fillHeight: true
0039             Layout.fillWidth: true
0040             contentWidth: scrollBar.visible ? width - scrollBar.width : width
0041             contentHeight: appletColumn.height
0042             flickableDirection: Flickable.VerticalFlick
0043             focus: true
0044 
0045             Keys.onUpPressed: scrollBar.decrease()
0046             Keys.onDownPressed: scrollBar.increase()
0047 
0048             ScrollBar.vertical: ScrollBar { id: scrollBar }
0049 
0050             Column {
0051                 id: appletColumn
0052 
0053                 width: parent.width
0054                 spacing: Kirigami.Units.smallSpacing
0055 
0056                 Repeater {
0057                     model: AppletProxyModel
0058 
0059                     delegate: Loader {
0060                         width: appletColumn.width
0061                         active: true
0062                         asynchronous: false
0063 
0064                         function initialize() {
0065                             setSource(mainscript, {
0066                                 "name": name,
0067                                 "appletId": appletId,
0068                                 "iconSource": icon,
0069                                 "collapsed": collapsed,
0070                                 "contentHeight": contentHeight,
0071                                 "configEnabled": Qt.binding(function() { return appletToolbar.configEnabled; } )
0072                             });
0073                         }
0074 
0075                         Component.onCompleted: initialize()
0076 
0077                         onStatusChanged: {
0078                             if (status == Loader.Error) {
0079                                 Context.error("Error loading applet: " + appletId);
0080                                 Context.error(sourceComponent.errorString());
0081                             }
0082                             if (status == Loader.Ready) {
0083                                 Context.debug("Applet loaded: " + appletId);
0084                             }
0085                         }
0086 
0087                         Connections {
0088                             target: AppletProxyModel
0089 
0090                             onDataChanged: {
0091                                 if (!!mainscript && mainscript != source) {
0092                                     Context.debug("Data changed for applet " + appletId);
0093                                     initialize();
0094                                 }
0095                             }
0096                         }
0097                         Connections {
0098                             target: appletFlickable
0099 
0100                             onScrollToApplet: {
0101                                 if (id == appletId) {
0102                                     appletFlickable.contentY = y;
0103                                     Context.debug("Scroll to applet: " + appletId);
0104                                 }
0105                             }
0106                         }
0107                     }
0108                 }
0109             }
0110         }
0111         AppletToolbarAddItem {
0112             id: appletToolbarAddItem
0113 
0114             Layout.fillWidth: true
0115             height: Kirigami.Units.iconSizes.enormous
0116             visible: appletToolbar.configEnabled
0117         }
0118         AppletToolbar {
0119             id: appletToolbar
0120 
0121             contextRoot: root
0122             addItem: appletToolbarAddItem
0123             flickable: appletFlickable
0124             Layout.alignment: Qt.AlignBottom
0125             Layout.fillWidth: true
0126         }
0127     }
0128 }