From ebd1d5532a7722f3fad0b8888ae2f54b7155fd6c Mon Sep 17 00:00:00 2001 From: Casper Jeukendrup <48658420+cbjeukendrup@users.noreply.github.com> Date: Sun, 8 Dec 2024 22:46:38 +0100 Subject: [PATCH] Improve `RoundedRadioButton`'s `implicitWidth`/`Height` Resolves: https://github.com/musescore/MuseScore/issues/25576 --- .../Muse/UiComponents/RoundedRadioButton.qml | 12 ++-- .../internal/EditStyle/BeamsPage.qml | 8 +-- .../internal/EditStyle/FretboardsPage.qml | 65 +++++++++---------- src/notation/view/widgets/editstyle.cpp | 2 +- .../internal/Export/ExportOptionsView.qml | 2 + .../internal/Export/MusicXmlSettingsPage.qml | 2 + .../NewScore/TimeSignatureSettings.qml | 34 +++++++--- 7 files changed, 66 insertions(+), 59 deletions(-) diff --git a/src/framework/uicomponents/qml/Muse/UiComponents/RoundedRadioButton.qml b/src/framework/uicomponents/qml/Muse/UiComponents/RoundedRadioButton.qml index 45da79927883a..52493a2260437 100644 --- a/src/framework/uicomponents/qml/Muse/UiComponents/RoundedRadioButton.qml +++ b/src/framework/uicomponents/qml/Muse/UiComponents/RoundedRadioButton.qml @@ -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 @@ -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 @@ -98,6 +97,7 @@ RadioDelegate { indicator: Item { x: root.leftPadding y: Boolean(parent) ? parent.height / 2 - height / 2 : 0 + implicitWidth: 20 implicitHeight: implicitWidth diff --git a/src/notation/qml/MuseScore/NotationScene/internal/EditStyle/BeamsPage.qml b/src/notation/qml/MuseScore/NotationScene/internal/EditStyle/BeamsPage.qml index 39b86d90653ba..8fba03c93e3ae 100644 --- a/src/notation/qml/MuseScore/NotationScene/internal/EditStyle/BeamsPage.qml +++ b/src/notation/qml/MuseScore/NotationScene/internal/EditStyle/BeamsPage.qml @@ -138,7 +138,6 @@ StyleDialogPage { RadioButtonGroup { Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter spacing: 12 orientation: ListView.Vertical @@ -147,14 +146,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 } diff --git a/src/notation/qml/MuseScore/NotationScene/internal/EditStyle/FretboardsPage.qml b/src/notation/qml/MuseScore/NotationScene/internal/EditStyle/FretboardsPage.qml index f47e3b120286f..635fedf9af9d7 100644 --- a/src/notation/qml/MuseScore/NotationScene/internal/EditStyle/FretboardsPage.qml +++ b/src/notation/qml/MuseScore/NotationScene/internal/EditStyle/FretboardsPage.qml @@ -85,71 +85,64 @@ Rectangle { 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 diff --git a/src/notation/view/widgets/editstyle.cpp b/src/notation/view/widgets/editstyle.cpp index aa3b2e83b0888..a9a4d423fb062 100644 --- a/src/notation/view/widgets/editstyle.cpp +++ b/src/notation/view/widgets/editstyle.cpp @@ -913,7 +913,7 @@ EditStyle::EditStyle(QWidget* parent) auto fretboardsPage = createQmlWidget( fretboardsWidget, QUrl(QString::fromUtf8("qrc:/qml/MuseScore/NotationScene/internal/EditStyle/FretboardsPage.qml"))); - fretboardsPage.widget->setMinimumSize(224, 1000); + fretboardsPage.widget->setMinimumSize(224, 1006); connect(fretboardsPage.view->rootObject(), SIGNAL(goToTextStylePage(QString)), this, SLOT(goToTextStylePage(QString))); fretboardsWidget->layout()->addWidget(fretboardsPage.widget); diff --git a/src/project/qml/MuseScore/Project/internal/Export/ExportOptionsView.qml b/src/project/qml/MuseScore/Project/internal/Export/ExportOptionsView.qml index ef72b01b9b63f..55d527cdd1ddb 100644 --- a/src/project/qml/MuseScore/Project/internal/Export/ExportOptionsView.qml +++ b/src/project/qml/MuseScore/Project/internal/Export/ExportOptionsView.qml @@ -161,6 +161,8 @@ Column { model: exportModel.availableUnitTypes delegate: RoundedRadioButton { + width: ListView.view.width + text: modelData["text"] navigation.name: "ExportType_" + text diff --git a/src/project/qml/MuseScore/Project/internal/Export/MusicXmlSettingsPage.qml b/src/project/qml/MuseScore/Project/internal/Export/MusicXmlSettingsPage.qml index da92fa9e7892a..0da0c6f9afdc5 100644 --- a/src/project/qml/MuseScore/Project/internal/Export/MusicXmlSettingsPage.qml +++ b/src/project/qml/MuseScore/Project/internal/Export/MusicXmlSettingsPage.qml @@ -35,6 +35,8 @@ ExportSettingsPage { model: root.model.musicXmlLayoutTypes() delegate: RoundedRadioButton { + width: ListView.view.width + text: modelData["text"] navigation.name: "MusicXmlLayoutTypeRadioButton " + text diff --git a/src/project/qml/MuseScore/Project/internal/NewScore/TimeSignatureSettings.qml b/src/project/qml/MuseScore/Project/internal/NewScore/TimeSignatureSettings.qml index 6e7c358f1edcc..4cf60b2bb2d10 100644 --- a/src/project/qml/MuseScore/Project/internal/NewScore/TimeSignatureSettings.qml +++ b/src/project/qml/MuseScore/Project/internal/NewScore/TimeSignatureSettings.qml @@ -152,26 +152,40 @@ FlatButton { Component { id: commonComp - StyledIconLabel { + Item { property string accessibleName: root.model.timeSignatureAccessibleName(AdditionalInfoModel.Common) - font.family: ui.theme.musicalFont.family - font.pixelSize: 30 - horizontalAlignment: Text.AlignLeft - iconCode: MusicalSymbolCodes.TIMESIG_COMMON + implicitWidth: commonLabel.implicitWidth + implicitHeight: 30 + + StyledIconLabel { + id: commonLabel + anchors.verticalCenter: parent.verticalCenter + font.family: ui.theme.musicalFont.family + font.pixelSize: 30 + horizontalAlignment: Text.AlignLeft + iconCode: MusicalSymbolCodes.TIMESIG_COMMON + } } } Component { id: cutComp - StyledIconLabel { + Item { property string accessibleName: root.model.timeSignatureAccessibleName(AdditionalInfoModel.Cut) - font.family: ui.theme.musicalFont.family - font.pixelSize: 30 - horizontalAlignment: Text.AlignLeft - iconCode: MusicalSymbolCodes.TIMESIG_CUT + implicitWidth: cutLabel.implicitWidth + implicitHeight: 30 + + StyledIconLabel { + id: cutLabel + anchors.verticalCenter: parent.verticalCenter + font.family: ui.theme.musicalFont.family + font.pixelSize: 30 + horizontalAlignment: Text.AlignLeft + iconCode: MusicalSymbolCodes.TIMESIG_CUT + } } } }