[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktouch/homescreen-ng] src/qml: Initial Version Of New Course Selector
From:       Sebastian Gottfried <null () kde ! org>
Date:       2017-06-30 13:48:00
Message-ID: E1dQwHA-0008Ck-MV () code ! kde ! org
[Download RAW message or body]

Git commit 3f9287d41fb3ae3cceb1f5fbcaa2101c2d341dd0 by Sebastian Gottfried.
Committed on 30/06/2017 at 13:47.
Pushed by gottfried into branch 'homescreen-ng'.

Initial Version Of New Course Selector

Very much unfinished by now, but there is a new sidebar now from which
the user can select from all courses KTouch is shipping with.

M  +63   -103  src/qml/homescreen/CourseSelector.qml
A  +95   -0    src/qml/homescreen/CourseSelectorKeyboardLayoutItem.qml     [License: \
GPL (v2+)] M  +20   -8    src/qml/homescreen/HomeScreen.qml
M  +1    -2    src/qml/homescreen/LessonSelector.qml
M  +3    -4    src/qml/homescreen/ProfileSelector.qml
M  +1    -1    src/qml/main.qml
M  +1    -0    src/qml/qml.qrc

https://commits.kde.org/ktouch/3f9287d41fb3ae3cceb1f5fbcaa2101c2d341dd0

diff --git a/src/qml/homescreen/CourseSelector.qml \
b/src/qml/homescreen/CourseSelector.qml index a8d6761..983f3e9 100644
--- a/src/qml/homescreen/CourseSelector.qml
+++ b/src/qml/homescreen/CourseSelector.qml
@@ -17,19 +17,23 @@
  */
 
 import QtQuick 2.4
-import QtQuick.Controls 1.3
+import QtQuick.Controls 2.0
 import QtQuick.Layouts 1.1
 import ktouch 1.0
 
-Item {
+import "../common"
+
+FocusScope {
     id: root
 
     property CategorizedResourceSortFilterProxyModel courseModel
     property Profile profile
     property KeyboardLayout keyboardLayout
     property string keyboardLayoutName
+    property DataIndexCourse selectedCourse
 
     signal lessonSelected(variant course, variant lesson)
+    signal courseSelectec(Course course)
 
     function selectLastUsedCourse() {
         if (!profile) {
@@ -89,130 +93,86 @@ Item {
         target: courseModel
         onRowsRemoved: {
             nextButton.visible = previousButton.visible = courseModel.rowCount() > 1
-            priv.currentIndex = -1
             selectLastUsedCourse()
 
         }
         onRowsInserted: {
             nextButton.visible = previousButton.visible = courseModel.rowCount() > 1
-            priv.currentIndex = -1
             selectLastUsedCourse()
         }
     }
 
-    QtObject {
-        id: priv
-        property int currentIndex: -1
+    ResourceModel {
+        id: resourceModel
+        dataIndex: ktouch.globalDataIndex
     }
 
-    SystemPalette {
-        id: palette
-        colorGroup: SystemPalette.Active
+    CategorizedResourceSortFilterProxyModel {
+        id: allKeyboardLayoutsModel
+        resourceModel: resourceModel
+        resourceTypeFilter: ResourceModel.KeyboardLayoutItem
     }
 
-    ColumnLayout {
-        anchors.fill: parent
-        spacing: 0
-
-        Rectangle {
-            id: head
-            Layout.fillWidth: true
-            height: Math.ceil(Math.max(courseTitleLabel.height, \
                courseDescriptionButton.height) + 6)
-            color: palette.base
-
-            RowLayout {
-                anchors {
-                    fill: parent
-                    leftMargin: 5
-                    rightMargin: 5
-                    topMargin: 3
-                    bottomMargin: 3
-                }
-
-                Label {
-                    anchors.verticalCenter: parent.verticalCenter
-                    id: courseTitleLabel
-                    font.pointSize: 1.5 * Qt.font({'family': 'sansserif'}).pointSize
-                    text: coursePageContainer.activePage.course.title
-                }
-
-                Item {
-                    id: smallSpacer
-                    height: parent.height
-                    width: 3
-                }
-
-                ToolButton {
-                    id: courseDescriptionButton
-                    anchors.verticalCenter: parent.verticalCenter
-                    iconName: "dialog-information"
-                    checkable: true
-                }
+    KColorScheme {
+        id: courseSelectorColorScheme
+        colorGroup: KColorScheme.Active
+        colorSet: KColorScheme.View
+    }
 
-                Item {
-                    Layout.fillWidth: true
-                    Layout.fillHeight: true
-                }
+    Rectangle {
+        id: bg
+        anchors.fill: parent
+        color: courseSelectorColorScheme.normalBackground
+    }
 
-                ToolButton {
-                    id: previousButton
-                    anchors.verticalCenter: parent.verticalCenter
-                    iconName: "arrow-left"
-                    enabled: priv.currentIndex > 0
-                    onClicked: {
-                        var newIndex = priv.currentIndex - 1
-                        root.selectCourse(newIndex, false)
-                    }
-                }
+    Flickable {
+        clip: true
+        anchors.fill: parent
+        contentWidth: width
+        contentHeight: content.height
+        Column {
+            id: content
+            width: parent.width
 
-                ToolButton {
-                    id: nextButton
-                    iconName: "arrow-right"
-                    enabled: priv.currentIndex < courseModel.rowCount()
-                    onClicked: {
-                        var newIndex = (priv.currentIndex + 1) % \
                (courseModel.rowCount() + 1)
-                        root.selectCourse(newIndex, false)
-                    }
-                }
+            ListItem {
+                width: parent.width
+                text: i18n('Courses For Your Keyboard Layout')
+                font.bold: true
+                bg.color: courseSelectorColorScheme.alternateBackground
+                bg.opacity: 1
+                label.opacity: 0.7
             }
-        }
 
-        Item {
-            Layout.fillWidth: true
-            Layout.minimumHeight: courseDescriptionItem.height
-            Layout.maximumHeight: courseDescriptionItem.height
-            CourseDescriptionItem {
-                id: courseDescriptionItem
-                active: courseDescriptionButton.checked
-                description: coursePageContainer.activePage.course.description
+            ListItem {
                 width: parent.width
+                text: i18n('Other Courses')
+                font.bold: true
+                bg.color: courseSelectorColorScheme.alternateBackground
+                bg.opacity: 1
+                label.opacity: 0.7
             }
-        }
 
-        Item {
-            id: coursePageContainer
-            property CoursePage activePage: page0
-            property CoursePage inactivePage: page1
-
-            Layout.fillWidth: true
-            Layout.fillHeight: true
-
-            CoursePage {
-                id: page0
-                profile: root.profile
-                keyboardLayout: root.keyboardLayout
-                keyboardLayoutName: root.keyboardLayoutName
-                onLessonSelected: root.lessonSelected(course, lesson)
-                Component.onCompleted: page0.showImmediately()
+            Repeater {
+                model: allKeyboardLayoutsModel
+                CourseSelectorKeyboardLayoutItem {
+                    width: parent.width
+                    name: keyboardLayoutName
+                    title: display
+                    resourceModel: allKeyboardLayoutsModel.resourceModel
+                    selectedCourse: root.selectedCourse
+                    onCourseSelected: {
+                        root.selectedCourse = course
+                    }
+                }
             }
 
-            CoursePage {
-                id: page1
-                profile: root.profile
-                keyboardLayout: root.keyboardLayout
-                keyboardLayoutName: root.keyboardLayoutName
-                onLessonSelected: root.lessonSelected(course, lesson)
-            }
         }
+        ScrollBar.vertical: ScrollBar { }
     }
+
+
+
+
+
+
 }
diff --git a/src/qml/homescreen/CourseSelectorKeyboardLayoutItem.qml \
b/src/qml/homescreen/CourseSelectorKeyboardLayoutItem.qml new file mode 100644
index 0000000..5105f41
--- /dev/null
+++ b/src/qml/homescreen/CourseSelectorKeyboardLayoutItem.qml
@@ -0,0 +1,95 @@
+/*
+ *  Copyright 2012  Sebastian Gottfried <sebastiangottfried@web.de>
+ *  Copyright 2015  Sebastian Gottfried <sebastiangottfried@web.de>
+ *
+ *  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) any later version.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.4
+import ktouch 1.0
+
+import "../common"
+
+Column {
+    id: root
+    property string name
+    property alias title: keyboardLayoutItem.text
+    property ResourceModel resourceModel
+    property DataIndexCourse selectedCourse
+
+    signal courseSelected(DataIndexCourse course)
+
+    height: keyboardLayoutItem.height + (loader.active? loader.height: 0)
+    clip: true
+
+    ListItem {
+        id: keyboardLayoutItem
+        icon: "input-keyboard"
+        width: parent.width
+        onClicked: {
+            loader.active = !loader.active
+        }
+    }
+
+    Loader {
+        id: loader
+        width: parent.width
+        active: false
+        property string keyboardLayoutNameFilter: root.name
+        sourceComponent: Component {
+            id: courseSelectionComponent
+
+            Column {
+                CategorizedResourceSortFilterProxyModel {
+                    id: courseModel
+                    resourceModel: root.resourceModel
+                    resourceTypeFilter: ResourceModel.CourseItem
+                    keyboardLayoutNameFilter: loader.keyboardLayoutNameFilter
+                }
+                Repeater {
+                    id: courseRepeater
+                    model: courseModel
+                    ListItem {
+                        text: display
+                        width: parent.width
+                        reserveSpaceForIcon: true
+                        highlighted: root.selectedCourse == dataRole
+                        onClicked: {
+                            courseSelected(dataRole)
+                        }
+                    }
+                }
+                ListItem {
+                    text: i18n("Custom Lessons")
+                    id: ownLessonsItem
+                    reserveSpaceForIcon: true
+                    width: parent.width
+                }
+                Component.onCompleted: {
+                    if (courseModel.rowCount()) {
+                        courseSelected(courseModel.data(courseModel.index(0, 0), \
ResourceModel.DataRole)) +                    }
+                }
+            }
+        }
+    }
+
+    Behavior on height {
+        NumberAnimation {
+            duration: 150
+            easing.type: Easing.InOutQuad
+        }
+    }
+}
+
diff --git a/src/qml/homescreen/HomeScreen.qml b/src/qml/homescreen/HomeScreen.qml
index 4b5972b..a6a8ac7 100644
--- a/src/qml/homescreen/HomeScreen.qml
+++ b/src/qml/homescreen/HomeScreen.qml
@@ -139,17 +139,29 @@ FocusScope {
             Layout.fillWidth: true
             Layout.fillHeight: true
 
-            CourseSelector {
-                id: courseSelector
-                opacity: 1 - initialProfileForm.opacity
-                courseModel: screen.courseModel
-                profile: d.profile
-                keyboardLayout: screen.keyboardLayout
-                keyboardLayoutName: screen.keyboardLayoutName
+            RowLayout {
                 anchors.fill: parent
-                onLessonSelected: screen.lessonSelected(course, lesson, d.profile)
+
+                CourseSelector {
+                    id: courseSelector
+                    Layout.fillHeight: true
+                    Layout.preferredWidth: 300
+                    opacity: 1 - initialProfileForm.opacity
+                    courseModel: screen.courseModel
+                    profile: d.profile
+                    keyboardLayout: screen.keyboardLayout
+                    keyboardLayoutName: screen.keyboardLayoutName
+                    onLessonSelected: screen.lessonSelected(course, lesson, \
d.profile) +                }
+
+                Item {
+                    id: filler
+                    Layout.fillHeight: true
+                    Layout.fillWidth: true
+                }
             }
 
+
             InitialProfileForm {
                 id: initialProfileForm
                 opacity: profileDataAccess.profileCount == 0? 1: 0
diff --git a/src/qml/homescreen/LessonSelector.qml \
b/src/qml/homescreen/LessonSelector.qml index 0609caa..17fdafa 100644
--- a/src/qml/homescreen/LessonSelector.qml
+++ b/src/qml/homescreen/LessonSelector.qml
@@ -109,8 +109,7 @@ Item {
                         }
                     }
                     iconSource: locked? "object-locked": ""
-                    label.opacity: locked? 0.5: 1.0
-                    title: lesson? lesson.title: ""
+                    text: lesson? lesson.title: ""
 
                 }
                 onModelChanged: update()
diff --git a/src/qml/homescreen/ProfileSelector.qml \
b/src/qml/homescreen/ProfileSelector.qml index 609a08d..c263b94 100644
--- a/src/qml/homescreen/ProfileSelector.qml
+++ b/src/qml/homescreen/ProfileSelector.qml
@@ -58,18 +58,17 @@ FocusScope {
                     ListView {
                         id: list
                         anchors.fill: parent
-                        anchors.margins: 3
-                        spacing: 3
                         model: profileDataAccess.profileCount + 1
                         clip: true
                         delegate: ListItem {
                             property bool isNewButton: index >= \
profileDataAccess.profileCount  width: list.width
-                            title: isNewButton?
+                            text: isNewButton?
                                     i18n("Create New Profile"):
                                     index < profileDataAccess.profileCount? \
profileDataAccess.profile(index).name: null  label.font.italic: isNewButton
-                            iconSource: isNewButton? "list-add": "user-identity"
+                            icon: isNewButton? "list-add": "user-identity"
+                            highlighted: ListView.isCurrentItem
                             onClicked: {
                                 list.currentIndex = index
                                 if (isNewButton) {
diff --git a/src/qml/main.qml b/src/qml/main.qml
index 8907209..4d1cbc3 100644
--- a/src/qml/main.qml
+++ b/src/qml/main.qml
@@ -32,7 +32,7 @@ Rectangle {
     }
 
     id: main
-    color: activePallete.window
+    color: Qt.darker(activePallete.window, 1.6)
 
     function switchScreen(from, to) {
         switchScreenAnimation.from = from
diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc
index 657960c..6c2c915 100644
--- a/src/qml/qml.qrc
+++ b/src/qml/qml.qrc
@@ -41,6 +41,7 @@
         <file>keyboard/KeyLabel.qml</file>
         <file>keyboard/KeyboardLayoutEditor.qml</file>
         <file>common/IconToolButton.qml</file>
+        <file>homescreen/CourseSelectorKeyboardLayoutItem.qml</file>
         <file>common/IconLabel.qml</file>
         <file>common/MonochromeIcon.qml</file>
     </qresource>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic