From 3118a9247982575e904bc3173662ef3a896b8f2c Mon Sep 17 00:00:00 2001 From: Samuel Ghinet Date: Wed, 1 Dec 2021 19:30:34 +0200 Subject: [PATCH] QDS: shrink the right margin of the project view for small sized dialog This also allows a bit smaller minimum width for the dialog. Also, did a bit of cleanup. Task-number: QDS-5500 Change-Id: I3660190ac0a73dd1da1c7d6f8ee76660b1fba6be Reviewed-by: Thomas Hartmann --- .../newprojectdialog/NewProjectDialog.qml | 33 +++++++++++++------ .../imports/NewProjectDialog/DialogValues.qml | 2 +- .../newprojectdialogimageprovider.cpp | 2 +- src/plugins/studiowelcome/qdsnewdialog.cpp | 2 +- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/share/qtcreator/qmldesigner/newprojectdialog/NewProjectDialog.qml b/share/qtcreator/qmldesigner/newprojectdialog/NewProjectDialog.qml index eb0cb21adf1..3e91ab70f11 100644 --- a/share/qtcreator/qmldesigner/newprojectdialog/NewProjectDialog.qml +++ b/share/qtcreator/qmldesigner/newprojectdialog/NewProjectDialog.qml @@ -133,7 +133,7 @@ Item { Rectangle { // TabBar readonly property int animDur: 500 - id: samTabRect + id: tabBar x: 10 // left padding width: parent.width - 64 // right padding height: DialogValues.projectViewHeaderHeight @@ -153,15 +153,15 @@ Item { verticalAlignment: Text.AlignVCenter color: tabBarRow.currIndex === index ? DialogValues.textColorInteraction : DialogValues.textColor - Behavior on color { ColorAnimation { duration: samTabRect.animDur } } + Behavior on color { ColorAnimation { duration: tabBar.animDur } } MouseArea { anchors.fill: parent onClicked: { tabBarRow.currIndex = index projectModel.setPage(index) - projectViewId.currentIndex = 0 - projectViewId.currentIndexChanged() + projectView.currentIndex = 0 + projectView.currentIndexChanged() strip.x = parent.x strip.width = parent.width @@ -180,13 +180,26 @@ Item { color: DialogValues.textColorInteraction anchors.bottom: parent.bottom - Behavior on x { SmoothedAnimation { duration: samTabRect.animDur } } - Behavior on width { SmoothedAnimation { duration: strip.width === 0 ? 0 : samTabRect.animDur } } // do not animate initial width + Behavior on x { SmoothedAnimation { duration: tabBar.animDur } } + Behavior on width { SmoothedAnimation { duration: strip.width === 0 ? 0 : tabBar.animDur } } // do not animate initial width + } + + Connections { + target: rootDialog + function onWidthChanged() { + if (rootDialog.width < 1200) { // 1200 = the width threshold + tabBar.width = tabBar.parent.width - 20 + projectView.width = projectView.parent.width - 20 + } else { + tabBar.width = tabBar.parent.width - 64 + projectView.width = projectView.parent.width - 64 + } + } } } // Rectangle NewProjectView { - id: projectViewId + id: projectView x: 10 // left padding width: parent.width - 64 // right padding height: DialogValues.projectViewHeight @@ -196,9 +209,9 @@ Item { target: rootDialog function onHeightChanged() { if (rootDialog.height < 700) { // 700 = minimum height big dialog - projectViewId.height = DialogValues.projectViewHeight / 2 + projectView.height = DialogValues.projectViewHeight / 2 } else { - projectViewId.height = DialogValues.projectViewHeight + projectView.height = DialogValues.projectViewHeight } } } @@ -213,7 +226,7 @@ Item { lineHeight: DialogValues.defaultLineHeight lineHeightMode: Text.FixedHeight leftPadding: 14 - width: projectViewId.width + width: projectView.width color: DialogValues.textColor wrapMode: Text.WordWrap maximumLineCount: 4 diff --git a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/DialogValues.qml b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/DialogValues.qml index 0dafb43e44b..b99b99dc952 100644 --- a/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/DialogValues.qml +++ b/share/qtcreator/qmldesigner/newprojectdialog/imports/NewProjectDialog/DialogValues.qml @@ -35,7 +35,7 @@ QtObject { readonly property int projectViewMinimumHeight: projectViewHeight readonly property int dialogContentHeight: projectViewHeight + 300 // i.e. dialog without header and footer readonly property int loadedPanesWidth: detailsPaneWidth + stylesPaneWidth - readonly property int detailsPaneWidth: 330 + detailsPanePadding * 2// + 10 // 50 + readonly property int detailsPaneWidth: 330 + detailsPanePadding * 2 readonly property int dialogTitleTextHeight: 47 /* detailsScrollableContentHeight - the full height that may need to be scrolled to be fully visible, if the dialog box is too small. */ diff --git a/src/plugins/studiowelcome/newprojectdialogimageprovider.cpp b/src/plugins/studiowelcome/newprojectdialogimageprovider.cpp index 0e502925040..e14678431ac 100644 --- a/src/plugins/studiowelcome/newprojectdialogimageprovider.cpp +++ b/src/plugins/studiowelcome/newprojectdialogimageprovider.cpp @@ -96,7 +96,7 @@ QPixmap NewProjectDialogImageProvider::requestDefaultPixmap(const QString &id, Q } if (pixmap.isNull()) - return QPixmap{}; + return {}; if (requestedSize.isValid()) return pixmap.scaled(requestedSize); diff --git a/src/plugins/studiowelcome/qdsnewdialog.cpp b/src/plugins/studiowelcome/qdsnewdialog.cpp index 1ab2a45ee8b..50e3a085ca0 100644 --- a/src/plugins/studiowelcome/qdsnewdialog.cpp +++ b/src/plugins/studiowelcome/qdsnewdialog.cpp @@ -94,7 +94,7 @@ QdsNewDialog::QdsNewDialog(QWidget *parent) m_dialog->setWindowModality(Qt::ApplicationModal); m_dialog->setWindowFlags(Qt::Dialog); m_dialog->setAttribute(Qt::WA_DeleteOnClose); - m_dialog->setMinimumSize(1110, 554); + m_dialog->setMinimumSize(1066, 554); QSize screenSize = m_dialog->screen()->geometry().size(); if (screenSize.height() < 1080)