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

More level preview improvements

- missing QML file
- display red "not selected" when no questions/answers are set
- colored table background (odd/even row differently)
parent 3e495e8f
Branches
Tags
No related merge requests found
......@@ -56,7 +56,6 @@ void TlevelPreviewItem::setLevel(Tlevel* tl) {
m_validLevel = tl != nullptr;
if (tl) {
static const QString space = QStringLiteral(" ");
static const QString notSelected = QStringLiteral("<font color=\"red\">=====</font>");// tr("not set");
m_instrGlyph = Tinstrument(tl->instrument).glyph();
m_header = getLevelSumary(tl->name);
m_description = tl->desc;
......@@ -91,41 +90,35 @@ void TlevelPreviewItem::setLevel(Tlevel* tl) {
if (tl->withDblAcc)
m_accidentals += (m_questions.isEmpty() ? QString() : space) + QLatin1String("x B");
if (tl->questionAs.isOnScore() || tl->questionAs.isName() || tl->questionAs.isOnInstr() || tl->questionAs.isSound()) {
m_questions.clear();
if (tl->questionAs.isOnScore())
m_questions += qaTypeSymbol(TQAtype::e_onScore, tl);
if (tl->questionAs.isName())
m_questions += (m_questions.isEmpty() ? QString() : space) + qaTypeSymbol(TQAtype::e_asName, tl);
if (tl->questionAs.isOnInstr())
m_questions += (m_questions.isEmpty() ? QString() : space) + qaTypeSymbol(TQAtype::e_onInstr, tl);
if (tl->questionAs.isSound()) {
m_questions += m_questions.isEmpty() ? QString() : space;
if (tl->canBeMelody())
m_questions += QLatin1String("m");
else
m_questions += qaTypeSymbol(TQAtype::e_asSound, tl);
}
} else
m_questions = notSelected;
if (tl->answerIsGuitar() || tl->answerIsNote() || tl->answerIsName() || tl->answerIsSound()) {
m_answers.clear();
if (tl->answerIsNote())
m_answers += qaTypeSymbol(TQAtype::e_onScore, tl);
if (tl->answerIsName())
m_answers += (m_answers.isEmpty() ? QString() : space) + qaTypeSymbol(TQAtype::e_asName, tl);
if (tl->answerIsGuitar())
m_answers += (m_answers.isEmpty() ? QString() : space) + qaTypeSymbol(TQAtype::e_onInstr, tl);
if (tl->answerIsSound()) {
m_answers += m_answers.isEmpty() ? QString() : space;
if (tl->canBeMelody())
m_answers += QLatin1String("m");
else
m_answers += qaTypeSymbol(TQAtype::e_asSound, tl);
}
} else
m_answers = notSelected;
m_questions.clear();
if (tl->questionAs.isOnScore())
m_questions += qaTypeSymbol(TQAtype::e_onScore, tl);
if (tl->questionAs.isName())
m_questions += (m_questions.isEmpty() ? QString() : space) + qaTypeSymbol(TQAtype::e_asName, tl);
if (tl->questionAs.isOnInstr())
m_questions += (m_questions.isEmpty() ? QString() : space) + qaTypeSymbol(TQAtype::e_onInstr, tl);
if (tl->questionAs.isSound()) {
m_questions += m_questions.isEmpty() ? QString() : space;
if (tl->canBeMelody())
m_questions += QLatin1String("m");
else
m_questions += qaTypeSymbol(TQAtype::e_asSound, tl);
}
m_answers.clear();
if (tl->answerIsNote())
m_answers += qaTypeSymbol(TQAtype::e_onScore, tl);
if (tl->answerIsName())
m_answers += (m_answers.isEmpty() ? QString() : space) + qaTypeSymbol(TQAtype::e_asName, tl);
if (tl->answerIsGuitar())
m_answers += (m_answers.isEmpty() ? QString() : space) + qaTypeSymbol(TQAtype::e_onInstr, tl);
if (tl->answerIsSound()) {
m_answers += m_answers.isEmpty() ? QString() : space;
if (tl->canBeMelody())
m_answers += QLatin1String("m");
else
m_answers += qaTypeSymbol(TQAtype::e_asSound, tl);
}
if (tl->canBeName() || tl->canBeScore() || tl->canBeSound())
m_requireOctave = tl->requireOctave ? tr("proper octave is required") : tr("octave does no matter");
......
......@@ -74,16 +74,18 @@ TlevelPreviewItem {
PreviewItem {
id: noteRangeIt
index: 1
handleWidth: true
height: Noo.fontSize() * 2
height: Noo.fontSize() * 2.5
text: Noo.TR("RangePage", "note range:").replace(":", " ")
text2: noteRange
textItem2.font { family: "Scorek"; pixelSize: Noo.fontSize() * 1.6 }
textItem2.y: height * -0.9
textItem2.y: Noo.fontSize() * -1.44
}
PreviewItem {
id: fretRangeIt
aboveItem: noteRangeIt
handleWidth: true
text: Noo.TR("RangePage", "fret range:").replace(":", " ")
text2: fretRange
......@@ -91,36 +93,49 @@ TlevelPreviewItem {
PreviewItem {
id: keyRangeIt
aboveItem: fretRangeIt
handleWidth: true
text: qsTranslate("TlevelPreviewItem", "key signature:").replace(":", " ")
text2: keyRange
textItem2.font.bold: true
}
PreviewItem {
id: accidentalsIt
aboveItem: keyRangeIt
handleWidth: true
text: Noo.TR("AccidsPage", "accidentals") + " "
text2: accidentals === "" ? qsTranslate("TlevelPreviewItem", "none") : accidentals
textItem2.font { family: accidentals === "" ? "default" : "Nootka"; pixelSize: Noo.fontSize() * (accidentals === "" ? 1.2 : 1.8) }
textItem2.font { family: accidentals === "" ? Noo.fontFamily() : "Nootka"; pointSize: Noo.fontSize() * (accidentals === "" ? 1 : 1.5) }
}
PreviewItem {
id: questionsIt
aboveItem: accidentalsIt
handleWidth: true
text: Noo.TR("LevelCreator", "Questions") + " "
text2: questions
textItem2.font { family: "Nootka"; pixelSize: Noo.fontSize() * 2.2 }
text2: questions === "" ? qsTr("not selected") : questions
textItem2.color: questions === "" ? "red" : activPal.text
textItem2.font { family: questions === "" ? Noo.fontFamily() : "Nootka"; pointSize: Noo.fontSize() * (questions === "" ? 1 : 1.5) }
}
PreviewItem {
id: answersIt
aboveItem: questionsIt
handleWidth: true
text: qsTranslate("LevelCreator", "Answers") + " "
text2: answers
textItem2.font { family: "Nootka"; pixelSize: Noo.fontSize() * 2.2 }
text2: answers === "" ? qsTr("not selected") : answers
textItem2.color: answers === "" ? "red" : activPal.text
textItem2.font { family: answers === "" ? Noo.fontFamily() : "Nootka"; pointSize: Noo.fontSize() * (answers === "" ? 1 : 1.5) }
}
PreviewItem {
aboveItem: answersIt
text: " "
width: answersIt.width
text2: requireOctave
textItem2 { width: width; horizontalAlignment: Text.AlignHCenter }
showBottomLine: true
}
} // Column
......@@ -131,6 +146,7 @@ TlevelPreviewItem {
layHorizontal: false
text: "<br>" + qsTranslate("TlevelPreviewItem", "Clef") + ":"
textItem2.font { family: "Scorek"; pixelSize: Noo.fontSize() * 4 }
//textItem2.y
text2: clef
}
}
......
/** This file is part of Nootka (http://nootka.sf.net) *
* Copyright (C) 2020 by Tomasz Bojczuk (seelook@gmail.com) *
* on the terms of GNU GPLv3 license (http://www.gnu.org/licenses) */
import QtQuick 2.9
Rectangle {
property int index: aboveItem ? aboveItem.index + (aboveItem.visible ? 1 : 0) : 0
property var aboveItem: null
property bool layHorizontal: true /** layout direction, horizontal by default */
property bool handleWidth: false /** When width is maximum value of all similar items */
property alias text: txt.text /** label */
property alias text2: txt2.text // value
property alias textItem: txt
property alias textItem2: txt2
property alias showBottomLine: bottomLine.visible
anchors.horizontalCenter: parent.horizontalCenter
implicitWidth: Math.max(layHorizontal ? txt.width + txt2.width : Math.max(txt.width, txt2.width)) + Noo.fontSize() * 2
implicitHeight: (layHorizontal ? Math.max(txt.height, txt2.height) : txt.height + txt2.height) + Noo.fontSize() / 2
color: index ? Noo.alpha(index % 2 === 1 ? activPal.alternateBase : activPal.base, 150) : "transparent"
visible: text2 !== ""
width: handleWidth ? maxLabelWidth + maxValueWidth + Noo.fontSize() * 2 : undefined
onImplicitWidthChanged: {
if (handleWidth) {
maxLabelWidth = Math.max(maxLabelWidth, txt.implicitWidth + Noo.fontSize())
maxValueWidth = Math.max(maxValueWidth, txt2.implicitWidth + Noo.fontSize())
}
}
Text {
id: txt
x: Noo.fontSize(); y: layHorizontal ? (parent.height - height) / 2 : 0
textFormat: Text.StyledText
color: activPal.text
}
Text {
id: txt2
x: handleWidth ? maxLabelWidth + Noo.fontSize() + (maxValueWidth - width) / 2 : (layHorizontal ? 0 : (parent.width - width) / 2)
y: (parent.height - height) / 2
horizontalAlignment: handleWidth ? Text.AlignHCenter : undefined
textFormat: Text.StyledText
color: activPal.text
}
Rectangle {
visible: handleWidth; color: activPal.text
width: Noo.fontSize() / 12;
height: parent.height
x: maxLabelWidth + Noo.fontSize() * 0.5
}
Rectangle {
id: bottomLine
visible: handleWidth; color: activPal.text
height: Noo.fontSize() / 12;
width: parent.width
y: parent.height - height / 2
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment