From ccc5cd04d339d9484c1caa56f5e28de7c209b201 Mon Sep 17 00:00:00 2001 From: Samuel Ghinet Date: Wed, 9 Mar 2022 14:40:52 +0200 Subject: [PATCH] New Project dialog fix: "Orientation" button doesn't work for equal sizes If the width equaled the height, for the project, then the orientation button didn't change visual state, when clicked. Also, renamed some fields in qml from "project" to "preset", because they actually refer to the preset, not to the project to be created. Task-number: QDS-5925 Change-Id: Ia776b24e0bf29a4bdf0e2f9f6ff26e5c0137ba4f Reviewed-by: Mahmoud Badri Reviewed-by: Thomas Hartmann --- .../newprojectdialog/NewProjectDialog.qml | 20 ++++++------- .../imports/NewProjectDialog/Details.qml | 3 ++ .../imports/NewProjectDialog/DialogValues.qml | 18 +++++------ .../NewProjectDialog/NewProjectView.qml | 30 +++++++++---------- 4 files changed, 37 insertions(+), 34 deletions(-) diff --git a/share/qtcreator/qmldesigner/newprojectdialog/NewProjectDialog.qml b/share/qtcreator/qmldesigner/newprojectdialog/NewProjectDialog.qml index 5d4d281ff86..4cc82bc79cc 100644 --- a/share/qtcreator/qmldesigner/newprojectdialog/NewProjectDialog.qml +++ b/share/qtcreator/qmldesigner/newprojectdialog/NewProjectDialog.qml @@ -163,14 +163,14 @@ Item { id: tabBar x: 10 // left padding width: parent.width - 20 // right padding - height: DialogValues.projectViewHeaderHeight + height: DialogValues.presetViewHeaderHeight color: DialogValues.lightPaneColor function selectTab(tabIndex, selectLast = false) { var item = repeater.itemAt(tabIndex) tabBarRow.currIndex = tabIndex - projectView.selectLast = selectLast + presetView.selectLast = selectLast BackendApi.presetModel.setPage(tabIndex) // NOTE: it resets preset model } @@ -244,10 +244,10 @@ Item { } // Rectangle Rectangle { - id: projectViewFrame + id: presetViewFrame x: 10 // left padding width: parent.width - 20 // right padding - height: DialogValues.projectViewHeight + height: DialogValues.presetViewHeight color: DialogValues.darkPaneColor Item { @@ -255,7 +255,7 @@ Item { anchors.margins: DialogValues.gridMargins NewProjectView { - id: projectView + id: presetView anchors.fill: parent loader: projectDetailsLoader @@ -265,12 +265,12 @@ Item { target: rootDialog function onHeightChanged() { if (rootDialog.height < 720) { // 720 = minimum height big dialog - DialogValues.projectViewHeight = - DialogValues.projectItemHeight + DialogValues.presetViewHeight = + DialogValues.presetItemHeight + 2 * DialogValues.gridMargins } else { - DialogValues.projectViewHeight = - DialogValues.projectItemHeight * 2 + DialogValues.presetViewHeight = + DialogValues.presetItemHeight * 2 + DialogValues.gridSpacing + 2 * DialogValues.gridMargins } @@ -289,7 +289,7 @@ Item { lineHeight: DialogValues.defaultLineHeight lineHeightMode: Text.FixedHeight leftPadding: 14 - width: projectViewFrame.width + width: presetViewFrame.width color: DialogValues.textColor wrapMode: Text.WordWrap maximumLineCount: 4 diff --git a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml index 97a5ac2bf9e..b348a6da350 100644 --- a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml +++ b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/Details.qml @@ -371,6 +371,9 @@ Item { if (widthField.realValue && heightField.realValue) { [widthField.realValue, heightField.realValue] = [heightField.realValue, widthField.realValue] orientationButton.checked = !orientationButton.checked + + if (widthField.realValue === heightField.realValue) + orientationButton.checked ? setVertical() : setHorizontal() } } diff --git a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/DialogValues.qml b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/DialogValues.qml index 7c11f231fc7..d85093738d8 100644 --- a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/DialogValues.qml +++ b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/DialogValues.qml @@ -33,9 +33,9 @@ QtObject { readonly property int dialogWidth: 1522 readonly property int dialogHeight: 940 - readonly property int projectViewMinimumWidth: 600 - readonly property int projectViewMinimumHeight: root.gridCellHeight - readonly property int dialogContentHeight: root.projectViewHeight + 300 // i.e. dialog without header and footer + readonly property int presetViewMinimumWidth: 600 + readonly property int presetViewMinimumHeight: root.gridCellHeight + readonly property int dialogContentHeight: root.presetViewHeight + 300 // i.e. dialog without header and footer readonly property int loadedPanesWidth: root.detailsPaneWidth + root.stylesPaneWidth readonly property int detailsPaneWidth: 330 + root.detailsPanePadding * 2 readonly property int dialogTitleTextHeight: 85 @@ -62,14 +62,14 @@ QtObject { readonly property int styleTextHeight: 18 readonly property int footerHeight: 73 - readonly property int projectItemWidth: 136 - readonly property int projectItemHeight: 110 - property int projectViewHeight: root.projectItemHeight * 2 + root.gridSpacing + root.gridMargins * 2 - readonly property int projectViewHeaderHeight: 38 + readonly property int presetItemWidth: 136 + readonly property int presetItemHeight: 110 + property int presetViewHeight: root.presetItemHeight * 2 + root.gridSpacing + root.gridMargins * 2 + readonly property int presetViewHeaderHeight: 38 readonly property int gridMargins: 20 - readonly property int gridCellWidth: root.projectItemWidth + root.gridSpacing - readonly property int gridCellHeight: root.projectItemHeight + root.gridSpacing + readonly property int gridCellWidth: root.presetItemWidth + root.gridSpacing + readonly property int gridCellHeight: root.presetItemHeight + root.gridSpacing readonly property int gridSpacing: 2 readonly property int dialogButtonWidth: 100 diff --git a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/NewProjectView.qml b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/NewProjectView.qml index aae984b069a..e8bb58cfa76 100644 --- a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/NewProjectView.qml +++ b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/NewProjectView.qml @@ -97,8 +97,8 @@ ScrollView { property bool hover: delegate.hovered || removeMouseArea.containsMouse - width: DialogValues.projectItemWidth - height: DialogValues.projectItemHeight + width: DialogValues.presetItemWidth + height: DialogValues.presetItemHeight onClicked: delegate.GridView.view.currentIndex = index @@ -107,7 +107,7 @@ ScrollView { width: parent.width height: parent.height color: delegate.hover ? scrollView.backgroundHoverColor : "transparent" - border.color: delegate.hover ? projectTypeName.color : "transparent" + border.color: delegate.hover ? presetName.color : "transparent" } function fontIconCode(index) { @@ -125,7 +125,7 @@ ScrollView { anchors.horizontalCenter: parent.horizontalCenter Label { - id: projectTypeIcon + id: presetIcon text: delegate.fontIconCode(index) color: DialogValues.textColor horizontalAlignment: Text.AlignHCenter @@ -137,25 +137,25 @@ ScrollView { } // Preset type icon Label Text { - id: projectTypeName + id: presetName color: DialogValues.textColor text: name font.pixelSize: DialogValues.defaultPixelSize lineHeight: DialogValues.defaultLineHeight lineHeightMode: Text.FixedHeight - width: DialogValues.projectItemWidth - 16 + width: DialogValues.presetItemWidth - 16 elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignTop Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: projectTypeName.width - Layout.minimumWidth: projectTypeName.width - Layout.maximumWidth: projectTypeName.width + Layout.preferredWidth: presetName.width + Layout.minimumWidth: presetName.width + Layout.maximumWidth: presetName.width ToolTip { id: toolTip y: -toolTip.height - visible: delegate.hovered && projectTypeName.truncated + visible: delegate.hovered && presetName.truncated text: name delay: 1000 height: 20 @@ -176,7 +176,7 @@ ScrollView { } Text { - id: projectTypeResolution + id: presetResolution color: DialogValues.textColor text: resolution font.pixelSize: DialogValues.defaultPixelSize @@ -219,7 +219,7 @@ ScrollView { : Qt.ArrowCursor onClicked: { - removePresetDialog.presetName = projectTypeName.text + removePresetDialog.presetName = presetName.text removePresetDialog.open() } } @@ -232,15 +232,15 @@ ScrollView { when: delegate.GridView.isCurrentItem PropertyChanges { - target: projectTypeName + target: presetName color: DialogValues.textColorInteraction } PropertyChanges { - target: projectTypeResolution + target: presetResolution color: DialogValues.textColorInteraction } PropertyChanges { - target: projectTypeIcon + target: presetIcon color: DialogValues.textColorInteraction } PropertyChanges {