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