forked from qt-creator/qt-creator
Making the find tool bar be more connected to the searched text.
This commit is contained in:
@@ -56,7 +56,6 @@ EditMode::EditMode(EditorManager *editorManager) :
|
||||
QWidget *rightSplitWidget = new QWidget;
|
||||
rightSplitWidget->setLayout(m_rightSplitWidgetLayout);
|
||||
m_rightSplitWidgetLayout->insertWidget(0, new Core::EditorManagerPlaceHolder(this));
|
||||
m_rightSplitWidgetLayout->addWidget(new Core::FindToolBarPlaceHolder(this));
|
||||
|
||||
MiniSplitter *rightPaneSplitter = new MiniSplitter;
|
||||
rightPaneSplitter->insertWidget(0, rightSplitWidget);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
@@ -144,6 +145,9 @@ EditorView::EditorView(OpenEditorsModel *model, QWidget *parent) :
|
||||
connect(m_lockButton, SIGNAL(clicked()), this, SLOT(makeEditorWritable()));
|
||||
connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeView()), Qt::QueuedConnection);
|
||||
}
|
||||
{
|
||||
tl->addWidget(new FindToolBarPlaceHolder(this));
|
||||
}
|
||||
{
|
||||
m_infoWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
|
||||
m_infoWidget->setLineWidth(1);
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include "findplaceholder.h"
|
||||
#include "modemanager.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtGui/QVBoxLayout>
|
||||
|
||||
|
||||
@@ -37,29 +39,31 @@ using namespace Core;
|
||||
|
||||
FindToolBarPlaceHolder *FindToolBarPlaceHolder::m_current = 0;
|
||||
|
||||
FindToolBarPlaceHolder::FindToolBarPlaceHolder(Core::IMode *mode, QWidget *parent)
|
||||
: QWidget(parent), m_mode(mode)
|
||||
FindToolBarPlaceHolder::FindToolBarPlaceHolder(QWidget *owner, QWidget *parent)
|
||||
: QWidget(parent), m_widget(owner)
|
||||
{
|
||||
setLayout(new QVBoxLayout);
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
||||
layout()->setMargin(0);
|
||||
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode *)),
|
||||
this, SLOT(currentModeChanged(Core::IMode *)));
|
||||
ExtensionSystem::PluginManager::instance()->addObject(this);
|
||||
}
|
||||
|
||||
FindToolBarPlaceHolder::~FindToolBarPlaceHolder()
|
||||
{
|
||||
ExtensionSystem::PluginManager::instance()->removeObject(this);
|
||||
}
|
||||
|
||||
void FindToolBarPlaceHolder::currentModeChanged(Core::IMode *mode)
|
||||
QWidget *FindToolBarPlaceHolder::widget() const
|
||||
{
|
||||
if (m_current == this)
|
||||
m_current = 0;
|
||||
if (m_mode == mode)
|
||||
m_current = this;
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
FindToolBarPlaceHolder *FindToolBarPlaceHolder::getCurrent()
|
||||
{
|
||||
return m_current;
|
||||
}
|
||||
|
||||
void FindToolBarPlaceHolder::setCurrent(FindToolBarPlaceHolder *placeHolder)
|
||||
{
|
||||
m_current = placeHolder;
|
||||
}
|
||||
|
||||
@@ -41,14 +41,15 @@ class CORE_EXPORT FindToolBarPlaceHolder : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FindToolBarPlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
||||
FindToolBarPlaceHolder(QWidget *owner, QWidget *parent = 0);
|
||||
~FindToolBarPlaceHolder();
|
||||
QWidget *widget() const;
|
||||
|
||||
static FindToolBarPlaceHolder *getCurrent();
|
||||
private slots:
|
||||
void currentModeChanged(Core::IMode *);
|
||||
static void setCurrent(FindToolBarPlaceHolder *placeHolder);
|
||||
|
||||
private:
|
||||
Core::IMode *m_mode;
|
||||
QWidget *m_widget;
|
||||
static FindToolBarPlaceHolder *m_current;
|
||||
};
|
||||
|
||||
|
||||
@@ -303,7 +303,7 @@ bool MainWindow::init(QString *errorMessage)
|
||||
oph->setCloseable(false);
|
||||
outputModeWidget->layout()->addWidget(oph);
|
||||
oph->setVisible(true); // since the output pane placeholder is invisible at startup by default (which makes sense in most cases)
|
||||
outputModeWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_outputMode));
|
||||
outputModeWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(outputModeWidget));
|
||||
outputModeWidget->setFocusProxy(oph);
|
||||
|
||||
connect(m_modeManager, SIGNAL(currentModeChanged(Core::IMode*)),
|
||||
|
||||
@@ -798,11 +798,11 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
|
||||
QBoxLayout *editorHolderLayout = new QVBoxLayout;
|
||||
editorHolderLayout->setMargin(0);
|
||||
editorHolderLayout->setSpacing(0);
|
||||
editorHolderLayout->addWidget(new EditorManagerPlaceHolder(m_debugMode));
|
||||
editorHolderLayout->addWidget(new FindToolBarPlaceHolder(m_debugMode));
|
||||
|
||||
QWidget *editorAndFindWidget = new QWidget;
|
||||
editorAndFindWidget->setLayout(editorHolderLayout);
|
||||
editorHolderLayout->addWidget(new EditorManagerPlaceHolder(m_debugMode));
|
||||
editorHolderLayout->addWidget(new FindToolBarPlaceHolder(editorAndFindWidget));
|
||||
|
||||
MiniSplitter *rightPaneSplitter = new MiniSplitter;
|
||||
rightPaneSplitter->addWidget(editorAndFindWidget);
|
||||
|
||||
@@ -45,7 +45,7 @@ CurrentDocumentFind::CurrentDocumentFind()
|
||||
: m_currentFind(0)
|
||||
{
|
||||
connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)),
|
||||
this, SLOT(updateCurrentFindFilter(QWidget*,QWidget*)));
|
||||
this, SLOT(updateCandidateFindFilter(QWidget*,QWidget*)));
|
||||
}
|
||||
|
||||
void CurrentDocumentFind::removeConnections()
|
||||
@@ -71,6 +71,11 @@ bool CurrentDocumentFind::isEnabled() const
|
||||
return m_currentFind && (!m_currentWidget || m_currentWidget->isVisible());
|
||||
}
|
||||
|
||||
bool CurrentDocumentFind::candidateIsEnabled() const
|
||||
{
|
||||
return (m_candidateFind != 0);
|
||||
}
|
||||
|
||||
bool CurrentDocumentFind::supportsReplace() const
|
||||
{
|
||||
QTC_ASSERT(m_currentFind, return false);
|
||||
@@ -139,7 +144,7 @@ void CurrentDocumentFind::clearFindScope()
|
||||
m_currentFind->clearFindScope();
|
||||
}
|
||||
|
||||
void CurrentDocumentFind::updateCurrentFindFilter(QWidget *old, QWidget *now)
|
||||
void CurrentDocumentFind::updateCandidateFindFilter(QWidget *old, QWidget *now)
|
||||
{
|
||||
Q_UNUSED(old)
|
||||
QWidget *candidate = now;
|
||||
@@ -149,13 +154,20 @@ void CurrentDocumentFind::updateCurrentFindFilter(QWidget *old, QWidget *now)
|
||||
if (!impl)
|
||||
candidate = candidate->parentWidget();
|
||||
}
|
||||
if (!impl || impl == m_currentFind)
|
||||
m_candidateWidget = candidate;
|
||||
m_candidateFind = impl;
|
||||
emit candidateChanged();
|
||||
}
|
||||
|
||||
void CurrentDocumentFind::acceptCandidate()
|
||||
{
|
||||
if (!m_candidateFind || m_candidateFind == m_currentFind)
|
||||
return;
|
||||
removeFindSupportConnections();
|
||||
if (m_currentFind)
|
||||
m_currentFind->highlightAll(QString(), 0);
|
||||
m_currentWidget = candidate;
|
||||
m_currentFind = impl;
|
||||
m_currentWidget = m_candidateWidget;
|
||||
m_currentFind = m_candidateFind;
|
||||
if (m_currentFind) {
|
||||
connect(m_currentFind, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
connect(m_currentFind, SIGNAL(destroyed(QObject*)), SLOT(findSupportDestroyed()));
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
QString completedFindString() const;
|
||||
|
||||
bool isEnabled() const;
|
||||
bool candidateIsEnabled() const;
|
||||
void highlightAll(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||
bool findIncremental(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||
bool findStep(const QString &txt, IFindSupport::FindFlags findFlags);
|
||||
@@ -62,6 +63,7 @@ public:
|
||||
IFindSupport::FindFlags findFlags);
|
||||
void defineFindScope();
|
||||
void clearFindScope();
|
||||
void acceptCandidate();
|
||||
|
||||
void removeConnections();
|
||||
bool setFocusToCurrentFindSupport();
|
||||
@@ -70,9 +72,10 @@ public:
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
void candidateChanged();
|
||||
|
||||
private slots:
|
||||
void updateCurrentFindFilter(QWidget *old, QWidget *now);
|
||||
void updateCandidateFindFilter(QWidget *old, QWidget *now);
|
||||
void findSupportDestroyed();
|
||||
|
||||
private:
|
||||
@@ -80,6 +83,8 @@ private:
|
||||
|
||||
QPointer<IFindSupport> m_currentFind;
|
||||
QPointer<QWidget> m_currentWidget;
|
||||
QPointer<IFindSupport> m_candidateFind;
|
||||
QPointer<QWidget> m_candidateWidget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "textfindconstants.h"
|
||||
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
@@ -75,7 +74,7 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
|
||||
//setup ui
|
||||
m_ui.setupUi(this);
|
||||
setFocusProxy(m_ui.findEdit);
|
||||
setProperty("topBorder", true);
|
||||
// setProperty("topBorder", true);
|
||||
setSingleRow(false);
|
||||
m_ui.findEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
m_ui.replaceEdit->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
@@ -213,8 +212,9 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen
|
||||
connect(m_regularExpressionAction, SIGNAL(triggered(bool)), this, SLOT(setRegularExpressions(bool)));
|
||||
lineEditMenu->addAction(m_regularExpressionAction);
|
||||
|
||||
connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateActions()));
|
||||
updateActions();
|
||||
connect(m_currentDocumentFind, SIGNAL(candidateChanged()), this, SLOT(adaptToCandidate()));
|
||||
connect(m_currentDocumentFind, SIGNAL(changed()), this, SLOT(updateToolBar()));
|
||||
updateToolBar();
|
||||
}
|
||||
|
||||
FindToolBar::~FindToolBar()
|
||||
@@ -264,11 +264,31 @@ bool FindToolBar::eventFilter(QObject *obj, QEvent *event)
|
||||
return Core::Utils::StyledBar::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
void FindToolBar::updateActions()
|
||||
|
||||
void FindToolBar::removeFromParent()
|
||||
{
|
||||
setVisible(false);
|
||||
setParent(0);
|
||||
Core::FindToolBarPlaceHolder::setCurrent(0);
|
||||
}
|
||||
|
||||
void FindToolBar::adaptToCandidate()
|
||||
{
|
||||
updateFindAction();
|
||||
if (findToolBarPlaceHolder() == Core::FindToolBarPlaceHolder::getCurrent()) {
|
||||
m_currentDocumentFind->acceptCandidate();
|
||||
}
|
||||
}
|
||||
|
||||
void FindToolBar::updateFindAction()
|
||||
{
|
||||
m_findInDocumentAction->setEnabled(m_currentDocumentFind->candidateIsEnabled());
|
||||
}
|
||||
|
||||
void FindToolBar::updateToolBar()
|
||||
{
|
||||
bool enabled = m_currentDocumentFind->isEnabled();
|
||||
bool replaceEnabled = enabled && m_currentDocumentFind->supportsReplace();
|
||||
m_findInDocumentAction->setEnabled(enabled);
|
||||
m_findNextAction->setEnabled(enabled);
|
||||
m_findPreviousAction->setEnabled(enabled);
|
||||
|
||||
@@ -507,19 +527,38 @@ void FindToolBar::hideAndResetFocus()
|
||||
hide();
|
||||
}
|
||||
|
||||
Core::FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const
|
||||
{
|
||||
QList<Core::FindToolBarPlaceHolder*> placeholders = ExtensionSystem::PluginManager::instance()
|
||||
->getObjects<Core::FindToolBarPlaceHolder>();
|
||||
QWidget *candidate = QApplication::focusWidget();
|
||||
while (candidate) {
|
||||
foreach (Core::FindToolBarPlaceHolder *ph, placeholders) {
|
||||
if (ph->widget() == candidate)
|
||||
return ph;
|
||||
}
|
||||
candidate = candidate->parentWidget();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FindToolBar::openFind()
|
||||
{
|
||||
if (!m_currentDocumentFind->isEnabled())
|
||||
if (!m_currentDocumentFind->candidateIsEnabled())
|
||||
return;
|
||||
Core::FindToolBarPlaceHolder *holder = Core::FindToolBarPlaceHolder::getCurrent();
|
||||
QLayout *findContainerLayout = holder ? holder->layout() : 0;
|
||||
|
||||
if (findContainerLayout) {
|
||||
findContainerLayout->addWidget(this);
|
||||
holder->setVisible(true);
|
||||
setVisible(true);
|
||||
setFocus();
|
||||
}
|
||||
Core::FindToolBarPlaceHolder *holder = findToolBarPlaceHolder();
|
||||
if (!holder)
|
||||
return;
|
||||
Core::FindToolBarPlaceHolder *previousHolder = Core::FindToolBarPlaceHolder::getCurrent();
|
||||
if (previousHolder)
|
||||
disconnect(previousHolder, SIGNAL(destroyed(QObject*)), this, SLOT(removeFromParent()));
|
||||
Core::FindToolBarPlaceHolder::setCurrent(holder);
|
||||
connect(holder, SIGNAL(destroyed(QObject*)), this, SLOT(removeFromParent()));
|
||||
m_currentDocumentFind->acceptCandidate();
|
||||
holder->layout()->addWidget(this);
|
||||
holder->setVisible(true);
|
||||
setVisible(true);
|
||||
setFocus();
|
||||
QString text = m_currentDocumentFind->currentFindString();
|
||||
if (!text.isEmpty())
|
||||
setFindText(text);
|
||||
@@ -528,7 +567,6 @@ void FindToolBar::openFind()
|
||||
selectFindText();
|
||||
}
|
||||
|
||||
|
||||
bool FindToolBar::focusNextPrevChild(bool next)
|
||||
{
|
||||
// close tab order change
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "ifindfilter.h"
|
||||
#include "currentdocumentfind.h"
|
||||
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QtGui/QStringListModel>
|
||||
@@ -74,13 +75,16 @@ private slots:
|
||||
|
||||
void hideAndResetFocus();
|
||||
void openFind();
|
||||
void updateActions();
|
||||
void updateFindAction();
|
||||
void updateToolBar();
|
||||
void findFlagsChanged();
|
||||
|
||||
void setCaseSensitive(bool sensitive);
|
||||
void setWholeWord(bool wholeOnly);
|
||||
void setRegularExpressions(bool regexp);
|
||||
|
||||
void adaptToCandidate();
|
||||
void removeFromParent();
|
||||
protected:
|
||||
bool focusNextPrevChild(bool next);
|
||||
|
||||
@@ -90,6 +94,7 @@ private:
|
||||
void setFindFlag(IFindSupport::FindFlag flag, bool enabled);
|
||||
bool hasFindFlag(IFindSupport::FindFlag flag);
|
||||
IFindSupport::FindFlags effectiveFindFlags();
|
||||
Core::FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const;
|
||||
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
void setFindText(const QString &text);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>5</number>
|
||||
|
||||
@@ -46,7 +46,7 @@ HelpMode::HelpMode(QWidget *widget, QWidget *centralWidget, QObject *parent)
|
||||
setPriority(Constants::P_MODE_HELP);
|
||||
setWidget(widget);
|
||||
m_centralWidget->layout()->setSpacing(0);
|
||||
m_centralWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(this));
|
||||
m_centralWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_centralWidget));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,17 +43,18 @@
|
||||
#include "searchwidget.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/findplaceholder.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/minisplitter.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
#include <coreplugin/rightpane.h>
|
||||
#include <coreplugin/sidebar.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <coreplugin/welcomemode.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
@@ -463,11 +464,16 @@ void HelpPlugin::createRightPaneSideBar()
|
||||
w->setLayout(hboxLayout);
|
||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(slotHideRightPane()));
|
||||
|
||||
m_rightPaneSideBar = new QWidget;
|
||||
QVBoxLayout *rightPaneLayout = new QVBoxLayout;
|
||||
rightPaneLayout->setMargin(0);
|
||||
rightPaneLayout->setSpacing(0);
|
||||
rightPaneLayout->addWidget(w);
|
||||
m_rightPaneSideBar->setLayout(rightPaneLayout);
|
||||
m_rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar);
|
||||
addAutoReleasedObject(new Core::BaseRightPaneWidget(m_rightPaneSideBar));
|
||||
|
||||
rightPaneLayout->addWidget(w);
|
||||
rightPaneLayout->addWidget(new Core::FindToolBarPlaceHolder(m_rightPaneSideBar));
|
||||
m_helpViewerForSideBar = new HelpViewer(m_helpEngine, 0);
|
||||
Aggregation::Aggregate *agg = new Aggregation::Aggregate();
|
||||
agg->add(m_helpViewerForSideBar);
|
||||
@@ -494,11 +500,6 @@ void HelpPlugin::createRightPaneSideBar()
|
||||
connect(copyActionSideBar, SIGNAL(triggered()), this, SLOT(copyFromSideBar()));
|
||||
copyActionSideBar->setText(cmd->action()->text());
|
||||
copyActionSideBar->setIcon(cmd->action()->icon());
|
||||
|
||||
m_rightPaneSideBar = new QWidget;
|
||||
m_rightPaneSideBar->setLayout(rightPaneLayout);
|
||||
m_rightPaneSideBar->setFocusProxy(m_helpViewerForSideBar);
|
||||
addAutoReleasedObject(new Core::BaseRightPaneWidget(m_rightPaneSideBar));
|
||||
}
|
||||
|
||||
void HelpPlugin::copyFromSideBar()
|
||||
|
||||
@@ -189,7 +189,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
|
||||
mode->setWidget(m_proWindow);
|
||||
mode->setContext(QList<int>() << pecontext);
|
||||
addAutoReleasedObject(mode);
|
||||
m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(mode));
|
||||
m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_proWindow));
|
||||
|
||||
m_buildManager = new BuildManager(this);
|
||||
connect(m_buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project *)),
|
||||
|
||||
Reference in New Issue
Block a user