diff --git a/src/plugins/coreplugin/findplaceholder.cpp b/src/plugins/coreplugin/findplaceholder.cpp index 001b882bfe565e1f199bbd837c8db10ef922a454..0bd5895baa62daf39ffd59a7ce6d8619b7b2606a 100644 --- a/src/plugins/coreplugin/findplaceholder.cpp +++ b/src/plugins/coreplugin/findplaceholder.cpp @@ -40,7 +40,7 @@ using namespace Core; FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0; FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent) - : QWidget(parent), m_widget(owner) + : QWidget(parent), m_owner(owner), m_subWidget(0) { setLayout(new QVBoxLayout); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); @@ -51,11 +51,28 @@ FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent) FindToolBarPlaceHolder::~FindToolBarPlaceHolder() { ExtensionSystem::PluginManager::instance()->removeObject(this); + if (m_subWidget) { + m_subWidget->setVisible(false); + m_subWidget->setParent(0); + } + if (m_current == this) + m_current = 0; } -QWidget *FindToolBarPlaceHolder::widget() const +QWidget *FindToolBarPlaceHolder::owner() const { - return m_widget; + return m_owner; +} + +void FindToolBarPlaceHolder::setWidget(QWidget *widget) +{ + if (m_subWidget) { + m_subWidget->setVisible(false); + m_subWidget->setParent(0); + } + m_subWidget = widget; + if (m_subWidget) + layout()->addWidget(m_subWidget); } FindToolBarPlaceHolder *FindToolBarPlaceHolder::getCurrent() diff --git a/src/plugins/coreplugin/findplaceholder.h b/src/plugins/coreplugin/findplaceholder.h index 59cf42d131b47f8301bdda37efef0ad0a160963b..c6f815476d747a9d1d62cd497ffb81afc1cbaf82 100644 --- a/src/plugins/coreplugin/findplaceholder.h +++ b/src/plugins/coreplugin/findplaceholder.h @@ -31,6 +31,8 @@ #define FINDPLACEHOLDER_H #include "core_global.h" + +#include <QtCore/QPointer> #include <QtGui/QWidget> namespace Core { @@ -43,13 +45,15 @@ class CORE_EXPORT FindToolBarPlaceHolder : public QWidget public: FindToolBarPlaceHolder(QWidget *owner, QWidget *parent = 0); ~FindToolBarPlaceHolder(); - QWidget *widget() const; + QWidget *owner() const; + void setWidget(QWidget *widget); static FindToolBarPlaceHolder *getCurrent(); static void setCurrent(FindToolBarPlaceHolder *placeHolder); private: - QWidget *m_widget; + QWidget *m_owner; + QPointer<QWidget> m_subWidget; static FindToolBarPlaceHolder *m_current; }; diff --git a/src/plugins/find/findplugin.cpp b/src/plugins/find/findplugin.cpp index 72bd60e0f3510e8be9b5b5e1c3a4dcbbc3eead58..d3574569d730b6337a0b6ccf67dcf79fea4f187c 100644 --- a/src/plugins/find/findplugin.cpp +++ b/src/plugins/find/findplugin.cpp @@ -107,6 +107,7 @@ void FindPlugin::extensionsInitialized() void FindPlugin::shutdown() { + m_findToolBar->setVisible(false); m_findToolBar->setParent(0); m_currentDocumentFind->removeConnections(); writeSettings(); diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp index 0ad3ecc44b949f53bd643dfae6ec4c2916ebe9b7..4c855ae2a76c23a180ac8fbfd271331ebeb012c2 100644 --- a/src/plugins/find/findtoolbar.cpp +++ b/src/plugins/find/findtoolbar.cpp @@ -264,14 +264,6 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event) return Core::Utils::StyledBar::eventFilter(obj, event); } - -void FindToolBar::removeFromParent() -{ - setVisible(false); - setParent(0); - Core::FindToolBarPlaceHolder::setCurrent(0); -} - void FindToolBar::adaptToCandidate() { updateFindAction(); @@ -534,7 +526,7 @@ Core::FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const QWidget *candidate = QApplication::focusWidget(); while (candidate) { foreach (Core::FindToolBarPlaceHolder *ph, placeholders) { - if (ph->widget() == candidate) + if (ph->owner() == candidate) return ph; } candidate = candidate->parentWidget(); @@ -551,11 +543,10 @@ void FindToolBar::openFind() return; Core::FindToolBarPlaceHolder *previousHolder = Core::FindToolBarPlaceHolder::getCurrent(); if (previousHolder) - disconnect(previousHolder, SIGNAL(destroyed(QObject*)), this, SLOT(removeFromParent())); + previousHolder->setWidget(0); Core::FindToolBarPlaceHolder::setCurrent(holder); - connect(holder, SIGNAL(destroyed(QObject*)), this, SLOT(removeFromParent())); m_currentDocumentFind->acceptCandidate(); - holder->layout()->addWidget(this); + holder->setWidget(this); holder->setVisible(true); setVisible(true); setFocus(); diff --git a/src/plugins/find/findtoolbar.h b/src/plugins/find/findtoolbar.h index b245f2b1b361ad694d2c17079ff6e0dca45e9e39..8922cc49250da346b4e0c87baf7dc888e8503421 100644 --- a/src/plugins/find/findtoolbar.h +++ b/src/plugins/find/findtoolbar.h @@ -84,7 +84,7 @@ private slots: void setRegularExpressions(bool regexp); void adaptToCandidate(); - void removeFromParent(); + protected: bool focusNextPrevChild(bool next);