Don't show some context menu items for selection with spaces only

This commit is contained in:
Abs62 2017-04-24 17:41:07 +03:00
parent 923d7850cc
commit bef8e2f8ac

View file

@ -1586,13 +1586,13 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
#endif #endif
QString selectedText = ui.definition->selectedText(); QString selectedText = ui.definition->selectedText();
QString text = selectedText.trimmed();
if ( selectedText.size() && selectedText.size() < 60 ) if ( text.size() && text.size() < 60 )
{ {
// We don't prompt for selections larger or equal to 60 chars, since // We don't prompt for selections larger or equal to 60 chars, since
// it ruins the menu and it's hardly a single word anyway. // it ruins the menu and it's hardly a single word anyway.
QString text = ui.definition->selectedText();
if( text.isRightToLeft() ) if( text.isRightToLeft() )
{ {
text.insert( 0, (ushort)0x202E ); // RLE, Right-to-Left Embedding text.insert( 0, (ushort)0x202E ); // RLE, Right-to-Left Embedding
@ -1633,7 +1633,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
QIcon(); QIcon();
lookupSelectionGr = new QAction( icon, tr( "Look up \"%1\" in %2" ). lookupSelectionGr = new QAction( icon, tr( "Look up \"%1\" in %2" ).
arg( ui.definition->selectedText() ). arg( text ).
arg( altGroup->name ), &menu ); arg( altGroup->name ), &menu );
menu.addAction( lookupSelectionGr ); menu.addAction( lookupSelectionGr );
@ -1641,14 +1641,14 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
{ {
lookupSelectionNewTabGr = new QAction( QIcon( ":/icons/addtab.png" ), lookupSelectionNewTabGr = new QAction( QIcon( ":/icons/addtab.png" ),
tr( "Look up \"%1\" in %2 in &New Tab" ). tr( "Look up \"%1\" in %2 in &New Tab" ).
arg( ui.definition->selectedText() ). arg( text ).
arg( altGroup->name ), &menu ); arg( altGroup->name ), &menu );
menu.addAction( lookupSelectionNewTabGr ); menu.addAction( lookupSelectionNewTabGr );
} }
} }
} }
if( selectedText.isEmpty() && !cfg.preferences.storeHistory) if( text.isEmpty() && !cfg.preferences.storeHistory)
{ {
QString txt = ui.definition->title(); QString txt = ui.definition->title();
if( txt.size() > 60 ) if( txt.size() > 60 )