Remove redundant option useExternalPlayer from Preferences

This change substantially reduces audio player configuration code
complexity. The single remaining bool option - useInternalPlayer -
is enough for the binary audio player implementation choice.

Removing the useExternalPlayer option doesn't change the application GUI
behavior except for minor differences in one or two corner cases, which
could be classified as bugs fixed by this commit. For example, before
this commit, if the configuration file contained the following lines
  <useExternalPlayer>0</useExternalPlayer>
  <useInternalPlayer>0</useInternalPlayer>
an external player would be actually used for audio playback, but
neither of the two audio radio buttons would be checked in
Preferences GUI, and audioPlaybackProgram line edit would be disabled.
Whereas, after this commit, an external player is still used for
audio playback, but useExternalPlayer radio button is checked
in Preferences GUI, and the audioPlaybackProgram line edit is enabled.
This commit is contained in:
Igor Kushnir 2018-03-25 17:09:35 +03:00
parent 6a77c23986
commit d5998cabb7
3 changed files with 1 additions and 13 deletions

View file

@ -115,10 +115,8 @@ Preferences::Preferences():
pronounceOnLoadMain( false ),
pronounceOnLoadPopup( false ),
#ifndef DISABLE_INTERNAL_PLAYER
useExternalPlayer( false ),
useInternalPlayer( true ),
#else
useExternalPlayer( true ),
useInternalPlayer( false ),
#endif
checkForNewReleases( true ),
@ -771,15 +769,11 @@ Class load() throw( exError )
c.preferences.pronounceOnLoadMain = ( preferences.namedItem( "pronounceOnLoadMain" ).toElement().text() == "1" );
c.preferences.pronounceOnLoadPopup = ( preferences.namedItem( "pronounceOnLoadPopup" ).toElement().text() == "1" );
if ( !preferences.namedItem( "useExternalPlayer" ).isNull() )
c.preferences.useExternalPlayer = ( preferences.namedItem( "useExternalPlayer" ).toElement().text() == "1" );
#ifndef DISABLE_INTERNAL_PLAYER
if ( !preferences.namedItem( "useInternalPlayer" ).isNull() )
c.preferences.useInternalPlayer = ( preferences.namedItem( "useInternalPlayer" ).toElement().text() == "1" );
#else
c.preferences.useInternalPlayer = false;
c.preferences.useExternalPlayer = true;
#endif
if ( !preferences.namedItem( "audioPlaybackProgram" ).isNull() )
@ -1662,10 +1656,6 @@ void save( Class const & c ) throw( exError )
opt.appendChild( dd.createTextNode( c.preferences.pronounceOnLoadPopup ? "1" : "0" ) );
preferences.appendChild( opt );
opt = dd.createElement( "useExternalPlayer" );
opt.appendChild( dd.createTextNode( c.preferences.useExternalPlayer ? "1" : "0" ) );
preferences.appendChild( opt );
opt = dd.createElement( "useInternalPlayer" );
opt.appendChild( dd.createTextNode( c.preferences.useInternalPlayer ? "1" : "0" ) );
preferences.appendChild( opt );

View file

@ -223,7 +223,6 @@ struct Preferences
// Whether the word should be pronounced on page load, in main window/popup
bool pronounceOnLoadMain, pronounceOnLoadPopup;
QString audioPlaybackProgram;
bool useExternalPlayer;
bool useInternalPlayer;
ProxyServer proxyServer;

View file

@ -250,7 +250,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ):
ui.useInternalPlayer->setChecked( true );
else
#endif
ui.useExternalPlayer->setChecked( p.useExternalPlayer );
ui.useExternalPlayer->setChecked( true );
ui.audioPlaybackProgram->setText( p.audioPlaybackProgram );
@ -399,7 +399,6 @@ Config::Preferences Preferences::getPreferences()
p.pronounceOnLoadMain = ui.pronounceOnLoadMain->isChecked();
p.pronounceOnLoadPopup = ui.pronounceOnLoadPopup->isChecked();
p.useExternalPlayer = ui.useExternalPlayer->isChecked();
p.useInternalPlayer = ui.useInternalPlayer->isChecked();
p.audioPlaybackProgram = ui.audioPlaybackProgram->text();