diff --git a/src/charts/qml/LevelPopup.qml b/src/charts/qml/LevelPopup.qml index 4f14a9a7d5eddb0b0b238a6e0826b8028864c272..31d706037dd1f74332a13fe9d2dcc71dc982976b 100644 --- a/src/charts/qml/LevelPopup.qml +++ b/src/charts/qml/LevelPopup.qml @@ -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() } diff --git a/src/charts/qml/LinearDelegate.qml b/src/charts/qml/LinearDelegate.qml index 0fa42edcd18e38c13883cb3b10a5ad85c11378f9..15f33b009fb303a62a60692e5e8d44dc0a5378f2 100644 --- a/src/charts/qml/LinearDelegate.qml +++ b/src/charts/qml/LinearDelegate.qml @@ -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 + } + + } + } diff --git a/src/qml/NoteName.qml b/src/qml/NoteName.qml index cd25447004178201357e87d772c343dbd183490a..84c1a62a8b90563b1393d87d070bf575bed77b62 100644 --- a/src/qml/NoteName.qml +++ b/src/qml/NoteName.qml @@ -39,7 +39,7 @@ TnameItem { Connections { target: score enabled: !GLOB.isExam - onNoteChanged: noteName.note = score.note + function onNoteChanged() : void { noteName.note = score.note } } Rectangle { diff --git a/src/qml/exam/ExamExecutor.qml b/src/qml/exam/ExamExecutor.qml index 8da9a3cba948b7441a3373eac9d906cb0179f8aa..2b89c490db5c80a539f948c01aff43c87a12d52a 100644 --- a/src/qml/exam/ExamExecutor.qml +++ b/src/qml/exam/ExamExecutor.qml @@ -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); } + } } diff --git a/src/qml/exam/ExamTip.qml b/src/qml/exam/ExamTip.qml index 31767649fd873d56a22517ff1c8a64424473cf22..d08d843c26cf81bfa5b8947e79d7c513a820527f 100644 --- a/src/qml/exam/ExamTip.qml +++ b/src/qml/exam/ExamTip.qml @@ -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; } diff --git a/src/qml/level/LevelCreator.qml b/src/qml/level/LevelCreator.qml index 85fc3ef06f8d20b65fea63a46e646e001ec17a69..fc264d5015b5b8fd78b98b1ef48a61c4c5a63e24 100644 --- a/src/qml/level/LevelCreator.qml +++ b/src/qml/level/LevelCreator.qml @@ -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, diff --git a/src/qml/level/LevelsPage.qml b/src/qml/level/LevelsPage.qml index 353bb81a3e7a65853a54179658cda2eff57e4d4b..d18f2336eb8822c126e1703b20121921034f6a59 100644 --- a/src/qml/level/LevelsPage.qml +++ b/src/qml/level/LevelsPage.qml @@ -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" diff --git a/src/qml/level/RangePage.qml b/src/qml/level/RangePage.qml index 9b29910a6ae0b97ebeb3fc397a93c315a2b1c889..ca73329ff78ab612a4c9dbaaa64675b12535b461 100644 --- a/src/qml/level/RangePage.qml +++ b/src/qml/level/RangePage.qml @@ -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); }