diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 049a974..efe224e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,193 +1,195 @@ ### # Copyright 2013-2015 Andreas Cord-Landwehr # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ### ecm_setup_version(0.6.50 VARIABLE_PREFIX ARTIKULATE VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/version.h" PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/ArtikulateConfigVersion.cmake" ) ecm_optional_add_subdirectory(qml) # set include directories include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${artikulate_SOURCE_DIR} ) # set the source code files from which Artikulate is compiled set(artikulateCore_SRCS + core/drawertrainingactions.cpp core/course.cpp core/resourcemanager.cpp core/language.cpp core/phrase.cpp core/phoneme.cpp core/phonemegroup.cpp core/unit.cpp core/skeleton.cpp core/editorsession.cpp + core/trainingaction.cpp core/trainingsession.cpp core/resources/resourceinterface.cpp core/resources/languageresource.cpp core/resources/courseresource.cpp core/resources/skeletonresource.cpp core/player.cpp core/recorder.cpp qmlcontrols/iconitem.cpp qmlcontrols/imagetexturescache.cpp qmlcontrols/managedtexturenode.cpp artikulate_debug.cpp ) kconfig_add_kcfg_files (artikulateCore_SRCS settings.kcfgc) add_library(artikulatecore SHARED ${artikulateCore_SRCS}) generate_export_header(artikulatecore BASE_NAME artikulatecore) target_link_libraries(artikulatecore LINK_PUBLIC artikulatelearnerprofile artikulatesound Qt5::XmlPatterns Qt5::Quick KF5::Archive KF5::ConfigGui ) # internal library without any API or ABI guarantee set(GENERIC_LIB_VERSION "0") set(GENERIC_LIB_SOVERSION "0") set_target_properties( artikulatecore PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} ) install( TARGETS artikulatecore DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS} ) install(FILES artikulate.knsrc DESTINATION ${CONFIG_INSTALL_DIR}) # set the source code files from which Artikulate is compiled set(artikulate_SRCS main.cpp mainwindow.cpp application.cpp artikulate_debug.cpp models/coursemodel.cpp models/coursefiltermodel.cpp models/languagemodel.cpp models/languageresourcemodel.cpp # models/learningprogressmodel.cpp //TODO must be adapted to new trainingsession models/unitmodel.cpp models/unitfiltermodel.cpp models/phrasemodel.cpp models/phraselistmodel.cpp models/phrasefiltermodel.cpp models/phonememodel.cpp models/phonemegroupmodel.cpp models/phonemeunitmodel.cpp models/profilemodel.cpp models/skeletonmodel.cpp ui/sounddevicedialogpage.cpp ui/appearencedialogpage.cpp ui/resourcesdialogpage.cpp ) ki18n_wrap_ui (artikulate_SRCS ui/resourcesdialogpage.ui ui/sounddevicedialogpage.ui ui/appearencedialogpage.ui ) qt5_add_resources(artikulate_SRCS qml/qml.qrc) kconfig_add_kcfg_files (artikulate_SRCS settings.kcfgc) set(artikulate_editor_SRCS main_editor.cpp mainwindow_editor.cpp application.cpp artikulate_debug.cpp models/coursemodel.cpp models/coursefiltermodel.cpp models/languagemodel.cpp models/languageresourcemodel.cpp # models/learningprogressmodel.cpp //TODO must be adapted to new trainingsession models/unitmodel.cpp models/unitfiltermodel.cpp models/phrasemodel.cpp models/phraselistmodel.cpp models/phrasefiltermodel.cpp models/phonememodel.cpp models/phonemegroupmodel.cpp models/phonemeunitmodel.cpp models/profilemodel.cpp models/skeletonmodel.cpp ui/sounddevicedialogpage.cpp ui/appearencedialogpage.cpp ui/resourcesdialogpage.cpp ui/exportghnsdialog.cpp ) ki18n_wrap_ui (artikulate_editor_SRCS ui/appearencedialogpage.ui ui/exportghnsdialog.ui ui/resourcesdialogpage.ui ui/sounddevicedialogpage.ui ) qt5_add_resources(artikulate_editor_SRCS qml/qml.qrc) kconfig_add_kcfg_files (artikulate_editor_SRCS settings.kcfgc) # executables add_executable(artikulate ${artikulate_SRCS}) target_link_libraries(artikulate LINK_PUBLIC artikulatelearnerprofile artikulatesound artikulatecore Qt5::Qml Qt5::Quick KF5::Crash KF5::NewStuff KF5::XmlGui ) qt5_add_resources(artikulate_editor_SRCS editor.qrc) add_executable(artikulate_editor ${artikulate_editor_SRCS}) target_link_libraries(artikulate_editor LINK_PUBLIC artikulatesound artikulatecore Qt5::Qml Qt5::Quick Qt5::QuickWidgets KF5::Crash KF5::NewStuff KF5::XmlGui ) install(FILES artikulate.kcfg DESTINATION ${KCFG_INSTALL_DIR}) install(TARGETS artikulate ${INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS artikulate_editor ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/src/application.cpp b/src/application.cpp index d512486..118af05 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -1,117 +1,119 @@ /* * Copyright 2013-2015 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 . */ #include "application.h" -#include "core/skeleton.h" #include "core/course.h" +#include "core/drawertrainingactions.h" +#include "core/editorsession.h" #include "core/language.h" -#include "core/resourcemanager.h" -#include "core/unit.h" -#include "core/phrase.h" #include "core/phoneme.h" #include "core/phonemegroup.h" -#include "core/trainingsession.h" -#include "core/editorsession.h" +#include "core/phrase.h" #include "core/player.h" #include "core/recorder.h" -#include "models/coursemodel.h" +#include "core/resourcemanager.h" +#include "core/skeleton.h" +#include "core/trainingsession.h" +#include "core/unit.h" #include "models/coursefiltermodel.h" +#include "models/coursemodel.h" #include "models/languagemodel.h" #include "models/languageresourcemodel.h" #include "models/learningprogressmodel.h" -#include "models/unitmodel.h" -#include "models/unitfiltermodel.h" -#include "models/phrasemodel.h" -#include "models/phraselistmodel.h" -#include "models/phrasefiltermodel.h" -#include "models/phonememodel.h" #include "models/phonemegroupmodel.h" +#include "models/phonememodel.h" #include "models/phonemeunitmodel.h" +#include "models/phrasefiltermodel.h" +#include "models/phraselistmodel.h" +#include "models/phrasemodel.h" #include "models/profilemodel.h" #include "models/skeletonmodel.h" +#include "models/unitfiltermodel.h" +#include "models/unitmodel.h" #include "qmlcontrols/iconitem.h" #include "liblearnerprofile/src/learner.h" #include "liblearnerprofile/src/profilemanager.h" #include "liblearnerprofile/src/learninggoal.h" #include "liblearnerprofile/src/models/learninggoalmodel.h" #include #include #include #include Application::Application(int& argc, char** argv) : QApplication(argc, argv) { registerQmlTypes(); } void Application::registerQmlTypes() { qmlRegisterUncreatableType( "artikulate", 1, 0, "TrainingSession", "TrainingSession is unique object provided by the backend"); qmlRegisterUncreatableType( "artikulate", 1, 0, "EditorSession", "EditorSession is unique object provided by the backend"); qmlRegisterUncreatableType( "artikulate", 1, 0, "ResourceManager", "ResourceManager is unique object provided by the backend"); qmlRegisterUncreatableType( "artikulate", 1, 0, "ProfileManager", "ProfileManager is unique object provided by the backend"); qmlRegisterType("artikulate", 1, 0, "Learner"); qmlRegisterType("artikulate", 1, 0, "LearningGoal"); qmlRegisterType("artikulate", 1, 0, "Unit"); qmlRegisterType("artikulate", 1, 0, "Skeleton"); qmlRegisterType("artikulate", 1, 0, "Course"); qmlRegisterType("artikulate", 1, 0, "Language"); qmlRegisterType("artikulate", 1, 0, "ResourceManager"); qmlRegisterType("artikulate", 1, 0, "Phrase"); qmlRegisterType("artikulate", 1, 0, "Phoneme"); qmlRegisterType("artikulate", 1, 0, "PhonemeGroup"); qmlRegisterType("artikulate", 1, 0, "Player"); qmlRegisterType("artikulate", 1, 0, "Recorder"); qmlRegisterType("artikulate", 1, 0, "Icon"); + qmlRegisterType("artikulate", 1, 0, "DrawerTrainingActions"); qmlRegisterType("artikulate", 1, 0, "CourseModel"); qmlRegisterType("artikulate", 1, 0, "CourseFilterModel"); qmlRegisterType("artikulate", 1, 0, "LanguageModel"); qmlRegisterType("artikulate", 1, 0, "LanguageResourceModel"); // qmlRegisterType("artikulate", 1, 0, "LearningProgressModel");//TODO must be ported to new trainingsession qmlRegisterType("artikulate", 1, 0, "UnitModel"); qmlRegisterType("artikulate", 1, 0, "UnitFilterModel"); qmlRegisterType("artikulate", 1, 0, "PhraseModel"); qmlRegisterType("artikulate", 1, 0, "PhraseListModel"); qmlRegisterType("artikulate", 1, 0, "PhraseFilterModel"); qmlRegisterType("artikulate", 1, 0, "PhonemeModel"); qmlRegisterType("artikulate", 1, 0, "PhonemeGroupModel"); qmlRegisterType("artikulate", 1, 0, "PhonemeUnitModel"); qmlRegisterType("artikulate", 1, 0, "ProfileModel"); qmlRegisterType("artikulate", 1, 0, "SkeletonModel"); qmlRegisterType("artikulate", 1, 0, "LearningGoalModel"); } diff --git a/src/core/drawertrainingactions.cpp b/src/core/drawertrainingactions.cpp new file mode 100644 index 0000000..a44dca7 --- /dev/null +++ b/src/core/drawertrainingactions.cpp @@ -0,0 +1,90 @@ +/* + * 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 . + */ + +#include "drawertrainingactions.h" +#include "trainingaction.h" +#include "course.h" +#include "unit.h" + +#include +#include + +DrawerTrainingActions::DrawerTrainingActions(QObject* parent) + : QObject(parent) + , m_course(nullptr) +{ +} + +void DrawerTrainingActions::setCourse(Course *course) +{ + if (course == m_course) { + return; + } + m_course = course; + emit courseChanged(course); + + updateActions(); +} + +Course * DrawerTrainingActions::course() const +{ + return m_course; +} + +void DrawerTrainingActions::setSession(TrainingSession *session) +{ + if (session == m_session) { + return; + } + m_session = session; + emit sessionChanged(); +} + +TrainingSession * DrawerTrainingActions::session() const +{ + return m_session; +} + +QList DrawerTrainingActions::actions() const +{ + return m_actions; +} + +void DrawerTrainingActions::updateActions() +{ + // cleanup + for (const auto &action : m_actions) { + action->deleteLater(); + } + m_actions.clear(); + + if (!m_course) { + return; + } + + for (const auto &unit : m_course->unitList()) { + auto action = new TrainingAction(unit->title()); + m_actions.append(action); + for (const auto &phrase : unit->phraseList()) { + action->appendChild(new TrainingAction(phrase, this, unit)); + } + } + emit actionsChanged(); +} diff --git a/src/core/drawertrainingactions.h b/src/core/drawertrainingactions.h new file mode 100644 index 0000000..defe091 --- /dev/null +++ b/src/core/drawertrainingactions.h @@ -0,0 +1,63 @@ +/* + * 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 . + */ + +#ifndef DRAWERTRAININGACTIONS_H +#define DRAWERTRAININGACTIONS_H + +#include "artikulatecore_export.h" +#include "trainingaction.h" +#include + +class Course; + +class ARTIKULATECORE_EXPORT DrawerTrainingActions : public QObject +{ + Q_OBJECT + Q_PROPERTY(Course *course READ course WRITE setCourse NOTIFY courseChanged) + Q_PROPERTY(TrainingSession *session READ session WRITE setSession NOTIFY sessionChanged) + Q_PROPERTY(QList actions READ actions NOTIFY actionsChanged) + +public: + DrawerTrainingActions(QObject *parent = nullptr); + void setCourse(Course *course); + Course * course() const; + void setSession(TrainingSession *session); + TrainingSession * session() const; + QList actions() const; + +private: + void updateActions(); + +Q_SIGNALS: + void courseChanged(Course *course); + void actionsChanged(); + void sessionChanged(); + /** + * Notify that training view shall be displayed. + */ + void triggerTrainingView(); + +private: + Course *m_course{nullptr}; + TrainingSession *m_session{nullptr}; + QList m_actions; +}; + +#endif diff --git a/src/core/trainingaction.cpp b/src/core/trainingaction.cpp new file mode 100644 index 0000000..5564bda --- /dev/null +++ b/src/core/trainingaction.cpp @@ -0,0 +1,77 @@ +/* + * 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 . + */ + +#include "trainingaction.h" +#include "drawertrainingactions.h" +#include "trainingsession.h" + +TrainingAction::TrainingAction(QObject *parent) + : QObject(parent) + , m_text(QString()) + , m_iconName(QString()) //TODO "rating-unrated" vs. "rating" +{ +} + +TrainingAction::TrainingAction(const QString &text, QObject *parent) + : QObject(parent) + , m_text(text) + , m_iconName(QString()) //TODO "rating-unrated" vs. "rating" +{ +} + +TrainingAction::TrainingAction(Phrase *phrase, DrawerTrainingActions *drawerTrainingActions, QObject* parent) + : QObject(parent) + , m_phrase(phrase) + , m_drawerTrainingActions(drawerTrainingActions) +{ + if (m_phrase) { + m_text = phrase->text(); + } +} + +void TrainingAction::appendChild(QObject* child) +{ + m_children.append(child); + emit childrenChanged(); +} + +void TrainingAction::trigger() +{ + if (m_phrase && m_drawerTrainingActions && m_drawerTrainingActions->session()) { + m_drawerTrainingActions->session()->setPhrase(m_phrase); + emit m_drawerTrainingActions->triggerTrainingView(); + } +} + +bool TrainingAction::enabled() const +{ + return m_enabled; +} + +void TrainingAction::setEnabled(bool enabled) +{ + if (enabled == m_enabled) { + return; + } + m_enabled = enabled; + emit enabledChanged(m_enabled); +} + + diff --git a/src/core/trainingaction.h b/src/core/trainingaction.h new file mode 100644 index 0000000..dfa0edf --- /dev/null +++ b/src/core/trainingaction.h @@ -0,0 +1,67 @@ +/* + * 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 . + */ + +#ifndef TRAININGACTION_H +#define TRAININGACTION_H + +#include "artikulatecore_export.h" +#include "phrase.h" +#include "trainingsession.h" +#include +#include + +class DrawerTrainingActions; + +class ARTIKULATECORE_EXPORT TrainingAction : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString text MEMBER m_text CONSTANT) + Q_PROPERTY(QString iconName MEMBER m_iconName CONSTANT) + Q_PROPERTY(bool visible MEMBER m_visible CONSTANT) + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(bool checked MEMBER m_checked CONSTANT) + Q_PROPERTY(QList children MEMBER m_children NOTIFY childrenChanged) + +Q_SIGNALS: + void changed(); + void childrenChanged(); + void enabledChanged(bool enabled); + +public: + TrainingAction(QObject *parent = nullptr); + TrainingAction(const QString &text, QObject *parent = nullptr); + TrainingAction(Phrase *phrase, DrawerTrainingActions *drawerActions, QObject *parent = nullptr); + void appendChild(QObject *child); + Q_INVOKABLE void trigger(); + bool enabled() const; + void setEnabled(bool enabled); + +private: + QString m_text; + QString m_iconName; + bool m_visible{true}; + bool m_enabled{true}; + bool m_checked{false}; + QList m_children; + Phrase *m_phrase{nullptr}; + DrawerTrainingActions * m_drawerTrainingActions{nullptr}; +}; + +#endif diff --git a/src/qml/ArtikulateDrawer.qml b/src/qml/ArtikulateDrawer.qml index ba66db8..1c72be4 100644 --- a/src/qml/ArtikulateDrawer.qml +++ b/src/qml/ArtikulateDrawer.qml @@ -1,130 +1,149 @@ /* * 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 +import artikulate 1.0 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("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(); + topContent: [ + ColumnLayout { + spacing: 0 + Layout.fillWidth: true + Layout.leftMargin: -root.leftPadding + Layout.rightMargin: -root.rightPadding + ActionListItem { + action: Kirigami.Action { + text: i18n("Training") + iconName: "artikulate" + onTriggered: { + root.pageStack.clear(); + root.pageStack.push(welcomePageComponent); + } } } - Kirigami.Action { - text: i18n("About KDE") - iconName: "help-about" - onTriggered: { - triggerAction("help_about_kde") - globalDrawer.resetMenu(); - } + Kirigami.Separator { + Layout.fillWidth: true } } ] + // ordinary Kirigami actions are filled from training units/phrases + actions: trainingActions.actions + DrawerTrainingActions { + id: trainingActions + course: g_trainingSession.course + session: g_trainingSession + onTriggerTrainingView: { + root.pageStack.clear(); + root.pageStack.push(trainingPageComponent); + } + } + +//TODO integrate again +// [ +// 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("Statistics") iconName: "user-properties" onTriggered: { root.pageStack.pop(); root.pageStack.push(profileSettingsPageComponent); } } } 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 00dc5f7..d0dc740 100644 --- a/src/qml/Main.qml +++ b/src/qml/Main.qml @@ -1,83 +1,79 @@ /* * 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: 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 { } } } diff --git a/src/qml/TrainingItemsPage.qml b/src/qml/TrainingItemsPage.qml deleted file mode 100644 index 0887a6b..0000000 --- a/src/qml/TrainingItemsPage.qml +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2013-2017 Andreas Cord-Landwehr - * Copyright 2013 Magdalena Konkiewicz - * - * 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 QtQml.Models 2.2 -import QtQuick.Controls 1.4 -import org.kde.kirigami 2.0 as Kirigami2 -import artikulate 1.0 - -Kirigami2.Page { - TreeView { - id: phraseTree - anchors.fill: parent - TableViewColumn { - title: i18n("Categories") - role: "text" - } - model: PhraseModel { - id: phraseModel - course: g_trainingSession.course - } - selection: ItemSelectionModel { - model: phraseTree.model - } - itemDelegate: Item { - property bool isUnit: phraseModel.isUnit(styleData.index) - Component { - id: unitRowBackground - Rectangle {anchors.fill: parent; color: "steelblue"} - } - Component { - id: phraseProgress - Row { - property int progress: isUnit ? 0 : phraseModel.phrase(styleData.index).progress - Repeater { - model: 3 - Icon { - width: 16 - height: width - icon: progress > index ? "rating" : "rating-unrated" - } - } - } - } - Loader { - anchors.fill: parent - sourceComponent: isUnit ? unitRowBackground : null - } - Row { - Text { - width: phraseTree.width - 130 //TODO check if this is really a reasonable value - anchors { - verticalCenter: parent.verticalCenter - topMargin: 5 - bottomMargin: 5 - } - color: { - if (isUnit) { - return "white"; - } - return styleData.textColor - } - elide: Text.ElideRight - text: " " + styleData.value - font.bold: isUnit - } - Loader { - sourceComponent: isUnit ? null : phraseProgress - } - } - } - onClicked: { - g_trainingSession.phrase = phraseModel.phrase(index) - } - Connections { - target: g_trainingSession - onPhraseChanged: { - phraseTree.expand(phraseModel.indexUnit(g_trainingSession.phrase.unit)) - phraseTree.selection.setCurrentIndex( - phraseModel.indexPhrase(g_trainingSession.phrase), - ItemSelectionModel.ClearAndSelect) - } - } - } -} diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc index 681ab65..9c93d3d 100644 --- a/src/qml/qml.qrc +++ b/src/qml/qml.qrc @@ -1,27 +1,26 @@ ActionListItem.qml ArtikulateDrawer.qml CheckListItem.qml CourseSwitcher.qml Editor.qml LanguageSwitcher.qml ListItem.qml Main.qml PhonemeUnitSelector.qml PhraseEditor.qml PhraseEditorEditStateComponent.qml PhraseEditorSoundComponent.qml PhraseEditorTypeComponent.qml ProfileSelector.qml ProfileSettingsPage.qml ProfileUserImageItem.qml SoundPlayer.qml SoundRecorder.qml TrainerCourseStatistics.qml - TrainingItemsPage.qml TrainingPage.qml UnitEditor.qml WelcomePage.qml