Commit 222be8f2 authored by Eike Ziller's avatar Eike Ziller

Find: Fix wrong target of (replace) next/previous actions.

They were always triggered on the find support that had the find tool bar,
even if the focus moved to a different one and even if the find tool bar was
not visible.

Task-number: QTCREATORBUG-11587
Change-Id: Ica7ef6275dc8a7e0e8b974c2796651c9ca7809a6
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 515c6d3a
......@@ -421,18 +421,22 @@ bool Action::hasAttribute(Command::CommandAttribute attr) const
}
void Command::augmentActionWithShortcutToolTip(QAction *a) const
{
a->setToolTip(stringWithAppendedShortcut(a->text()));
QObject::connect(this, &Core::Command::keySequenceChanged, a, [this, a]() {
a->setToolTip(stringWithAppendedShortcut(a->text()));
});
QObject::connect(a, &QAction::changed, this, [this, a]() {
a->setToolTip(stringWithAppendedShortcut(a->text()));
});
}
QToolButton *Command::toolButtonWithAppendedShortcut(QAction *action, Command *cmd)
{
QToolButton *button = new QToolButton;
button->setDefaultAction(action);
if (cmd) {
action->setToolTip(cmd->stringWithAppendedShortcut(action->text()));
QObject::connect(cmd, &Core::Command::keySequenceChanged, action, [cmd, action]() {
action->setToolTip(cmd->stringWithAppendedShortcut(action->text()));
});
QObject::connect(action, &QAction::changed, cmd, [cmd, action]() {
action->setToolTip(cmd->stringWithAppendedShortcut(action->text()));
});
}
if (cmd)
cmd->augmentActionWithShortcutToolTip(action);
return button;
}
......@@ -88,6 +88,7 @@ public:
virtual void setKeySequence(const QKeySequence &key) = 0;
virtual QString stringWithAppendedShortcut(const QString &str) const = 0;
void augmentActionWithShortcutToolTip(QAction *action) const;
static QToolButton *toolButtonWithAppendedShortcut(QAction *action, Command *cmd);
virtual bool isScriptable() const = 0;
......
......@@ -72,9 +72,9 @@ bool CurrentDocumentFind::isEnabled() const
return m_currentFind && (!m_currentWidget || m_currentWidget->isVisible());
}
bool CurrentDocumentFind::candidateIsEnabled() const
IFindSupport *CurrentDocumentFind::candidate() const
{
return (m_candidateFind != 0);
return m_candidateFind;
}
bool CurrentDocumentFind::supportsReplace() const
......
......@@ -53,7 +53,7 @@ public:
QString completedFindString() const;
bool isEnabled() const;
bool candidateIsEnabled() const;
IFindSupport *candidate() const;
void highlightAll(const QString &txt, FindFlags findFlags);
IFindSupport::Result findIncremental(const QString &txt, FindFlags findFlags);
IFindSupport::Result findStep(const QString &txt, FindFlags findFlags);
......
......@@ -181,8 +181,7 @@ void FindPlugin::openFindFilter()
void FindPlugin::openFindDialog(IFindFilter *filter)
{
if (d->m_currentDocumentFind->candidateIsEnabled())
d->m_currentDocumentFind->acceptCandidate();
d->m_currentDocumentFind->acceptCandidate();
const QString currentFindString =
d->m_currentDocumentFind->isEnabled() ?
d->m_currentDocumentFind->currentFindString() : QString();
......
This diff is collapsed.
......@@ -99,13 +99,19 @@ public slots:
private slots:
void invokeFindNext();
void invokeGlobalFindNext();
void invokeFindPrevious();
void invokeGlobalFindPrevious();
void invokeFindStep();
void invokeReplace();
void invokeGlobalReplace();
void invokeReplaceNext();
void invokeGlobalReplaceNext();
void invokeReplacePrevious();
void invokeGlobalReplacePrevious();
void invokeReplaceStep();
void invokeReplaceAll();
void invokeGlobalReplaceAll();
void invokeResetIncrementalSearch();
void invokeFindIncremental();
......@@ -118,7 +124,7 @@ private slots:
void openFind(bool focus = true);
void findNextSelected();
void findPreviousSelected();
void updateFindAction();
void updateGlobalActions();
void updateToolBar();
void findFlagsChanged();
void findEditButtonClicked();
......@@ -145,6 +151,7 @@ private:
Core::FindToolBarPlaceHolder *findToolBarPlaceHolder() const;
bool toolBarHasFocus() const;
bool canShowAllControls(bool replaceIsVisible) const;
void acceptCandidateAndMoveToolBar();
bool eventFilter(QObject *obj, QEvent *event);
void setFindText(const QString &text);
......
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