forked from qt-creator/qt-creator
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:
@@ -58,7 +58,6 @@ SOURCES += corejsextensions.cpp \
|
|||||||
progressmanager/progressbar.cpp \
|
progressmanager/progressbar.cpp \
|
||||||
progressmanager/futureprogress.cpp \
|
progressmanager/futureprogress.cpp \
|
||||||
reaper.cpp \
|
reaper.cpp \
|
||||||
statusbarwidget.cpp \
|
|
||||||
coreplugin.cpp \
|
coreplugin.cpp \
|
||||||
modemanager.cpp \
|
modemanager.cpp \
|
||||||
basefilewizard.cpp \
|
basefilewizard.cpp \
|
||||||
@@ -175,7 +174,6 @@ HEADERS += corejsextensions.h \
|
|||||||
ifilewizardextension.h \
|
ifilewizardextension.h \
|
||||||
versiondialog.h \
|
versiondialog.h \
|
||||||
core_global.h \
|
core_global.h \
|
||||||
statusbarwidget.h \
|
|
||||||
coreplugin.h \
|
coreplugin.h \
|
||||||
modemanager.h \
|
modemanager.h \
|
||||||
basefilewizard.h \
|
basefilewizard.h \
|
||||||
|
|||||||
@@ -159,8 +159,6 @@ Project {
|
|||||||
"sidebarwidget.h",
|
"sidebarwidget.h",
|
||||||
"statusbarmanager.cpp",
|
"statusbarmanager.cpp",
|
||||||
"statusbarmanager.h",
|
"statusbarmanager.h",
|
||||||
"statusbarwidget.cpp",
|
|
||||||
"statusbarwidget.h",
|
|
||||||
"styleanimator.cpp",
|
"styleanimator.cpp",
|
||||||
"styleanimator.h",
|
"styleanimator.h",
|
||||||
"systemsettings.cpp",
|
"systemsettings.cpp",
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <coreplugin/settingsdatabase.h>
|
#include <coreplugin/settingsdatabase.h>
|
||||||
#include <coreplugin/statusbarwidget.h>
|
#include <coreplugin/statusbarmanager.h>
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
@@ -114,11 +114,8 @@ void Locator::initialize(CorePlugin *corePlugin, const QStringList &, QString *)
|
|||||||
mtools->addAction(cmd);
|
mtools->addAction(cmd);
|
||||||
|
|
||||||
auto locatorWidget = LocatorManager::createLocatorInputWidget(ICore::mainWindow());
|
auto locatorWidget = LocatorManager::createLocatorInputWidget(ICore::mainWindow());
|
||||||
StatusBarWidget *view = new StatusBarWidget;
|
StatusBarManager::addStatusBarWidget(locatorWidget, StatusBarManager::First,
|
||||||
view->setWidget(locatorWidget);
|
Context("LocatorWidget"));
|
||||||
view->setContext(Context("LocatorWidget"));
|
|
||||||
view->setPosition(StatusBarWidget::First);
|
|
||||||
m_corePlugin->addAutoReleasedObject(view);
|
|
||||||
|
|
||||||
new LocatorManager(this);
|
new LocatorManager(this);
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@
|
|||||||
#include "navigationwidget.h"
|
#include "navigationwidget.h"
|
||||||
#include "rightpane.h"
|
#include "rightpane.h"
|
||||||
#include "editormanager/ieditorfactory.h"
|
#include "editormanager/ieditorfactory.h"
|
||||||
#include "statusbarwidget.h"
|
|
||||||
#include "systemsettings.h"
|
#include "systemsettings.h"
|
||||||
#include "externaltoolmanager.h"
|
#include "externaltoolmanager.h"
|
||||||
#include "editormanager/systemeditor.h"
|
#include "editormanager/systemeditor.h"
|
||||||
@@ -176,7 +175,6 @@ MainWindow::MainWindow() :
|
|||||||
m_rightNavigationWidget = new NavigationWidget(m_toggleRightSideBarAction, Side::Right);
|
m_rightNavigationWidget = new NavigationWidget(m_toggleRightSideBarAction, Side::Right);
|
||||||
m_rightPaneWidget = new RightPaneWidget();
|
m_rightPaneWidget = new RightPaneWidget();
|
||||||
|
|
||||||
m_statusBarManager = new StatusBarManager;
|
|
||||||
m_messageManager = new MessageManager;
|
m_messageManager = new MessageManager;
|
||||||
m_editorManager = new EditorManager(this);
|
m_editorManager = new EditorManager(this);
|
||||||
m_externalToolManager = new ExternalToolManager();
|
m_externalToolManager = new ExternalToolManager();
|
||||||
@@ -274,10 +272,6 @@ MainWindow::~MainWindow()
|
|||||||
// All modes are now gone
|
// All modes are now gone
|
||||||
OutputPaneManager::destroy();
|
OutputPaneManager::destroy();
|
||||||
|
|
||||||
// Now that the OutputPaneManager is gone, is a good time to delete the view
|
|
||||||
PluginManager::removeObject(m_outputView);
|
|
||||||
delete m_outputView;
|
|
||||||
|
|
||||||
delete m_leftNavigationWidget;
|
delete m_leftNavigationWidget;
|
||||||
delete m_rightNavigationWidget;
|
delete m_rightNavigationWidget;
|
||||||
m_leftNavigationWidget = nullptr;
|
m_leftNavigationWidget = nullptr;
|
||||||
@@ -287,8 +281,7 @@ MainWindow::~MainWindow()
|
|||||||
m_editorManager = nullptr;
|
m_editorManager = nullptr;
|
||||||
delete m_progressManager;
|
delete m_progressManager;
|
||||||
m_progressManager = nullptr;
|
m_progressManager = nullptr;
|
||||||
delete m_statusBarManager;
|
|
||||||
m_statusBarManager = nullptr;
|
|
||||||
PluginManager::removeObject(m_coreImpl);
|
PluginManager::removeObject(m_coreImpl);
|
||||||
delete m_coreImpl;
|
delete m_coreImpl;
|
||||||
m_coreImpl = nullptr;
|
m_coreImpl = nullptr;
|
||||||
@@ -310,7 +303,6 @@ bool MainWindow::init(QString *errorMessage)
|
|||||||
Q_UNUSED(errorMessage)
|
Q_UNUSED(errorMessage)
|
||||||
|
|
||||||
PluginManager::addObject(m_coreImpl);
|
PluginManager::addObject(m_coreImpl);
|
||||||
m_statusBarManager->init();
|
|
||||||
m_progressManager->init(); // needs the status bar manager
|
m_progressManager->init(); // needs the status bar manager
|
||||||
|
|
||||||
PluginManager::addObject(m_generalSettings);
|
PluginManager::addObject(m_generalSettings);
|
||||||
@@ -320,12 +312,6 @@ bool MainWindow::init(QString *errorMessage)
|
|||||||
PluginManager::addObject(m_mimeTypeSettings);
|
PluginManager::addObject(m_mimeTypeSettings);
|
||||||
PluginManager::addObject(m_systemEditor);
|
PluginManager::addObject(m_systemEditor);
|
||||||
|
|
||||||
// Add widget to the bottom, we create the view here instead of inside the
|
|
||||||
// OutputPaneManager, since the StatusBarManager needs to be initialized before
|
|
||||||
m_outputView = new StatusBarWidget;
|
|
||||||
m_outputView->setWidget(OutputPaneManager::instance()->buttonsWidget());
|
|
||||||
m_outputView->setPosition(StatusBarWidget::Second);
|
|
||||||
PluginManager::addObject(m_outputView);
|
|
||||||
MessageManager::init();
|
MessageManager::init();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1166,7 +1152,7 @@ void MainWindow::restoreWindowState()
|
|||||||
restoreState(settings->value(QLatin1String(windowStateKey)).toByteArray());
|
restoreState(settings->value(QLatin1String(windowStateKey)).toByteArray());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
show();
|
show();
|
||||||
m_statusBarManager->restoreSettings();
|
StatusBarManager::restoreSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
class StatusBarWidget;
|
|
||||||
class EditorManager;
|
class EditorManager;
|
||||||
class ExternalToolManager;
|
class ExternalToolManager;
|
||||||
class HelpManager;
|
class HelpManager;
|
||||||
@@ -66,7 +65,6 @@ class ProgressManagerPrivate;
|
|||||||
class ShortcutSettings;
|
class ShortcutSettings;
|
||||||
class ToolSettings;
|
class ToolSettings;
|
||||||
class MimeTypeSettings;
|
class MimeTypeSettings;
|
||||||
class StatusBarManager;
|
|
||||||
class VersionDialog;
|
class VersionDialog;
|
||||||
class WindowSupport;
|
class WindowSupport;
|
||||||
class SystemEditor;
|
class SystemEditor;
|
||||||
@@ -159,14 +157,12 @@ private:
|
|||||||
ProgressManagerPrivate *m_progressManager = nullptr;
|
ProgressManagerPrivate *m_progressManager = nullptr;
|
||||||
JsExpander *m_jsExpander = nullptr;
|
JsExpander *m_jsExpander = nullptr;
|
||||||
VcsManager *m_vcsManager = nullptr;
|
VcsManager *m_vcsManager = nullptr;
|
||||||
StatusBarManager *m_statusBarManager = nullptr;
|
|
||||||
ModeManager *m_modeManager = nullptr;
|
ModeManager *m_modeManager = nullptr;
|
||||||
HelpManager *m_helpManager = nullptr;
|
HelpManager *m_helpManager = nullptr;
|
||||||
FancyTabWidget *m_modeStack = nullptr;
|
FancyTabWidget *m_modeStack = nullptr;
|
||||||
NavigationWidget *m_leftNavigationWidget = nullptr;
|
NavigationWidget *m_leftNavigationWidget = nullptr;
|
||||||
NavigationWidget *m_rightNavigationWidget = nullptr;
|
NavigationWidget *m_rightNavigationWidget = nullptr;
|
||||||
RightPaneWidget *m_rightPaneWidget = nullptr;
|
RightPaneWidget *m_rightPaneWidget = nullptr;
|
||||||
StatusBarWidget *m_outputView = nullptr;
|
|
||||||
VersionDialog *m_versionDialog = nullptr;
|
VersionDialog *m_versionDialog = nullptr;
|
||||||
|
|
||||||
QList<IContext *> m_activeContext;
|
QList<IContext *> m_activeContext;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
#include "ioutputpane.h"
|
#include "ioutputpane.h"
|
||||||
#include "modemanager.h"
|
#include "modemanager.h"
|
||||||
|
#include "statusbarmanager.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
@@ -212,11 +213,6 @@ OutputPaneManager::~OutputPaneManager()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *OutputPaneManager::buttonsWidget()
|
|
||||||
{
|
|
||||||
return m_buttonsWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return shortcut as Alt+<number> or Cmd+<number> if number is a non-zero digit
|
// Return shortcut as Alt+<number> or Cmd+<number> if number is a non-zero digit
|
||||||
static inline QKeySequence paneShortCut(int number)
|
static inline QKeySequence paneShortCut(int number)
|
||||||
{
|
{
|
||||||
@@ -229,6 +225,8 @@ static inline QKeySequence paneShortCut(int number)
|
|||||||
|
|
||||||
void OutputPaneManager::init()
|
void OutputPaneManager::init()
|
||||||
{
|
{
|
||||||
|
StatusBarManager::addStatusBarWidget(m_buttonsWidget, StatusBarManager::Second);
|
||||||
|
|
||||||
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
|
ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
|
||||||
|
|
||||||
// Window->Output Panes
|
// Window->Output Panes
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ class OutputPaneManager : public QWidget
|
|||||||
public:
|
public:
|
||||||
void init();
|
void init();
|
||||||
static OutputPaneManager *instance();
|
static OutputPaneManager *instance();
|
||||||
QWidget *buttonsWidget();
|
|
||||||
void updateStatusButtons(bool visible);
|
void updateStatusButtons(bool visible);
|
||||||
static void updateMaximizeButton(bool maximized);
|
static void updateMaximizeButton(bool maximized);
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,7 @@
|
|||||||
#include "../icontext.h"
|
#include "../icontext.h"
|
||||||
#include "../coreconstants.h"
|
#include "../coreconstants.h"
|
||||||
#include "../icore.h"
|
#include "../icore.h"
|
||||||
#include "../statusbarwidget.h"
|
#include "../statusbarmanager.h"
|
||||||
|
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
@@ -286,8 +285,8 @@ ProgressManagerPrivate::~ProgressManagerPrivate()
|
|||||||
stopFadeOfSummaryProgress();
|
stopFadeOfSummaryProgress();
|
||||||
qDeleteAll(m_taskList);
|
qDeleteAll(m_taskList);
|
||||||
m_taskList.clear();
|
m_taskList.clear();
|
||||||
ExtensionSystem::PluginManager::removeObject(m_statusBarWidgetContainer);
|
StatusBarManager::destroyStatusBarWidget(m_statusBarWidget);
|
||||||
delete m_statusBarWidgetContainer;
|
m_statusBarWidget = nullptr;
|
||||||
cleanup();
|
cleanup();
|
||||||
m_instance = 0;
|
m_instance = 0;
|
||||||
}
|
}
|
||||||
@@ -304,7 +303,6 @@ void ProgressManagerPrivate::init()
|
|||||||
{
|
{
|
||||||
readSettings();
|
readSettings();
|
||||||
|
|
||||||
m_statusBarWidgetContainer = new StatusBarWidget;
|
|
||||||
m_statusBarWidget = new QWidget;
|
m_statusBarWidget = new QWidget;
|
||||||
QHBoxLayout *layout = new QHBoxLayout(m_statusBarWidget);
|
QHBoxLayout *layout = new QHBoxLayout(m_statusBarWidget);
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
@@ -326,10 +324,8 @@ void ProgressManagerPrivate::init()
|
|||||||
layout->addWidget(m_summaryProgressWidget);
|
layout->addWidget(m_summaryProgressWidget);
|
||||||
ToggleButton *toggleButton = new ToggleButton(m_statusBarWidget);
|
ToggleButton *toggleButton = new ToggleButton(m_statusBarWidget);
|
||||||
layout->addWidget(toggleButton);
|
layout->addWidget(toggleButton);
|
||||||
m_statusBarWidgetContainer->setWidget(m_statusBarWidget);
|
|
||||||
m_statusBarWidgetContainer->setPosition(StatusBarWidget::RightCorner);
|
|
||||||
ExtensionSystem::PluginManager::addObject(m_statusBarWidgetContainer);
|
|
||||||
m_statusBarWidget->installEventFilter(this);
|
m_statusBarWidget->installEventFilter(this);
|
||||||
|
StatusBarManager::addStatusBarWidget(m_statusBarWidget, StatusBarManager::RightCorner);
|
||||||
|
|
||||||
QAction *toggleProgressView = new QAction(tr("Toggle Progress Details"), this);
|
QAction *toggleProgressView = new QAction(tr("Toggle Progress Details"), this);
|
||||||
toggleProgressView->setCheckable(true);
|
toggleProgressView->setCheckable(true);
|
||||||
|
|||||||
@@ -27,9 +27,8 @@
|
|||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "minisplitter.h"
|
#include "minisplitter.h"
|
||||||
#include "statusbarwidget.h"
|
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@@ -37,11 +36,14 @@
|
|||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
|
||||||
static const char kSettingsGroup[] = "StatusBar";
|
namespace Core {
|
||||||
static const char kLeftSplitWidthKey[] = "LeftSplitWidth";
|
|
||||||
|
|
||||||
using namespace Core;
|
const char kSettingsGroup[] = "StatusBar";
|
||||||
using namespace Core::Internal;
|
const char kLeftSplitWidthKey[] = "LeftSplitWidth";
|
||||||
|
|
||||||
|
static QPointer<QSplitter> m_splitter;
|
||||||
|
static QList<QPointer<QWidget>> m_statusBarWidgets;
|
||||||
|
static QList<QPointer<IContext>> m_contexts;
|
||||||
|
|
||||||
static QWidget *createWidget(QWidget *parent)
|
static QWidget *createWidget(QWidget *parent)
|
||||||
{
|
{
|
||||||
@@ -52,7 +54,7 @@ static QWidget *createWidget(QWidget *parent)
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBarManager::StatusBarManager()
|
static void createStatusBarManager()
|
||||||
{
|
{
|
||||||
QStatusBar *bar = ICore::statusBar();
|
QStatusBar *bar = ICore::statusBar();
|
||||||
|
|
||||||
@@ -82,47 +84,54 @@ StatusBarManager::StatusBarManager()
|
|||||||
QWidget *rightCornerWidget = createWidget(bar);
|
QWidget *rightCornerWidget = createWidget(bar);
|
||||||
bar->insertPermanentWidget(1, rightCornerWidget);
|
bar->insertPermanentWidget(1, rightCornerWidget);
|
||||||
m_statusBarWidgets.append(rightCornerWidget);
|
m_statusBarWidgets.append(rightCornerWidget);
|
||||||
|
|
||||||
|
QObject::connect(ICore::instance(), &ICore::saveSettingsRequested, [] {
|
||||||
|
QSettings *s = ICore::settings();
|
||||||
|
s->beginGroup(QLatin1String(kSettingsGroup));
|
||||||
|
s->setValue(QLatin1String(kLeftSplitWidthKey), m_splitter->sizes().at(0));
|
||||||
|
s->endGroup();
|
||||||
|
});
|
||||||
|
|
||||||
|
QObject::connect(ICore::instance(), &ICore::coreAboutToClose, [] {
|
||||||
|
// This is the catch-all on rampdown. Individual items may
|
||||||
|
// have been removed earlier by destroyStatusBarWidget().
|
||||||
|
for (const QPointer<IContext> &context : m_contexts)
|
||||||
|
ICore::removeContextObject(context);
|
||||||
|
m_contexts.clear();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
StatusBarManager::~StatusBarManager()
|
void StatusBarManager::addStatusBarWidget(QWidget *widget,
|
||||||
|
StatusBarPosition position,
|
||||||
|
const Context &ctx)
|
||||||
{
|
{
|
||||||
|
if (!m_splitter)
|
||||||
|
createStatusBarManager();
|
||||||
|
|
||||||
|
QTC_ASSERT(widget, return);
|
||||||
|
QTC_CHECK(widget->parent() == nullptr); // We re-parent, so user code does need / should not set it.
|
||||||
|
m_statusBarWidgets.at(position)->layout()->addWidget(widget);
|
||||||
|
|
||||||
|
auto context = new IContext;
|
||||||
|
context->setWidget(widget);
|
||||||
|
context->setContext(ctx);
|
||||||
|
m_contexts.append(context);
|
||||||
|
|
||||||
|
ICore::addContextObject(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBarManager::init()
|
void StatusBarManager::destroyStatusBarWidget(QWidget *widget)
|
||||||
{
|
{
|
||||||
connect(ExtensionSystem::PluginManager::instance(), &ExtensionSystem::PluginManager::objectAdded,
|
QTC_ASSERT(widget, return);
|
||||||
this, &StatusBarManager::objectAdded);
|
for (const QPointer<IContext> &context : m_contexts) {
|
||||||
connect(ExtensionSystem::PluginManager::instance(), &ExtensionSystem::PluginManager::aboutToRemoveObject,
|
if (context->widget() == widget) {
|
||||||
this, &StatusBarManager::aboutToRemoveObject);
|
ICore::removeContextObject(context);
|
||||||
connect(ICore::instance(), &ICore::saveSettingsRequested, this, &StatusBarManager::saveSettings);
|
m_contexts.removeAll(context);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
void StatusBarManager::objectAdded(QObject *obj)
|
}
|
||||||
{
|
widget->setParent(nullptr);
|
||||||
StatusBarWidget *view = qobject_cast<StatusBarWidget *>(obj);
|
delete widget;
|
||||||
if (!view)
|
|
||||||
return;
|
|
||||||
|
|
||||||
QWidget *viewWidget = view->widget();
|
|
||||||
m_statusBarWidgets.at(view->position())->layout()->addWidget(viewWidget);
|
|
||||||
|
|
||||||
ICore::addContextObject(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusBarManager::aboutToRemoveObject(QObject *obj)
|
|
||||||
{
|
|
||||||
StatusBarWidget *view = qobject_cast<StatusBarWidget *>(obj);
|
|
||||||
if (!view)
|
|
||||||
return;
|
|
||||||
ICore::removeContextObject(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusBarManager::saveSettings()
|
|
||||||
{
|
|
||||||
QSettings *s = ICore::settings();
|
|
||||||
s->beginGroup(QLatin1String(kSettingsGroup));
|
|
||||||
s->setValue(QLatin1String(kLeftSplitWidthKey), m_splitter->sizes().at(0));
|
|
||||||
s->endGroup();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusBarManager::restoreSettings()
|
void StatusBarManager::restoreSettings()
|
||||||
@@ -140,3 +149,5 @@ void StatusBarManager::restoreSettings()
|
|||||||
sum += w;
|
sum += w;
|
||||||
m_splitter->setSizes(QList<int>() << leftSplitWidth << (sum - leftSplitWidth));
|
m_splitter->setSizes(QList<int>() << leftSplitWidth << (sum - leftSplitWidth));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Core
|
||||||
|
|||||||
@@ -25,36 +25,20 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QList>
|
#include "icontext.h"
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QSplitter;
|
|
||||||
class QWidget;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class StatusBarManager : public QObject
|
class CORE_EXPORT StatusBarManager
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StatusBarManager();
|
enum StatusBarPosition { First=0, Second=1, Third=2, LastLeftAligned=Third, RightCorner};
|
||||||
~StatusBarManager();
|
|
||||||
|
|
||||||
void init();
|
static void addStatusBarWidget(QWidget *widget,
|
||||||
void restoreSettings();
|
StatusBarPosition position,
|
||||||
|
const Context &ctx = Context());
|
||||||
private:
|
static void destroyStatusBarWidget(QWidget *widget);
|
||||||
void objectAdded(QObject *obj);
|
static void restoreSettings();
|
||||||
void aboutToRemoveObject(QObject *obj);
|
|
||||||
void saveSettings();
|
|
||||||
|
|
||||||
QSplitter *m_splitter;
|
|
||||||
QList<QWidget *> m_statusBarWidgets;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "statusbarwidget.h"
|
|
||||||
|
|
||||||
using namespace Core;
|
|
||||||
|
|
||||||
StatusBarWidget::StatusBarWidget(QObject *parent)
|
|
||||||
: IContext(parent), m_defaultPosition(StatusBarWidget::First)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
StatusBarWidget::~StatusBarWidget()
|
|
||||||
{
|
|
||||||
delete m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
StatusBarWidget::StatusBarPosition StatusBarWidget::position() const
|
|
||||||
{
|
|
||||||
return m_defaultPosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StatusBarWidget::setPosition(StatusBarWidget::StatusBarPosition position)
|
|
||||||
{
|
|
||||||
m_defaultPosition = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
** Contact: https://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at https://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU General Public License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU
|
|
||||||
** General Public License version 3 as published by the Free Software
|
|
||||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
||||||
** included in the packaging of this file. Please review the following
|
|
||||||
** information to ensure the GNU General Public License requirements will
|
|
||||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "core_global.h"
|
|
||||||
#include "icontext.h"
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
|
|
||||||
class CORE_EXPORT StatusBarWidget : public IContext
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum StatusBarPosition { First=0, Second=1, Third=2, LastLeftAligned=Third, RightCorner};
|
|
||||||
|
|
||||||
StatusBarWidget(QObject *parent = 0);
|
|
||||||
~StatusBarWidget();
|
|
||||||
|
|
||||||
StatusBarWidget::StatusBarPosition position() const;
|
|
||||||
void setPosition(StatusBarWidget::StatusBarPosition position);
|
|
||||||
|
|
||||||
private:
|
|
||||||
StatusBarWidget::StatusBarPosition m_defaultPosition;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Core
|
|
||||||
@@ -47,7 +47,6 @@
|
|||||||
#include <coreplugin/idocument.h>
|
#include <coreplugin/idocument.h>
|
||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
#include <coreplugin/statusbarwidget.h>
|
|
||||||
#include <coreplugin/statusbarmanager.h>
|
#include <coreplugin/statusbarmanager.h>
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorerconstants.h>
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
@@ -1177,7 +1176,7 @@ private:
|
|||||||
UserCommandMap m_userCommandMap;
|
UserCommandMap m_userCommandMap;
|
||||||
UserCommandMap m_defaultUserCommandMap;
|
UserCommandMap m_defaultUserCommandMap;
|
||||||
|
|
||||||
StatusBarWidget *m_statusBar;
|
MiniBuffer *m_miniBuffer = nullptr;
|
||||||
// @TODO: Delete
|
// @TODO: Delete
|
||||||
//WordCompletion *m_wordCompletion;
|
//WordCompletion *m_wordCompletion;
|
||||||
FakeVimCompletionAssistProvider *m_wordProvider = nullptr;
|
FakeVimCompletionAssistProvider *m_wordProvider = nullptr;
|
||||||
@@ -1229,8 +1228,6 @@ FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin)
|
|||||||
QString cmd = QString::fromLatin1(":echo User command %1 executed.<CR>");
|
QString cmd = QString::fromLatin1(":echo User command %1 executed.<CR>");
|
||||||
defaultUserCommandMap().insert(i, cmd.arg(i));
|
defaultUserCommandMap().insert(i, cmd.arg(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_statusBar = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::onCoreAboutToClose()
|
void FakeVimPluginPrivate::onCoreAboutToClose()
|
||||||
@@ -2154,8 +2151,8 @@ void FakeVimPluginPrivate::showCommandBuffer(FakeVimHandler *handler, const QStr
|
|||||||
int messageLevel)
|
int messageLevel)
|
||||||
{
|
{
|
||||||
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
||||||
if (MiniBuffer *w = qobject_cast<MiniBuffer *>(m_statusBar->widget()))
|
QTC_ASSERT(m_miniBuffer, return);
|
||||||
w->setContents(contents, cursorPos, anchorPos, messageLevel, handler);
|
m_miniBuffer->setContents(contents, cursorPos, anchorPos, messageLevel, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPluginPrivate::showExtraInformation(FakeVimHandler *, const QString &text)
|
void FakeVimPluginPrivate::showExtraInformation(FakeVimHandler *, const QString &text)
|
||||||
@@ -2273,16 +2270,15 @@ bool FakeVimPlugin::initialize(const QStringList &arguments, QString *errorMessa
|
|||||||
|
|
||||||
ExtensionSystem::IPlugin::ShutdownFlag FakeVimPlugin::aboutToShutdown()
|
ExtensionSystem::IPlugin::ShutdownFlag FakeVimPlugin::aboutToShutdown()
|
||||||
{
|
{
|
||||||
d->aboutToShutdown();
|
StatusBarManager::destroyStatusBarWidget(d->m_miniBuffer);
|
||||||
|
d->m_miniBuffer = nullptr;
|
||||||
return SynchronousShutdown;
|
return SynchronousShutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPlugin::extensionsInitialized()
|
void FakeVimPlugin::extensionsInitialized()
|
||||||
{
|
{
|
||||||
d->m_statusBar = new StatusBarWidget;
|
d->m_miniBuffer = new MiniBuffer;
|
||||||
d->m_statusBar->setWidget(new MiniBuffer);
|
StatusBarManager::addStatusBarWidget(d->m_miniBuffer, StatusBarManager::LastLeftAligned);
|
||||||
d->m_statusBar->setPosition(StatusBarWidget::LastLeftAligned);
|
|
||||||
addAutoReleasedObject(d->m_statusBar);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
|
|||||||
Reference in New Issue
Block a user