Avoid status bar flickering while indexing

If you hide the progress details with the toggle button, we show a
progress bar in the status bar, and in case of indexing prefix that with
a details label (n/N). Since these numbers change all the time, the
label changes slightly in size, and if the window is small enough that
leads to the output pane buttons resizing all the time.

Avoid that flickering by restricting the details label to a grid.

Fixes: QTCREATORBUG-27255
Change-Id: I3d031779f9fe1ce960e44e8a65e613c2bac3b107
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2022-03-29 14:31:54 +02:00
parent f99094a0b8
commit b4f2ac0dd4
2 changed files with 27 additions and 8 deletions

View File

@@ -269,16 +269,23 @@ void ProgressManagerPrivate::init()
m_summaryProgressWidget = new QWidget(m_statusBarWidget);
m_summaryProgressWidget->setVisible(!m_progressViewPinned);
m_summaryProgressWidget->setGraphicsEffect(m_opacityEffect);
m_summaryProgressLayout = new QHBoxLayout(m_summaryProgressWidget);
m_summaryProgressLayout->setContentsMargins(0, 0, 0, 2);
m_summaryProgressLayout->setSpacing(0);
m_summaryProgressWidget->setLayout(m_summaryProgressLayout);
auto summaryProgressLayout = new QHBoxLayout(m_summaryProgressWidget);
summaryProgressLayout->setContentsMargins(0, 0, 0, 2);
summaryProgressLayout->setSpacing(0);
m_summaryProgressWidget->setLayout(summaryProgressLayout);
m_statusDetailsWidgetContainer = new QWidget(m_summaryProgressWidget);
m_statusDetailsWidgetLayout = new QHBoxLayout(m_summaryProgressWidget);
m_statusDetailsWidgetLayout->setContentsMargins(0, 0, 0, 0);
m_statusDetailsWidgetLayout->setSpacing(0);
m_statusDetailsWidgetLayout->addStretch(1);
m_statusDetailsWidgetContainer->setLayout(m_statusDetailsWidgetLayout);
summaryProgressLayout->addWidget(m_statusDetailsWidgetContainer);
m_summaryProgressBar = new ProgressBar(m_summaryProgressWidget);
m_summaryProgressBar->setMinimumWidth(70);
m_summaryProgressBar->setTitleVisible(false);
m_summaryProgressBar->setSeparatorVisible(false);
m_summaryProgressBar->setCancelEnabled(false);
m_summaryProgressLayout->addWidget(m_summaryProgressBar);
summaryProgressLayout->addWidget(m_summaryProgressBar);
layout->addWidget(m_summaryProgressWidget);
auto toggleButton = new QToolButton(m_statusBarWidget);
layout->addWidget(toggleButton);
@@ -609,6 +616,8 @@ void ProgressManagerPrivate::updateVisibilityWithDelay()
QTimer::singleShot(150, this, &ProgressManagerPrivate::updateVisibility);
}
const int RASTER = 20;
void ProgressManagerPrivate::updateStatusDetailsWidget()
{
QWidget *candidateWidget = nullptr;
@@ -636,16 +645,25 @@ void ProgressManagerPrivate::updateStatusDetailsWidget()
}
}
// make size fit on raster, to avoid flickering in status bar
// because the output pane buttons resize, if the widget changes a lot (like it is the case for
// the language server indexing)
if (candidateWidget) {
const int preferredWidth = candidateWidget->sizeHint().width();
const int width = preferredWidth + (RASTER - preferredWidth % RASTER);
m_statusDetailsWidgetContainer->setFixedWidth(width);
}
if (candidateWidget == m_currentStatusDetailsWidget)
return;
if (m_currentStatusDetailsWidget) {
m_currentStatusDetailsWidget->hide();
m_summaryProgressLayout->removeWidget(m_currentStatusDetailsWidget);
m_statusDetailsWidgetLayout->removeWidget(m_currentStatusDetailsWidget);
}
if (candidateWidget) {
m_summaryProgressLayout->insertWidget(0, candidateWidget);
m_statusDetailsWidgetLayout->addWidget(candidateWidget);
candidateWidget->show();
}

View File

@@ -101,7 +101,8 @@ private:
StatusBarWidget *m_statusBarWidgetContainer;
QWidget *m_statusBarWidget;
QWidget *m_summaryProgressWidget;
QHBoxLayout *m_summaryProgressLayout;
QWidget *m_statusDetailsWidgetContainer = nullptr;
QHBoxLayout *m_statusDetailsWidgetLayout = nullptr;
QWidget *m_currentStatusDetailsWidget = nullptr;
QPointer<FutureProgress> m_currentStatusDetailsProgress;
QLabel *m_statusDetailsLabel = nullptr;