diff --git a/doc/src/howto/creator-keyboard-shortcuts.qdoc b/doc/src/howto/creator-keyboard-shortcuts.qdoc index d2ca4715a74f5c6bea13101390c4dcef9e7415a6..08d133f2657c9c21785c7a9e540bc6feb4f332fa 100644 --- a/doc/src/howto/creator-keyboard-shortcuts.qdoc +++ b/doc/src/howto/creator-keyboard-shortcuts.qdoc @@ -417,6 +417,12 @@ \row \o Find previous \o Shift+F3 + \row + \o Find next occurence of selected text + \o Ctrl+F3 + \row + \o Find previous occurence of selected text + \o Ctrl+Shift+F3 \row \o Replace next \o Ctrl+= diff --git a/src/plugins/find/findtoolbar.cpp b/src/plugins/find/findtoolbar.cpp index 1a7f8eefeb50e13ad709069d9ce4ae87b6e91e91..9b1017f1f3ed3485484fe4d6c4bc0eab7db4e7ba 100644 --- a/src/plugins/find/findtoolbar.cpp +++ b/src/plugins/find/findtoolbar.cpp @@ -183,6 +183,18 @@ FindToolBar::FindToolBar(FindPlugin *plugin, CurrentDocumentFind *currentDocumen connect(m_findPreviousAction, SIGNAL(triggered()), this, SLOT(invokeFindPrevious())); m_ui.findPreviousButton->setDefaultAction(cmd->action()); + m_findNextSelectedAction = new QAction(tr("Find Next (Selected)"), this); + cmd = am->registerAction(m_findNextSelectedAction, Constants::FIND_NEXT_SELECTED, globalcontext); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+F3"))); + mfind->addAction(cmd, Constants::G_FIND_ACTIONS); + connect(m_findNextSelectedAction, SIGNAL(triggered()), this, SLOT(findNextSelected())); + + m_findPreviousSelectedAction = new QAction(tr("Find Previous (Selected)"), this); + cmd = am->registerAction(m_findPreviousSelectedAction, Constants::FIND_PREV_SELECTED, globalcontext); + cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+F3"))); + mfind->addAction(cmd, Constants::G_FIND_ACTIONS); + connect(m_findPreviousSelectedAction, SIGNAL(triggered()), this, SLOT(findPreviousSelected())); + m_replaceAction = new QAction(tr("Replace"), this); cmd = am->registerAction(m_replaceAction, Constants::REPLACE, globalcontext); cmd->setDefaultKeySequence(QKeySequence()); @@ -327,7 +339,10 @@ void FindToolBar::adaptToCandidate() void FindToolBar::updateFindAction() { - m_findInDocumentAction->setEnabled(m_currentDocumentFind->candidateIsEnabled()); + bool enabled = m_currentDocumentFind->candidateIsEnabled(); + m_findInDocumentAction->setEnabled(enabled); + m_findNextSelectedAction->setEnabled(enabled); + m_findPreviousSelectedAction->setEnabled(enabled); } void FindToolBar::updateToolBar() @@ -605,13 +620,13 @@ Core::FindToolBarPlaceHolder *FindToolBar::findToolBarPlaceHolder() const return 0; } -void FindToolBar::openFind() +void FindToolBar::openFind(bool focus) { setBackward(false); - openFindToolBar(); + openFindToolBar(focus); } -void FindToolBar::openFindToolBar() +void FindToolBar::openFindToolBar(bool focus) { installEventFilters(); if (!m_currentDocumentFind->candidateIsEnabled()) @@ -627,13 +642,27 @@ void FindToolBar::openFindToolBar() holder->setWidget(this); holder->setVisible(true); setVisible(true); - setFocus(); + if (focus) + setFocus(); QString text = m_currentDocumentFind->currentFindString(); if (!text.isEmpty()) setFindText(text); m_currentDocumentFind->defineFindScope(); m_currentDocumentFind->highlightAll(getFindText(), effectiveFindFlags()); - selectFindText(); + if (focus) + selectFindText(); +} + +void FindToolBar::findNextSelected() +{ + openFind(false); + invokeFindNext(); +} + +void FindToolBar::findPreviousSelected() +{ + openFind(false); + invokeFindPrevious(); } bool FindToolBar::focusNextPrevChild(bool next) diff --git a/src/plugins/find/findtoolbar.h b/src/plugins/find/findtoolbar.h index aa4f07e5b6889210defaf582e5ab8a6bde969c59..0fa68aea0b9117a9f6ad507ed27c4b0c40da4352 100644 --- a/src/plugins/find/findtoolbar.h +++ b/src/plugins/find/findtoolbar.h @@ -60,7 +60,7 @@ public: void readSettings(); void writeSettings(); - void openFindToolBar(); + void openFindToolBar(bool focus = true); void setUseFakeVim(bool on); public slots: @@ -84,7 +84,9 @@ private slots: void updateFromFindClipboard(); void hideAndResetFocus(); - void openFind(); + void openFind(bool focus = true); + void findNextSelected(); + void findPreviousSelected(); void updateFindAction(); void updateToolBar(); void findFlagsChanged(); @@ -121,6 +123,8 @@ private: QCompleter *m_findCompleter; QCompleter *m_replaceCompleter; QAction *m_findInDocumentAction; + QAction *m_findNextSelectedAction; + QAction *m_findPreviousSelectedAction; QAction *m_enterFindStringAction; QAction *m_findNextAction; QAction *m_findPreviousAction; diff --git a/src/plugins/find/textfindconstants.h b/src/plugins/find/textfindconstants.h index ab9f0bc92dffa6c42d638f9b93d3ebe216eaf05e..d470e111723f2689880b3abfa7f802b5fe648a66 100644 --- a/src/plugins/find/textfindconstants.h +++ b/src/plugins/find/textfindconstants.h @@ -51,6 +51,8 @@ const char G_FIND_ACTIONS[] = "Find.FindMenu.Actions"; const char ADVANCED_FIND[] = "Find.Dialog"; const char FIND_IN_DOCUMENT[] = "Find.FindInCurrentDocument"; +const char FIND_NEXT_SELECTED[]= "Find.FindNextSelected"; +const char FIND_PREV_SELECTED[]= "Find.FindPreviousSelected"; const char FIND_NEXT[] = "Find.FindNext"; const char FIND_PREVIOUS[] = "Find.FindPrevious"; const char REPLACE[] = "Find.Replace";