diff --git a/src/qml/ActionListItem.qml b/src/qml/ActionListItem.qml new file mode 100644 index 0000000..799b45b --- /dev/null +++ b/src/qml/ActionListItem.qml @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright © 2015 Aleix Pol Gonzalez * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License as * + * published by the Free Software Foundation; either version 2 of * + * the License or (at your option) version 3 or any later version * + * accepted by the membership of KDE e.V. (or its successor approved * + * by the membership of KDE e.V.), which shall act as a proxy * + * defined in Section 14 of version 3 of the license. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program. If not, see . * + ***************************************************************************/ + +import QtQuick 2.5 +import QtQuick.Controls 2.0 +import org.kde.kirigami 2.3 as Kirigami + +Kirigami.BasicListItem +{ + id: item + property QtObject action: null + checked: action.checked + icon: action.iconName + separatorVisible: false + visible: action.enabled + onClicked: { + action.trigger() + } + + Kirigami.MnemonicData.enabled: item.enabled && item.visible + Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.MenuItem + Kirigami.MnemonicData.label: action.text + label: Kirigami.MnemonicData.richTextLabel + + readonly property var p0: Shortcut { + sequence: item.Kirigami.MnemonicData.sequence + onActivated: item.clicked() + } +} diff --git a/src/qml/ArtikulateDrawer.qml b/src/qml/ArtikulateDrawer.qml new file mode 100644 index 0000000..2815529 --- /dev/null +++ b/src/qml/ArtikulateDrawer.qml @@ -0,0 +1,143 @@ +/* + * Copyright 2018 Andreas Cord-Landwehr + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License or (at your option) version 3 or any later version + * accepted by the membership of KDE e.V. (or its successor approved + * by the membership of KDE e.V.), which shall act as a proxy + * defined in Section 14 of version 3 of the license. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import QtQuick 2.5 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.0 as QQC2 +import org.kde.kirigami 2.0 as Kirigami + +Kirigami.GlobalDrawer { + id: root + + title: "Artikulate" + titleIcon: "artikulate" + resetMenuOnTriggered: false + bottomPadding: 0 + property QtObject pageStack + + // enforce drawer always to be open + modal: false + handleVisible: false + + actions: [ + Kirigami.Action { + text: i18n("Welcome") + iconName: "artikulate" + onTriggered: { + root.pageStack.clear(); + root.pageStack.push(welcomePageComponent); + } + }, + Kirigami.Action { + text: i18n("Training") + iconName: "document-open" + onTriggered: { + root.pageStack.clear(); + root.pageStack.push(trainingItemsPageComponent); + root.pageStack.push(trainingPageComponent); + } + }, + Kirigami.Action { + text: i18n("User Profile") + iconName: "user-properties" + onTriggered: { + root.pageStack.clear(); + root.pageStack.push(profileSettingsPageComponent); + } + Kirigami.Action { + text: i18n("Configure Profile") + iconName: "user-properties" + onTriggered: { + root.pageStack.pop(); + root.pageStack.push(profileSettingsPageComponent); + } + } + Kirigami.Action { + text: i18n("Training Languages"); + onTriggered: { + root.pageStack.pop(); + root.pageStack.push(languageSettingsPageComponent); + } + } + }, + Kirigami.Action { + text: i18n("Help") + iconName: "help-about" + Kirigami.Action { + text: i18n("Artikulate Handbook") + iconName: "help-contents" + onTriggered: { + triggerAction("help_contents"); + globalDrawer.resetMenu(); + } + } + Kirigami.Action { + text: i18n("Report Bug") + iconName: "tools-report-bug" + onTriggered: { + triggerAction("help_report_bug"); + globalDrawer.resetMenu(); + } + } + Kirigami.Action { + text: i18n("About Artikulate") + iconName: "artikulate" + onTriggered: { + triggerAction("help_about_app") + globalDrawer.resetMenu(); + } + } + Kirigami.Action { + text: i18n("About KDE") + iconName: "help-about" + onTriggered: { + triggerAction("help_about_kde") + globalDrawer.resetMenu(); + } + } + } + ] + + ColumnLayout { + spacing: 0 + Layout.fillWidth: true + Layout.leftMargin: -root.leftPadding + Layout.rightMargin: -root.rightPadding + + Kirigami.Separator { + Layout.fillWidth: true + } + + ActionListItem { + action: Kirigami.Action { + text: i18n("Settings") + iconName: "settings-configure" + onTriggered: triggerSettingsDialog() + } + } + ActionListItem { + action: Kirigami.Action { + text: i18n("Download Training") + iconName: "get-hot-new-stuff" + onTriggered: triggerDownloadCourses() + } + } + } +} diff --git a/src/qml/Main.qml b/src/qml/Main.qml index b025c17..8a054d0 100644 --- a/src/qml/Main.qml +++ b/src/qml/Main.qml @@ -1,182 +1,87 @@ /* * Copyright 2013-2017 Andreas Cord-Landwehr * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.5 import QtQuick.Controls 2.0 as QQC2 import org.kde.kirigami 2.0 as Kirigami2 import artikulate 1.0 Kirigami2.ApplicationWindow { id: root function changePage(pageItem) { root.pageStack.clear(); root.pageStack.push(pageItem); root.pageStack.push(pageItem); } // header: Text { // font.pointSize: Kirigami2.Units.gridUnit * 1 // text: pageStack.currentItem.title // } header: Kirigami2.ApplicationHeader { } - globalDrawer: Kirigami2.GlobalDrawer { - title: "Artikulate" - titleIcon: "artikulate" - resetMenuOnTriggered: false - - // enforce drawer always to be open - modal: false - handleVisible: false - - actions: [ - Kirigami2.Action { - text: i18n("Welcome") - iconName: "artikulate" - onTriggered: { - root.pageStack.clear(); - root.pageStack.push(welcomePageComponent); - } - }, - Kirigami2.Action { - text: i18n("Training") - iconName: "document-open" - onTriggered: { - root.pageStack.clear(); - root.pageStack.push(trainingItemsPageComponent); - root.pageStack.push(trainingPageComponent); - } - }, - Kirigami2.Action { - text: i18n("Download Training") - iconName: "get-hot-new-stuff" - onTriggered: triggerDownloadCourses() - }, - Kirigami2.Action { - text: i18n("User Profile") - iconName: "user-properties" - onTriggered: { - root.pageStack.clear(); - root.pageStack.push(profileSettingsPageComponent); - } - Kirigami2.Action { - text: i18n("Configure Profile") - iconName: "user-properties" - onTriggered: { - root.pageStack.pop(); - root.pageStack.push(profileSettingsPageComponent); - } - } - Kirigami2.Action { - text: i18n("Training Languages"); - onTriggered: { - root.pageStack.pop(); - root.pageStack.push(languageSettingsPageComponent); - } - } - }, - Kirigami2.Action { - text: i18n("Configure Artikulate...") - iconName: "settings-configure" - onTriggered: triggerSettingsDialog() - }, - Kirigami2.Action { - text: i18n("Help") - iconName: "help-about" - Kirigami2.Action { - text: i18n("Artikulate Handbook") - iconName: "help-contents" - onTriggered: { - triggerAction("help_contents"); - globalDrawer.resetMenu(); - } - } - Kirigami2.Action { - text: i18n("Report Bug") - iconName: "tools-report-bug" - onTriggered: { - triggerAction("help_report_bug"); - globalDrawer.resetMenu(); - } - } - Kirigami2.Action { - text: i18n("About Artikulate") - iconName: "artikulate" - onTriggered: { - triggerAction("help_about_app") - globalDrawer.resetMenu(); - } - } - Kirigami2.Action { - text: i18n("About KDE") - iconName: "help-about" - onTriggered: { - triggerAction("help_about_kde") - globalDrawer.resetMenu(); - } - } - } - ] + globalDrawer: ArtikulateDrawer { + pageStack: root.pageStack } contextDrawer: Kirigami2.ContextDrawer { id: contextDrawer } signal triggerDownloadCourses(); signal triggerSettingsDialog(); signal triggerAction(string actionName); signal switchMenuBarVisibility(); property Learner learner: g_profileManager.activeProfile property ResourceManager resourceManager: g_resourceManager CourseModel { id: availableCourseModel resourceManager: g_resourceManager } pageStack.initialPage: welcomePageComponent // pages Component { id: welcomePageComponent WelcomePage { } } Component { id: trainingPageComponent TrainingPage { } } Component { id: trainingItemsPageComponent TrainingItemsPage { } } Component { id: profileSettingsPageComponent ProfileSettingsPage { } } Component { id: languageSettingsPageComponent LanguageSettingsPage { } } } diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index a3f320b..d3d1fd1 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -1,26 +1,28 @@ - Main.qml + ActionListItem.qml + ArtikulateDrawer.qml CheckListItem.qml CourseSwitcher.qml Editor.qml + LanguageSettingsPage.qml LanguageSwitcher.qml ListItem.qml - WelcomePage.qml + Main.qml PhonemeUnitSelector.qml PhraseEditor.qml PhraseEditorEditStateComponent.qml PhraseEditorSoundComponent.qml PhraseEditorTypeComponent.qml + ProfileSelector.qml ProfileSettingsPage.qml - LanguageSettingsPage.qml ProfileUserImageItem.qml - ProfileSelector.qml SoundPlayer.qml SoundRecorder.qml TrainerCourseStatistics.qml - TrainingPage.qml TrainingItemsPage.qml + TrainingPage.qml UnitEditor.qml + WelcomePage.qml