diff --git a/articleview.cc b/articleview.cc index 5c24862f..da625ed0 100644 --- a/articleview.cc +++ b/articleview.cc @@ -1378,6 +1378,11 @@ bool ArticleView::closeSearch() return false; } +bool ArticleView::isSearchOpened() +{ + return searchIsOpened; +} + void ArticleView::showEvent( QShowEvent * ev ) { QFrame::showEvent( ev ); diff --git a/articleview.hh b/articleview.hh index 76f36dd2..2de9ebd7 100644 --- a/articleview.hh +++ b/articleview.hh @@ -144,6 +144,8 @@ public: /// wasn't open. bool closeSearch(); + bool isSearchOpened(); + /// Jumps to the article specified by the dictionary id, /// by executing a javascript code. void jumpToDictionary( QString const & ); @@ -173,6 +175,11 @@ signals: /// switch focus to word input. void typingEvent( QString const & text ); +public slots: + + void on_searchPrevious_clicked(); + void on_searchNext_clicked(); + private slots: void loadFinished( bool ok ); @@ -195,8 +202,6 @@ private slots: /// Opens the search area void openSearch(); - void on_searchPrevious_clicked(); - void on_searchNext_clicked(); void on_searchText_textEdited(); void on_searchText_returnPressed(); void on_searchCloseButton_clicked(); diff --git a/mainwindow.cc b/mainwindow.cc index e7886082..0909be1f 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -30,6 +30,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ): groupList( &searchPaneTitleBar ), foundInDictsLabel( &dictsPaneTitleBar ), escAction( this ), + f3Action( this ), + shiftF3Action( this ), focusTranslateLineAction( this ), addTabAction( this ), closeCurrentTabAction( this ), @@ -165,6 +167,20 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( &escAction, SIGNAL( triggered() ), this, SLOT( handleEsc() ) ); + f3Action.setShortcutContext( Qt::ApplicationShortcut ); + f3Action.setShortcut( QKeySequence( "F3" ) ); + connect( &f3Action, SIGNAL( triggered() ), + this, SLOT( handleF3() ) ); + + addAction( &f3Action ); + + shiftF3Action.setShortcutContext( Qt::WidgetWithChildrenShortcut ); + shiftF3Action.setShortcut( QKeySequence( "Shift+F3" ) ); + connect( &shiftF3Action, SIGNAL( triggered() ), + this, SLOT( handleShiftF3() ) ); + + addAction( &shiftF3Action ); + focusTranslateLineAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); focusTranslateLineAction.setShortcuts( QList< QKeySequence >() << QKeySequence( "Alt+D" ) << @@ -1322,6 +1338,24 @@ void MainWindow::handleEsc() focusTranslateLine(); } +void MainWindow::handleF3() +{ + ArticleView & view = dynamic_cast< ArticleView & >( *( ui.tabWidget->currentWidget() ) ); + + if( view.isSearchOpened() ) + view.on_searchNext_clicked(); + else + editDictionaries(); +} + +void MainWindow::handleShiftF3() +{ + ArticleView & view = dynamic_cast< ArticleView & >( *( ui.tabWidget->currentWidget() ) ); + + if( view.isSearchOpened() ) + view.on_searchPrevious_clicked(); +} + void MainWindow::focusTranslateLine() { if ( ui.searchPane->isFloating() ) diff --git a/mainwindow.hh b/mainwindow.hh index d41eebd4..27d47c10 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -69,7 +69,7 @@ private: /// Fonts saved before words zooming is in effect, so it could be reset back. QFont wordListDefaultFont, translateLineDefaultFont; - QAction escAction, focusTranslateLineAction, addTabAction, closeCurrentTabAction, + QAction escAction, f3Action, shiftF3Action, focusTranslateLineAction, addTabAction, closeCurrentTabAction, closeAllTabAction, closeRestTabAction, switchToNextTabAction, switchToPrevTabAction, showDictBarNamesAction, useSmallIconsInToolbarsAction, toggleMenuBarAction; @@ -241,6 +241,10 @@ private slots: /// Closes any opened search in the article view, and focuses the translateLine/close main window to tray. void handleEsc(); + /// Either triggers Edit Dictionaries menu option or perform a Find Next action. + void handleF3(); + void handleShiftF3(); + /// Gives the keyboard focus to the translateLine and selects all the text /// it has. void focusTranslateLine(); diff --git a/mainwindow.ui b/mainwindow.ui index 78e8b94b..ef59fe25 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -281,22 +281,7 @@ :/icons/book.png:/icons/book.png - &Dictionaries... - - - F3 - - - - - - :/icons/playsound.png:/icons/playsound.png - - - &Groups... - - - F3 + &Dictionaries... F3