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

List:       kde-commits
Subject:    [ktouch/homescreen-ng] src/qml: Implement New Popup Dialog Component
From:       Sebastian Gottfried <null () kde ! org>
Date:       2017-10-31 16:16:46
Message-ID: E1e9ZDa-00021i-E9 () code ! kde ! org
[Download RAW message or body]

Git commit 8cff11495dd88f3f33ed359cd561c61164d3dcf6 by Sebastian Gottfried.
Committed on 31/10/2017 at 16:16.
Pushed by gottfried into branch 'homescreen-ng'.

Implement New Popup Dialog Component

This time based on QQC2's Dialog component. Will replace SheetDialog
and all the over overlay implementations in the app.

A  +115  -0    src/qml/common/PopupDialog.qml     [License: GPL (v2+)]
M  +0    -23   src/qml/homescreen/HomeScreen.qml
M  +23   -2    src/qml/homescreen/ProfileComboBox.qml
M  +65   -58   src/qml/main.qml
M  +25   -24   src/qml/qml.qrc

https://commits.kde.org/ktouch/8cff11495dd88f3f33ed359cd561c61164d3dcf6

diff --git a/src/qml/common/PopupDialog.qml b/src/qml/common/PopupDialog.qml
new file mode 100644
index 0000000..cbb17de
--- /dev/null
+++ b/src/qml/common/PopupDialog.qml
@@ -0,0 +1,115 @@
+/*
+ *  Copyright 2017  Sebastian Gottfried <sebastian.gottfried@posteo.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 QtQuick.Controls 2.2
+import ktouch 1.0
+import QtGraphicalEffects 1.0
+
+Dialog {
+    id: root
+    dim: true
+
+    margins: {
+        left: 40
+        bottom: 40
+        right: 40
+        top: 40
+    }
+
+    width: parent.width - leftMargin - rightMargin
+    height: parent.height - topMargin - bottomMargin
+
+    Component.onCompleted: {
+        var candidate = root
+        while (candidate.parent) {
+            candidate = candidate.parent
+        }
+        if (candidate) {
+            root.parent = candidate
+        }
+    }
+
+    Item {
+        id: dimOverlay
+        parent: root.parent
+        width: root.parent.width
+        height: root.parent.height
+        visible: root.visible && root.dim
+
+        ShaderEffectSource {
+            id: effectSource
+            sourceItem: root.parent.appContent
+            anchors.fill: parent
+            hideSource: false
+        }
+
+        HueSaturation {
+            id: desaturatedBackground
+            source: effectSource
+            anchors.fill: parent
+            lightness: -0.3
+            saturation: -0.5
+            visible: false
+        }
+
+        FastBlur {
+            anchors.fill: parent
+            source: desaturatedBackground
+            radius: 50
+        }
+
+        Rectangle {
+            anchors.fill: parent
+            color: "#55000000"
+        }
+    }
+
+
+    background: Rectangle {
+        color: dialogColorScheme.normalBackground
+
+        KColorScheme {
+            id: dialogColorScheme
+            colorGroup: KColorScheme.Active
+            colorSet: KColorScheme.Window
+        }
+    }
+
+    header: Rectangle {
+        height: titleLabel.implicitHeight
+        color: toolbarColorScheme.toolbarBackground
+
+        KColorScheme {
+            id: toolbarColorScheme
+            colorGroup: KColorScheme.Active
+            colorSet: KColorScheme.Complementary
+            property color toolbarBackground: \
Qt.darker(toolbarColorScheme.shade(toolbarColorScheme.hoverDecoration, \
KColorScheme.MidShade, toolbarColorScheme.contrast, -0.2), 1.3) +        }
+
+        Label {
+            id: titleLabel
+            text: root.title
+            width: parent.width
+            color: toolbarColorScheme.normalText
+            font.bold: true
+            padding: font.pixelSize
+        }
+
+    }
+
+}
diff --git a/src/qml/homescreen/HomeScreen.qml b/src/qml/homescreen/HomeScreen.qml
index 6f279cf..2b4d935 100644
--- a/src/qml/homescreen/HomeScreen.qml
+++ b/src/qml/homescreen/HomeScreen.qml
@@ -123,7 +123,6 @@ FocusScope {
                                 safeLastUsedProfile(profile)
                             }
                         }
-
                     }
                 }
 
@@ -167,26 +166,4 @@ FocusScope {
             }
         }
     }
-
-    SheetDialog {
-        id: profileSelectorSheet
-        anchors.fill: parent
-        onOpened: {
-            if (profileComboBox.profile) {
-                var index = \
                profileDataAccess.indexOfProfile(profileComboBox.profile)
-                profileSelector.selectProfile(index)
-            }
-        }
-        onClosed: {
-            profileButton.checked = false;
-        }
-        content: ProfileSelector {
-            id: profileSelector
-            anchors.fill: parent
-            onProfileChosen: {
-                screen.switchToProfile(profile)
-                profileSelectorSheet.close()
-            }
-        }
-    }
 }
diff --git a/src/qml/homescreen/ProfileComboBox.qml \
b/src/qml/homescreen/ProfileComboBox.qml index b12c921..2594a86 100644
--- a/src/qml/homescreen/ProfileComboBox.qml
+++ b/src/qml/homescreen/ProfileComboBox.qml
@@ -1,5 +1,5 @@
 /*
- *  Copyright 20175  Sebastian Gottfried <sebastian.gottfried@posteo.de>
+ *  Copyright 2017  Sebastian Gottfried <sebastian.gottfried@posteo.de>
  *
  *  This program is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU General Public License as
@@ -133,9 +133,9 @@ ComboBox {
                             mouse.accepted = true
                         }
                         onClicked: {
-                            console.log("manage profile")
                             root.popup.close()
                             mouse.accepted = true
+                            manageProfileDialog.open()
                         }
                     }
                 }
@@ -151,4 +151,25 @@ ComboBox {
             }
         }
     }
+
+    PopupDialog {
+        id: manageProfileDialog
+        modal: true
+        focus: true
+        title: i18n("Manage Profiles")
+        closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
+        contentItem:  ProfileSelector {
+            id: profileSelector
+            onProfileChosen: {
+                root.profile = profile
+                manageProfileDialog.close()
+            }
+        }
+        onOpened: {
+            if (profileComboBox.profile) {
+                var index = \
profileDataAccess.indexOfProfile(profileComboBox.profile) +                \
profileSelector.selectProfile(index) +            }
+        }
+    }
 }
diff --git a/src/qml/main.qml b/src/qml/main.qml
index d90c3d3..a29e16a 100644
--- a/src/qml/main.qml
+++ b/src/qml/main.qml
@@ -26,14 +26,9 @@ import "./trainingscreen"
 import "./scorescreen"
 
 Rectangle {
-    KColorScheme {
-        id: activePallete
-        colorGroup: KColorScheme.Active
-        colorSet: KColorScheme.Window
-    }
-
     id: main
     color: activePallete.normalBackground
+    property Item appContent: appContentItem
 
     function switchScreen(from, to) {
         switchScreenAnimation.from = from
@@ -41,6 +36,12 @@ Rectangle {
         switchScreenAnimation.start()
     }
 
+    KColorScheme {
+        id: activePallete
+        colorGroup: KColorScheme.Active
+        colorSet: KColorScheme.Window
+    }
+
     DataAccess {
         id: dataAccess
     }
@@ -120,66 +121,72 @@ Rectangle {
         id: customLessonCopy
     }
 
-    HomeScreen {
-        id: homeScreen
+    Item {
         anchors.fill: parent
-        keyboardLayout: keyboardLayout
-        keyboardLayoutName: keyboardLayout.isValid? keyboardLayout.name: helper.name
-        visible: false
-        focus: true
-        onLessonSelected: {
-            trainingScreen.profile = profile
-            var lessonIndex = -1;
-            for (var i = 0; i < course.lessonCount; i++) {
-                if (lesson === course.lesson(i)) {
-                    lessonIndex = i
-                    break
+        id: appContentItem
+        layer.enabled: true
+
+        HomeScreen {
+            id: homeScreen
+            anchors.fill: parent
+            keyboardLayout: keyboardLayout
+            keyboardLayoutName: keyboardLayout.isValid? keyboardLayout.name: \
helper.name +            visible: false
+            focus: true
+            onLessonSelected: {
+                trainingScreen.profile = profile
+                var lessonIndex = -1;
+                for (var i = 0; i < course.lessonCount; i++) {
+                    if (lesson === course.lesson(i)) {
+                        lessonIndex = i
+                        break
+                    }
                 }
-            }
-            selectedCourse.copyFrom(course)
+                selectedCourse.copyFrom(course)
 
-            if (lessonIndex !== -1) {
-                selectedCourse.selectedLesson = selectedCourse.lesson(lessonIndex)
+                if (lessonIndex !== -1) {
+                    selectedCourse.selectedLesson = \
selectedCourse.lesson(lessonIndex) +                }
+                else {
+                    customLessonCopy.copyFrom(lesson)
+                    selectedCourse.selectedLesson = customLessonCopy
+                }
+
+                main.switchScreen(homeScreen, trainingScreen)
             }
-            else {
-                customLessonCopy.copyFrom(lesson)
-                selectedCourse.selectedLesson = customLessonCopy
+            Component.onCompleted: {
+                homeScreen.reset()
+                homeScreen.visible = true
             }
-
-            main.switchScreen(homeScreen, trainingScreen)
-        }
-        Component.onCompleted: {
-            homeScreen.reset()
-            homeScreen.visible = true
         }
-    }
 
-    TrainingScreen {
-        id: trainingScreen
-        anchors.fill: parent
-        visible: false
-        keyboardLayout: keyboardLayout
-        course: selectedCourse
-        lesson: selectedCourse.selectedLesson
-        onRestartRequested: main.switchScreen(trainingScreen, trainingScreen)
-        onAbortRequested: main.switchScreen(trainingScreen, homeScreen)
-        onFinished: main.switchScreen(trainingScreen, scoreScreen)
-    }
+        TrainingScreen {
+            id: trainingScreen
+            anchors.fill: parent
+            visible: false
+            keyboardLayout: keyboardLayout
+            course: selectedCourse
+            lesson: selectedCourse.selectedLesson
+            onRestartRequested: main.switchScreen(trainingScreen, trainingScreen)
+            onAbortRequested: main.switchScreen(trainingScreen, homeScreen)
+            onFinished: main.switchScreen(trainingScreen, scoreScreen)
+        }
 
-    ScoreScreen {
-        id: scoreScreen
-        anchors.fill: parent
-        visible: false
-        course: trainingScreen.course
-        lesson: trainingScreen.lesson
-        stats: trainingScreen.stats
-        profile: trainingScreen.profile
-        referenceStats: trainingScreen.referenceStats
-        onHomeScreenRequested: main.switchScreen(scoreScreen, homeScreen)
-        onLessonRepetionRequested: main.switchScreen(scoreScreen, trainingScreen)
-        onNextLessonRequested: {
-            selectedCourse.selectedLesson = lesson
-            main.switchScreen(scoreScreen, trainingScreen)
+        ScoreScreen {
+            id: scoreScreen
+            anchors.fill: parent
+            visible: false
+            course: trainingScreen.course
+            lesson: trainingScreen.lesson
+            stats: trainingScreen.stats
+            profile: trainingScreen.profile
+            referenceStats: trainingScreen.referenceStats
+            onHomeScreenRequested: main.switchScreen(scoreScreen, homeScreen)
+            onLessonRepetionRequested: main.switchScreen(scoreScreen, \
trainingScreen) +            onNextLessonRequested: {
+                selectedCourse.selectedLesson = lesson
+                main.switchScreen(scoreScreen, trainingScreen)
+            }
         }
     }
 
diff --git a/src/qml/qml.qrc b/src/qml/qml.qrc
index 180ccb0..1eb6af0 100644
--- a/src/qml/qml.qrc
+++ b/src/qml/qml.qrc
@@ -1,51 +1,52 @@
 <RCC>
     <qresource prefix="/qml">
-        <file>main.qml</file>
-        <file>meters/AccuracyMeter.qml</file>
-        <file>meters/CharactersPerMinuteMeter.qml</file>
-        <file>meters/ElapsedTimeMeter.qml</file>
-        <file>meters/Meter.qml</file>
-        <file>meters/StatBox.qml</file>
+        <file>common/Balloon.qml</file>
         <file>common/DetailedRadioButton.qml</file>
         <file>common/IconButton.qml</file>
+        <file>common/IconLabel.qml</file>
+        <file>common/IconToolButton.qml</file>
         <file>common/InfoItem.qml</file>
         <file>common/InformationTable.qml</file>
         <file>common/InlineToolbar.qml</file>
         <file>common/LearningProgressChart.qml</file>
         <file>common/ListItem.qml</file>
         <file>common/MessageBox.qml</file>
+        <file>common/MonochromeIcon.qml</file>
+        <file>common/PopupDialog.qml</file>
         <file>common/SelectionGrip.qml</file>
         <file>common/SelectionRectangle.qml</file>
         <file>common/SheetDialog.qml</file>
-        <file>common/Balloon.qml</file>
-        <file>scorescreen/ScoreScreen.qml</file>
-        <file>trainingscreen/KeyboardUnavailableNotice.qml</file>
-        <file>trainingscreen/TrainingScreenMenuOverlay.qml</file>
-        <file>trainingscreen/TrainingScreen.qml</file>
-        <file>trainingscreen/TrainingScreenToolbar.qml</file>
-        <file>trainingscreen/TrainingWidget.qml</file>
         <file>homescreen/CourseDescriptionItem.qml</file>
         <file>homescreen/CourseSelector.qml</file>
+        <file>homescreen/CourseSelectorKeyboardLayoutItem.qml</file>
         <file>homescreen/CourseSelectorKeyboardLayoutList.qml</file>
+        <file>homescreen/CustomLessonSelector.qml</file>
+        <file>homescreen/HomeScreen.qml</file>
         <file>homescreen/InitialProfileForm.qml</file>
         <file>homescreen/LessonLockedNotice.qml</file>
         <file>homescreen/LessonPreview.qml</file>
-        <file>homescreen/LessonSelectorBase.qml</file>
-        <file>homescreen/HomeScreen.qml</file>
-        <file>homescreen/CustomLessonSelector.qml</file>
-        <file>homescreen/ProfileForm.qml</file>
         <file>homescreen/LessonSelector.qml</file>
+        <file>homescreen/LessonSelectorBase.qml</file>
         <file>homescreen/LessonSelectorItem.qml</file>
-        <file>homescreen/ProfileSelector.qml</file>
+        <file>homescreen/ProfileComboBox.qml</file>
         <file>homescreen/ProfileDetailsItem.qml</file>
-        <file>keyboard/Keyboard.qml</file>
+        <file>homescreen/ProfileForm.qml</file>
+        <file>homescreen/ProfileSelector.qml</file>
         <file>keyboard/KeyItem.qml</file>
         <file>keyboard/KeyLabel.qml</file>
+        <file>keyboard/Keyboard.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>
-        <file>homescreen/ProfileComboBox.qml</file>
+        <file>main.qml</file>
+        <file>meters/AccuracyMeter.qml</file>
+        <file>meters/CharactersPerMinuteMeter.qml</file>
+        <file>meters/ElapsedTimeMeter.qml</file>
+        <file>meters/Meter.qml</file>
+        <file>meters/StatBox.qml</file>
+        <file>scorescreen/ScoreScreen.qml</file>
+        <file>trainingscreen/KeyboardUnavailableNotice.qml</file>
+        <file>trainingscreen/TrainingScreen.qml</file>
+        <file>trainingscreen/TrainingScreenMenuOverlay.qml</file>
+        <file>trainingscreen/TrainingScreenToolbar.qml</file>
+        <file>trainingscreen/TrainingWidget.qml</file>
     </qresource>
 </RCC>


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

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