diff options
-rw-r--r-- | core/qthelper.cpp | 31 | ||||
-rw-r--r-- | core/qthelper.h | 2 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDiveInformation.cpp | 2 |
3 files changed, 24 insertions, 11 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 203234f05..f8c06d755 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -626,16 +626,34 @@ QString get_salinity_string(int salinity) return QStringLiteral("%L1%2").arg(salinity / 10.0).arg(gettextFromC::tr("g/ℓ")); } +// the water types need to match the watertypes enum +static const char *waterTypes[] = { + QT_TRANSLATE_NOOP("gettextFromC", "Fresh"), + QT_TRANSLATE_NOOP("gettextFromC", "Brackish"), + QT_TRANSLATE_NOOP("gettextFromC", "EN13319"), + QT_TRANSLATE_NOOP("gettextFromC", "Salt"), + QT_TRANSLATE_NOOP("gettextFromC", "Use DC") +}; + QString get_water_type_string(int salinity) { if (salinity < 10050) - return waterTypes[FRESHWATER]; + return gettextFromC::tr(waterTypes[FRESHWATER]); else if (salinity < 10190) - return waterTypes[BRACKISHWATER]; + return gettextFromC::tr(waterTypes[BRACKISHWATER]); else if (salinity < 10210) - return waterTypes[EN13319WATER]; + return gettextFromC::tr(waterTypes[EN13319WATER]); else - return waterTypes[SALTWATER]; + return gettextFromC::tr(waterTypes[SALTWATER]); +} + +QStringList getWaterTypesAsString() +{ + QStringList res; + res.reserve(std::end(waterTypes) - std::begin(waterTypes)); // Waiting for C++17's std::size() + for (const char *t: waterTypes) + res.push_back(gettextFromC::tr(t)); + return res; } QString getSubsurfaceDataPath(QString folderToFind) @@ -1178,11 +1196,6 @@ QString localFilePath(const QString &originalFilename) return localFilenameOf.value(originalFilename, originalFilename); } -// the water types need to match the watertypes enum -const QStringList waterTypes = { - gettextFromC::tr("Fresh"), gettextFromC::tr("Brackish"), gettextFromC::tr("EN13319"), gettextFromC::tr("Salt"), gettextFromC::tr("Use DC") -}; - // TODO: Apparently Qt has no simple way of listing the supported video // codecs? Do we have to query them by hand using QMediaPlayer::hasSupport()? const QStringList videoExtensionsList = { diff --git a/core/qthelper.h b/core/qthelper.h index a3394e684..16303fe7d 100644 --- a/core/qthelper.h +++ b/core/qthelper.h @@ -38,7 +38,7 @@ int getCloudURL(QString &filename); bool parseGpsText(const QString &gps_text, double *latitude, double *longitude); void init_proxy(); QString getUUID(); -extern const QStringList waterTypes; +QStringList getWaterTypesAsString(); extern const QStringList videoExtensionsList; QStringList mediaExtensionFilters(); QStringList imageExtensionFilters(); diff --git a/desktop-widgets/tab-widgets/TabDiveInformation.cpp b/desktop-widgets/tab-widgets/TabDiveInformation.cpp index eeb6d30cc..99ac898a4 100644 --- a/desktop-widgets/tab-widgets/TabDiveInformation.cpp +++ b/desktop-widgets/tab-widgets/TabDiveInformation.cpp @@ -27,7 +27,7 @@ TabDiveInformation::TabDiveInformation(QWidget *parent) : TabBase(parent), ui(ne QStringList atmPressTypes { "mbar", get_depth_unit() ,tr("Use DC")}; ui->atmPressType->insertItems(0, atmPressTypes); pressTypeIndex = 0; - ui->waterTypeCombo->insertItems(0, waterTypes); + ui->waterTypeCombo->insertItems(0, getWaterTypesAsString()); // This needs to be the same order as enum dive_comp_type in dive.h! QStringList types; |