1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** Licensees holding valid Qt Commercial licenses may use this file in
12 ** accordance with the Qt Commercial License Agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and Nokia.
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** If you are unsure which license is appropriate for your use, please
26 ** contact the sales department at http://qt.nokia.com/contact.
28 **************************************************************************/
30 #include "statusbarmanager.h"
32 #include "coreconstants.h"
33 #include "mainwindow.h"
34 #include "statusbarwidget.h"
36 #include <coreplugin/actionmanager/actionmanager.h>
37 #include <coreplugin/actionmanager/command.h>
38 #include <aggregation/aggregate.h>
39 #include <extensionsystem/pluginmanager.h>
41 #include <QtCore/QSettings>
42 #include <QtGui/QHBoxLayout>
43 #include <QtGui/QLabel>
44 #include <QtGui/QStatusBar>
47 using namespace Core::Internal;
49 StatusBarManager::StatusBarManager(MainWindow *mainWnd)
53 for (int i = 0; i <= StatusBarWidget::Last; ++i) {
54 QWidget *w = new QWidget();
55 m_mainWnd->statusBar()->insertPermanentWidget(i, w);
56 w->setLayout(new QHBoxLayout);
58 w->layout()->setMargin(0);
59 m_statusBarWidgets.append(w);
61 m_mainWnd->statusBar()->insertPermanentWidget(StatusBarWidget::Last+1,
65 StatusBarManager::~StatusBarManager()
69 void StatusBarManager::init()
71 connect(ExtensionSystem::PluginManager::instance(), SIGNAL(objectAdded(QObject*)),
72 this, SLOT(objectAdded(QObject*)));
73 connect(ExtensionSystem::PluginManager::instance(), SIGNAL(aboutToRemoveObject(QObject*)),
74 this, SLOT(aboutToRemoveObject(QObject*)));
77 void StatusBarManager::objectAdded(QObject *obj)
79 StatusBarWidget *view = Aggregation::query<StatusBarWidget>(obj);
83 QWidget *viewWidget = 0;
84 viewWidget = view->widget();
85 m_statusBarWidgets.at(view->position())->layout()->addWidget(viewWidget);
87 m_mainWnd->addContextObject(view);
90 void StatusBarManager::aboutToRemoveObject(QObject *obj)
92 StatusBarWidget *view = Aggregation::query<StatusBarWidget>(obj);
95 m_mainWnd->removeContextObject(view);
98 void StatusBarManager::extensionsInitalized()