Skip to content
Snippets Groups Projects
Commit 12ffaa20 authored by SeeLook's avatar SeeLook :musical_note:
Browse files

Exams: updated JS calls, code format

parent e8c84530
No related branches found
No related tags found
No related merge requests found
...@@ -2,26 +2,33 @@ ...@@ -2,26 +2,33 @@
* Copyright (C) 2018-2021 by Tomasz Bojczuk (seelook@gmail.com) * * Copyright (C) 2018-2021 by Tomasz Bojczuk (seelook@gmail.com) *
* on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) */ * on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) */
import QtQuick 2.12
import "../" import "../"
import "../level" import "../level"
import QtQuick 2.12
Tmenu { Tmenu {
id: lPop id: lPop
property alias levelPreview: levelPreview
width: NOO.factor() * 40; height: parent.height / 2 property alias levelPreview: levelPreview
x: (parent.width - width) / 2; y: parent.height / 12
visible: true width: NOO.factor() * 40
height: parent.height / 2
Column { x: (parent.width - width) / 2
width: parent.width; padding: NOO.factor() / 2 y: parent.height / 12
LevelPreview { visible: true
id: levelPreview onClosed: destroy()
width: parent.width - NOO.factor(); height: lPop.height - NOO.factor()
Column {
width: parent.width
padding: NOO.factor() / 2
LevelPreview {
id: levelPreview
width: parent.width - NOO.factor()
height: lPop.height - NOO.factor()
}
} }
}
onClosed: destroy()
} }
...@@ -2,120 +2,201 @@ ...@@ -2,120 +2,201 @@
* Copyright (C) 2019-2021 by Tomasz Bojczuk (seelook@gmail.com) * * Copyright (C) 2019-2021 by Tomasz Bojczuk (seelook@gmail.com) *
* on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) */ * on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) */
import QtQuick 2.12 import Nootka
import Nootka.Charts
import Qt5Compat.GraphicalEffects import Qt5Compat.GraphicalEffects
import QtQuick 2.12
import Nootka.Charts 1.0 TlinChartDelegate {
id: lineDel
property var hintText: null
TlinChartDelegate { onNrChanged: {
id: lineDel if (groupNr > -1) {
var h = getHintText();
Rectangle { // average line if (h !== "") {
visible: averageY > 0.0 if (!hintText)
color: chartItem.averLineGroup === groupNr ? "#00c0c0" : (groupNr % 2 ? "#008080" : "#00a0a0") hintText = hintComp.createObject(lineDel);
x: width / 2; z: 1
y: parent.height * 0.1 + maxDataHeight - (averageY / chartItem.maxYValue()) * maxDataHeight - height / 2 hintText.text = h;
width: parent.width; height: lThick / 2 } else {
MouseArea { if (hintText)
id: averMa hintText.destroy();
width: parent.width; height: parent.height * 5; y: -2 * parent.height
hoverEnabled: true }
onEntered: lineEntered(mouseX, parent.y)
onExited: lineExited()
}
}
Rectangle { // X axis line (partial)
color: activPal.text
y: parent.height - width + lThick / 2
width: parent.width; height: lThick
Rectangle { // X tick
color: activPal.text
x: parent.width - lThick; y: lThick
width: lThick; height: lThick * 2
Column { // X value (description)
y: lThick * 2
anchors.horizontalCenter: parent.horizontalCenter
Text { // question number
text: nrText; font { pixelSize: lineDel.width / 7 }
anchors.horizontalCenter: parent.horizontalCenter
color: activPal.text; textFormat: Text.StyledText; horizontalAlignment: Text.AlignHCenter
}
Item { // note name
width: childrenRect.width; height: lineDel.width / 4
anchors.horizontalCenter: parent.horizontalCenter
Text {
y: -lineDel.width / (nrText === "" ? 5 : 4.5)
text: noteText; font { pixelSize: lineDel.width / 5; family: "Scorek" }
color: activPal.text; textFormat: Text.StyledText
}
}
Text { // position on instrument
text: posText; font { pixelSize: lineDel.width / 6 }
anchors.horizontalCenter: parent.horizontalCenter
color: activPal.text; textFormat: Text.RichText
} }
Text { // key signature }
text: keyText; font { pixelSize: lineDel.width / 7; italic: true }
anchors.horizontalCenter: parent.horizontalCenter // average line
color: activPal.text; textFormat: Text.PlainText Rectangle {
visible: averageY > 0
color: chartItem.averLineGroup === groupNr ? "#00c0c0" : (groupNr % 2 ? "#008080" : "#00a0a0")
x: width / 2
z: 1
y: parent.height * 0.1 + maxDataHeight - (averageY / chartItem.maxYValue()) * maxDataHeight - height / 2
width: parent.width
height: lThick / 2
MouseArea {
id: averMa
width: parent.width
height: parent.height * 5
y: -2 * parent.height
hoverEnabled: true
onEntered: lineEntered(mouseX, parent.y)
onExited: lineExited()
} }
}
} }
}
// X axis line (partial)
Text { Rectangle {
id: nText color: activPal.text
color: pointColor; text: pointSymbol y: parent.height - width + lThick / 2
y: pointY - (pointSymbol === "M" ? height * 0.3 : height * 0.8) width: parent.width
x: parent.width - (pointSymbol === "M" ? width * 0.5 : width / 3) height: lThick
font { pixelSize: lineDel.width / 2; family: "Nootka" }
visible: false // X tick
} Rectangle {
DropShadow { color: activPal.text
z: 5010 x: parent.width - lThick
anchors.fill: nText y: lThick
horizontalOffset: lineDel.width / 35 width: lThick
verticalOffset: horizontalOffset height: lThick * 2
radius: NOO.factor()
samples: 1 + radius * 2 // X value (description)
color: activPal.shadow Column {
source: nText y: lThick * 2
scale: ma.containsMouse ? 1.4 : 1.0 anchors.horizontalCenter: parent.horizontalCenter
Behavior on scale { enabled: GLOB.useAnimations; NumberAnimation { duration: 150 }}
MouseArea { // question number
id: ma Text {
anchors.fill: parent text: nrText
hoverEnabled: true anchors.horizontalCenter: parent.horizontalCenter
onEntered: pointEntered() color: activPal.text
onExited: pointExited() textFormat: Text.StyledText
horizontalAlignment: Text.AlignHCenter
font {
pixelSize: lineDel.width / 7
}
}
// note name
Item {
width: childrenRect.width
height: lineDel.width / 4
anchors.horizontalCenter: parent.horizontalCenter
Text {
y: -lineDel.width / (nrText === "" ? 5 : 4.5)
text: noteText
color: activPal.text
textFormat: Text.StyledText
font {
pixelSize: lineDel.width / 5
family: "Scorek"
}
}
}
// position on instrument
Text {
text: posText
anchors.horizontalCenter: parent.horizontalCenter
color: activPal.text
textFormat: Text.RichText
font {
pixelSize: lineDel.width / 6
}
}
// key signature
Text {
text: keyText
anchors.horizontalCenter: parent.horizontalCenter
color: activPal.text
textFormat: Text.PlainText
font {
pixelSize: lineDel.width / 7
italic: true
}
}
}
}
} }
}
Component {
id: hintComp
Text { Text {
z: -1 id: nText
x: (parent.width - width) / 2; y: parent.height * 0.05
color: NOO.alpha(activPal.text, 75) color: pointColor
textFormat: Text.RichText text: pointSymbol
y: pointY - (pointSymbol === "M" ? height * 0.3 : height * 0.8)
x: parent.width - (pointSymbol === "M" ? width * 0.5 : width / 3)
visible: false
font {
pixelSize: lineDel.width / 2
family: "Nootka"
}
} }
}
DropShadow {
property var hintText: null z: 5010
anchors.fill: nText
onNrChanged: { horizontalOffset: lineDel.width / 35
if (groupNr > -1) { verticalOffset: horizontalOffset
var h = getHintText() radius: NOO.factor()
if (h !== "") { samples: 1 + radius * 2
if (!hintText) color: activPal.shadow
hintText = hintComp.createObject(lineDel) source: nText
hintText.text = h scale: ma.containsMouse ? 1.4 : 1
} else {
if (hintText) MouseArea {
hintText.destroy() id: ma
}
anchors.fill: parent
hoverEnabled: true
onEntered: pointEntered()
onExited: pointExited()
}
Behavior on scale {
enabled: GLOB.useAnimations
NumberAnimation {
duration: 150
}
}
} }
}
Component {
id: hintComp
Text {
z: -1
x: (parent.width - width) / 2
y: parent.height * 0.05
color: NOO.alpha(activPal.text, 75)
textFormat: Text.RichText
}
}
} }
...@@ -39,7 +39,7 @@ TnameItem { ...@@ -39,7 +39,7 @@ TnameItem {
Connections { Connections {
target: score target: score
enabled: !GLOB.isExam enabled: !GLOB.isExam
onNoteChanged: noteName.note = score.note function onNoteChanged() : void { noteName.note = score.note }
} }
Rectangle { Rectangle {
......
...@@ -68,60 +68,67 @@ Texecutor { ...@@ -68,60 +68,67 @@ Texecutor {
Connections { Connections {
target: tipHandler target: tipHandler
onWantStartTip: { function onWantStartTip(text: string, color: color, pos: point) : void {
var s = Qt.createComponent("qrc:/exam/ExamTip.qml"); let s = Qt.createComponent("qrc:/exam/ExamTip.qml");
tipHandler.startTip = s.createObject(executor, { tipHandler.startTip = s.createObject(executor, {
"text": text, text: text,
"offX": pos.x, offX: pos.x,
"offY": pos.y, offY: pos.y,
"bg": color bg: color
}); });
} }
onWantQuestionTip: {
var s = Qt.createComponent("qrc:/exam/QuestionTip.qml"); function onWantQuestionTip(text: string, pos: point) : void {
let s = Qt.createComponent("qrc:/exam/QuestionTip.qml");
tipHandler.questionTip = s.createObject(executor, { tipHandler.questionTip = s.createObject(executor, {
"text": text, text: text,
"offX": pos.x, offX: pos.x,
"offY": pos.y offY: pos.y
}); });
} }
onWantConfirmTip: {
var s = Qt.createComponent("qrc:/exam/ExamTip.qml"); function onWantConfirmTip(text: string, color: color, pos: point) : void {
let s = Qt.createComponent("qrc:/exam/ExamTip.qml");
tipHandler.confirmTip = s.createObject(executor, { tipHandler.confirmTip = s.createObject(executor, {
"text": text, text: text,
"offX": pos.x, offX: pos.x,
"offY": pos.y, offY: pos.y,
"bg": color, bg: color,
"showExit": !NOO.isAndroid() showExit: !NOO.isAndroid()
}); });
} }
onWantResultTip: {
var r = Qt.createComponent("qrc:/exam/ResultTip.qml"); function onWantResultTip(text: string, color: color) : void {
let r = Qt.createComponent("qrc:/exam/ResultTip.qml");
tipHandler.resultTip = r.createObject(executor.parent, { tipHandler.resultTip = r.createObject(executor.parent, {
"text": text, text: text,
"color": color color: color
}); });
} }
onWantTryAgainTip: {
var a = Qt.createComponent("qrc:/exam/ResultTip.qml"); function onWantTryAgainTip() : void {
let a = Qt.createComponent("qrc:/exam/ResultTip.qml");
tipHandler.tryAgainTip = a.createObject(executor.parent, { tipHandler.tryAgainTip = a.createObject(executor.parent, {
"text": qsTranslate("TtipHandler", "Try again!"), text: qsTranslate("TtipHandler", "Try again!"),
"color": GLOB.wrongColor, color: GLOB.wrongColor,
"targetY": Math.min(executor.width, executor.height) / 12 targetY: Math.min(executor.width, executor.height) / 12
}); });
} }
onWantWhatNextTip: {
var s = Qt.createComponent("qrc:/exam/ExamTip.qml"); function onWantWhatNextTip(text: string, color: color, pos: point) : void {
let s = Qt.createComponent("qrc:/exam/ExamTip.qml");
tipHandler.whatNextTip = s.createObject(executor, { tipHandler.whatNextTip = s.createObject(executor, {
"text": text, text: text,
"offX": pos.x, offX: pos.x,
"offY": pos.y, offY: pos.y,
"bg": color bg: color
}); });
} }
onWantCertificate: {
function onWantCertificate() : void {
tipHandler.certTip = Qt.createComponent("qrc:/exam/Certificate.qml").createObject(nootkaWindow.contentItem.parent); tipHandler.certTip = Qt.createComponent("qrc:/exam/Certificate.qml").createObject(nootkaWindow.contentItem.parent);
} }
} }
} }
...@@ -31,12 +31,12 @@ GlowRect { ...@@ -31,12 +31,12 @@ GlowRect {
width: text.width width: text.width
height: text.height height: text.height
scale: GLOB.useAnimations ? 0 : 1 scale: GLOB.useAnimations ? 0 : 1
Component.onCompleted: { Component.onCompleted: {
eW = executor.width; eW = executor.width;
eH = executor.height; eH = executor.height;
if (GLOB.useAnimations) if (GLOB.useAnimations)
scale = 1; scale = 1;
} }
border { border {
...@@ -50,7 +50,7 @@ GlowRect { ...@@ -50,7 +50,7 @@ GlowRect {
color: activPal.text color: activPal.text
textFormat: Text.RichText textFormat: Text.RichText
padding: NOO.factor() padding: NOO.factor()
onLinkActivated: { onLinkActivated: link => {
executor.tipLink(link); executor.tipLink(link);
tip.destroy(); tip.destroy();
} }
...@@ -60,7 +60,6 @@ GlowRect { ...@@ -60,7 +60,6 @@ GlowRect {
acceptedButtons: Qt.NoButton acceptedButtons: Qt.NoButton
cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor cursorShape: parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
} }
} }
Image { Image {
...@@ -85,12 +84,12 @@ GlowRect { ...@@ -85,12 +84,12 @@ GlowRect {
Connections { Connections {
target: executor target: executor
onWidthChanged: { function onWidthChanged() : void {
scale = (executor.width / eW) * scale; scale = (executor.width / eW) * scale;
offX = offX * (executor.width / eW); offX = offX * (executor.width / eW);
eW = executor.width; eW = executor.width;
} }
onHeightChanged: { function onHeightChanged() : void {
offY = offY * (executor.height / eH); offY = offY * (executor.height / eH);
eH = executor.height; eH = executor.height;
} }
......
...@@ -50,7 +50,7 @@ TlevelCreatorItem { ...@@ -50,7 +50,7 @@ TlevelCreatorItem {
pages.pages[2].saveLevel(); pages.pages[2].saveLevel();
} }
onWantValidationMessage: { onWantValidationMessage: title, message, accent => {
var c = Qt.createComponent("qrc:/level/LevelValidationMessage.qml"); var c = Qt.createComponent("qrc:/level/LevelValidationMessage.qml");
c.createObject(creator, { c.createObject(creator, {
"caption": title, "caption": title,
......
...@@ -72,12 +72,12 @@ Column { ...@@ -72,12 +72,12 @@ Column {
Connections { Connections {
target: creator target: creator
onSaveNewLevel: { function onSaveNewLevel(name: string, desc: string) : void {
newLevelPopup.name = name === "" ? qsTr("new level") : name; newLevelPopup.name = name === "" ? qsTr("new level") : name;
newLevelPopup.desc = desc; newLevelPopup.desc = desc;
newLevelPopup.open(); newLevelPopup.open();
} }
onWantNotSavedMessage: { function onWantNotSavedMessage(title: string, message: string) : void {
if (!notSavedMess) { if (!notSavedMess) {
notSavedMess = Qt.createComponent("qrc:/Tmessage.qml").createObject(creator, { notSavedMess = Qt.createComponent("qrc:/Tmessage.qml").createObject(creator, {
"accent": "#ff557f" "accent": "#ff557f"
......
...@@ -17,7 +17,7 @@ Tflickable { ...@@ -17,7 +17,7 @@ Tflickable {
Connections { Connections {
target: creator target: creator
onUpdateLevel: { function onUpdateLevel() : void {
rangeScore.setNote(0, creator.loNote); rangeScore.setNote(0, creator.loNote);
rangeScore.setNote(1, creator.hiNote); rangeScore.setNote(1, creator.hiNote);
} }
...@@ -65,12 +65,12 @@ Tflickable { ...@@ -65,12 +65,12 @@ Tflickable {
Connections { Connections {
target: rangeScore.firstStaff.clef target: rangeScore.firstStaff.clef
onClicked: creator.clef = rangeScore.clef function onClicked() : void { creator.clef = rangeScore.clef }
} }
Connections { Connections {
target: rangeScore.scoreObj target: rangeScore.scoreObj
onClicked: { function onClicked() : void {
creator.loNote = rangeScore.scoreObj.noteAt(0); creator.loNote = rangeScore.scoreObj.noteAt(0);
creator.hiNote = rangeScore.scoreObj.noteAt(1); creator.hiNote = rangeScore.scoreObj.noteAt(1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment