Commit f68d6cf0 authored by hjk's avatar hjk

Fixes: rename OutputPane into OutputPaneManager

    RevBy:    dt
    Details:  also clean up the class interface a bit
parent a0a4cec8
......@@ -131,7 +131,6 @@ MainWindow::MainWindow() :
m_versionDialog(0),
m_activeContext(0),
m_pluginManager(0),
m_outputPane(new OutputPane(m_globalContext)),
m_outputMode(0),
m_generalSettings(new GeneralSettings),
m_shortcutSettings(new ShortcutSettings),
......@@ -150,6 +149,8 @@ MainWindow::MainWindow() :
#endif
m_toggleSideBarButton(new QToolButton)
{
OutputPaneManager::create();
setWindowTitle(tr("Qt Creator"));
qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png"));
setDockNestingEnabled(true);
......@@ -247,9 +248,9 @@ MainWindow::~MainWindow()
//because they might trigger stuff that tries to access data from editorwindow, like removeContextWidget
// All modes are now gone
delete OutputPane::instance();
OutputPaneManager::destroy();
// Now that the OutputPane is gone, is a good time to delete the view
// Now that the OutputPaneManager is gone, is a good time to delete the view
m_pluginManager->removeObject(m_outputView);
delete m_outputView;
......@@ -299,14 +300,15 @@ bool MainWindow::init(ExtensionSystem::PluginManager *pm, QString *)
outputModeWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_outputMode));
outputModeWidget->setFocusProxy(oph);
m_outputMode->setContext(m_outputPane->context());
m_outputMode->setContext(m_globalContext);
m_pluginManager->addObject(m_outputMode);
m_pluginManager->addObject(m_generalSettings);
m_pluginManager->addObject(m_shortcutSettings);
// Add widget to the bottom, we create the view here instead of inside the OutputPane, since
// the ViewManager needs to be initilized before
m_outputView = new Core::BaseView("OutputWindow.Buttons", m_outputPane->buttonsWidget(), QList<int>(), Core::IView::Second);
// Add widget to the bottom, we create the view here instead of inside the
// OutputPaneManager, since the ViewManager needs to be initilized before
m_outputView = new Core::BaseView("OutputWindow.Buttons",
OutputPaneManager::instance()->buttonsWidget(), QList<int>(), Core::IView::Second);
m_pluginManager->addObject(m_outputView);
return true;
}
......@@ -318,7 +320,7 @@ void MainWindow::extensionsInitialized()
m_viewManager->extensionsInitalized();
m_messageManager->init(m_pluginManager);
m_outputPane->init(m_pluginManager);
OutputPaneManager::instance()->init();
m_actionManager->initialize();
readSettings();
......@@ -756,7 +758,7 @@ void MainWindow::setFocusToEditor()
if (focusWidget && focusWidget == qApp->focusWidget()) {
if (FindToolBarPlaceHolder::getCurrent())
FindToolBarPlaceHolder::getCurrent()->hide();
m_outputPane->slotHide();
OutputPaneManager::instance()->slotHide();
RightPaneWidget::instance()->setShown(false);
}
}
......
......@@ -80,13 +80,12 @@ class CoreImpl;
class FancyTabWidget;
class GeneralSettings;
class NavigationWidget;
class OutputPane;
class ProgressManagerPrivate;
class ShortcutSettings;
class ViewManager;
class VersionDialog;
class CORE_EXPORT MainWindow : public QMainWindow
class CORE_EXPORT MainWindow : public QMainWindow
{
Q_OBJECT
......@@ -198,7 +197,6 @@ private:
ExtensionSystem::PluginManager *m_pluginManager;
OutputPane *m_outputPane;
BaseMode *m_outputMode;
GeneralSettings *m_generalSettings;
ShortcutSettings *m_shortcutSettings;
......
......@@ -81,7 +81,7 @@ private:
OutputPanePlaceHolder *OutputPanePlaceHolder::m_current = 0;
OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent)
:QWidget(parent), m_mode(mode), m_closeable(true)
: QWidget(parent), m_mode(mode), m_closeable(true)
{
setVisible(false);
setLayout(new QVBoxLayout);
......@@ -98,8 +98,8 @@ OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent)
OutputPanePlaceHolder::~OutputPanePlaceHolder()
{
if (m_current == this) {
OutputPane::instance()->setParent(0);
OutputPane::instance()->hide();
OutputPaneManager::instance()->setParent(0);
OutputPaneManager::instance()->hide();
}
}
......@@ -117,45 +117,54 @@ void OutputPanePlaceHolder::currentModeChanged(Core::IMode *mode)
{
if (m_current == this) {
m_current = 0;
OutputPane::instance()->setParent(0);
OutputPane::instance()->hide();
OutputPane::instance()->updateStatusButtons(false);
OutputPaneManager::instance()->setParent(0);
OutputPaneManager::instance()->hide();
OutputPaneManager::instance()->updateStatusButtons(false);
}
if (m_mode == mode) {
m_current = this;
layout()->addWidget(OutputPane::instance());
OutputPane::instance()->show();
OutputPane::instance()->updateStatusButtons(isVisible());
OutputPane::instance()->setCloseable(m_closeable);
layout()->addWidget(OutputPaneManager::instance());
OutputPaneManager::instance()->show();
OutputPaneManager::instance()->updateStatusButtons(isVisible());
OutputPaneManager::instance()->setCloseable(m_closeable);
}
}
////
// OutputPane
// OutputPaneManager
////
OutputPane *OutputPane::m_instance = 0;
static OutputPaneManager *m_instance = 0;
OutputPane *OutputPane::instance()
void OutputPaneManager::create()
{
m_instance = new OutputPaneManager;
}
void OutputPaneManager::destroy()
{
delete m_instance;
m_instance = 0;
}
OutputPaneManager *OutputPaneManager::instance()
{
return m_instance;
}
void OutputPane::updateStatusButtons(bool visible)
void OutputPaneManager::updateStatusButtons(bool visible)
{
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
if (m_buttons.value(idx))
m_buttons.value(idx)->setChecked(visible);
}
OutputPane::OutputPane(const QList<int> &context, QWidget *parent) :
OutputPaneManager::OutputPaneManager(QWidget *parent) :
QWidget(parent),
m_context(context),
m_widgetComboBox(new QComboBox),
m_clearButton(new QToolButton),
m_closeButton(new QToolButton),
m_closeAction(0),
m_pluginManager(0),
m_lastIndex(-1),
m_outputWidgetPane(new QStackedWidget),
m_opToolBarWidgets(new QStackedWidget)
......@@ -191,24 +200,19 @@ OutputPane::OutputPane(const QList<int> &context, QWidget *parent) :
#else
m_buttonsWidget->layout()->setSpacing(4);
#endif
m_instance = this;
}
OutputPane::~OutputPane()
OutputPaneManager::~OutputPaneManager()
{
m_instance = 0;
}
QWidget *OutputPane::buttonsWidget()
QWidget *OutputPaneManager::buttonsWidget()
{
return m_buttonsWidget;
}
void OutputPane::init(ExtensionSystem::PluginManager *pm)
void OutputPaneManager::init()
{
m_pluginManager = pm;
ActionManager *am = Core::ICore::instance()->actionManager();
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
......@@ -217,7 +221,8 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
mpanes->menu()->setTitle(tr("Output &Panes"));
QList<IOutputPane*> panes = m_pluginManager->getObjects<IOutputPane>();
QList<IOutputPane*> panes = ExtensionSystem::PluginManager::instance()
->getObjects<IOutputPane>();
QMultiMap<int, IOutputPane*> sorted;
foreach (IOutputPane* outPane, panes)
sorted.insertMulti(outPane->priorityInStatusBar(), outPane);
......@@ -251,7 +256,7 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
actionId.remove(QLatin1Char(' '));
QAction *action = new QAction(outPane->name(), this);
Command *cmd = am->registerAction(action, actionId, m_context);
Command *cmd = am->registerAction(action, actionId, QList<int>() << Constants::C_GLOBAL_ID);
if (outPane->priorityInStatusBar() != -1) {
#ifdef Q_OS_MAC
cmd->setDefaultKeySequence(QKeySequence("Ctrl+" + QString::number(shortcutNumber)));
......@@ -281,7 +286,7 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
changePage();
}
void OutputPane::shortcutTriggered()
void OutputPaneManager::shortcutTriggered()
{
QAction *action = qobject_cast<QAction*>(sender());
if (action && m_actions.contains(action)) {
......@@ -305,7 +310,7 @@ void OutputPane::shortcutTriggered()
}
}
void OutputPane::buttonTriggered()
void OutputPaneManager::buttonTriggered()
{
QPushButton *button = qobject_cast<QPushButton *>(sender());
QMap<int, QPushButton *>::const_iterator it, end;
......@@ -327,7 +332,7 @@ void OutputPane::buttonTriggered()
}
}
void OutputPane::updateToolTip()
void OutputPaneManager::updateToolTip()
{
QAction *action = qobject_cast<QAction*>(sender());
if (action) {
......@@ -337,7 +342,7 @@ void OutputPane::updateToolTip()
}
}
void OutputPane::slotHide()
void OutputPaneManager::slotHide()
{
if (OutputPanePlaceHolder::m_current) {
OutputPanePlaceHolder::m_current->setVisible(false);
......@@ -350,7 +355,7 @@ void OutputPane::slotHide()
}
}
int OutputPane::findIndexForPage(IOutputPane *out)
int OutputPaneManager::findIndexForPage(IOutputPane *out)
{
if (!out)
return -1;
......@@ -370,7 +375,7 @@ int OutputPane::findIndexForPage(IOutputPane *out)
return -1;
}
void OutputPane::ensurePageVisible(int idx)
void OutputPaneManager::ensurePageVisible(int idx)
{
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() != idx) {
m_widgetComboBox->setCurrentIndex(m_widgetComboBox->findData(idx));
......@@ -380,13 +385,13 @@ void OutputPane::ensurePageVisible(int idx)
}
void OutputPane::showPage(bool focus)
void OutputPaneManager::showPage(bool focus)
{
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
showPage(idx, focus);
}
void OutputPane::showPage(int idx, bool focus)
void OutputPaneManager::showPage(int idx, bool focus)
{
IOutputPane *out = m_pageMap.value(idx);
if (idx > -1) {
......@@ -405,7 +410,7 @@ void OutputPane::showPage(int idx, bool focus)
}
}
void OutputPane::togglePage(bool focus)
void OutputPaneManager::togglePage(bool focus)
{
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
if (OutputPanePlaceHolder::m_current
......@@ -417,23 +422,23 @@ void OutputPane::togglePage(bool focus)
}
}
void OutputPane::setCloseable(bool b)
void OutputPaneManager::setCloseable(bool b)
{
m_closeAction->setVisible(b);
}
bool OutputPane::closeable()
bool OutputPaneManager::closeable()
{
return m_closeButton->isVisibleTo(m_closeButton->parentWidget());
}
void OutputPane::focusInEvent(QFocusEvent *e)
void OutputPaneManager::focusInEvent(QFocusEvent *e)
{
if (m_outputWidgetPane->currentWidget())
m_outputWidgetPane->currentWidget()->setFocus(e->reason());
}
void OutputPane::changePage()
void OutputPaneManager::changePage()
{
if (m_outputWidgetPane->count() <= 0)
return;
......@@ -470,7 +475,7 @@ void OutputPane::changePage()
m_lastIndex = idx;
}
void OutputPane::clearPage()
void OutputPaneManager::clearPage()
{
if (m_pageMap.contains(m_outputWidgetPane->currentIndex()))
m_pageMap.value(m_outputWidgetPane->currentIndex())->clearContents();
......
......@@ -47,21 +47,20 @@ class QStackedWidget;
class QPushButton;
QT_END_NAMESPACE
namespace ExtensionSystem { class PluginManager; }
namespace Core {
class IMode;
class IOutputPane;
namespace Internal {
class OutputPane;
class OutputPaneManager;
class MainWindow;
}
class CORE_EXPORT OutputPanePlaceHolder : public QWidget
{
friend class Core::Internal::OutputPane; // needs to set m_visible and thus access m_current
friend class Core::Internal::OutputPaneManager; // needs to set m_visible and thus access m_current
Q_OBJECT
public:
OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
......@@ -80,17 +79,13 @@ private:
namespace Internal {
class OutputPane
: public QWidget
class OutputPaneManager : public QWidget
{
Q_OBJECT
public:
OutputPane(const QList<int> &context, QWidget *parent = 0);
~OutputPane();
void init(ExtensionSystem::PluginManager *pm);
static OutputPane *instance();
const QList<int> &context() const { return m_context; }
void init();
static OutputPaneManager *instance();
void setCloseable(bool b);
bool closeable();
QWidget *buttonsWidget();
......@@ -103,7 +98,7 @@ public slots:
protected:
void focusInEvent(QFocusEvent *e);
private slots:;
private slots:
void changePage();
void showPage(bool focus);
void togglePage(bool focus);
......@@ -112,17 +107,23 @@ private slots:;
void buttonTriggered();
private:
// the only class that is allowed to create and destroy
friend class MainWindow;
static void create();
static void destroy();
OutputPaneManager(QWidget *parent = 0);
~OutputPaneManager();
void showPage(int idx, bool focus);
void ensurePageVisible(int idx);
int findIndexForPage(IOutputPane *out);
const QList<int> m_context;
QComboBox *m_widgetComboBox;
QToolButton *m_clearButton;
QToolButton *m_closeButton;
QAction *m_closeAction;
ExtensionSystem::PluginManager *m_pluginManager;
QMap<int, Core::IOutputPane*> m_pageMap;
int m_lastIndex;
......@@ -132,7 +133,7 @@ private:
QMap<int, QPushButton *> m_buttons;
QMap<QAction *, int> m_actions;
static OutputPane *m_instance;
static OutputPaneManager *m_instance;
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment