From 1aa05ae5e35aad82bf294aaf5e28df75dcf96cbe Mon Sep 17 00:00:00 2001 From: dt <qtc-committer@nokia.com> Date: Tue, 11 Aug 2009 16:37:24 +0200 Subject: [PATCH] Fix flickering in the project pane. This isn't a nice fix but the least evil version of a hack i could come up. The source of the flickering is: We have a deeply nested structure of widgets on the project pane. If we call hide() on such a deeply nested widget, it will activate() it's parent layout synchronously. That will then post an event (via updateGeometries() ) to its parent layout that it needs relayouting. Which then will post to its parent layout the same. And for each LayoutRequested, there's a painting in between. The fix instead calls activate() up the chain until we are at the viewport. This immediately relayouts everything. This adds a non obvoius potentially for breakeage if the widgets are embedded in a different widget hierarchy. But well, that's life. --- src/plugins/projectexplorer/buildstep.cpp | 8 ++++++++ src/plugins/projectexplorer/buildstep.h | 3 +++ src/plugins/projectexplorer/buildstepspage.cpp | 10 +++++++--- .../projectexplorer/environmenteditmodel.cpp | 16 ++++++++++++++++ .../projectexplorer/environmenteditmodel.h | 6 ++++++ src/plugins/projectexplorer/projectwindow.cpp | 3 ++- .../qt4buildenvironmentwidget.cpp | 8 ++++++++ .../qt4buildenvironmentwidget.h | 1 + .../qt4projectmanager/qt4projectconfigwidget.cpp | 1 + 9 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/buildstep.cpp b/src/plugins/projectexplorer/buildstep.cpp index ee9326128bb..710dae58219 100644 --- a/src/plugins/projectexplorer/buildstep.cpp +++ b/src/plugins/projectexplorer/buildstep.cpp @@ -31,6 +31,7 @@ #include "buildconfiguration.h" #include <utils/qtcassert.h> +#include <QtGui/QLayout> using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; @@ -133,6 +134,13 @@ bool BuildStep::immutable() const return false; } +void BuildConfigWidget::fixupLayout(QWidget *widget) +{ + QWidget *parent = widget; + while((parent = parent->parentWidget()) && parent && parent->layout()) + parent->layout()->activate(); +} + IBuildStepFactory::IBuildStepFactory() { diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index 681077ede1c..ef36ddc9cad 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -171,6 +171,9 @@ public: :QWidget(0) {} + // This function iterates all parents and relayouts + // This is a hack to work around flickering + void fixupLayout(QWidget *widget); virtual QString displayName() const = 0; // This is called to set up the config widget before showing it diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp index baf19c2889e..f35ee1578c7 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -97,10 +97,14 @@ BuildStepsPage::~BuildStepsPage() void BuildStepsPage::toggleDetails() { QToolButton *tb = qobject_cast<QToolButton *>(sender()); - if (tb) - foreach(const BuildStepsWidgetStruct &s, m_buildSteps) - if (s.detailsButton == tb) + if (tb) { + foreach(const BuildStepsWidgetStruct &s, m_buildSteps) { + if (s.detailsButton == tb) { s.widget->setVisible(!s.widget->isVisible()); + fixupLayout(s.widget); + } + } + } } void BuildStepsPage::updateSummary() diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp index 57ad65b8af7..3c2b5214a29 100644 --- a/src/plugins/projectexplorer/environmenteditmodel.cpp +++ b/src/plugins/projectexplorer/environmenteditmodel.cpp @@ -520,9 +520,25 @@ EnvironmentWidget::~EnvironmentWidget() m_model = 0; } +bool EnvironmentWidget::detailsVisible() const +{ + return m_details->isVisible(); +} + +void EnvironmentWidget::setDetailsVisible(bool b) +{ + m_details->setVisible(b); +} + void EnvironmentWidget::toggleDetails() { m_details->setVisible(!m_details->isVisible()); + emit detailsVisibleChanged(m_details->isVisible()); +} + +QWidget *EnvironmentWidget::detailsWidget() const +{ + return m_details; } void EnvironmentWidget::setBaseEnvironment(const ProjectExplorer::Environment &env) diff --git a/src/plugins/projectexplorer/environmenteditmodel.h b/src/plugins/projectexplorer/environmenteditmodel.h index f897b4c8544..8cc2debad4a 100644 --- a/src/plugins/projectexplorer/environmenteditmodel.h +++ b/src/plugins/projectexplorer/environmenteditmodel.h @@ -104,12 +104,18 @@ public: QList<EnvironmentItem> userChanges() const; void setUserChanges(QList<EnvironmentItem> list); + bool detailsVisible() const; + void setDetailsVisible(bool b); + + QWidget *detailsWidget() const; + public slots: void updateButtons(); void toggleDetails(); signals: void userChangesUpdated(); + void detailsVisibleChanged(bool visible); private slots: void editEnvironmentButtonClicked(); diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 6854ea960ce..7d9cb03135f 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -76,8 +76,9 @@ PanelsWidget::PanelsWidget(QWidget *parent) topwidgetLayout->addWidget(verticalWidget); topwidgetLayout->addStretch(10); - setWidgetResizable(true); setFrameStyle(QFrame::NoFrame); + setWidgetResizable(true); + setWidget(topwidget); } diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp index ddc7210fe21..6c18557da4f 100644 --- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp @@ -54,10 +54,18 @@ Qt4BuildEnvironmentWidget::Qt4BuildEnvironmentWidget(Qt4Project *project) connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()), this, SLOT(environmentModelUserChangesUpdated())); + connect(m_buildEnvironmentWidget, SIGNAL(detailsVisibleChanged(bool)), + this, SLOT(layoutFixup())); + connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)), this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool))); } +void Qt4BuildEnvironmentWidget::layoutFixup() +{ + fixupLayout(m_buildEnvironmentWidget->detailsWidget()); +} + QString Qt4BuildEnvironmentWidget::displayName() const { return tr("Build Environment"); diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h index f89154a11a2..f55051ce1ba 100644 --- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h +++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h @@ -58,6 +58,7 @@ public: private slots: void environmentModelUserChangesUpdated(); void clearSystemEnvironmentCheckBoxClicked(bool checked); + void layoutFixup(); private: ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget; diff --git a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp index 454feeed30f..8e0619af43d 100644 --- a/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp +++ b/src/plugins/qt4projectmanager/qt4projectconfigwidget.cpp @@ -120,6 +120,7 @@ Qt4ProjectConfigWidget::~Qt4ProjectConfigWidget() void Qt4ProjectConfigWidget::toggleDetails() { m_ui->detailsWidget->setVisible(!m_ui->detailsWidget->isVisible()); + fixupLayout(m_ui->detailsWidget); } void Qt4ProjectConfigWidget::updateDetails() -- GitLab