Commit 14876596 authored by Sebastian Gottfried's avatar Sebastian Gottfried
Browse files

Qt5: Port CourseSelector.qml And Friends

With this most of the functionality of the home screen is there again.
Still missing is the profile managment form and the custom lesson
dialog has some severe layout issues.
parent 442b70c9
......@@ -18,7 +18,7 @@
#include "application.h"
#include <QQmlEngine>
#include <QJSValue>
#include <QQmlContext>
#include <KDeclarative/KDeclarative>
......@@ -77,10 +77,10 @@ void Application::setupDeclarativeBindings(QQmlEngine* qmlEngine)
kDeclarative.setDeclarativeEngine(qmlEngine);
kDeclarative.setupBindings();
QJSValue globalObject = qmlEngine->globalObject();
QQmlContext* rootContext = qmlEngine->rootContext();
globalObject.setProperty("utils", qmlEngine->newQObject(new Utils()));
globalObject.setProperty("strFormatter", qmlEngine->newQObject(new StringFormatter()));
rootContext->setContextProperty("utils", new Utils());
rootContext->setContextProperty("strFormatter", new StringFormatter());
}
void Application::registerQmlTypes()
......
/*
* 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
......@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import ktouch 1.0
Rectangle {
......@@ -26,9 +27,14 @@ Rectangle {
property string description
property bool active: false
height: active || content.opacity > 0? childrenRect.height: 0
SystemPalette {
id: palette
colorGroup: SystemPalette.Active
}
height: active || content.opacity > 0? content.height: 0
visible: height > 0
color: theme.backgroundColor
color: palette.base
Behavior on height {
NumberAnimation {
......@@ -68,11 +74,10 @@ Rectangle {
}
}
PlasmaComponents.Label {
Label {
id: descriptionLabel
anchors.centerIn: parent
width: parent.width - 10
font.pointSize: theme.smallestFont.pointSize
}
}
......
/*
* 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
......@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
......
/*
* 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
......@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
......@@ -107,16 +108,22 @@ Item {
property int currentIndex: -1
}
Column {
SystemPalette {
id: palette
colorGroup: SystemPalette.Active
}
ColumnLayout {
anchors.fill: parent
spacing: 0
Rectangle {
id: head
width: parent.width
height: Math.ceil(courseTitleLabel.height + 6)
color: theme.backgroundColor
Layout.fillWidth: true
height: Math.ceil(Math.max(courseTitleLabel.height, courseDescriptionButton.height) + 6)
color: palette.base
Row {
RowLayout {
anchors {
fill: parent
leftMargin: 5
......@@ -125,10 +132,10 @@ Item {
bottomMargin: 3
}
PlasmaComponents.Label {
Label {
anchors.verticalCenter: parent.verticalCenter
id: courseTitleLabel
height: paintedHeight
font.pointSize: 1.5 * theme.defaultFont.pointSize
font.pointSize: 1.5 * Qt.font({'family': 'sansserif'}).pointSize
text: coursePageContainer.activePage.course.title
}
......@@ -138,20 +145,22 @@ Item {
width: 3
}
PlasmaComponents.ToolButton {
ToolButton {
id: courseDescriptionButton
iconSource: "dialog-information"
anchors.verticalCenter: parent.verticalCenter
iconName: "dialog-information"
checkable: true
}
Item {
width: parent.width - courseTitleLabel.width - smallSpacer.width - courseDescriptionButton.width - previousButton.width - nextButton.width - (parent.children.length - 1) * parent.spacing
height: parent.height
Layout.fillWidth: true
Layout.fillHeight: true
}
PlasmaComponents.ToolButton {
ToolButton {
id: previousButton
iconSource: "arrow-left"
anchors.verticalCenter: parent.verticalCenter
iconName: "arrow-left"
enabled: priv.currentIndex > 0
visible: courseRepeater.count > 0
onClicked: {
......@@ -160,9 +169,9 @@ Item {
}
}
PlasmaComponents.ToolButton {
ToolButton {
id: nextButton
iconSource: "arrow-right"
iconName: "arrow-right"
enabled: priv.currentIndex < courseRepeater.count
visible: courseRepeater.count > 0
onClicked: {
......@@ -173,11 +182,16 @@ Item {
}
}
CourseDescriptionItem {
id: courseDescriptionItem
width: parent.width
active: courseDescriptionButton.checked
description: coursePageContainer.activePage.course.description
Item {
Layout.fillWidth: true
Layout.minimumHeight: courseDescriptionItem.height
Layout.maximumHeight: courseDescriptionItem.height
CourseDescriptionItem {
id: courseDescriptionItem
active: courseDescriptionButton.checked
description: coursePageContainer.activePage.course.description
width: parent.width
}
}
Item {
......@@ -185,8 +199,8 @@ Item {
property CoursePage activePage: page0
property CoursePage inactivePage: page1
width: parent.width
height: parent.height - head.height - courseDescriptionItem.height
Layout.fillWidth: true
Layout.fillHeight: true
CoursePage {
id: page0
......
/*
* Copyright 2013 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
......@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
......@@ -54,10 +55,10 @@ Item {
}
function createNewLesson() {
tmpLesson.id = uuid()
tmpLesson.id = utils.uuid()
tmpLesson.title = ""
tmpLesson.text = ""
if (showCustomLessonDialog(tmpLesson, root.keyboardLayout)) {
if (ktouch.showCustomLessonDialog(tmpLesson, root.keyboardLayout)) {
profileDataAccess.storeCustomLesson(tmpLesson, root.profile, keyboardLayoutName)
update()
lessonList.currentIndex = lessonList.count - 2
......@@ -66,7 +67,7 @@ Item {
function editLesson() {
tmpLesson.copyFrom(base.selectedLesson)
if (showCustomLessonDialog(tmpLesson, root.keyboardLayout)) {
if (ktouch.showCustomLessonDialog(tmpLesson, root.keyboardLayout)) {
profileDataAccess.storeCustomLesson(tmpLesson, root.profile, keyboardLayoutName)
update()
}
......@@ -122,41 +123,40 @@ Item {
anchors.fill: parent
list: ListView {
id: lessonList
anchors.fill: parent
model: course.isValid? course.lessonCount + 1: 0
clip: true
delegate: ListItem {
property Lesson lesson: index < course.lessonCount? course.lesson(index): null
property bool isNewButton: index == course.lessonCount
width: lessonList.width - scrollBar.width
onClicked: {
lessonList.currentIndex = index
if (isNewButton) {
createNewLesson()
list: ScrollView {
width: 500
height: 500
ListView {
id: lessonList
anchors.fill: parent
model: course.isValid? course.lessonCount + 1: 0
clip: true
delegate: ListItem {
property Lesson lesson: index < course.lessonCount? course.lesson(index): null
property bool isNewButton: index == course.lessonCount
width: lessonList.width
onClicked: {
lessonList.currentIndex = index
if (isNewButton) {
createNewLesson()
}
}
}
onDoubleClicked: {
if (!isNewButton) {
lessonSelected(course, lesson)
onDoubleClicked: {
if (!isNewButton) {
lessonSelected(course, lesson)
}
}
title: isNewButton? i18n("Create New Custom Lesson"): (lesson? lesson.title: "")
iconSource: isNewButton? "list-add": ""
label.font.italic: isNewButton
}
title: isNewButton? i18n("Create New Custom Lesson"): (lesson? lesson.title: "")
iconSource: isNewButton? "list-add": ""
label.font.italic: isNewButton
}
onCurrentIndexChanged: updateSelectedLesson()
onModelChanged: selectLastLesson()
onCurrentIndexChanged: updateSelectedLesson()
PlasmaComponents.ScrollBar {
id: scrollBar
flickableItem: lessonList
onModelChanged: selectLastLesson()
}
}
......@@ -170,16 +170,14 @@ Item {
}
opacity: base.selectedLesson !== null? 1: 0
content: [
PlasmaComponents.ToolButton {
ToolButton {
iconSource: "document-edit"
text: i18n("Edit")
onClicked: editLesson()
width: minimumWidth
},
PlasmaComponents.ToolButton {
ToolButton {
iconSource: "edit-delete"
text: i18n("Delete")
width: minimumWidth
onClicked: deleteLesson()
}
]
......@@ -204,23 +202,21 @@ Item {
}
opacity: !!lastDeletedLesson? 1: 0
content: [
PlasmaComponents.Label {
Label {
text: i18n("'%1' deleted.", undoToolbar.lastDeletedLessonTitle)
},
Item {
width: 5
height: 1
},
PlasmaComponents.ToolButton {
ToolButton {
iconSource: "edit-undo"
text: i18n("Undo")
width: minimumWidth
onClicked: undoLessonDeletion()
},
PlasmaComponents.ToolButton {
ToolButton {
iconSource: "dialog-close"
text: i18n("Dismiss")
width: minimumWidth
onClicked: confirmLessonDeletion()
}
]
......
......@@ -71,9 +71,10 @@ FocusScope {
ColumnLayout {
anchors.fill: parent
spacing: 0
ToolBar {
visible: homeScreenAccordion.opacity > 0
visible: courseSelector.opacity > 0
id: header
Layout.fillWidth: true
......@@ -119,9 +120,8 @@ FocusScope {
Layout.fillWidth: true
Layout.fillHeight: true
/*
CourseSelector {
id: homeScreenAccordion
id: courseSelector
opacity: 1 - initialProfileForm.opacity
courseModel: screen.courseModel
profile: d.profile
......@@ -130,7 +130,6 @@ FocusScope {
anchors.fill: parent
onLessonSelected: screen.lessonSelected(course, lesson, d.profile)
}
*/
InitialProfileForm {
id: initialProfileForm
......
/*
* Copyright 2013 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
......@@ -15,9 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import QtQuick 2.4
Item {
......@@ -29,10 +28,15 @@ Item {
width: contentArea.width + 6
height: contentArea.height + 6
SystemPalette {
id: palette
colorGroup: SystemPalette.Active
}
Rectangle {
anchors.fill: parent
id: background
color: "#888"
color: pallete.mid
opacity: 0.7
radius: 3
}
......
/*
* 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
......@@ -15,9 +16,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import org.kde.qtextracomponents 0.1
import org.kde.plasma.components 0.1 as PlasmaComponents
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import QtGraphicalEffects 1.0
import org.kde.kquickcontrolsaddons 2.0
import ktouch 1.0
Item {
id: root
......@@ -25,11 +30,15 @@ Item {
width: content.width + 40
height: content.height + 40
SystemPalette {
id: palette
colorGroup: SystemPalette.Active
}
Rectangle {
anchors.fill: parent
id: background
color: "#000"
opacity: 0.7
anchors.fill: parent
color: palette.base
radius: 15
}
......@@ -49,17 +58,16 @@ Item {
QIconItem {
id: icon
anchors.horizontalCenter: parent.horizontalCenter
icon: QIcon("object-locked")
width: theme.enormousIconSize
height: theme.enormousIconSize
icon: "object-locked"
width: 128
height: 128
}
PlasmaComponents.Label {
Label {
id: text
text: i18n("Complete Previous Lessons to Unlock")
anchors.horizontalCenter: parent.horizontalCenter
horizontalAlignment: Text.AlignHCenter
color: "#fff"
font.weight: Font.Bold
wrapMode: Text.Wrap
}
......
......@@ -15,7 +15,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import QtQuick 2.4
import ktouch 1.0
Item {
......
/*
* 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
......@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
......@@ -86,32 +87,31 @@ Item {
LessonSelectorBase {
anchors.fill: parent
list: ListView {
id: lessonList
property int lastUnlockedIndex: 0
list:ScrollView {
anchors.fill: parent
model: course.isValid? course.lessonCount: 0
clip: true
delegate: ListItem {
property Lesson lesson: index < course.lessonCount? course.lesson(index): null
property bool locked: index > lessonList.lastUnlockedIndex
width: lessonList.width - scrollBar.width
onClicked: lessonList.currentIndex = index
onDoubleClicked: {
if (!locked) {
lessonSelected(course, lesson)
ListView {
anchors.fill: parent
id: lessonList
property int lastUnlockedIndex: 0
model: course.isValid? course.lessonCount: 0
spacing: 3
clip: true
delegate: ListItem {
property Lesson lesson: index < course.lessonCount? course.lesson(index): null
property bool locked: index > lessonList.lastUnlockedIndex
width: lessonList.width
onClicked: lessonList.currentIndex = index
onDoubleClicked: {
if (!locked) {
lessonSelected(course, lesson)
}
}
}
iconSource: locked? "object-locked": ""
label.opacity: locked? 0.5: 1.0
title: lesson? lesson.title: ""
}
onModelChanged: update()
iconSource: locked? "object-locked": ""
label.opacity: locked? 0.5: 1.0
title: lesson? lesson.title: ""
PlasmaComponents.ScrollBar {
id: scrollBar
flickableItem: lessonList
}
onModelChanged: update()
}
}
......
/*
* Copyright 2013 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
......@@ -15,9 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.1
import org.kde.plasma.core 0.1 as PlasmaCore
import org.kde.plasma.components 0.1 as PlasmaComponents
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Layouts 1.1
import ktouch 1.0
Item {
......@@ -39,9 +40,10 @@ Item {
id: listContainer<