forked from qt-creator/qt-creator
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 <david.schulz@qt.io>
This commit is contained in:
@@ -899,6 +899,8 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
|
|||||||
int bottomMargin = 9;
|
int bottomMargin = 9;
|
||||||
int heightWithoutKitArea = 0;
|
int heightWithoutKitArea = 0;
|
||||||
|
|
||||||
|
QRect newGeometry;
|
||||||
|
|
||||||
if (!onlySummary) {
|
if (!onlySummary) {
|
||||||
// list widget height
|
// list widget height
|
||||||
int maxItemCount = m_projectListWidget->maxCount();
|
int maxItemCount = m_projectListWidget->maxCount();
|
||||||
@@ -959,7 +961,7 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
|
|||||||
m_listWidgets[RUN]->setColumnWidth(1, runColumnWidth);
|
m_listWidgets[RUN]->setColumnWidth(1, runColumnWidth);
|
||||||
m_summaryLabel->resize(x - 1, summaryLabelHeight);
|
m_summaryLabel->resize(x - 1, summaryLabelHeight);
|
||||||
m_kitAreaWidget->resize(x - 1, kitAreaHeight);
|
m_kitAreaWidget->resize(x - 1, kitAreaHeight);
|
||||||
setFixedSize(x, heightWithoutKitArea + kitAreaHeight);
|
newGeometry.setSize({x, heightWithoutKitArea + kitAreaHeight});
|
||||||
} else {
|
} else {
|
||||||
if (keepSize)
|
if (keepSize)
|
||||||
heightWithoutKitArea = height() - oldSummaryLabelY + 1;
|
heightWithoutKitArea = height() - oldSummaryLabelY + 1;
|
||||||
@@ -967,12 +969,13 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
|
|||||||
heightWithoutKitArea = qMax(summaryLabelHeight + bottomMargin, alignedWithActionHeight);
|
heightWithoutKitArea = qMax(summaryLabelHeight + bottomMargin, alignedWithActionHeight);
|
||||||
m_summaryLabel->resize(m_summaryLabel->sizeHint().width(), heightWithoutKitArea - bottomMargin);
|
m_summaryLabel->resize(m_summaryLabel->sizeHint().width(), heightWithoutKitArea - bottomMargin);
|
||||||
m_kitAreaWidget->resize(m_kitAreaWidget->sizeHint());
|
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));
|
newGeometry.translate(statusBar->mapToGlobal(QPoint{0, 0}));
|
||||||
moveTo -= QPoint(0, height());
|
newGeometry.translate(QPoint{0, -newGeometry.height()});
|
||||||
move(moveTo);
|
repaint();
|
||||||
|
setGeometry(newGeometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MiniProjectTargetSelector::projectAdded(Project *project)
|
void MiniProjectTargetSelector::projectAdded(Project *project)
|
||||||
@@ -1543,7 +1546,10 @@ void MiniProjectTargetSelector::updateSummary()
|
|||||||
summary.append(QLatin1String("<br/>"));
|
summary.append(QLatin1String("<br/>"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (summary != m_summaryLabel->text()) {
|
||||||
m_summaryLabel->setText(summary);
|
m_summaryLabel->setText(summary);
|
||||||
|
doLayout(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MiniProjectTargetSelector::paintEvent(QPaintEvent *)
|
void MiniProjectTargetSelector::paintEvent(QPaintEvent *)
|
||||||
|
Reference in New Issue
Block a user