Skip to content

Commit

Permalink
Merge pull request #25778 from cbjeukendrup/editstyle_qml_cleanup
Browse files Browse the repository at this point in the history
Clean up some QML code in EditStyle dialog
  • Loading branch information
RomanPudashkin authored Dec 12, 2024
2 parents b4f3204 + 03eeaff commit 22510c3
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 154 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ RadioDelegate {

ButtonGroup.group: ListView.view && ListView.view instanceof RadioButtonGroup ? ListView.view.radioButtonGroup : null

implicitHeight: 20
implicitWidth: ListView.view
? (ListView.view.orientation === Qt.Vertical
? ListView.view.width
: (ListView.view.width - (ListView.view.spacing * (ListView.view.count - 1))) / ListView.view.count)
: 20
implicitWidth: leftPadding + implicitIndicatorWidth + spacing + implicitContentWidth + rightPadding
implicitHeight: topPadding + Math.max(implicitIndicatorHeight, implicitContentHeight) + bottomPadding

spacing: 6
padding: 0
Expand Down Expand Up @@ -74,6 +70,9 @@ RadioDelegate {
anchors.fill: parent
anchors.leftMargin: root.indicator.width + root.spacing + root.leftPadding

implicitWidth: contentLoader.implicitWidth
implicitHeight: contentLoader.implicitHeight

Loader {
id: contentLoader

Expand All @@ -90,6 +89,7 @@ RadioDelegate {
text: root.text
font: root.font
horizontalAlignment: Qt.AlignLeft
wrapMode: Text.WordWrap
}
}
}
Expand All @@ -98,6 +98,7 @@ RadioDelegate {
indicator: Item {
x: root.leftPadding
y: Boolean(parent) ? parent.height / 2 - height / 2 : 0

implicitWidth: 20
implicitHeight: implicitWidth

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,24 @@ GroupBox {
id: root

padding: 12
spacing: 4

background: Rectangle {
y: root.topPadding - root.bottomPadding
width: parent.width
height: parent.height - root.topPadding + root.bottomPadding
x: root.leftInset
y: root.topInset + root.implicitLabelHeight + root.spacing

width: root.width - x - root.rightInset
height: root.height - y - root.bottomInset

color: ui.theme.backgroundPrimaryColor
border.color: ui.theme.strokeColor
radius: 3 //
radius: 3
}

label: StyledTextLabel {
x: 0
x: root.leftInset
y: root.topInset

width: root.availableWidth

text: root.title
Expand Down
2 changes: 1 addition & 1 deletion src/notation/notationscene.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<file>qml/MuseScore/NotationScene/internal/EditStyle/accidentalImages/octaveOffset-OFF.png</file>
<file>qml/MuseScore/NotationScene/internal/EditStyle/accidentalImages/octaveOffset-ON.png</file>
<file>qml/MuseScore/NotationScene/internal/EditStyle/FretboardsPage.qml</file>
<file>qml/MuseScore/NotationScene/internal/EditStyle/BasicStyleSelectorWithSpinboxAndReset.qml</file>
<file>qml/MuseScore/NotationScene/internal/EditStyle/StyleSpinboxWithReset.qml</file>
<file>qml/MuseScore/NotationScene/PercussionPanel.qml</file>
<file>qml/MuseScore/NotationScene/internal/PercussionPanelToolBar.qml</file>
<file>qml/MuseScore/NotationScene/internal/PercussionPanelPad.qml</file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,16 @@ StyleDialogPage {

StyledGroupBox {
width: parent.width
height: 120
height: Math.max(120, implicitHeight)

title: qsTrc("notation", "Beam style")
label.x: 0

RowLayout {
anchors.fill: parent
spacing: 12

RadioButtonGroup {
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter

spacing: 12
orientation: ListView.Vertical
Expand All @@ -147,14 +145,11 @@ StyleDialogPage {
{ title: qsTrc("notation", "Draw inner stems through beams"), value: false },
{ title: qsTrc("notation", "Draw inner stems to nearest beam (“French” style)"), value: true }
]
delegate: RoundedRadioButton {
leftPadding: 0
spacing: 6

delegate: RoundedRadioButton {
width: ListView.view.width
text: modelData.title

checked: modelData.value === beamsPageModel.frenchStyleBeams.value

onToggled: {
beamsPageModel.frenchStyleBeams.value = modelData.value
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Rectangle {
anchors.fill: parent
color: ui.theme.backgroundPrimaryColor

readonly property real controlAreaWidth: 204

signal goToTextStylePage(string s)

StyledGroupBox {
Expand All @@ -48,108 +50,100 @@ Rectangle {
spacing: 12
width: parent.width

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.fretY
label: qsTrc("notation", "Position above:")
suffix: qsTrc("global", "sp")
controlAreaWidth: 204
controlAreaWidth: root.controlAreaWidth
}

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.fretMag
label: qsTrc("notation", "Scale:")
inPercentage: true
controlAreaWidth: 204
controlAreaWidth: root.controlAreaWidth
}

IconAndTextButtonSelector {
styleItem: fretboardsPage.fretOrientation
label: qsTrc("notation", "Orientation:")

Layout.preferredHeight: 70
controlAreaWidth: root.controlAreaWidth

model: [
{ iconCode: IconCode.FRETBOARD_VERTICAL, text: qsTrc("notation", "Vertical"), value: 0 },
{ iconCode: IconCode.FRETBOARD_HORIZONTAL, text: qsTrc("notation", "Horizontal"), value: 1 }
]
}

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.fretNutThickness
label: qsTrc("notation", "Nut line thickness:")
suffix: qsTrc("global", "sp")
controlAreaWidth: 204
controlAreaWidth: root.controlAreaWidth
}

StyledGroupBox {
Layout.fillWidth: true

title: qsTrc("notation", "Fret number")

ColumnLayout {
width: parent.width
spacing: 12

RowLayout {
spacing: 12

StyledTextLabel {
horizontalAlignment: Text.AlignLeft
text: qsTrc("notation", "Position:")
}
RowLayout {
spacing: 8
RoundedRadioButton {
checked: fretboardsPage.fretNumPos.value === 0
onToggled: fretboardsPage.fretNumPos.value = 0
}
StyledTextLabel {
horizontalAlignment: Text.AlignLeft
text: fretboardsPage.fretOrientation.value === 0 ? qsTrc("notation", "Left") : qsTrc("notation", "Bottom")
}

RoundedRadioButton {
text: fretboardsPage.fretOrientation.value === 0 ? qsTrc("notation", "Left") : qsTrc("notation", "Bottom")
checked: fretboardsPage.fretNumPos.value === 0
onToggled: fretboardsPage.fretNumPos.value = 0
}
RowLayout {
spacing: 8
RoundedRadioButton {
checked: fretboardsPage.fretNumPos.value === 1
onToggled: fretboardsPage.fretNumPos.value = 1
}
StyledTextLabel {
horizontalAlignment: Text.AlignLeft
text: fretboardsPage.fretOrientation.value === 0 ? qsTrc("notation", "Right") : qsTrc("notation", "Top")
}

RoundedRadioButton {
text: fretboardsPage.fretOrientation.value === 0 ? qsTrc("notation", "Right") : qsTrc("notation", "Top")
checked: fretboardsPage.fretNumPos.value === 1
onToggled: fretboardsPage.fretNumPos.value = 1
}
}

StyledGroupBox {
title: qsTrc("notation", "Format:")
Layout.fillWidth: true

ColumnLayout {
RowLayout {
spacing: 8
RoundedRadioButton {
checked: fretboardsPage.fretUseCustomSuffix.value === false
onToggled: fretboardsPage.fretUseCustomSuffix.value = false
}
StyledTextLabel {
horizontalAlignment: Text.AlignLeft
text: qsTrc("notation", "Number only")
}
width: parent.width
spacing: 12

RoundedRadioButton {
text: qsTrc("notation", "Number only")
checked: fretboardsPage.fretUseCustomSuffix.value === false
onToggled: fretboardsPage.fretUseCustomSuffix.value = false
}

RowLayout {
spacing: 8

RoundedRadioButton {
text: qsTrc("notation", "Custom suffix:")
checked: fretboardsPage.fretUseCustomSuffix.value === true
onToggled: fretboardsPage.fretUseCustomSuffix.value = true
}
StyledTextLabel {
horizontalAlignment: Text.AlignLeft
text: qsTrc("notation", "Custom suffix:")
}

TextInputField {
enabled: fretboardsPage.fretUseCustomSuffix.value === true
Layout.preferredWidth: 60
enabled: fretboardsPage.fretUseCustomSuffix.value === true
currentText: fretboardsPage.fretCustomSuffix.value
onTextChanged: function(newTextValue) {
onTextEdited: function(newTextValue) {
fretboardsPage.fretCustomSuffix.value = newTextValue
}
}

StyledTextLabel {
visible: fretboardsPage.fretUseCustomSuffix.value === true
horizontalAlignment: Text.AlignLeft
Expand All @@ -169,12 +163,11 @@ Rectangle {
}
}

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.fretDotSpatiumSize
label: qsTrc("notation", "Dot size:")
suffix: qsTrc("global", "sp")
controlAreaWidth: 204

controlAreaWidth: root.controlAreaWidth
}

StyledGroupBox {
Expand All @@ -189,20 +182,19 @@ Rectangle {
IconAndTextButtonSelector {
styleItem: fretboardsPage.barreAppearanceSlur
label: qsTrc("notation", "Appearance:")

Layout.preferredHeight: 70
controlAreaWidth: root.controlAreaWidth

model: [
{ iconCode: IconCode.FRETBOARD_BARRE_LINE, text: qsTrc("notation", "Line"), value: false },
{ iconCode: IconCode.FRETBOARD_BARRE_SLUR, text: qsTrc("notation", "Slur"), value: true }
]
}

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.barreLineWidth
label: qsTrc("notation", "Line thickness:")
inPercentage: true
controlAreaWidth: 204
controlAreaWidth: root.controlAreaWidth
}
}
}
Expand All @@ -224,41 +216,40 @@ Rectangle {
IconAndTextButtonSelector {
styleItem: fretboardsPage.fretStyleExtended
label: qsTrc("notation", "Fretboard style:")

Layout.preferredHeight: 70
controlAreaWidth: root.controlAreaWidth

model: [
{ iconCode: IconCode.FRETBOARD_VERTICAL, text: qsTrc("notation", "Trimmed"), value: false },
{ iconCode: IconCode.FRETBOARD_EXTENDED, text: qsTrc("notation", "Extended"), value: true }
]
}

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.fretStringSpacing
label: qsTrc("notation", "String spacing:")
suffix: qsTrc("global", "sp")
controlAreaWidth: 204
controlAreaWidth: root.controlAreaWidth
}

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.fretFretSpacing
label: qsTrc("notation", "Fret spacing:")
suffix: qsTrc("global", "sp")
controlAreaWidth: 204
controlAreaWidth: root.controlAreaWidth
}

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.maxFretShiftAbove
label: qsTrc("notation", "Maximum shift above:")
suffix: qsTrc("global", "sp")
controlAreaWidth: 204
controlAreaWidth: root.controlAreaWidth
}

BasicStyleSelectorWithSpinboxAndReset {
StyleSpinboxWithReset {
styleItem: fretboardsPage.maxFretShiftBelow
label: qsTrc("notation", "Maximum shift below:")
suffix: qsTrc("global", "sp")
controlAreaWidth: 204
controlAreaWidth: root.controlAreaWidth
}
}
}
Expand Down
Loading

0 comments on commit 22510c3

Please sign in to comment.