mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17: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 ),
|
switchExpandModeAction( this ),
|
||||||
focusHeadwordsDlgAction( this ),
|
focusHeadwordsDlgAction( this ),
|
||||||
focusArticleViewAction( this ),
|
focusArticleViewAction( this ),
|
||||||
|
addAllTabToFavoritesAction( this ),
|
||||||
trayIconMenu( this ),
|
trayIconMenu( this ),
|
||||||
addTab( this ),
|
addTab( this ),
|
||||||
cfg( cfg_ ),
|
cfg( cfg_ ),
|
||||||
|
@ -451,11 +452,19 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
||||||
|
|
||||||
addAction( &switchExpandModeAction );
|
addAction( &switchExpandModeAction );
|
||||||
|
|
||||||
|
addAllTabToFavoritesAction.setText( tr( "Add all tabs to Favorites" ) );
|
||||||
|
|
||||||
|
connect( &addAllTabToFavoritesAction, SIGNAL( triggered() ),
|
||||||
|
this, SLOT( addAllTabsToFavorites() ) );
|
||||||
|
|
||||||
tabMenu = new QMenu(this);
|
tabMenu = new QMenu(this);
|
||||||
tabMenu->addAction( &closeCurrentTabAction );
|
tabMenu->addAction( &closeCurrentTabAction );
|
||||||
tabMenu->addAction( &closeRestTabAction );
|
tabMenu->addAction( &closeRestTabAction );
|
||||||
tabMenu->addSeparator();
|
tabMenu->addSeparator();
|
||||||
tabMenu->addAction( &closeAllTabAction );
|
tabMenu->addAction( &closeAllTabAction );
|
||||||
|
tabMenu->addSeparator();
|
||||||
|
tabMenu->addAction( addToFavorites );
|
||||||
|
tabMenu->addAction( &addAllTabToFavoritesAction );
|
||||||
|
|
||||||
// Dictionary bar names
|
// Dictionary bar names
|
||||||
|
|
||||||
|
@ -4489,6 +4498,30 @@ void MainWindow::addWordToFavorites( QString const & word, unsigned groupId )
|
||||||
ui.favoritesPaneWidget->addHeadword( folder, word );
|
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 )
|
bool MainWindow::isWordPresentedInFavorites( QString const & word, unsigned groupId )
|
||||||
{
|
{
|
||||||
QString folder;
|
QString folder;
|
||||||
|
|
|
@ -121,7 +121,8 @@ private:
|
||||||
closeAllTabAction, closeRestTabAction,
|
closeAllTabAction, closeRestTabAction,
|
||||||
switchToNextTabAction, switchToPrevTabAction,
|
switchToNextTabAction, switchToPrevTabAction,
|
||||||
showDictBarNamesAction, useSmallIconsInToolbarsAction, toggleMenuBarAction,
|
showDictBarNamesAction, useSmallIconsInToolbarsAction, toggleMenuBarAction,
|
||||||
switchExpandModeAction, focusHeadwordsDlgAction, focusArticleViewAction;
|
switchExpandModeAction, focusHeadwordsDlgAction, focusArticleViewAction,
|
||||||
|
addAllTabToFavoritesAction;
|
||||||
QToolBar * navToolbar;
|
QToolBar * navToolbar;
|
||||||
MainStatusBar * mainStatusBar;
|
MainStatusBar * mainStatusBar;
|
||||||
QAction * navBack, * navForward, * navPronounce, * enableScanPopup;
|
QAction * navBack, * navForward, * navPronounce, * enableScanPopup;
|
||||||
|
@ -282,6 +283,8 @@ private slots:
|
||||||
|
|
||||||
void addCurrentTabToFavorites();
|
void addCurrentTabToFavorites();
|
||||||
|
|
||||||
|
void addAllTabsToFavorites();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
// Executed in response to a user click on an 'add tab' tool button
|
// Executed in response to a user click on an 'add tab' tool button
|
||||||
|
|
Loading…
Reference in a new issue