From 0ddc0eb8e95ecb3815f9ae40407d9c3fbef8cec2 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Tue, 6 Dec 2022 12:34:05 +0100 Subject: [PATCH] ProjectExplorer: Re-layout target selector When the summary changes, we need to recalculate the layout as it might change the height of the target selector. Otherwise the selector might move while the mouse is still pressed, leading to an unwanted selection. Change-Id: Ic1f1ffc89376caf33ecf1be80b7aeda52839bc5e Reviewed-by: David Schulz --- .../miniprojecttargetselector.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp index 5ea8a718dfa..4186eb21327 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp +++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp @@ -899,6 +899,8 @@ void MiniProjectTargetSelector::doLayout(bool keepSize) int bottomMargin = 9; int heightWithoutKitArea = 0; + QRect newGeometry; + if (!onlySummary) { // list widget height int maxItemCount = m_projectListWidget->maxCount(); @@ -959,7 +961,7 @@ void MiniProjectTargetSelector::doLayout(bool keepSize) m_listWidgets[RUN]->setColumnWidth(1, runColumnWidth); m_summaryLabel->resize(x - 1, summaryLabelHeight); m_kitAreaWidget->resize(x - 1, kitAreaHeight); - setFixedSize(x, heightWithoutKitArea + kitAreaHeight); + newGeometry.setSize({x, heightWithoutKitArea + kitAreaHeight}); } else { if (keepSize) heightWithoutKitArea = height() - oldSummaryLabelY + 1; @@ -967,12 +969,13 @@ void MiniProjectTargetSelector::doLayout(bool keepSize) heightWithoutKitArea = qMax(summaryLabelHeight + bottomMargin, alignedWithActionHeight); m_summaryLabel->resize(m_summaryLabel->sizeHint().width(), heightWithoutKitArea - bottomMargin); m_kitAreaWidget->resize(m_kitAreaWidget->sizeHint()); - setFixedSize(m_summaryLabel->width() + 1, heightWithoutKitArea + kitAreaHeight); //1 extra pixel for the border + newGeometry.setSize({m_summaryLabel->width() + 1, heightWithoutKitArea + kitAreaHeight}); } - QPoint moveTo = statusBar->mapToGlobal(QPoint(0, 0)); - moveTo -= QPoint(0, height()); - move(moveTo); + newGeometry.translate(statusBar->mapToGlobal(QPoint{0, 0})); + newGeometry.translate(QPoint{0, -newGeometry.height()}); + repaint(); + setGeometry(newGeometry); } void MiniProjectTargetSelector::projectAdded(Project *project) @@ -1543,7 +1546,10 @@ void MiniProjectTargetSelector::updateSummary() summary.append(QLatin1String("
")); } } - m_summaryLabel->setText(summary); + if (summary != m_summaryLabel->text()) { + m_summaryLabel->setText(summary); + doLayout(false); + } } void MiniProjectTargetSelector::paintEvent(QPaintEvent *)