Skip to content
Snippets Groups Projects
Commit cafd160c authored by SeeLook's avatar SeeLook
Browse files

Better way for initializing base dialog item delegates

parent 7d5c99b0
No related branches found
No related tags found
No related merge requests found
...@@ -25,26 +25,23 @@ import "fakeTrans.js" as Fake ...@@ -25,26 +25,23 @@ import "fakeTrans.js" as Fake
Dialog { Dialog {
title: qsTr("About Nootka")
visible: true visible: true
title: qsTr("About Nootka")
// width: pages.width; height: pages.height // width: pages.width; height: pages.height
width: nootkaWindow.width * 0.75; height: nootkaWindow.height * 0.75 width: nootkaWindow.width * 0.75; height: nootkaWindow.height * 0.75
PagesDialog { PagesDialog { id: pages }
id: pages
anchors.fill: parent Component.onCompleted: {
model: ListModel { id: pageModel } pages.addItem("nootka-frame", qsTr("About"), "About")
Component.onCompleted: { pages.addItem("help-frame", Fake.tr("QShortcut", "Help"), "Help")
pageModel.append({"iconName": "nootka-frame", "buttonText": qsTr("About"), "page": "About"}) pages.addItem("author", qsTr("Authors"), "Authors")
pageModel.append({"iconName": "help-frame", "buttonText": Fake.tr("QShortcut", "Help"), "page": "Help"}) pages.addItem("license", qsTr("License"), "License")
pageModel.append({"iconName": "author", "buttonText": qsTr("Authors"), "page": "Authors"}) pages.addItem("support", qsTr("Support"), "Support")
pageModel.append({"iconName": "license", "buttonText": qsTr("License"), "page": "License"}) pages.addItem("donors", qsTr("Donors", "Would be 'Sponsors' or even 'Backers' - translate as such as You fill, what sounds/looks better in Your language"), "Donors")
pageModel.append({"iconName": "support", "buttonText": qsTr("Support"), "page": "Support"}) pages.addItem("chlog", qsTr("Changes"), "Changes")
pageModel.append({"iconName": "donors", "buttonText": qsTr("Donors", "Would be 'Sponsors' or even 'Backers' - translate as such as You fill, what sounds/looks better in Your language"), "page": "Donors"}) pages.addItem("qt", "Qt", "Qt")
pageModel.append({"iconName": "chlog", "buttonText": qsTr("Changes"), "page": "Changes"})
pageModel.append({"iconName": "qt", "buttonText": "Qt", "page": "Qt"})
}
} }
} }
...@@ -21,29 +21,24 @@ import QtQuick.Controls 2.0 ...@@ -21,29 +21,24 @@ import QtQuick.Controls 2.0
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import "fakeTrans.js" as Fake
Dialog { Dialog {
title: "Nootka - " + qsTr("application's settings")
visible: true visible: true
width: nootkaWindow.width * 0.75; height: nootkaWindow.height * 0.75
title: "Nootka - " + qsTr("application's settings")
// width: pages.width; height: pages.height // width: pages.width; height: pages.height
width: nootkaWindow.width * 0.75; height: nootkaWindow.height * 0.75 PagesDialog { id: pages }
standardButtons: StandardButton.Apply | StandardButton.Cancel | StandardButton.RestoreDefaults | StandardButton.Help
PagesDialog { Component.onCompleted: {
id: pages pages.addItem("global", qsTr("Common"), "Common")
anchors.fill: parent pages.addItem("scoreSettings", "Score", "Score")
model: ListModel { id: pageModel } pages.addItem("guitarSettings", qsTr("Instrument"), "Instrument")
Component.onCompleted: { pages.addItem("soundSettings", qsTr("Sound"), "Sound")
pageModel.append({"iconName": "global", "buttonText": qsTr("Common"), "page": "Common"}) pages.addItem("questionsSettings", qsTr("Exercises") + "\n& " + qsTr("Exam"), "Exam")
pageModel.append({"iconName": "scoreSettings", "buttonText": "Score", "page": "Score"}) pages.addItem("appearance", qsTr("Appearance"), "Appearance")
pageModel.append({"iconName": "guitarSettings", "buttonText": qsTr("Instrument"), "page": "Instrument"})
pageModel.append({"iconName": "soundSettings", "buttonText": qsTr("Sound"), "page": "Sound"})
pageModel.append({"iconName": "questionsSettings", "buttonText": qsTr("Exercises") + "\n& " + qsTr("Exam"), "page": "Exam"})
pageModel.append({"iconName": "appearance", "buttonText": qsTr("Appearance"), "page": "Appearance"})
}
} }
standardButtons: StandardButton.Apply | StandardButton.Cancel | StandardButton.RestoreDefaults | StandardButton.Help
} }
...@@ -29,8 +29,10 @@ import QtQuick.Window 2.0 ...@@ -29,8 +29,10 @@ import QtQuick.Window 2.0
*/ */
Item { Item {
property alias model: navList.model
property alias stack: stack property alias stack: stack
property alias model: navList.model
anchors.fill: parent
Rectangle { color: activPal.base; x: navList.x; y: navList.y; width: navList.width; height: navList.height } Rectangle { color: activPal.base; x: navList.x; y: navList.y; width: navList.width; height: navList.height }
Rectangle { // highlight Rectangle { // highlight
...@@ -40,6 +42,11 @@ Item { ...@@ -40,6 +42,11 @@ Item {
Behavior on y { enabled: GLOB.useAnimations; SpringAnimation { spring: 2; damping: 0.1; duration: 500 }} Behavior on y { enabled: GLOB.useAnimations; SpringAnimation { spring: 2; damping: 0.1; duration: 500 }}
} }
function addItem(icon, text, page) {
navList.pages.push("qrc:/" + page + "Page.qml")
model.append({ "iconName": icon, "buttonText": text })
}
Row { Row {
anchors { fill: parent } anchors { fill: parent }
spacing: Screen.pixelDensity * 2 spacing: Screen.pixelDensity * 2
...@@ -54,6 +61,8 @@ Item { ...@@ -54,6 +61,8 @@ Item {
property HeadButton prevButt: null property HeadButton prevButt: null
property int prevDelegate: -1 property int prevDelegate: -1
model: ListModel { id: pageModel }
delegate: Component { delegate: Component {
HeadButton { HeadButton {
id: delegateButt id: delegateButt
...@@ -77,7 +86,6 @@ Item { ...@@ -77,7 +86,6 @@ Item {
if (index === navList.prevDelegate) // workaround to avoid loading delegate twice if (index === navList.prevDelegate) // workaround to avoid loading delegate twice
return return
navList.prevDelegate = index navList.prevDelegate = index
navList.pages.push("qrc:/" + page + "Page.qml")
var w = Math.max(navList.width, width) var w = Math.max(navList.width, width)
navList.width = w navList.width = w
butHigh.width = w butHigh.width = w
...@@ -90,7 +98,7 @@ Item { ...@@ -90,7 +98,7 @@ Item {
butHigh.y = delegateButt.y butHigh.y = delegateButt.y
butHigh.width = delegateButt.width butHigh.width = delegateButt.width
butHigh.height = delegateButt.height butHigh.height = delegateButt.height
stack.push("qrc:/" + page + "Page.qml") stack.push(navList.pages[0])
navList.pages[0] = stack.currentItem navList.pages[0] = stack.currentItem
} }
} }
...@@ -112,8 +120,8 @@ Item { ...@@ -112,8 +120,8 @@ Item {
width: parent.width - navList.width - Screen.pixelDensity * 2 width: parent.width - navList.width - Screen.pixelDensity * 2
height: parent.height height: parent.height
// fade animations // fade animations
pushEnter: Transition { PropertyAnimation { property: "opacity"; from: 0; to: 1; duration: 300 }} pushEnter: Transition { enabled: GLOB.useAnimations; PropertyAnimation { property: "opacity"; from: 0; to: 1; duration: 300 }}
pushExit: Transition { PropertyAnimation { property: "opacity"; from: 1; to: 0; duration: 300 }} pushExit: Transition { enabled: GLOB.useAnimations; PropertyAnimation { property: "opacity"; from: 1; to: 0; duration: 300 }}
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment