mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Add shortcuts for Previous/Next actions on Article search (Ctrl + F)
This commit is contained in:
parent
0726b90f30
commit
5f97db0449
|
@ -1378,6 +1378,11 @@ bool ArticleView::closeSearch()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool ArticleView::isSearchOpened()
|
||||
{
|
||||
return searchIsOpened;
|
||||
}
|
||||
|
||||
void ArticleView::showEvent( QShowEvent * ev )
|
||||
{
|
||||
QFrame::showEvent( ev );
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() )
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -281,22 +281,7 @@
|
|||
<normaloff>:/icons/book.png</normaloff>:/icons/book.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Dictionaries...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F3</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="groups">
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/icons/playsound.png</normaloff>:/icons/playsound.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Groups...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>F3</string>
|
||||
<string>&Dictionaries... F3</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="preferences">
|
||||
|
|
Loading…
Reference in a new issue