diff options
Diffstat (limited to 'qt_helpers.cpp')
| -rw-r--r-- | qt_helpers.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/qt_helpers.cpp b/qt_helpers.cpp index dd474e19..5e4b233a 100644 --- a/qt_helpers.cpp +++ b/qt_helpers.cpp @@ -6,6 +6,8 @@ #include <QStyle> #include <QVariant> #include <QDateTime> +#include <QCoreApplication> +#include <QDir> QString font_as_stylesheet (QFont const& font) { @@ -48,3 +50,21 @@ QDateTime qt_truncate_date_time_to (QDateTime dt, int milliseconds) dt.setMSecsSinceEpoch (dt.toMSecsSinceEpoch () / milliseconds * milliseconds); return dt; } + +QString app_sounds_directory (QString const& subdirectory) +{ +#if defined (__APPLE__) + QString root {QCoreApplication::applicationDirPath () + "/../Resources/sounds"}; +#else + QString root {QCoreApplication::applicationDirPath () + "/sounds"}; +#endif + auto child = subdirectory; + while (child.startsWith (QChar {'/'})) + { + child.remove (0, 1); + } + + QDir dir {root}; + auto path = child.isEmpty () ? dir.absolutePath () : dir.absoluteFilePath (child); + return QDir::cleanPath (path) + QChar {'/'}; +} |
