diff --git a/config.cc b/config.cc
index 48ca3103..ee7f1358 100644
--- a/config.cc
+++ b/config.cc
@@ -182,14 +182,24 @@ InputPhrase Preferences::sanitizeInputPhrase( QString const & inputPhrase ) cons
{
InputPhrase result;
- if( limitInputPhraseLength && inputPhrase.size() > inputPhraseLengthLimit )
+ QString _phase = inputPhrase;
+ if( stripClipboard )
+ {
+ auto parts = inputPhrase.split( QChar::LineFeed, Qt::SkipEmptyParts );
+ if( !parts.empty() )
+ {
+ _phase = parts[ 0 ];
+ }
+ }
+
+ if( limitInputPhraseLength && _phase.size() > inputPhraseLengthLimit )
{
gdDebug( "Ignoring an input phrase %d symbols long. The configured maximum input phrase length is %d symbols.",
- inputPhrase.size(), inputPhraseLengthLimit );
+ _phase.size(), inputPhraseLengthLimit );
return result;
}
- const QString withPunct = inputPhrase.simplified();
+ const QString withPunct = _phase.simplified();
result.phrase = gd::toQString( Folding::trimWhitespaceOrPunct( gd::toWString( withPunct ) ) );
if ( !result.isValid() )
return result; // The suffix of an invalid input phrase must be empty.
@@ -267,6 +277,7 @@ Preferences::Preferences():
, inputPhraseLengthLimit( 1000 )
, maxDictionaryRefsInContextMenu ( 20 )
, synonymSearchEnabled( true )
+ , stripClipboard( false )
{
}
@@ -1005,6 +1016,9 @@ Class load()
if ( !preferences.namedItem( "synonymSearchEnabled" ).isNull() )
c.preferences.synonymSearchEnabled = ( preferences.namedItem( "synonymSearchEnabled" ).toElement().text() == "1" );
+ if ( !preferences.namedItem( "stripClipboard" ).isNull() )
+ c.preferences.stripClipboard = ( preferences.namedItem( "stripClipboard" ).toElement().text() == "1" );
+
QDomNode fts = preferences.namedItem( "fullTextSearch" );
if ( !fts.isNull() )
@@ -1960,6 +1974,10 @@ void save( Class const & c )
opt.appendChild( dd.createTextNode( c.preferences.synonymSearchEnabled ? "1" : "0" ) );
preferences.appendChild( opt );
+ opt = dd.createElement( "stripClipboard" );
+ opt.appendChild( dd.createTextNode( c.preferences.stripClipboard ? "1" : "0" ) );
+ preferences.appendChild( opt );
+
{
QDomNode hd = dd.createElement( "fullTextSearch" );
preferences.appendChild( hd );
diff --git a/config.hh b/config.hh
index b2ce2d7c..71b39ed4 100644
--- a/config.hh
+++ b/config.hh
@@ -372,6 +372,7 @@ struct Preferences
unsigned short maxDictionaryRefsInContextMenu;
bool synonymSearchEnabled;
+ bool stripClipboard;
QString addonStyle;
diff --git a/preferences.cc b/preferences.cc
index f08380b5..4c5cffc3 100644
--- a/preferences.cc
+++ b/preferences.cc
@@ -227,6 +227,8 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.synonymSearchEnabled->setChecked( p.synonymSearchEnabled );
+ ui.stripClipboard->setChecked( p.stripClipboard );
+
ui.maxDictsInContextMenu->setValue( p.maxDictionaryRefsInContextMenu );
// Different platforms have different keys available
@@ -443,6 +445,7 @@ Config::Preferences Preferences::getPreferences()
p.inputPhraseLengthLimit = ui.inputPhraseLengthLimit->value();
p.ignoreDiacritics = ui.ignoreDiacritics->isChecked();
p.ignorePunctuation = ui.ignorePunctuation->isChecked();
+ p.stripClipboard = ui.stripClipboard->isChecked();
p.synonymSearchEnabled = ui.synonymSearchEnabled->isChecked();
diff --git a/preferences.ui b/preferences.ui
index f3c0403b..4a670971 100644
--- a/preferences.ui
+++ b/preferences.ui
@@ -1743,6 +1743,13 @@ from Stardict, Babylon and GLS dictionaries
+ -
+
+
+ When using clipboard,strip everything after newline
+
+
+
-