diff options
| author | Christoph Berg <myon@debian.org> | 2026-06-22 12:03:44 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-06-22 12:03:44 +0200 |
| commit | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (patch) | |
| tree | 6d9c83527c56458a8360ba080bf5f4ca73d526dc /qt_helpers.cpp | |
| parent | 4b089ae3f7e9e2d5662f718f663b26a4e8ee63ca (diff) | |
New upstream version 3.0.2+dfsgupstream/3.0.2+dfsg
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 {'/'}; +} |
