Skip to content

Commit

Permalink
opt: do not show dictionary menu when set the dictionary count=0 (#1652)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
xiaoyifang and autofix-ci[bot] authored Jul 8, 2024
1 parent 6486e7b commit 7669316
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/ui/articleview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1610,32 +1610,34 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
unsigned refsAdded = 0;
bool maxDictionaryRefsReached = false;

for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i, ++refsAdded ) {
// Find this dictionary

auto dictionary = dictionaryGroup->getDictionaryById( i->toUtf8().data() );
if ( dictionary ) {
QAction * action = nullptr;
if ( refsAdded == cfg.preferences.maxDictionaryRefsInContextMenu ) {
// Enough! Or the menu would become too large.
maxDictionaryRefsAction = new QAction( ".........", &menu );
action = maxDictionaryRefsAction;
maxDictionaryRefsReached = true;
}
else {
action = new QAction( dictionary->getIcon(), QString::fromUtf8( dictionary->getName().c_str() ), &menu );
// Force icons in menu on all platforms,
// since without them it will be much harder
// to find things.
action->setIconVisibleInMenu( true );
if ( cfg.preferences.maxDictionaryRefsInContextMenu > 0 ) {
for ( QStringList::const_iterator i = ids.constBegin(); i != ids.constEnd(); ++i, ++refsAdded ) {
// Find this dictionary

auto dictionary = dictionaryGroup->getDictionaryById( i->toUtf8().data() );
if ( dictionary ) {
QAction * action = nullptr;
if ( refsAdded == cfg.preferences.maxDictionaryRefsInContextMenu ) {
// Enough! Or the menu would become too large.
maxDictionaryRefsAction = new QAction( ".........", &menu );
action = maxDictionaryRefsAction;
maxDictionaryRefsReached = true;
}
else {
action = new QAction( dictionary->getIcon(), QString::fromUtf8( dictionary->getName().c_str() ), &menu );
// Force icons in menu on all platforms,
// since without them it will be much harder
// to find things.
action->setIconVisibleInMenu( true );
}
menu.addAction( action );

tableOfContents[ action ] = *i;
}
menu.addAction( action );

tableOfContents[ action ] = *i;
if ( maxDictionaryRefsReached )
break;
}

if ( maxDictionaryRefsReached )
break;
}

menu.addSeparator();
Expand Down

0 comments on commit 7669316

Please sign in to comment.