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