Warning, /utilities/klimbgrades/src/Global.qml is written in an unsupported language. File is not indexed.

0001 /*
0002  *   Copyright 2016 Marco Martin <mart@kde.org>
0003  *
0004  *   This program is free software; you can redistribute it and/or modify
0005  *   it under the terms of the GNU Library General Public License as
0006  *   published by the Free Software Foundation; either version 2, or
0007  *   (at your option) any later version.
0008  *
0009  *   This program is distributed in the hope that it will be useful,
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *   GNU Library General Public License for more details
0013  *
0014  *   You should have received a copy of the GNU Library General Public
0015  *   License along with this program; if not, write to the
0016  *   Free Software Foundation, Inc.,
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
0018  */
0019 
0020 import QtQuick 2.0
0021 import QtQuick.Layouts 1.2
0022 import QtQuick.Controls 2.0 as Controls
0023 import org.kde.kirigami 2.0 as Kirigami
0024 
0025 Kirigami.ScrollablePage {
0026     id: root
0027 
0028     property alias model: mainRepeater.model
0029     property int defaultGrade
0030 
0031     //Close the drawer with the back button
0032     onBackRequested: {
0033         if (sheet.sheetOpen) {
0034             event.accepted = true;
0035             sheet.close();
0036         }
0037     }
0038 
0039     actions {
0040         main: Kirigami.Action {
0041             iconName: "view-refresh"
0042             text: qsTr("Reset")
0043             onTriggered: root.model.currentGrade = root.defaultGrade;
0044         }
0045         contextualActions: [
0046             Kirigami.Action {
0047                 text: qsTr("Set Record")
0048                 tooltip: qsTr("Set Grade As Personal Record")
0049                 iconName: "games-highscores"
0050                 onTriggered: {
0051                     root.model.personalRecord = root.model.currentGrade;
0052                 }
0053             },
0054             Kirigami.Action {
0055                 text: qsTr("Clear")
0056                 tooltip: qsTr("Clear Personal Record")
0057                 iconName: "edit-clear"
0058                 enabled: root.model.personalRecord > 0
0059                 onTriggered: {
0060                     root.model.personalRecord = 0;
0061                 }
0062             }
0063         ]
0064     }
0065     Kirigami.OverlaySheet {
0066         id: sheet
0067         parent: applicationWindow().overlay
0068         property alias description: descrLabel.text
0069         property string url
0070         ColumnLayout {
0071             property int implicitWidth: Kirigami.Units.gridUnit * 25
0072             Kirigami.Label {
0073                 id: descrLabel
0074                 Layout.fillWidth: true
0075                 wrapMode: Text.WordWrap
0076             }
0077             Controls.Button {
0078                 anchors.horizontalCenter: parent.horizontalCenter
0079                 text: qsTr("Source: Wikipedia")
0080                 onClicked: {
0081                     Qt.openUrlExternally(sheet.url);
0082                     sheet.close();
0083                 }
0084             }
0085         }
0086     }
0087 
0088     Column {
0089         id: mainLayout
0090         anchors.horizontalCenter: parent.horizontalCenter
0091         spacing: Kirigami.Units.gridUnit * 2
0092         Repeater {
0093             id: mainRepeater
0094             delegate: GradeWidgetBase {
0095                 page: root
0096                 availableGradesModel: root.model
0097                 anchors.horizontalCenter: parent.horizontalCenter
0098                 visible: model.enabledRole
0099                 scaleName: model.nameRole
0100                 url: model.urlRole
0101                 description: model.descriptionRole
0102             }
0103         }
0104     }
0105 }