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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ArticleView::isSearchOpened()
|
||||||
|
{
|
||||||
|
return searchIsOpened;
|
||||||
|
}
|
||||||
|
|
||||||
void ArticleView::showEvent( QShowEvent * ev )
|
void ArticleView::showEvent( QShowEvent * ev )
|
||||||
{
|
{
|
||||||
QFrame::showEvent( ev );
|
QFrame::showEvent( ev );
|
||||||
|
|
|
@ -144,6 +144,8 @@ public:
|
||||||
/// wasn't open.
|
/// wasn't open.
|
||||||
bool closeSearch();
|
bool closeSearch();
|
||||||
|
|
||||||
|
bool isSearchOpened();
|
||||||
|
|
||||||
/// Jumps to the article specified by the dictionary id,
|
/// Jumps to the article specified by the dictionary id,
|
||||||
/// by executing a javascript code.
|
/// by executing a javascript code.
|
||||||
void jumpToDictionary( QString const & );
|
void jumpToDictionary( QString const & );
|
||||||
|
@ -173,6 +175,11 @@ signals:
|
||||||
/// switch focus to word input.
|
/// switch focus to word input.
|
||||||
void typingEvent( QString const & text );
|
void typingEvent( QString const & text );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
void on_searchPrevious_clicked();
|
||||||
|
void on_searchNext_clicked();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void loadFinished( bool ok );
|
void loadFinished( bool ok );
|
||||||
|
@ -195,8 +202,6 @@ private slots:
|
||||||
/// Opens the search area
|
/// Opens the search area
|
||||||
void openSearch();
|
void openSearch();
|
||||||
|
|
||||||
void on_searchPrevious_clicked();
|
|
||||||
void on_searchNext_clicked();
|
|
||||||
void on_searchText_textEdited();
|
void on_searchText_textEdited();
|
||||||
void on_searchText_returnPressed();
|
void on_searchText_returnPressed();
|
||||||
void on_searchCloseButton_clicked();
|
void on_searchCloseButton_clicked();
|
||||||
|
|
|
@ -30,6 +30,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
groupList( &searchPaneTitleBar ),
|
groupList( &searchPaneTitleBar ),
|
||||||
foundInDictsLabel( &dictsPaneTitleBar ),
|
foundInDictsLabel( &dictsPaneTitleBar ),
|
||||||
escAction( this ),
|
escAction( this ),
|
||||||
|
f3Action( this ),
|
||||||
|
shiftF3Action( this ),
|
||||||
focusTranslateLineAction( this ),
|
focusTranslateLineAction( this ),
|
||||||
addTabAction( this ),
|
addTabAction( this ),
|
||||||
closeCurrentTabAction( this ),
|
closeCurrentTabAction( this ),
|
||||||
|
@ -165,6 +167,20 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
connect( &escAction, SIGNAL( triggered() ),
|
connect( &escAction, SIGNAL( triggered() ),
|
||||||
this, SLOT( handleEsc() ) );
|
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.setShortcutContext( Qt::WidgetWithChildrenShortcut );
|
||||||
focusTranslateLineAction.setShortcuts( QList< QKeySequence >() <<
|
focusTranslateLineAction.setShortcuts( QList< QKeySequence >() <<
|
||||||
QKeySequence( "Alt+D" ) <<
|
QKeySequence( "Alt+D" ) <<
|
||||||
|
@ -1322,6 +1338,24 @@ void MainWindow::handleEsc()
|
||||||
focusTranslateLine();
|
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()
|
void MainWindow::focusTranslateLine()
|
||||||
{
|
{
|
||||||
if ( ui.searchPane->isFloating() )
|
if ( ui.searchPane->isFloating() )
|
||||||
|
|
|
@ -69,7 +69,7 @@ private:
|
||||||
/// Fonts saved before words zooming is in effect, so it could be reset back.
|
/// Fonts saved before words zooming is in effect, so it could be reset back.
|
||||||
QFont wordListDefaultFont, translateLineDefaultFont;
|
QFont wordListDefaultFont, translateLineDefaultFont;
|
||||||
|
|
||||||
QAction escAction, focusTranslateLineAction, addTabAction, closeCurrentTabAction,
|
QAction escAction, f3Action, shiftF3Action, focusTranslateLineAction, addTabAction, closeCurrentTabAction,
|
||||||
closeAllTabAction, closeRestTabAction,
|
closeAllTabAction, closeRestTabAction,
|
||||||
switchToNextTabAction, switchToPrevTabAction,
|
switchToNextTabAction, switchToPrevTabAction,
|
||||||
showDictBarNamesAction, useSmallIconsInToolbarsAction, toggleMenuBarAction;
|
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.
|
/// Closes any opened search in the article view, and focuses the translateLine/close main window to tray.
|
||||||
void handleEsc();
|
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
|
/// Gives the keyboard focus to the translateLine and selects all the text
|
||||||
/// it has.
|
/// it has.
|
||||||
void focusTranslateLine();
|
void focusTranslateLine();
|
||||||
|
|
|
@ -281,22 +281,7 @@
|
||||||
<normaloff>:/icons/book.png</normaloff>:/icons/book.png</iconset>
|
<normaloff>:/icons/book.png</normaloff>:/icons/book.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Dictionaries...</string>
|
<string>&Dictionaries... F3</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>
|
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="preferences">
|
<action name="preferences">
|
||||||
|
|
Loading…
Reference in a new issue