Core: Detach status bar handling from global object pool

Instead of relying on addObject notification, provide a
StatusBarManager::addStatusBarWidget() method to create,
register and keep track of an IContext object.

That's essentially what was StatusBarWidget before, but does
not need to be known on the user side. For removal, this
provides a StatusBarManager::destroyStatusBarWidget(),
any not explicitly removed items are handled in response
to ICore::coreAboutToClose()

The StatusBarManager class is fully static now, could
be a namespace.

Change-Id: Ia2bd13b391c3f68c8dfd584b53524a9649cc0787
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2018-01-24 17:41:53 +01:00
parent 1442919823
commit 3c91777e48
13 changed files with 80 additions and 220 deletions

View File

@@ -32,8 +32,7 @@
#include "../icontext.h"
#include "../coreconstants.h"
#include "../icore.h"
#include "../statusbarwidget.h"
#include "../statusbarmanager.h"
#include <extensionsystem/pluginmanager.h>
#include <utils/hostosinfo.h>
@@ -286,8 +285,8 @@ ProgressManagerPrivate::~ProgressManagerPrivate()
stopFadeOfSummaryProgress();
qDeleteAll(m_taskList);
m_taskList.clear();
ExtensionSystem::PluginManager::removeObject(m_statusBarWidgetContainer);
delete m_statusBarWidgetContainer;
StatusBarManager::destroyStatusBarWidget(m_statusBarWidget);
m_statusBarWidget = nullptr;
cleanup();
m_instance = 0;
}
@@ -304,7 +303,6 @@ void ProgressManagerPrivate::init()
{
readSettings();
m_statusBarWidgetContainer = new StatusBarWidget;
m_statusBarWidget = new QWidget;
QHBoxLayout *layout = new QHBoxLayout(m_statusBarWidget);
layout->setContentsMargins(0, 0, 0, 0);
@@ -326,10 +324,8 @@ void ProgressManagerPrivate::init()
layout->addWidget(m_summaryProgressWidget);
ToggleButton *toggleButton = new ToggleButton(m_statusBarWidget);
layout->addWidget(toggleButton);
m_statusBarWidgetContainer->setWidget(m_statusBarWidget);
m_statusBarWidgetContainer->setPosition(StatusBarWidget::RightCorner);
ExtensionSystem::PluginManager::addObject(m_statusBarWidgetContainer);
m_statusBarWidget->installEventFilter(this);
StatusBarManager::addStatusBarWidget(m_statusBarWidget, StatusBarManager::RightCorner);
QAction *toggleProgressView = new QAction(tr("Toggle Progress Details"), this);
toggleProgressView->setCheckable(true);