diff --git a/src/plugins/coreplugin/rightpane.cpp b/src/plugins/coreplugin/rightpane.cpp index d51882c6adf62d429af58e69033446c0ea321d3b..e321d0787febbcc378aa79dbbbfbf02a0083d322 100644 --- a/src/plugins/coreplugin/rightpane.cpp +++ b/src/plugins/coreplugin/rightpane.cpp @@ -34,7 +34,6 @@ #include "rightpane.h" #include <coreplugin/modemanager.h> -#include <extensionsystem/pluginmanager.h> #include <QtCore/QSettings> @@ -129,53 +128,38 @@ void RightPanePlaceHolder::currentModeChanged(Core::IMode *mode) RightPaneWidget *RightPaneWidget::m_instance = 0; RightPaneWidget::RightPaneWidget() - : m_shown(true), m_width(0) + : m_shown(true), m_width(0), m_widget(0) { m_instance = this; QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); setLayout(layout); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - - BaseRightPaneWidget *rpw = pm->getObject<BaseRightPaneWidget>(); - if (rpw) { - layout->addWidget(rpw->widget()); - } - connect(pm, SIGNAL(objectAdded(QObject *)), - this, SLOT(objectAdded(QObject *))); - connect(pm, SIGNAL(aboutToRemoveObject(QObject *)), - this, SLOT(aboutToRemoveObject(QObject *))); } RightPaneWidget::~RightPaneWidget() { + clearWidget(); m_instance = 0; } -void RightPaneWidget::objectAdded(QObject *obj) +RightPaneWidget *RightPaneWidget::instance() { - BaseRightPaneWidget *rpw = qobject_cast<BaseRightPaneWidget *>(obj); - if (rpw) { - layout()->addWidget(rpw->widget()); - setFocusProxy(rpw->widget()); - } + return m_instance; } -void RightPaneWidget::aboutToRemoveObject(QObject *obj) +void RightPaneWidget::setWidget(QWidget *widget) { - BaseRightPaneWidget *rpw = qobject_cast<BaseRightPaneWidget *>(obj); - if (rpw) { - delete rpw->widget(); + clearWidget(); + m_widget = widget; + if (m_widget) { + m_widget->setParent(this); + layout()->addWidget(m_widget); + setFocusProxy(m_widget); + m_widget->show(); } } -RightPaneWidget *RightPaneWidget::instance() -{ - return m_instance; -} - int RightPaneWidget::storedWidth() { return m_width; @@ -227,21 +211,11 @@ bool RightPaneWidget::isShown() return m_shown; } -///// -// BaseRightPaneWidget -///// - -BaseRightPaneWidget::BaseRightPaneWidget(QWidget *widget) -{ - m_widget = widget; -} - -BaseRightPaneWidget::~BaseRightPaneWidget() -{ - -} - -QWidget *BaseRightPaneWidget::widget() const +void RightPaneWidget::clearWidget() { - return m_widget; + if (m_widget) { + m_widget->hide(); + m_widget->setParent(0); + m_widget = 0; + } } diff --git a/src/plugins/coreplugin/rightpane.h b/src/plugins/coreplugin/rightpane.h index edd535a95df07846336509fdbd8f63298258c9fa..edececd3e71f5767ff909783d7590c7e4396dc38 100644 --- a/src/plugins/coreplugin/rightpane.h +++ b/src/plugins/coreplugin/rightpane.h @@ -47,13 +47,6 @@ namespace Core { class IMode; class RightPaneWidget; -// TODO: The right pane works only for the help plugin atm. It can't cope -// with more than one plugin publishing objects they want in the right pane -// For that the API would need to be different. (Might be that instead of -// adding objects to the pool, there should be a method -// RightPaneWidget::setWidget(QWidget *w) Anyway if a second plugin wants to -// show something there, redesign this API - class CORE_EXPORT RightPanePlaceHolder : public QWidget { friend class Core::RightPaneWidget; @@ -73,21 +66,6 @@ private: static RightPanePlaceHolder* m_current; }; - -class CORE_EXPORT BaseRightPaneWidget : public QObject -{ - Q_OBJECT - -public: - BaseRightPaneWidget(QWidget *widget); - ~BaseRightPaneWidget(); - QWidget *widget() const; - -private: - QWidget *m_widget; -}; - - class CORE_EXPORT RightPaneWidget : public QWidget { Q_OBJECT @@ -104,18 +82,18 @@ public: static RightPaneWidget *instance(); + void setWidget(QWidget *widget); + int storedWidth(); protected: void resizeEvent(QResizeEvent *); -private slots: - void objectAdded(QObject *obj); - void aboutToRemoveObject(QObject *obj); - private: + void clearWidget(); bool m_shown; int m_width; + QWidget *m_widget; static RightPaneWidget *m_instance; }; diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index af520f1403333ff03502ebf1d61a75cb346a13e0..a2bcbb90b97d21b37d0e26a82b6619aedfaa66c6 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -554,8 +554,6 @@ void HelpPlugin::createRightPaneContextViewer() layout->addWidget(toolButton(close)); QWidget *rightPaneSideBar = new QWidget; - addAutoReleasedObject(new Core::BaseRightPaneWidget(rightPaneSideBar)); - m_helpViewerForSideBar = new HelpViewer(qreal(0.0), rightPaneSideBar); connect(m_helpViewerForSideBar, SIGNAL(openFindToolBar()), this, SLOT(openFindToolBar())); @@ -834,6 +832,7 @@ HelpViewer* HelpPlugin::viewerForContextMode() } if (placeHolder && showSideBySide) { + RightPaneWidget::instance()->setWidget(m_helpViewerForSideBar->parentWidget()); RightPaneWidget::instance()->setShown(true); createRightPaneContextViewer(); return m_helpViewerForSideBar;