forked from qt-creator/qt-creator
Core: Use ActionBuilder to set up find menu entries
Change-Id: I93784d6c571988be5476f0f8e9cce7411ae392be Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -110,6 +110,11 @@ void ActionBuilder::setText(const QString &text)
|
|||||||
d->action->setText(text);
|
d->action->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActionBuilder::setIconText(const QString &text)
|
||||||
|
{
|
||||||
|
d->action->setIconText(text);
|
||||||
|
}
|
||||||
|
|
||||||
void ActionBuilder::setToolTip(const QString &toolTip)
|
void ActionBuilder::setToolTip(const QString &toolTip)
|
||||||
{
|
{
|
||||||
d->action->setToolTip(toolTip);
|
d->action->setToolTip(toolTip);
|
||||||
@@ -148,6 +153,11 @@ void ActionBuilder::setOnTriggered(QObject *guard, const std::function<void(bool
|
|||||||
QObject::connect(d->action, &QAction::triggered, guard, func);
|
QObject::connect(d->action, &QAction::triggered, guard, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActionBuilder::setOnToggled(QObject *guard, const std::function<void (bool)> &func)
|
||||||
|
{
|
||||||
|
QObject::connect(d->action, &QAction::toggled, guard, func);
|
||||||
|
}
|
||||||
|
|
||||||
void ActionBuilder::setDefaultKeySequence(const QKeySequence &seq)
|
void ActionBuilder::setDefaultKeySequence(const QKeySequence &seq)
|
||||||
{
|
{
|
||||||
d->command->setDefaultKeySequence(seq);
|
d->command->setDefaultKeySequence(seq);
|
||||||
@@ -224,6 +234,11 @@ void ActionBuilder::bindContextAction(QAction **dest)
|
|||||||
*dest = d->action;
|
*dest = d->action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ActionBuilder::augmentActionWithShortcutToolTip()
|
||||||
|
{
|
||||||
|
d->command->augmentActionWithShortcutToolTip(d->action);
|
||||||
|
}
|
||||||
|
|
||||||
void ActionBuilder::setId(Id id)
|
void ActionBuilder::setId(Id id)
|
||||||
{
|
{
|
||||||
d->actionId = id;
|
d->actionId = id;
|
||||||
|
@@ -36,6 +36,7 @@ public:
|
|||||||
void setContext(const Utils::Id id);
|
void setContext(const Utils::Id id);
|
||||||
void setContext(const Core::Context &context);
|
void setContext(const Core::Context &context);
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
void setIconText(const QString &text);
|
||||||
void setToolTip(const QString &toolTip);
|
void setToolTip(const QString &toolTip);
|
||||||
void setCommandAttribute(Core::Command::CommandAttribute attr);
|
void setCommandAttribute(Core::Command::CommandAttribute attr);
|
||||||
void setCommandDescription(const QString &desc);
|
void setCommandDescription(const QString &desc);
|
||||||
@@ -43,6 +44,7 @@ public:
|
|||||||
void setOnTriggered(const std::function<void()> &func);
|
void setOnTriggered(const std::function<void()> &func);
|
||||||
void setOnTriggered(QObject *guard, const std::function<void()> &func);
|
void setOnTriggered(QObject *guard, const std::function<void()> &func);
|
||||||
void setOnTriggered(QObject *guard, const std::function<void(bool)> &func);
|
void setOnTriggered(QObject *guard, const std::function<void(bool)> &func);
|
||||||
|
void setOnToggled(QObject *guard, const std::function<void(bool)> &func);
|
||||||
void setDefaultKeySequence(const QKeySequence &seq);
|
void setDefaultKeySequence(const QKeySequence &seq);
|
||||||
void setDefaultKeySequences(const QList<QKeySequence> &seqs);
|
void setDefaultKeySequences(const QList<QKeySequence> &seqs);
|
||||||
void setDefaultKeySequence(const QString &mac, const QString &nonMac);
|
void setDefaultKeySequence(const QString &mac, const QString &nonMac);
|
||||||
@@ -59,6 +61,7 @@ public:
|
|||||||
QAction *commandAction() const;
|
QAction *commandAction() const;
|
||||||
QAction *contextAction() const;
|
QAction *contextAction() const;
|
||||||
void bindContextAction(QAction **dest);
|
void bindContextAction(QAction **dest);
|
||||||
|
void augmentActionWithShortcutToolTip();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ActionBuilderPrivate *d = nullptr;
|
class ActionBuilderPrivate *d = nullptr;
|
||||||
|
@@ -267,20 +267,20 @@ void FindPrivate::setupMenu()
|
|||||||
mfind->appendGroup(Constants::G_FIND_FILTERS);
|
mfind->appendGroup(Constants::G_FIND_FILTERS);
|
||||||
mfind->appendGroup(Constants::G_FIND_FLAGS);
|
mfind->appendGroup(Constants::G_FIND_FLAGS);
|
||||||
mfind->appendGroup(Constants::G_FIND_ACTIONS);
|
mfind->appendGroup(Constants::G_FIND_ACTIONS);
|
||||||
Command *cmd;
|
|
||||||
mfind->addSeparator(Constants::G_FIND_FLAGS);
|
mfind->addSeparator(Constants::G_FIND_FLAGS);
|
||||||
mfind->addSeparator(Constants::G_FIND_ACTIONS);
|
mfind->addSeparator(Constants::G_FIND_ACTIONS);
|
||||||
|
|
||||||
ActionContainer *mfindadvanced = ActionManager::createMenu(Constants::M_FIND_ADVANCED);
|
ActionContainer *mfindadvanced = ActionManager::createMenu(Constants::M_FIND_ADVANCED);
|
||||||
mfindadvanced->menu()->setTitle(Tr::tr("Advanced Find"));
|
mfindadvanced->menu()->setTitle(Tr::tr("Advanced Find"));
|
||||||
mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS);
|
mfind->addMenu(mfindadvanced, Constants::G_FIND_FILTERS);
|
||||||
m_openFindDialog = new QAction(Tr::tr("Open Advanced Find..."), this);
|
|
||||||
m_openFindDialog->setIconText(Tr::tr("Advanced..."));
|
ActionBuilder openFindDialog(this, Constants::ADVANCED_FIND);
|
||||||
cmd = ActionManager::registerAction(m_openFindDialog, Constants::ADVANCED_FIND);
|
openFindDialog.setText(Tr::tr("Open Advanced Find..."));
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Shift+F")));
|
openFindDialog.setIconText(Tr::tr("Advanced..."));
|
||||||
mfindadvanced->addAction(cmd);
|
openFindDialog.bindContextAction(&m_openFindDialog);
|
||||||
connect(m_openFindDialog, &QAction::triggered,
|
openFindDialog.setDefaultKeySequence(Tr::tr("Ctrl+Shift+F"));
|
||||||
this, [] { Find::openFindDialog(nullptr); });
|
openFindDialog.setContainer(Constants::M_FIND_ADVANCED);
|
||||||
|
openFindDialog.setOnTriggered(this, [] { Find::openFindDialog(nullptr); });
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString filterActionName(const IFindFilter *filter)
|
static QString filterActionName(const IFindFilter *filter)
|
||||||
@@ -290,30 +290,30 @@ static QString filterActionName(const IFindFilter *filter)
|
|||||||
|
|
||||||
void FindPrivate::setupFilterMenuItems()
|
void FindPrivate::setupFilterMenuItems()
|
||||||
{
|
{
|
||||||
Command *cmd;
|
|
||||||
|
|
||||||
ActionContainer *mfindadvanced = ActionManager::actionContainer(Constants::M_FIND_ADVANCED);
|
|
||||||
bool haveEnabledFilters = false;
|
bool haveEnabledFilters = false;
|
||||||
const Id base("FindFilter.");
|
const Id base("FindFilter.");
|
||||||
const QList<IFindFilter *> sortedFilters = Utils::sorted(IFindFilter::allFindFilters(),
|
const QList<IFindFilter *> sortedFilters = Utils::sorted(IFindFilter::allFindFilters(),
|
||||||
&IFindFilter::displayName);
|
&IFindFilter::displayName);
|
||||||
for (IFindFilter *filter : sortedFilters) {
|
for (IFindFilter *filter : sortedFilters) {
|
||||||
QAction *action = new QAction(filterActionName(filter), this);
|
ActionBuilder findScope(this, base.withSuffix(filter->id()));
|
||||||
|
findScope.setText(filterActionName(filter));
|
||||||
bool isEnabled = filter->isEnabled();
|
bool isEnabled = filter->isEnabled();
|
||||||
if (isEnabled)
|
if (isEnabled)
|
||||||
haveEnabledFilters = true;
|
haveEnabledFilters = true;
|
||||||
action->setEnabled(isEnabled);
|
findScope.setEnabled(isEnabled);
|
||||||
cmd = ActionManager::registerAction(action, base.withSuffix(filter->id()));
|
findScope.setDefaultKeySequence(filter->defaultShortcut());
|
||||||
cmd->setDefaultKeySequence(filter->defaultShortcut());
|
findScope.setCommandAttribute(Command::CA_UpdateText);
|
||||||
cmd->setAttribute(Command::CA_UpdateText);
|
findScope.setContainer(Constants::M_FIND_ADVANCED);
|
||||||
mfindadvanced->addAction(cmd);
|
findScope.setOnTriggered(this, [filter] { Find::openFindDialog(filter); });
|
||||||
connect(action, &QAction::triggered, this, [filter] { Find::openFindDialog(filter); });
|
|
||||||
connect(filter, &IFindFilter::enabledChanged, this, [filter, action] {
|
QAction *findScopeAction = findScope.contextAction();
|
||||||
action->setEnabled(filter->isEnabled());
|
connect(filter, &IFindFilter::enabledChanged, this, [filter, findScopeAction] {
|
||||||
|
findScopeAction->setEnabled(filter->isEnabled());
|
||||||
d->m_openFindDialog->setEnabled(d->isAnyFilterEnabled());
|
d->m_openFindDialog->setEnabled(d->isAnyFilterEnabled());
|
||||||
});
|
});
|
||||||
connect(filter, &IFindFilter::displayNameChanged,
|
connect(filter, &IFindFilter::displayNameChanged, this, [filter, findScopeAction] {
|
||||||
this, [filter, action] { action->setText(filterActionName(filter)); });
|
findScopeAction->setText(filterActionName(filter));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
d->m_findDialog->setFindFilters(sortedFilters);
|
d->m_findDialog->setFindFilters(sortedFilters);
|
||||||
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
d->m_openFindDialog->setEnabled(haveEnabledFilters);
|
||||||
|
@@ -236,8 +236,6 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|||||||
|
|
||||||
// register actions
|
// register actions
|
||||||
Context findcontext(Constants::C_FINDTOOLBAR);
|
Context findcontext(Constants::C_FINDTOOLBAR);
|
||||||
ActionContainer *mfind = ActionManager::actionContainer(Constants::M_FIND);
|
|
||||||
Command *cmd;
|
|
||||||
|
|
||||||
auto advancedAction = new QAction(Tr::tr("Open Advanced Find..."), this);
|
auto advancedAction = new QAction(Tr::tr("Open Advanced Find..."), this);
|
||||||
advancedAction->setIconText(Tr::tr("Advanced..."));
|
advancedAction->setIconText(Tr::tr("Advanced..."));
|
||||||
@@ -249,158 +247,191 @@ FindToolBar::FindToolBar(CurrentDocumentFind *currentDocumentFind)
|
|||||||
Find::openFindDialog(nullptr, m_findEdit->text());
|
Find::openFindDialog(nullptr, m_findEdit->text());
|
||||||
});
|
});
|
||||||
|
|
||||||
m_goToCurrentFindAction = new QAction(this);
|
ActionBuilder goToCurrentFindAction(this, Constants::S_RETURNTOEDITOR);
|
||||||
ActionManager::registerAction(m_goToCurrentFindAction, Constants::S_RETURNTOEDITOR,
|
goToCurrentFindAction.setContext(findcontext);
|
||||||
findcontext);
|
goToCurrentFindAction.bindContextAction(&m_goToCurrentFindAction);
|
||||||
connect(m_goToCurrentFindAction, &QAction::triggered,
|
goToCurrentFindAction.setOnTriggered(this, [this] { setFocusToCurrentFindSupport(); });
|
||||||
this, &FindToolBar::setFocusToCurrentFindSupport);
|
|
||||||
|
|
||||||
QIcon icon = Icon::fromTheme("edit-find-replace");
|
ActionBuilder findInDocumentAction(this, Constants::FIND_IN_DOCUMENT);
|
||||||
m_findInDocumentAction = new QAction(icon, Tr::tr("Find/Replace"), this);
|
findInDocumentAction.setText(Tr::tr("Find/Replace"));
|
||||||
cmd = ActionManager::registerAction(m_findInDocumentAction, Constants::FIND_IN_DOCUMENT);
|
findInDocumentAction.setIcon(Icon::fromTheme("edit-find-replace"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence::Find);
|
findInDocumentAction.bindContextAction(&m_findInDocumentAction);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_CURRENTDOCUMENT);
|
findInDocumentAction.setDefaultKeySequence(QKeySequence::Find);
|
||||||
connect(m_findInDocumentAction, &QAction::triggered, this, [this] { openFind(); });
|
findInDocumentAction.setContainer(Constants::M_FIND, Constants::G_FIND_CURRENTDOCUMENT);
|
||||||
|
findInDocumentAction.setOnTriggered(this, [this] { openFind(); });
|
||||||
|
|
||||||
// Pressing the find shortcut while focus is in the tool bar should not change the search text,
|
// Pressing the find shortcut while focus is in the tool bar should not change the search text,
|
||||||
// so register a different find action for the tool bar
|
// so register a different find action for the tool bar
|
||||||
auto localFindAction = new QAction(this);
|
ActionBuilder localFindAction(this, Constants::FIND_IN_DOCUMENT);
|
||||||
ActionManager::registerAction(localFindAction, Constants::FIND_IN_DOCUMENT, findcontext);
|
localFindAction.setText(m_findInDocumentAction->text());
|
||||||
connect(localFindAction, &QAction::triggered, this, [this] {
|
localFindAction.setContext(findcontext);
|
||||||
|
localFindAction.setOnTriggered(this, [this] {
|
||||||
openFindToolBar(FindToolBar::OpenFlags(UpdateAll & ~UpdateFindText));
|
openFindToolBar(FindToolBar::OpenFlags(UpdateAll & ~UpdateFindText));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (QApplication::clipboard()->supportsFindBuffer()) {
|
if (QApplication::clipboard()->supportsFindBuffer()) {
|
||||||
m_enterFindStringAction = new QAction(Tr::tr("Enter Find String"), this);
|
ActionBuilder enterFindStringAction(this, "Find.EnterFindString");
|
||||||
cmd = ActionManager::registerAction(m_enterFindStringAction, "Find.EnterFindString");
|
enterFindStringAction.setText(Tr::tr("Enter Find String"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+E")));
|
enterFindStringAction.setDefaultKeySequence(Tr::tr("Ctrl+E"));
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
enterFindStringAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
connect(m_enterFindStringAction, &QAction::triggered,
|
enterFindStringAction.bindContextAction(&m_enterFindStringAction);
|
||||||
this, &FindToolBar::putSelectionToFindClipboard);
|
enterFindStringAction.setOnTriggered(this, [this] { putSelectionToFindClipboard(); });
|
||||||
connect(QApplication::clipboard(), &QClipboard::findBufferChanged, this, &FindToolBar::updateFromFindClipboard);
|
connect(QApplication::clipboard(), &QClipboard::findBufferChanged, this, &FindToolBar::updateFromFindClipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_findNextAction = new QAction(Tr::tr("Find Next"), this);
|
ActionBuilder findNextAction(this, Constants::FIND_NEXT);
|
||||||
cmd = ActionManager::registerAction(m_findNextAction, Constants::FIND_NEXT);
|
findNextAction.setText(Tr::tr("Find Next"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence::FindNext);
|
findNextAction.bindContextAction(&m_findNextAction);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
findNextAction.setDefaultKeySequence(QKeySequence::FindNext);
|
||||||
connect(m_findNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindNext);
|
findNextAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
m_localFindNextAction = new QAction(m_findNextAction->text(), this);
|
findNextAction.setOnTriggered(this, [this] { invokeGlobalFindNext(); });
|
||||||
cmd = ActionManager::registerAction(m_localFindNextAction, Constants::FIND_NEXT, findcontext);
|
|
||||||
cmd->augmentActionWithShortcutToolTip(m_localFindNextAction);
|
ActionBuilder localFindNextAction(this, Constants::FIND_NEXT);
|
||||||
connect(m_localFindNextAction, &QAction::triggered, this, &FindToolBar::invokeFindNext);
|
localFindNextAction.setText(m_findNextAction->text());
|
||||||
|
localFindNextAction.bindContextAction(&m_localFindNextAction);
|
||||||
|
localFindNextAction.setContext(findcontext);
|
||||||
|
localFindNextAction.augmentActionWithShortcutToolTip();
|
||||||
|
localFindNextAction.setOnTriggered(this, [this] { invokeFindNext(); });
|
||||||
m_findNextButton->setDefaultAction(m_localFindNextAction);
|
m_findNextButton->setDefaultAction(m_localFindNextAction);
|
||||||
|
|
||||||
m_findPreviousAction = new QAction(Tr::tr("Find Previous"), this);
|
ActionBuilder findPreviousAction(this, Constants::FIND_PREVIOUS);
|
||||||
cmd = ActionManager::registerAction(m_findPreviousAction, Constants::FIND_PREVIOUS);
|
findPreviousAction.setText(Tr::tr("Find Previous"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence::FindPrevious);
|
findPreviousAction.bindContextAction(&m_findPreviousAction);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
findPreviousAction.setDefaultKeySequence(QKeySequence::FindPrevious);
|
||||||
connect(m_findPreviousAction, &QAction::triggered, this, &FindToolBar::invokeGlobalFindPrevious);
|
findPreviousAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
m_localFindPreviousAction = new QAction(m_findPreviousAction->text(), this);
|
findPreviousAction.setOnTriggered(this, [this] { invokeGlobalFindPrevious(); });
|
||||||
cmd = ActionManager::registerAction(m_localFindPreviousAction, Constants::FIND_PREVIOUS, findcontext);
|
|
||||||
cmd->augmentActionWithShortcutToolTip(m_localFindPreviousAction);
|
ActionBuilder localFindPreviousAction(this, Constants::FIND_PREVIOUS);
|
||||||
connect(m_localFindPreviousAction, &QAction::triggered, this, &FindToolBar::invokeFindPrevious);
|
localFindPreviousAction.setText(m_findPreviousAction->text());
|
||||||
|
localFindPreviousAction.bindContextAction(&m_localFindPreviousAction);
|
||||||
|
localFindPreviousAction.setContext(findcontext);
|
||||||
|
localFindPreviousAction.augmentActionWithShortcutToolTip();
|
||||||
|
localFindPreviousAction.setOnTriggered(this, [this] { invokeFindPrevious(); });
|
||||||
m_findPreviousButton->setDefaultAction(m_localFindPreviousAction);
|
m_findPreviousButton->setDefaultAction(m_localFindPreviousAction);
|
||||||
|
|
||||||
m_findNextSelectedAction = new QAction(Tr::tr("Find Next (Selected)"), this);
|
ActionBuilder findNextSelectedAction(this, Constants::FIND_NEXT_SELECTED);
|
||||||
cmd = ActionManager::registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED);
|
findNextSelectedAction.setText(Tr::tr("Find Next (Selected)"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+F3")));
|
findNextSelectedAction.bindContextAction(&m_findNextSelectedAction);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
findNextSelectedAction.setDefaultKeySequence(Tr::tr("Ctrl+F3"));
|
||||||
connect(m_findNextSelectedAction, &QAction::triggered, this, &FindToolBar::findNextSelected);
|
findNextSelectedAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
|
findNextSelectedAction.setOnTriggered(this, [this] { findNextSelected(); });
|
||||||
|
|
||||||
m_findPreviousSelectedAction = new QAction(Tr::tr("Find Previous (Selected)"), this);
|
ActionBuilder findPreviousSelectedAction(this, Constants::FIND_PREV_SELECTED);
|
||||||
cmd = ActionManager::registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED);
|
findPreviousSelectedAction.setText(Tr::tr("Find Previous (Selected)"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Shift+F3")));
|
findPreviousSelectedAction.bindContextAction(&m_findPreviousSelectedAction);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
findPreviousSelectedAction.setDefaultKeySequence(Tr::tr("Ctrl+Shift+F3"));
|
||||||
connect(m_findPreviousSelectedAction, &QAction::triggered,
|
findPreviousSelectedAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
this, &FindToolBar::findPreviousSelected);
|
findPreviousSelectedAction.setOnTriggered(this, [this] { findPreviousSelected(); });
|
||||||
|
|
||||||
m_selectAllAction = new QAction(Tr::tr("Select All"), this);
|
ActionBuilder selectAllAction(this, Constants::FIND_SELECT_ALL);
|
||||||
cmd = ActionManager::registerAction(m_selectAllAction, Constants::FIND_SELECT_ALL);
|
selectAllAction.setText(Tr::tr("Select All"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+Alt+Return")));
|
selectAllAction.bindContextAction(&m_selectAllAction);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
selectAllAction.setDefaultKeySequence(Tr::tr("Ctrl+Alt+Return"));
|
||||||
connect(m_selectAllAction, &QAction::triggered, this, &FindToolBar::selectAll);
|
selectAllAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
m_localSelectAllAction = new QAction(m_selectAllAction->text(), this);
|
selectAllAction.setOnTriggered(this, [this] { selectAll(); });
|
||||||
cmd = ActionManager::registerAction(m_localSelectAllAction, Constants::FIND_SELECT_ALL, findcontext);
|
|
||||||
cmd->augmentActionWithShortcutToolTip(m_localSelectAllAction);
|
ActionBuilder localSelectAllAction(this, Constants::FIND_SELECT_ALL);
|
||||||
connect(m_localSelectAllAction, &QAction::triggered, this, &FindToolBar::selectAll);
|
localSelectAllAction.setText(m_selectAllAction->text());
|
||||||
|
localSelectAllAction.setContext(findcontext);
|
||||||
|
localSelectAllAction.bindContextAction(&m_localSelectAllAction);
|
||||||
|
localSelectAllAction.augmentActionWithShortcutToolTip();
|
||||||
|
localSelectAllAction.setOnTriggered(this, [this] { selectAll(); });
|
||||||
m_selectAllButton->setDefaultAction(m_localSelectAllAction);
|
m_selectAllButton->setDefaultAction(m_localSelectAllAction);
|
||||||
|
|
||||||
m_replaceAction = new QAction(Tr::tr("Replace"), this);
|
ActionBuilder replaceAction(this, Constants::REPLACE);
|
||||||
cmd = ActionManager::registerAction(m_replaceAction, Constants::REPLACE);
|
replaceAction.setText(Tr::tr("Replace"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence());
|
replaceAction.bindContextAction(&m_replaceAction);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
replaceAction.setDefaultKeySequence({});
|
||||||
connect(m_replaceAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplace);
|
replaceAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
m_localReplaceAction = new QAction(m_replaceAction->text(), this);
|
replaceAction.setOnTriggered(this, [this] { invokeGlobalReplace(); });
|
||||||
cmd = ActionManager::registerAction(m_localReplaceAction, Constants::REPLACE, findcontext);
|
|
||||||
cmd->augmentActionWithShortcutToolTip(m_localReplaceAction);
|
ActionBuilder localReplaceAction(this, Constants::REPLACE);
|
||||||
connect(m_localReplaceAction, &QAction::triggered, this, &FindToolBar::invokeReplace);
|
localReplaceAction.setText(m_replaceAction->text());
|
||||||
|
localReplaceAction.setContext(findcontext);
|
||||||
|
localReplaceAction.bindContextAction(&m_localReplaceAction);
|
||||||
|
localReplaceAction.augmentActionWithShortcutToolTip();
|
||||||
|
localReplaceAction.setOnTriggered(this, [this] { invokeReplace(); });
|
||||||
m_replaceButton->setDefaultAction(m_localReplaceAction);
|
m_replaceButton->setDefaultAction(m_localReplaceAction);
|
||||||
|
|
||||||
m_replaceNextAction = new QAction(Tr::tr("Replace && Find"), this);
|
ActionBuilder replaceNextAction(this, Constants::REPLACE_NEXT);
|
||||||
cmd = ActionManager::registerAction(m_replaceNextAction, Constants::REPLACE_NEXT);
|
replaceNextAction.setText(Tr::tr("Replace && Find"));
|
||||||
cmd->setDefaultKeySequence(QKeySequence(Tr::tr("Ctrl+=")));
|
replaceNextAction.bindContextAction(&m_replaceNextAction);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
replaceNextAction.setDefaultKeySequence(Tr::tr("Ctrl+="));
|
||||||
connect(m_replaceNextAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceNext);
|
replaceNextAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
m_localReplaceNextAction = new QAction(m_replaceNextAction->text(), this);
|
replaceNextAction.setOnTriggered(this, [this] { invokeGlobalReplaceNext(); });
|
||||||
m_localReplaceNextAction->setIconText(m_replaceNextAction->text()); // Workaround QTBUG-23396
|
|
||||||
cmd = ActionManager::registerAction(m_localReplaceNextAction, Constants::REPLACE_NEXT, findcontext);
|
ActionBuilder localReplaceNextAction(this, Constants::REPLACE_NEXT);
|
||||||
cmd->augmentActionWithShortcutToolTip(m_localReplaceNextAction);
|
localReplaceNextAction.setText(m_replaceNextAction->text());
|
||||||
connect(m_localReplaceNextAction, &QAction::triggered, this, &FindToolBar::invokeReplaceNext);
|
localReplaceNextAction.setIconText(m_replaceNextAction->text()); // Workaround QTBUG-23396
|
||||||
|
localReplaceNextAction.setContext(findcontext);
|
||||||
|
localReplaceNextAction.bindContextAction(&m_localReplaceNextAction);
|
||||||
|
localReplaceNextAction.augmentActionWithShortcutToolTip();
|
||||||
|
localReplaceNextAction.setOnTriggered(this, [this] { invokeReplaceNext(); });
|
||||||
m_replaceNextButton->setDefaultAction(m_localReplaceNextAction);
|
m_replaceNextButton->setDefaultAction(m_localReplaceNextAction);
|
||||||
|
|
||||||
m_replacePreviousAction = new QAction(Tr::tr("Replace && Find Previous"), this);
|
ActionBuilder replacePreviousAction(this, Constants::REPLACE_PREVIOUS);
|
||||||
cmd = ActionManager::registerAction(m_replacePreviousAction, Constants::REPLACE_PREVIOUS);
|
replacePreviousAction.setText(Tr::tr("Replace && Find Previous"));
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
replacePreviousAction.bindContextAction(&m_replacePreviousAction);
|
||||||
connect(m_replacePreviousAction, &QAction::triggered,
|
replacePreviousAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
this, &FindToolBar::invokeGlobalReplacePrevious);
|
replacePreviousAction.setOnTriggered(this, [this] { invokeGlobalReplacePrevious(); });
|
||||||
m_localReplacePreviousAction = new QAction(m_replacePreviousAction->text(), this);
|
|
||||||
cmd = ActionManager::registerAction(m_localReplacePreviousAction, Constants::REPLACE_PREVIOUS, findcontext);
|
|
||||||
cmd->augmentActionWithShortcutToolTip(m_localReplacePreviousAction);
|
|
||||||
connect(m_localReplacePreviousAction, &QAction::triggered,
|
|
||||||
this, &FindToolBar::invokeReplacePrevious);
|
|
||||||
|
|
||||||
m_replaceAllAction = new QAction(Tr::tr("Replace All"), this);
|
ActionBuilder localReplacePreviousAction(this, Constants::REPLACE_PREVIOUS);
|
||||||
cmd = ActionManager::registerAction(m_replaceAllAction, Constants::REPLACE_ALL);
|
localReplacePreviousAction.setText(m_replacePreviousAction->text());
|
||||||
mfind->addAction(cmd, Constants::G_FIND_ACTIONS);
|
localReplacePreviousAction.setContext(findcontext);
|
||||||
connect(m_replaceAllAction, &QAction::triggered, this, &FindToolBar::invokeGlobalReplaceAll);
|
localReplacePreviousAction.bindContextAction(&m_localReplacePreviousAction);
|
||||||
m_localReplaceAllAction = new QAction(m_replaceAllAction->text(), this);
|
localReplacePreviousAction.augmentActionWithShortcutToolTip();
|
||||||
cmd = ActionManager::registerAction(m_localReplaceAllAction, Constants::REPLACE_ALL, findcontext);
|
localReplacePreviousAction.setOnTriggered(this, [this] { invokeReplacePrevious(); });
|
||||||
cmd->augmentActionWithShortcutToolTip(m_localReplaceAllAction);
|
|
||||||
connect(m_localReplaceAllAction, &QAction::triggered, this, &FindToolBar::invokeReplaceAll);
|
ActionBuilder replaceAllAction(this, Constants::REPLACE_ALL);
|
||||||
|
replaceAllAction.setText(Tr::tr("Replace All"));
|
||||||
|
replaceAllAction.bindContextAction(&m_replaceAllAction);
|
||||||
|
replaceAllAction.setDefaultKeySequence(Tr::tr("Ctrl+Alt+Return"));
|
||||||
|
replaceAllAction.setContainer(Constants::M_FIND, Constants::G_FIND_ACTIONS);
|
||||||
|
replaceAllAction.setOnTriggered(this, [this] { invokeGlobalReplaceAll(); });
|
||||||
|
|
||||||
|
ActionBuilder localReplaceAllAction(this, Constants::REPLACE_ALL);
|
||||||
|
localReplaceAllAction.setText(m_replaceAllAction->text());
|
||||||
|
localReplaceAllAction.setContext(findcontext);
|
||||||
|
localReplaceAllAction.bindContextAction(&m_localReplaceAllAction);
|
||||||
|
localReplaceAllAction.augmentActionWithShortcutToolTip();
|
||||||
|
localReplaceAllAction.setOnTriggered(this, [this] { invokeReplaceAll(); });
|
||||||
m_replaceAllButton->setDefaultAction(m_localReplaceAllAction);
|
m_replaceAllButton->setDefaultAction(m_localReplaceAllAction);
|
||||||
|
|
||||||
m_caseSensitiveAction = new QAction(Tr::tr("Case Sensitive"), this);
|
ActionBuilder caseSensitiveAction(this, Constants::CASE_SENSITIVE);
|
||||||
m_caseSensitiveAction->setIcon(Icons::FIND_CASE_INSENSITIVELY.icon());
|
caseSensitiveAction.setText(Tr::tr("Case Sensitive"));
|
||||||
m_caseSensitiveAction->setCheckable(true);
|
caseSensitiveAction.bindContextAction(&m_caseSensitiveAction);
|
||||||
m_caseSensitiveAction->setChecked(false);
|
caseSensitiveAction.setIcon(Icons::FIND_CASE_INSENSITIVELY.icon());
|
||||||
cmd = ActionManager::registerAction(m_caseSensitiveAction, Constants::CASE_SENSITIVE);
|
caseSensitiveAction.setCheckable(true);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_FLAGS);
|
caseSensitiveAction.setChecked(false);
|
||||||
connect(m_caseSensitiveAction, &QAction::toggled, this, &FindToolBar::setCaseSensitive);
|
caseSensitiveAction.setContainer(Constants::M_FIND, Constants::G_FIND_FLAGS);
|
||||||
|
caseSensitiveAction.setOnToggled(this, [this](bool on) { setCaseSensitive(on); });
|
||||||
|
|
||||||
m_wholeWordAction = new QAction(Tr::tr("Whole Words Only"), this);
|
ActionBuilder wholeWordAction(this, Constants::WHOLE_WORDS);
|
||||||
m_wholeWordAction->setIcon(Icons::FIND_WHOLE_WORD.icon());
|
wholeWordAction.setText(Tr::tr("Whole Words Only"));
|
||||||
m_wholeWordAction->setCheckable(true);
|
wholeWordAction.bindContextAction(&m_wholeWordAction);
|
||||||
m_wholeWordAction->setChecked(false);
|
wholeWordAction.setIcon(Icons::FIND_WHOLE_WORD.icon());
|
||||||
cmd = ActionManager::registerAction(m_wholeWordAction, Constants::WHOLE_WORDS);
|
wholeWordAction.setCheckable(true);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_FLAGS);
|
wholeWordAction.setChecked(false);
|
||||||
connect(m_wholeWordAction, &QAction::toggled, this, &FindToolBar::setWholeWord);
|
wholeWordAction.setContainer(Constants::M_FIND, Constants::G_FIND_FLAGS);
|
||||||
|
wholeWordAction.setOnToggled(this, [this](bool on) { setWholeWord(on); });
|
||||||
|
|
||||||
m_regularExpressionAction = new QAction(Tr::tr("Use Regular Expressions"), this);
|
ActionBuilder regularExpressionAction(this, Constants::REGULAR_EXPRESSIONS);
|
||||||
m_regularExpressionAction->setIcon(Icons::FIND_REGEXP.icon());
|
regularExpressionAction.setText(Tr::tr("Use Regular Expressions"));
|
||||||
m_regularExpressionAction->setCheckable(true);
|
regularExpressionAction.bindContextAction(&m_regularExpressionAction);
|
||||||
m_regularExpressionAction->setChecked(false);
|
regularExpressionAction.setIcon(Icons::FIND_REGEXP.icon());
|
||||||
cmd = ActionManager::registerAction(m_regularExpressionAction, Constants::REGULAR_EXPRESSIONS);
|
regularExpressionAction.setCheckable(true);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_FLAGS);
|
regularExpressionAction.setChecked(false);
|
||||||
connect(m_regularExpressionAction, &QAction::toggled, this, &FindToolBar::setRegularExpressions);
|
regularExpressionAction.setContainer(Constants::M_FIND, Constants::G_FIND_FLAGS);
|
||||||
|
regularExpressionAction.setOnToggled(this, [this](bool on) { setRegularExpressions(on); });
|
||||||
|
|
||||||
m_preserveCaseAction = new QAction(Tr::tr("Preserve Case when Replacing"), this);
|
ActionBuilder preserveCaseAction(this, Constants::PRESERVE_CASE);
|
||||||
m_preserveCaseAction->setIcon(Icons::FIND_PRESERVE_CASE.icon());
|
preserveCaseAction.setText(Tr::tr("Preserve Case when Replacing"));
|
||||||
m_preserveCaseAction->setCheckable(true);
|
preserveCaseAction.bindContextAction(&m_preserveCaseAction);
|
||||||
m_preserveCaseAction->setChecked(false);
|
preserveCaseAction.setIcon(Icons::FIND_PRESERVE_CASE.icon());
|
||||||
cmd = ActionManager::registerAction(m_preserveCaseAction, Constants::PRESERVE_CASE);
|
preserveCaseAction.setCheckable(true);
|
||||||
mfind->addAction(cmd, Constants::G_FIND_FLAGS);
|
preserveCaseAction.setChecked(false);
|
||||||
connect(m_preserveCaseAction, &QAction::toggled, this, &FindToolBar::setPreserveCase);
|
preserveCaseAction.setContainer(Constants::M_FIND, Constants::G_FIND_FLAGS);
|
||||||
|
preserveCaseAction.setOnToggled(this, [this](bool on) { setPreserveCase(on); });
|
||||||
|
|
||||||
connect(m_currentDocumentFind, &CurrentDocumentFind::candidateChanged,
|
connect(m_currentDocumentFind, &CurrentDocumentFind::candidateChanged,
|
||||||
this, &FindToolBar::adaptToCandidate);
|
this, &FindToolBar::adaptToCandidate);
|
||||||
|
Reference in New Issue
Block a user