articleSizeLimit option: minor code cleanup

When an integral value is converted to a signed integer type, if the
result is not representable, the resulting value is implementation
defined (until C++20). Convert the string value from configuration file
to the target type (int) to avoid the redundant type conversion.

Use the more direct and efficient QSpinBox::value() instead of
QAbstractSpinBox::text().toInt().
This commit is contained in:
Igor Kushnir 2020-11-06 21:51:44 +02:00
parent 63aeb0ef6d
commit 0b7c65023c
2 changed files with 2 additions and 2 deletions

View file

@ -907,7 +907,7 @@ Class load() THROW_SPEC( exError )
c.preferences.collapseBigArticles = ( preferences.namedItem( "collapseBigArticles" ).toElement().text() == "1" ); c.preferences.collapseBigArticles = ( preferences.namedItem( "collapseBigArticles" ).toElement().text() == "1" );
if ( !preferences.namedItem( "articleSizeLimit" ).isNull() ) if ( !preferences.namedItem( "articleSizeLimit" ).isNull() )
c.preferences.articleSizeLimit = preferences.namedItem( "articleSizeLimit" ).toElement().text().toUInt() ; c.preferences.articleSizeLimit = preferences.namedItem( "articleSizeLimit" ).toElement().text().toInt();
if ( !preferences.namedItem( "maxDictionaryRefsInContextMenu" ).isNull() ) if ( !preferences.namedItem( "maxDictionaryRefsInContextMenu" ).isNull() )
c.preferences.maxDictionaryRefsInContextMenu = preferences.namedItem( "maxDictionaryRefsInContextMenu" ).toElement().text().toUShort(); c.preferences.maxDictionaryRefsInContextMenu = preferences.namedItem( "maxDictionaryRefsInContextMenu" ).toElement().text().toUShort();

View file

@ -417,7 +417,7 @@ Config::Preferences Preferences::getPreferences()
p.confirmFavoritesDeletion = ui.confirmFavoritesDeletion->isChecked(); p.confirmFavoritesDeletion = ui.confirmFavoritesDeletion->isChecked();
p.collapseBigArticles = ui.collapseBigArticles->isChecked(); p.collapseBigArticles = ui.collapseBigArticles->isChecked();
p.articleSizeLimit = ui.articleSizeLimit->text().toInt(); p.articleSizeLimit = ui.articleSizeLimit->value();
p.ignoreDiacritics = ui.ignoreDiacritics->isChecked(); p.ignoreDiacritics = ui.ignoreDiacritics->isChecked();
p.synonymSearchEnabled = ui.synonymSearchEnabled->isChecked(); p.synonymSearchEnabled = ui.synonymSearchEnabled->isChecked();