mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
cleanup: simplify DSL's expand mode
Related code was related to DSL's [*][/*] tag. One of the feature removed is Ctrl+8 to toggle current articleview's AlwaysExpand mode, because DSL is the only format that has this feature and User can turn on AlwaysExpand Mode on Preferences. There is no need to assign a shortcut for it.
This commit is contained in:
parent
7ac1877544
commit
0731253489
|
@ -24,14 +24,15 @@ using std::list;
|
|||
|
||||
ArticleMaker::ArticleMaker( vector< sptr< Dictionary::Class > > const & dictionaries_,
|
||||
vector< Instances::Group > const & groups_,
|
||||
const Config::Preferences & cfg_,
|
||||
QString const & displayStyle_,
|
||||
QString const & addonStyle_):
|
||||
dictionaries( dictionaries_ ),
|
||||
groups( groups_ ),
|
||||
cfg(cfg_),
|
||||
displayStyle( displayStyle_ ),
|
||||
addonStyle( addonStyle_ ),
|
||||
needExpandOptionalParts( true )
|
||||
, collapseBigArticles( true )
|
||||
collapseBigArticles( true )
|
||||
, articleLimitSize( 500 )
|
||||
{
|
||||
}
|
||||
|
@ -280,7 +281,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor(
|
|||
if ( groupId == Instances::Group::HelpGroupId )
|
||||
{
|
||||
// This is a special group containing internal welcome/help pages
|
||||
string result = makeHtmlHeader( phrase.phrase, QString(), needExpandOptionalParts );
|
||||
string result = makeHtmlHeader( phrase.phrase, QString(), cfg.alwaysExpandOptionalParts);
|
||||
|
||||
if ( phrase.phrase == tr( "Welcome!" ) )
|
||||
{
|
||||
|
@ -353,7 +354,7 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor(
|
|||
string header = makeHtmlHeader( phrase.phrase,
|
||||
activeGroup && activeGroup->icon.size() ?
|
||||
activeGroup->icon : QString(),
|
||||
needExpandOptionalParts );
|
||||
cfg.alwaysExpandOptionalParts );
|
||||
|
||||
if ( mutedDicts.size() )
|
||||
{
|
||||
|
@ -369,13 +370,13 @@ sptr< Dictionary::DataRequest > ArticleMaker::makeDefinitionFor(
|
|||
return std::make_shared<ArticleRequest>( phrase, activeGroup ? activeGroup->name : "",
|
||||
contexts, unmutedDicts, header,
|
||||
collapseBigArticles ? articleLimitSize : -1,
|
||||
needExpandOptionalParts, ignoreDiacritics );
|
||||
cfg.alwaysExpandOptionalParts, ignoreDiacritics );
|
||||
}
|
||||
else
|
||||
return std::make_shared<ArticleRequest>( phrase, activeGroup ? activeGroup->name : "",
|
||||
contexts, activeDicts, header,
|
||||
collapseBigArticles ? articleLimitSize : -1,
|
||||
needExpandOptionalParts, ignoreDiacritics );
|
||||
cfg.alwaysExpandOptionalParts, ignoreDiacritics );
|
||||
}
|
||||
|
||||
sptr< Dictionary::DataRequest > ArticleMaker::makeNotFoundTextFor(
|
||||
|
@ -422,11 +423,6 @@ sptr< Dictionary::DataRequest > ArticleMaker::makePicturePage( string const & ur
|
|||
return r;
|
||||
}
|
||||
|
||||
void ArticleMaker::setExpandOptionalParts( bool expand )
|
||||
{
|
||||
needExpandOptionalParts = expand;
|
||||
}
|
||||
|
||||
void ArticleMaker::setCollapseParameters( bool autoCollapse, int articleSize )
|
||||
{
|
||||
collapseBigArticles = autoCollapse;
|
||||
|
|
|
@ -20,10 +20,10 @@ class ArticleMaker: public QObject
|
|||
|
||||
std::vector< sptr< Dictionary::Class > > const & dictionaries;
|
||||
std::vector< Instances::Group > const & groups;
|
||||
const Config::Preferences & cfg;
|
||||
|
||||
QString displayStyle, addonStyle;
|
||||
|
||||
bool needExpandOptionalParts;
|
||||
bool collapseBigArticles;
|
||||
int articleLimitSize;
|
||||
|
||||
|
@ -35,6 +35,7 @@ public:
|
|||
/// of the inquiries, although those changes are perfectly legal.
|
||||
ArticleMaker( std::vector< sptr< Dictionary::Class > > const & dictionaries,
|
||||
std::vector< Instances::Group > const & groups,
|
||||
const Config::Preferences & cfg,
|
||||
QString const & displayStyle,
|
||||
QString const & addonStyle);
|
||||
|
||||
|
@ -69,9 +70,6 @@ public:
|
|||
/// Create page with one picture
|
||||
sptr< Dictionary::DataRequest > makePicturePage( std::string const & url ) const;
|
||||
|
||||
/// Set auto expanding optional parts of articles
|
||||
void setExpandOptionalParts( bool expand );
|
||||
|
||||
/// Add base path to file path if it's relative and file not found
|
||||
/// Return true if path successfully adjusted
|
||||
static bool adjustFilePath( QString & fileName );
|
||||
|
|
|
@ -121,7 +121,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
showDictBarNamesAction( tr( "Show Names in Dictionary &Bar" ), this ),
|
||||
useSmallIconsInToolbarsAction( tr( "Show Small Icons in &Toolbars" ), this ),
|
||||
toggleMenuBarAction( tr( "&Menubar" ), this ),
|
||||
switchExpandModeAction( this ),
|
||||
focusHeadwordsDlgAction( this ),
|
||||
focusArticleViewAction( this ),
|
||||
addAllTabToFavoritesAction( this ),
|
||||
|
@ -130,7 +129,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
cfg( cfg_ ),
|
||||
history( History::Load(), cfg_.preferences.maxStringsInHistory, cfg_.maxHeadwordSize ),
|
||||
dictionaryBar( this, configEvents, cfg.editDictionaryCommandLine, cfg.preferences.maxDictionaryRefsInContextMenu ),
|
||||
articleMaker( dictionaries, groupInstances, cfg.preferences.displayStyle,
|
||||
articleMaker( dictionaries, groupInstances, cfg.preferences , cfg.preferences.displayStyle,
|
||||
cfg.preferences.addonStyle ),
|
||||
articleNetMgr( this, dictionaries, articleMaker,
|
||||
cfg.preferences.disallowContentFromOtherSites, cfg.preferences.hideGoldenDictHeader ),
|
||||
|
@ -460,16 +459,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
|
||||
addAction( &switchToPrevTabAction );
|
||||
|
||||
switchExpandModeAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
|
||||
switchExpandModeAction.setShortcuts( QList< QKeySequence >() <<
|
||||
QKeySequence( Qt::CTRL | Qt::Key_8 ) <<
|
||||
QKeySequence( Qt::CTRL | Qt::Key_Asterisk ) <<
|
||||
QKeySequence( Qt::CTRL | Qt::SHIFT | Qt::Key_8 ) );
|
||||
|
||||
connect( &switchExpandModeAction, &QAction::triggered, this, &MainWindow::switchExpandOptionalPartsMode );
|
||||
|
||||
addAction( &switchExpandModeAction );
|
||||
|
||||
addAllTabToFavoritesAction.setText( tr( "Add all tabs to Favorites" ) );
|
||||
|
||||
connect( &addAllTabToFavoritesAction, &QAction::triggered, this, &MainWindow::addAllTabsToFavorites );
|
||||
|
@ -771,8 +760,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
|
|||
this,&MainWindow::phraseReceived,
|
||||
Qt::QueuedConnection);
|
||||
|
||||
connect( this, &MainWindow::setExpandOptionalParts, scanPopup, &ScanPopup::setViewExpandMode );
|
||||
connect( scanPopup, &ScanPopup::setExpandMode, this, &MainWindow::setExpandMode );
|
||||
connect( scanPopup, &ScanPopup::inspectSignal,this,&MainWindow::inspectElement );
|
||||
connect( scanPopup, &ScanPopup::forceAddWordToHistory, this, &MainWindow::forceAddWordToHistory );
|
||||
connect( scanPopup, &ScanPopup::showDictionaryInfo, this, &MainWindow::showDictionaryInfo );
|
||||
|
@ -1715,10 +1702,6 @@ ArticleView * MainWindow::createNewTab( bool switchToIt,
|
|||
|
||||
connect( view, &ArticleView::forceAddWordToHistory, this, &MainWindow::forceAddWordToHistory );
|
||||
|
||||
connect( this, &MainWindow::setExpandOptionalParts, view, &ArticleView::receiveExpandOptionalParts );
|
||||
|
||||
connect( view, &ArticleView::setExpandMode, this, &MainWindow::setExpandMode );
|
||||
|
||||
connect( view, &ArticleView::sendWordToHistory, this, &MainWindow::addWordToHistory );
|
||||
|
||||
connect( view, &ArticleView::sendWordToInputLine, this, &MainWindow::sendWordToInputLine );
|
||||
|
@ -2245,9 +2228,7 @@ void MainWindow::editPreferences()
|
|||
// See if we need to reapply expand optional parts mode
|
||||
if( cfg.preferences.alwaysExpandOptionalParts != p.alwaysExpandOptionalParts )
|
||||
{
|
||||
emit setExpandOptionalParts( p.alwaysExpandOptionalParts );
|
||||
// Signal setExpandOptionalParts reload all articles
|
||||
needReload = false;
|
||||
needReload = true;
|
||||
}
|
||||
|
||||
// See if we need to change help language
|
||||
|
@ -4199,18 +4180,6 @@ void MainWindow::forceAddWordToHistory( const QString & word )
|
|||
history.enableAdd( cfg.preferences.storeHistory );
|
||||
}
|
||||
|
||||
void MainWindow::setExpandMode( bool expand )
|
||||
{
|
||||
articleMaker.setExpandOptionalParts( expand );
|
||||
}
|
||||
|
||||
void MainWindow::switchExpandOptionalPartsMode()
|
||||
{
|
||||
ArticleView * view = getCurrentArticleView();
|
||||
if( view )
|
||||
view->switchExpandOptionalParts();
|
||||
}
|
||||
|
||||
void MainWindow::foundDictsPaneClicked( QListWidgetItem * item )
|
||||
{
|
||||
Qt::KeyboardModifiers m = QApplication::keyboardModifiers();
|
||||
|
|
|
@ -73,7 +73,6 @@ public slots:
|
|||
void phraseReceived( Config::InputPhrase const & );
|
||||
void wordReceived( QString const & );
|
||||
void headwordReceived( QString const &, QString const & );
|
||||
void setExpandMode( bool expand );
|
||||
void headwordFromFavorites( QString const &, QString const & );
|
||||
void quitApp();
|
||||
|
||||
|
@ -115,7 +114,7 @@ private:
|
|||
closeAllTabAction, closeRestTabAction,
|
||||
switchToNextTabAction, switchToPrevTabAction,
|
||||
showDictBarNamesAction, useSmallIconsInToolbarsAction, toggleMenuBarAction,
|
||||
switchExpandModeAction, focusHeadwordsDlgAction, focusArticleViewAction,
|
||||
focusHeadwordsDlgAction, focusArticleViewAction,
|
||||
addAllTabToFavoritesAction;
|
||||
QToolBar * navToolbar;
|
||||
MainStatusBar * mainStatusBar;
|
||||
|
@ -320,9 +319,6 @@ private slots:
|
|||
void switchToPrevTab();
|
||||
void ctrlReleased();
|
||||
|
||||
// Switch optional parts expand mode for current tab
|
||||
void switchExpandOptionalPartsMode();
|
||||
|
||||
// Handling of active tab list
|
||||
void createTabList();
|
||||
void fillWindowsMenu();
|
||||
|
@ -493,9 +489,6 @@ private slots:
|
|||
void inspectElement( QWebEnginePage * );
|
||||
|
||||
signals:
|
||||
/// Set optional parts expand mode for all tabs
|
||||
void setExpandOptionalParts( bool expand );
|
||||
|
||||
/// Retranslate Ctrl(Shift) + Click on dictionary pane to dictionary toolbar
|
||||
void clickOnDictPane( QString const & id );
|
||||
|
||||
|
|
|
@ -109,9 +109,6 @@ ScanPopup::ScanPopup( QWidget * parent,
|
|||
dictionaryBar.toggleViewAction()
|
||||
);
|
||||
|
||||
connect( this, &ScanPopup::switchExpandMode, definition, &ArticleView::switchExpandOptionalParts );
|
||||
connect( this, &ScanPopup::setViewExpandMode, definition, &ArticleView::receiveExpandOptionalParts );
|
||||
connect( definition, &ArticleView::setExpandMode, this, &ScanPopup::setExpandMode );
|
||||
connect( definition, &ArticleView::inspectSignal, this, &ScanPopup::inspectElementWhenPinned );
|
||||
connect( definition, &ArticleView::forceAddWordToHistory, this, &ScanPopup::forceAddWordToHistory );
|
||||
connect( this, &ScanPopup::closeMenu, definition, &ArticleView::closePopupMenu );
|
||||
|
|
|
@ -67,10 +67,8 @@ signals:
|
|||
void sendPhraseToMainWindow( Config::InputPhrase const & phrase );
|
||||
/// Close opened menus when window hide
|
||||
void closeMenu();
|
||||
/// Signals to set expand optional parts mode (retranslation from/to MainWindow and dictionary bar)
|
||||
void setExpandMode( bool expand );
|
||||
|
||||
void inspectSignal(QWebEnginePage * page);
|
||||
void setViewExpandMode( bool expand );
|
||||
/// Signal to switch expand optional parts mode
|
||||
void switchExpandMode();
|
||||
/// Signal to add word to history even if history is disabled
|
||||
|
|
|
@ -479,8 +479,6 @@ void ArticleView::showDefinition( Config::InputPhrase const & phrase, unsigned g
|
|||
// Any search opened is probably irrelevant now
|
||||
closeSearch();
|
||||
|
||||
emit setExpandMode( expandOptionalParts );
|
||||
|
||||
load( req );
|
||||
|
||||
//QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||
|
@ -531,8 +529,6 @@ void ArticleView::showDefinition( QString const & word, QStringList const & dict
|
|||
// Clear highlight all button selection
|
||||
searchPanel->highlightAll->setChecked( false );
|
||||
|
||||
emit setExpandMode( expandOptionalParts );
|
||||
|
||||
load( req );
|
||||
|
||||
webview->setCursor( Qt::WaitCursor );
|
||||
|
@ -2433,19 +2429,6 @@ void ArticleView::showEvent( QShowEvent * ev )
|
|||
ftsSearchPanel->hide();
|
||||
}
|
||||
|
||||
void ArticleView::receiveExpandOptionalParts( bool expand )
|
||||
{
|
||||
if( expandOptionalParts != expand )
|
||||
switchExpandOptionalParts();
|
||||
}
|
||||
|
||||
void ArticleView::switchExpandOptionalParts()
|
||||
{
|
||||
expandOptionalParts = !expandOptionalParts;
|
||||
emit setExpandMode( expandOptionalParts );
|
||||
reload();
|
||||
}
|
||||
|
||||
void ArticleView::copyAsText()
|
||||
{
|
||||
QString text = webview->selectedText();
|
||||
|
|
|
@ -291,9 +291,6 @@ signals:
|
|||
/// Signal to close popup menu
|
||||
void closePopupMenu();
|
||||
|
||||
/// Signal to set optional parts expand mode
|
||||
void setExpandMode ( bool expand );
|
||||
|
||||
void sendWordToInputLine( QString const & word );
|
||||
|
||||
void storeResourceSavePath(QString const & );
|
||||
|
@ -318,10 +315,6 @@ public slots:
|
|||
/// Handles F3 and Shift+F3 for search navigation
|
||||
bool handleF3( QObject * obj, QEvent * ev );
|
||||
|
||||
/// Control optional parts expanding
|
||||
void receiveExpandOptionalParts( bool expand );
|
||||
void switchExpandOptionalParts();
|
||||
|
||||
/// Selects an entire text of the current article
|
||||
void selectCurrentArticle();
|
||||
//receive signal from weburlinterceptor.
|
||||
|
|
Loading…
Reference in a new issue