Skip to content

Commit

Permalink
scide: add "Find Next/Previous" actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jleben committed Nov 15, 2012
1 parent 717d1a5 commit 9add8d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions editors/sc-ide/widgets/find_replace_tool.cpp
Expand Up @@ -20,6 +20,8 @@

#include "find_replace_tool.hpp"
#include "code_editor/editor.hpp"
#include "../core/main.hpp"
#include "../core/settings/manager.hpp"

#include <QApplication>
#include <QTextBlock>
Expand Down Expand Up @@ -114,6 +116,19 @@ TextFindReplacePanel::TextFindReplacePanel( QWidget * parent ):
connect(mFindField, SIGNAL(returnPressed()), this, SLOT(onFindFieldReturn()));
connect(mFindField, SIGNAL(textChanged(QString)), this, SLOT(onFindFieldTextChanged()));
connect(mReplaceField, SIGNAL(returnPressed()), this, SLOT(replace()));

Settings::Manager *settings = Main::settings();
QAction *action;

action = mActions[FindNext] = new QAction(tr("Find Next"), this);
action->setShortcut(tr("Ctrl+G", "Find Next"));
connect( action, SIGNAL(triggered()), this, SLOT(findNext()) );
settings->addAction( action, "editor-find-next", "Text Editor" );

action = mActions[FindPrevious] = new QAction(tr("Find Previous"), this);
action->setShortcut(tr("Ctrl+Shift+G", "Find Previous"));
connect( action, SIGNAL(triggered()), this, SLOT(findPrevious()) );
settings->addAction( action, "editor-find-previous", "Text Editor" );
}

void TextFindReplacePanel::setMode( Mode mode )
Expand Down
10 changes: 10 additions & 0 deletions editors/sc-ide/widgets/find_replace_tool.hpp
Expand Up @@ -46,6 +46,13 @@ class TextFindReplacePanel : public QWidget
Replace
};

enum ActionRole {
FindNext,
FindPrevious,

ActionCount
};

public:
TextFindReplacePanel( QWidget * parent = 0 );

Expand All @@ -63,6 +70,8 @@ class TextFindReplacePanel : public QWidget
QRegExp regexp();
QTextDocument::FindFlags flags();

QAction *action ( ActionRole role ) { return mActions[role]; }

public Q_SLOTS:
void findNext();
void findPrevious();
Expand Down Expand Up @@ -90,6 +99,7 @@ private Q_SLOTS:
QAction *mMatchCaseAction;
QAction *mRegExpAction;
QAction *mWholeWordAction;
QAction *mActions[ActionCount];

QGridLayout *mGrid;

Expand Down
2 changes: 2 additions & 0 deletions editors/sc-ide/widgets/main_window.cpp
Expand Up @@ -501,6 +501,8 @@ void MainWindow::createMenus()
menu->addAction( mEditors->action(MultiEditor::Paste) );
menu->addSeparator();
menu->addAction( mActions[Find] );
menu->addAction( mFindReplaceTool->action(TextFindReplacePanel::FindNext) );
menu->addAction( mFindReplaceTool->action(TextFindReplacePanel::FindPrevious) );
menu->addAction( mActions[Replace] );
menu->addSeparator();
menu->addAction( mEditors->action(MultiEditor::IndentWithSpaces) );
Expand Down

0 comments on commit 9add8d5

Please sign in to comment.