Warning, /education/minuet/src/app/qml/Main.qml is written in an unsupported language. File is not indexed.

0001 /****************************************************************************
0002 **
0003 ** Copyright (C) 2016 by Sandro S. Andrade <sandroandrade@kde.org>
0004 **
0005 ** This program is free software; you can redistribute it and/or
0006 ** modify it under the terms of the GNU General Public License as
0007 ** published by the Free Software Foundation; either version 2 of
0008 ** the License or (at your option) version 3 or any later version
0009 ** accepted by the membership of KDE e.V. (or its successor approved
0010 ** by the membership of KDE e.V.), which shall act as a proxy
0011 ** defined in Section 14 of version 3 of the license.
0012 **
0013 ** This program is distributed in the hope that it will be useful,
0014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
0015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0016 ** GNU General Public License for more details.
0017 **
0018 ** You should have received a copy of the GNU General Public License
0019 ** along with this program.  If not, see <http://www.gnu.org/licenses/>.
0020 **
0021 ****************************************************************************/
0022 
0023 import QtQuick 2.7
0024 import QtQuick.Controls 2.0
0025 import QtQuick.Layouts 1.3
0026 import QtQuick.Window 2.0
0027 import QtQuick.Controls.Material 2.0
0028 
0029 ApplicationWindow {
0030     id: applicationWindow
0031     visible: true
0032     width: Screen.width; height: Screen.height
0033     visibility: Window.Maximized
0034 
0035     property string titleText: "Minuet"
0036 
0037     Component {
0038         id: androidToolBar
0039         ToolBar {
0040             Material.primary: "#181818"
0041             Material.foreground: "white"
0042             RowLayout {
0043                 spacing: 20
0044                 anchors.fill: parent
0045                 height: parent.height / 5
0046 
0047                 ToolButton {
0048                     contentItem: Image {
0049                         fillMode: Image.Pad
0050                         horizontalAlignment: Image.AlignHCenter
0051                         verticalAlignment: Image.AlignVCenter
0052                         source: "qrc:/menu.png"
0053                     }
0054                     onClicked: drawer.open()
0055                 }
0056 
0057                 Label {
0058                     text: titleText
0059                     elide: Label.ElideRight
0060                     font { weight: Font.Bold; pixelSize: 16 }
0061                     horizontalAlignment: Qt.AlignHCenter
0062                     verticalAlignment: Qt.AlignVCenter
0063                     Layout.fillWidth: true
0064                 }
0065 
0066                 ToolButton {
0067                     contentItem: Image {
0068                         fillMode: Image.Pad
0069                         horizontalAlignment: Image.AlignHCenter
0070                         verticalAlignment: Image.AlignVCenter
0071                         source: "qrc:/more_vert.png"
0072                     }
0073                     onClicked: optionsMenu.open()
0074 
0075                     Menu {
0076                         id: optionsMenu
0077                         x: parent.width - width
0078                         transformOrigin: Menu.TopRight
0079                         MenuItem {
0080                             text: i18n("About")
0081                             onTriggered: aboutDialog.open()
0082                         }
0083                     }
0084                 }
0085             }
0086         }
0087     }
0088 
0089     Item {
0090         id: mainContainer
0091         anchors {
0092             top: parent.top
0093             bottom: parent.bottom
0094             right: parent.right
0095             left: Qt.platform.os == "android" ?  parent.left : drawer.right;
0096             margins: Screen.width >= 1024 ? 20 : 5
0097         }
0098 
0099         Image {
0100             source: "qrc:/qml/images/minuet-background.png"
0101             anchors.fill: parent
0102             fillMode: Image.Tile
0103         }
0104         ExerciseView {
0105             id: exerciseView
0106             anchors.fill: parent
0107 
0108             currentExercise: minuetMenu.currentExercise
0109         }
0110 /*      THIS IS THE DASHBOARD
0111         Frame {
0112             id: frame
0113             anchors { fill: parent; margins: 15 }
0114             Label {
0115                 id: greetings
0116                 width: parent.width
0117                 wrapMode: Text.WordWrap
0118                 horizontalAlignment: Text.AlignHCenter
0119                 text: "Hi, what kind of ear training exercise do you want to practice today?"
0120                 font { family: "Roboto" }
0121             }
0122             Grid {
0123                 rows: 2
0124                 columns: 2
0125                 anchors.centerIn: parent
0126                 spacing: 40
0127                 Repeater {
0128                     model: [
0129                         { icon: "qrc:/minuet-chords.svg", title: "Chords" },
0130                         { icon: "qrc:/minuet-intervals.svg", title: "Intervals" },
0131                         { icon: "qrc:/minuet-rhythms.svg", title: "Rhythms" },
0132                         { icon: "qrc:/minuet-scales.svg", title: "Scales" }
0133                     ]
0134                     Column {
0135                         Image {
0136                             source: modelData.icon
0137                             fillMode: Image.PreserveAspectFit
0138                             sourceSize.width: frame.width/4;
0139                             width: frame.width/4; height: width
0140                             anchors.horizontalCenter: parent.horizontalCenter
0141                             MouseArea {
0142                                 anchors.fill: parent
0143                                 onClicked: {
0144                                     frame.visible = true
0145                                     stackView.currentExerciseMenuItem = null
0146                                     exerciseController.currentExercise ={}
0147                                     titleText = "Minuet"
0148                                     
0149                                     while (stackView.depth > 1) {
0150                                         stackView.pop()
0151                                         minuetMenu.exerciseArray.pop()
0152                                         currentExerciseParent.text = minuetMenu.exerciseArray.toString()
0153                                         minuetMenu.backPressed()
0154                                     }
0155                                     
0156                                     for (var i = 0; i < exerciseController.exercises.length; ++i) {
0157                                         if (exerciseController.exercises[i].name == modelData.title) {
0158                                             frame.visible = true
0159                                             stackView.push(categoryMenu.createObject(stackView, {model: exerciseController.exercises[i].children}))
0160                                             currentExerciseParent.text = exerciseController.exercises[i].name
0161                                             minuetMenu.exerciseArray.push(exerciseController.exercises[i].name)
0162                                             break
0163                                         }
0164                                     }
0165                                     drawer.open()
0166                                 }
0167                             }
0168                         }
0169                         Label {
0170                             width: frame.width/4
0171                             wrapMode: Text.WordWrap
0172                             anchors.horizontalCenter: parent.horizontalCenter
0173                             horizontalAlignment: Text.AlignHCenter
0174                             text: modelData.title
0175                             font { family: "Roboto" }
0176                         }
0177                     }
0178                 }
0179             }
0180         }
0181 */
0182     }
0183 
0184     MinuetMenuContainer {
0185         id: drawer
0186 
0187         MinuetMenu {
0188             id: minuetMenu
0189             onBackPressed: {
0190                 exerciseView.resetTest()
0191                 core.soundController.reset()
0192             }
0193             onCurrentExerciseChanged: if (Qt.platform.os == "android" && currentExercise != undefined) drawer.close()
0194         }
0195     }
0196 
0197     AboutDialog {
0198         id: aboutDialog
0199     }
0200     
0201     Binding {
0202         target: core.exerciseController
0203         property: "currentExercise"
0204         value: minuetMenu.currentExercise
0205     }
0206     
0207     Binding {
0208         target: core.soundController
0209         property: "playMode"
0210         value: (minuetMenu.currentExercise != undefined) ? minuetMenu.currentExercise["playMode"]:""
0211     }
0212     
0213     Shortcut {
0214         sequence: StandardKey.Quit
0215         onActivated: Qt.quit()
0216     }
0217     
0218     Component.onCompleted: if (Qt.platform.os == "android") header = androidToolBar.createObject(applicationWindow)
0219 }