all repos — mgba @ 17fa98fe4e90de445af406e962d1b49ce8865265

mGBA Game Boy Advance Emulator

Qt: ConfigController::getOption now has a default argument
Vicki Pfau vi@endrift.com
Thu, 03 Aug 2017 22:20:32 -0700
commit

17fa98fe4e90de445af406e962d1b49ce8865265

parent

75e609f65cec1e3e7336f305dda75eac4e17f0ab

2 files changed, 10 insertions(+), 6 deletions(-)

jump to
M src/platform/qt/ConfigController.cppsrc/platform/qt/ConfigController.cpp

@@ -158,12 +158,16 @@ }

m_optionSet[optionName]->setValue(mCoreConfigGetValue(&m_config, key)); } -QString ConfigController::getOption(const char* key) const { - return QString(mCoreConfigGetValue(&m_config, key)); +QString ConfigController::getOption(const char* key, const QVariant& defaultVal) const { + const char* val = mCoreConfigGetValue(&m_config, key); + if (val) { + return QString(val); + } + return defaultVal.toString(); } -QString ConfigController::getOption(const QString& key) const { - return getOption(key.toUtf8().constData()); +QString ConfigController::getOption(const QString& key, const QVariant& defaultVal) const { + return getOption(key.toUtf8().constData(), defaultVal); } QVariant ConfigController::getQtOption(const QString& key, const QString& group) const {
M src/platform/qt/ConfigController.hsrc/platform/qt/ConfigController.h

@@ -70,8 +70,8 @@

ConfigOption* addOption(const char* key); void updateOption(const char* key); - QString getOption(const char* key) const; - QString getOption(const QString& key) const; + QString getOption(const char* key, const QVariant& defaultVal = QVariant()) const; + QString getOption(const QString& key, const QVariant& defaultVal = QVariant()) const; QVariant getQtOption(const QString& key, const QString& group = QString()) const;