mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
Clean up accessing system setting values for a specific player.
Remove the ugly "save, change and restore platform" accesses and extend the settings class to allow accessing player specific system values. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22254 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9a5174c8a3
commit
6cea3308d0
3 changed files with 44 additions and 25 deletions
|
@ -220,6 +220,25 @@ void RbSettings::setSubValue(QString sub, enum UserSettings setting, QVariant va
|
||||||
userSettings->setValue(s, value);
|
userSettings->setValue(s, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QVariant RbSettings::platformValue(QString platform, enum SystemSettings setting)
|
||||||
|
{
|
||||||
|
ensureRbSettingsExists();
|
||||||
|
|
||||||
|
// locate setting item
|
||||||
|
int i = 0;
|
||||||
|
while(SystemSettingsList[i].setting != setting)
|
||||||
|
i++;
|
||||||
|
|
||||||
|
QString s = SystemSettingsList[i].name;
|
||||||
|
s.replace(":platform:", platform);
|
||||||
|
QString d = SystemSettingsList[i].def;
|
||||||
|
d.replace(":platform:", platform);
|
||||||
|
qDebug() << "[Settings] GET P:" << s << systemSettings->value(s, d).toString();
|
||||||
|
return systemSettings->value(s, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList RbSettings::platforms()
|
QStringList RbSettings::platforms()
|
||||||
{
|
{
|
||||||
ensureRbSettingsExists();
|
ensureRbSettingsExists();
|
||||||
|
@ -250,6 +269,7 @@ QStringList RbSettings::languages()
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString RbSettings::name(QString platform)
|
QString RbSettings::name(QString platform)
|
||||||
{
|
{
|
||||||
ensureRbSettingsExists();
|
ensureRbSettingsExists();
|
||||||
|
|
|
@ -114,7 +114,7 @@ class RbSettings : public QObject
|
||||||
static QMap<int, QString> usbIdMap(enum MapType);
|
static QMap<int, QString> usbIdMap(enum MapType);
|
||||||
//! get a value from system settings
|
//! get a value from system settings
|
||||||
static QVariant value(enum SystemSettings setting);
|
static QVariant value(enum SystemSettings setting);
|
||||||
//! get a vaulue from user settings
|
//! get a value from user settings
|
||||||
static QVariant value(enum UserSettings setting);
|
static QVariant value(enum UserSettings setting);
|
||||||
//! set a user setting value
|
//! set a user setting value
|
||||||
static void setValue(enum UserSettings setting , QVariant value);
|
static void setValue(enum UserSettings setting , QVariant value);
|
||||||
|
@ -122,6 +122,8 @@ class RbSettings : public QObject
|
||||||
static QVariant subValue(QString sub, enum UserSettings setting);
|
static QVariant subValue(QString sub, enum UserSettings setting);
|
||||||
//! set a user setting from a subvalue (ie for encoders and tts engines)
|
//! set a user setting from a subvalue (ie for encoders and tts engines)
|
||||||
static void setSubValue(QString sub, enum UserSettings setting, QVariant value);
|
static void setSubValue(QString sub, enum UserSettings setting, QVariant value);
|
||||||
|
//! get a value from system settings for a named platform.
|
||||||
|
static QVariant platformValue(QString platform, enum SystemSettings setting);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! you shouldnt call this, its a fully static calls
|
//! you shouldnt call this, its a fully static calls
|
||||||
|
@ -137,3 +139,4 @@ class RbSettings : public QObject
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -367,18 +367,14 @@ void Config::updateTtsState(int index)
|
||||||
|
|
||||||
void Config::updateEncState()
|
void Config::updateEncState()
|
||||||
{
|
{
|
||||||
// FIXME: this is a workaround to make the encoder follow the device selection
|
|
||||||
// even with the settings (and thus the device) being saved. Needs to be redone
|
|
||||||
// properly later by extending the settings object
|
|
||||||
if(ui.treeDevices->selectedItems().size() == 0)
|
if(ui.treeDevices->selectedItems().size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
||||||
QString olddevice = RbSettings::value(RbSettings::Platform).toString();
|
QString encoder = RbSettings::platformValue(devname,
|
||||||
RbSettings::setValue(RbSettings::Platform, devname);
|
RbSettings::CurEncoder).toString();
|
||||||
QString encoder = RbSettings::value(RbSettings::CurEncoder).toString();
|
ui.encoderName->setText(EncBase::getEncoderName(RbSettings::platformValue(devname,
|
||||||
ui.encoderName->setText(EncBase::getEncoderName(RbSettings::value(RbSettings::CurEncoder).toString()));
|
RbSettings::CurEncoder).toString()));
|
||||||
RbSettings::setValue(RbSettings::Platform, olddevice);
|
|
||||||
|
|
||||||
EncBase* enc = EncBase::getEncoder(this,encoder);
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
||||||
|
|
||||||
|
@ -673,14 +669,16 @@ void Config::testTts()
|
||||||
TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
|
TTSBase* tts = TTSBase::getTTS(this,ui.comboTts->itemData(index).toString());
|
||||||
if(!tts->configOk())
|
if(!tts->configOk())
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this,tr("TTS configuration invalid"),tr("TTS configuration invalid. \n Please configure TTS engine."));
|
QMessageBox::warning(this,tr("TTS configuration invalid"),
|
||||||
|
tr("TTS configuration invalid. \n Please configure TTS engine."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!tts->start(&errstr))
|
if(!tts->start(&errstr))
|
||||||
{
|
{
|
||||||
QMessageBox::warning(this,tr("Could not start TTS engine"),tr("Could not start TTS engine.\n") + errstr
|
QMessageBox::warning(this,tr("Could not start TTS engine"),
|
||||||
+tr("\nPlease configure TTS engine."));
|
tr("Could not start TTS engine.\n") + errstr
|
||||||
|
+ tr("\nPlease configure TTS engine."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,11 +690,12 @@ void Config::testTts()
|
||||||
if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError)
|
if(tts->voice(tr("Rockbox Utility Voice Test"),filename,&errstr) == FatalError)
|
||||||
{
|
{
|
||||||
tts->stop();
|
tts->stop();
|
||||||
QMessageBox::warning(this,tr("Could not voice test string"),tr("Could not voice test string.\n") + errstr
|
QMessageBox::warning(this,tr("Could not voice test string"),
|
||||||
+tr("\nPlease configure TTS engine."));
|
tr("Could not voice test string.\n") + errstr
|
||||||
|
+ tr("\nPlease configure TTS engine."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tts->stop();
|
tts->stop();
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
QString exe = findExecutable("aplay");
|
QString exe = findExecutable("aplay");
|
||||||
if(exe == "") exe = findExecutable("play");
|
if(exe == "") exe = findExecutable("play");
|
||||||
|
@ -704,25 +703,21 @@ void Config::testTts()
|
||||||
{
|
{
|
||||||
QProcess::execute(exe+" "+filename);
|
QProcess::execute(exe+" "+filename);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
QSound::play(filename);
|
QSound::play(filename);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::configEnc()
|
void Config::configEnc()
|
||||||
{
|
{
|
||||||
// FIXME: this is a workaround to make the encoder follow the device selection
|
|
||||||
// even with the settings (and thus the device) being saved. Needs to be redone
|
|
||||||
// properly later by extending the settings object
|
|
||||||
if(ui.treeDevices->selectedItems().size() == 0)
|
if(ui.treeDevices->selectedItems().size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
QString devname = ui.treeDevices->selectedItems().at(0)->data(0, Qt::UserRole).toString();
|
||||||
QString olddevice = RbSettings::value(RbSettings::CurrentPlatform).toString();
|
QString encoder = RbSettings::platformValue(devname,
|
||||||
RbSettings::setValue(RbSettings::CurrentPlatform,devname);
|
RbSettings::CurEncoder).toString();
|
||||||
QString encoder = RbSettings::value(RbSettings::CurEncoder).toString();
|
ui.encoderName->setText(EncBase::getEncoderName(RbSettings::platformValue(devname,
|
||||||
ui.encoderName->setText(EncBase::getEncoderName(RbSettings::value(RbSettings::CurEncoder).toString()));
|
RbSettings::CurEncoder).toString()));
|
||||||
RbSettings::setValue(RbSettings::CurrentPlatform,olddevice);
|
|
||||||
|
|
||||||
|
|
||||||
EncBase* enc = EncBase::getEncoder(this,encoder);
|
EncBase* enc = EncBase::getEncoder(this,encoder);
|
||||||
|
@ -732,3 +727,4 @@ void Config::configEnc()
|
||||||
|
|
||||||
updateEncState();
|
updateEncState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue