mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Append "Add to favorites" action to tabs context menu
This commit is contained in:
parent
7217a1e24c
commit
65be9f2f8a
|
@ -107,6 +107,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
switchExpandModeAction( this ),
|
||||
focusHeadwordsDlgAction( this ),
|
||||
focusArticleViewAction( this ),
|
||||
addAllTabToFavoritesAction( this ),
|
||||
trayIconMenu( this ),
|
||||
addTab( this ),
|
||||
cfg( cfg_ ),
|
||||
|
@ -451,11 +452,19 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
|
||||
addAction( &switchExpandModeAction );
|
||||
|
||||
addAllTabToFavoritesAction.setText( tr( "Add all tabs to Favorites" ) );
|
||||
|
||||
connect( &addAllTabToFavoritesAction, SIGNAL( triggered() ),
|
||||
this, SLOT( addAllTabsToFavorites() ) );
|
||||
|
||||
tabMenu = new QMenu(this);
|
||||
tabMenu->addAction( &closeCurrentTabAction );
|
||||
tabMenu->addAction( &closeRestTabAction );
|
||||
tabMenu->addSeparator();
|
||||
tabMenu->addAction( &closeAllTabAction );
|
||||
tabMenu->addSeparator();
|
||||
tabMenu->addAction( addToFavorites );
|
||||
tabMenu->addAction( &addAllTabToFavoritesAction );
|
||||
|
||||
// Dictionary bar names
|
||||
|
||||
|
@ -4489,6 +4498,30 @@ void MainWindow::addWordToFavorites( QString const & word, unsigned groupId )
|
|||
ui.favoritesPaneWidget->addHeadword( folder, word );
|
||||
}
|
||||
|
||||
void MainWindow::addAllTabsToFavorites()
|
||||
{
|
||||
QString folder;
|
||||
Instances::Group const * igrp = groupInstances.findGroup( cfg.lastMainGroupId );
|
||||
if( igrp )
|
||||
folder = igrp->favoritesFolder;
|
||||
|
||||
for( int i = 0; i < ui.tabWidget->count(); i++ )
|
||||
{
|
||||
QString headword = ui.tabWidget->tabText( i );
|
||||
|
||||
// Reset table header to original headword
|
||||
|
||||
headword.replace( "&&", "&" );
|
||||
if( headword.startsWith( QChar( 0x202E ) ) )
|
||||
headword = headword.mid( 1 );
|
||||
if( headword.endsWith( QChar( 0x202C ) ) )
|
||||
headword.chop( 1 );
|
||||
|
||||
ui.favoritesPaneWidget->addHeadword( folder, headword );
|
||||
}
|
||||
addToFavorites->setIcon( blueStarIcon );
|
||||
}
|
||||
|
||||
bool MainWindow::isWordPresentedInFavorites( QString const & word, unsigned groupId )
|
||||
{
|
||||
QString folder;
|
||||
|
|
|
@ -121,7 +121,8 @@ private:
|
|||
closeAllTabAction, closeRestTabAction,
|
||||
switchToNextTabAction, switchToPrevTabAction,
|
||||
showDictBarNamesAction, useSmallIconsInToolbarsAction, toggleMenuBarAction,
|
||||
switchExpandModeAction, focusHeadwordsDlgAction, focusArticleViewAction;
|
||||
switchExpandModeAction, focusHeadwordsDlgAction, focusArticleViewAction,
|
||||
addAllTabToFavoritesAction;
|
||||
QToolBar * navToolbar;
|
||||
MainStatusBar * mainStatusBar;
|
||||
QAction * navBack, * navForward, * navPronounce, * enableScanPopup;
|
||||
|
@ -282,6 +283,8 @@ private slots:
|
|||
|
||||
void addCurrentTabToFavorites();
|
||||
|
||||
void addAllTabsToFavorites();
|
||||
|
||||
private slots:
|
||||
|
||||
// Executed in response to a user click on an 'add tab' tool button
|
||||
|
|
Loading…
Reference in a new issue