Skip to content

Commit

Permalink
fix(sfx): sfx playback name should conv to camelCase
Browse files Browse the repository at this point in the history
Change-Id: I6a1e024be4031f1d5b814fc4c05d8d008c2e24a8
  • Loading branch information
BLumia committed Jul 9, 2018
1 parent 1242bf6 commit 870cf29
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions src/util/ddesktopservices_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,41 @@ static QString soundEffectFilePath(const QString &name)
return QString();
}

/*!
* \brief Converts \p name from 'key-name' notation
* to camel case 'keyName' or 'KeyName'.
* This function converts GSettings key names to names
* suitable for Qt getters and setters.
*
* Well fsck this.
*
* \param name key name
* \return key name converted to camel case
* \internal
*/
static QString GSettingsKeyToCamelCase(const QString name)
{
QStringList parts = name.split('-', QString::SkipEmptyParts);
for (int i=1; i<parts.size(); ++i)
parts[i][0] = parts[i][0].toUpper();

return parts.join("");
}

static bool systemSoundEffectEnabled(const QString &name)
{
QGSettings settings("com.deepin.dde.sound-effect");

const bool effEnabled = settings.get("enabled").toBool();
QString newName = GSettingsKeyToCamelCase(name);

if (effEnabled) {
const QStringList list = settings.keys();
if (!list.contains(name)) {
if (!list.contains(newName)) {
return false;
}

return settings.get(name).toBool();
return settings.get(newName).toBool();
}

return effEnabled;
Expand Down

0 comments on commit 870cf29

Please sign in to comment.