mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
opt: do not show dictionary menu when set the dictionary count=0 (#1652)
* opt: do not show dictionary menu when set the dictionary count=0 * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
6486e7b57c
commit
7669316bcd
|
@ -1610,32 +1610,34 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
|
||||||
unsigned refsAdded = 0;
|
unsigned refsAdded = 0;
|
||||||
bool maxDictionaryRefsReached = false;
|
bool maxDictionaryRefsReached = false;
|
||||||
|
|
||||||
for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i, ++refsAdded ) {
|
if ( cfg.preferences.maxDictionaryRefsInContextMenu > 0 ) {
|
||||||
// Find this dictionary
|
for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i, ++refsAdded ) {
|
||||||
|
// Find this dictionary
|
||||||
|
|
||||||
auto dictionary = dictionaryGroup->getDictionaryById( i->toUtf8().data() );
|
auto dictionary = dictionaryGroup->getDictionaryById( i->toUtf8().data() );
|
||||||
if ( dictionary ) {
|
if ( dictionary ) {
|
||||||
QAction * action = nullptr;
|
QAction * action = nullptr;
|
||||||
if ( refsAdded == cfg.preferences.maxDictionaryRefsInContextMenu ) {
|
if ( refsAdded == cfg.preferences.maxDictionaryRefsInContextMenu ) {
|
||||||
// Enough! Or the menu would become too large.
|
// Enough! Or the menu would become too large.
|
||||||
maxDictionaryRefsAction = new QAction( ".........", &menu );
|
maxDictionaryRefsAction = new QAction( ".........", &menu );
|
||||||
action = maxDictionaryRefsAction;
|
action = maxDictionaryRefsAction;
|
||||||
maxDictionaryRefsReached = true;
|
maxDictionaryRefsReached = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
action = new QAction( dictionary->getIcon(), QString::fromUtf8( dictionary->getName().c_str() ), &menu );
|
action = new QAction( dictionary->getIcon(), QString::fromUtf8( dictionary->getName().c_str() ), &menu );
|
||||||
// Force icons in menu on all platforms,
|
// Force icons in menu on all platforms,
|
||||||
// since without them it will be much harder
|
// since without them it will be much harder
|
||||||
// to find things.
|
// to find things.
|
||||||
action->setIconVisibleInMenu( true );
|
action->setIconVisibleInMenu( true );
|
||||||
}
|
}
|
||||||
menu.addAction( action );
|
menu.addAction( action );
|
||||||
|
|
||||||
tableOfContents[ action ] = *i;
|
tableOfContents[ action ] = *i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( maxDictionaryRefsReached )
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( maxDictionaryRefsReached )
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
Loading…
Reference in a new issue