summaryrefslogtreecommitdiff
path: root/qt_helpers.cpp
diff options
context:
space:
mode:
authorChristoph Berg <myon@debian.org>2026-06-22 12:03:55 +0200
committerChristoph Berg <myon@debian.org>2026-06-22 12:03:55 +0200
commitde18fc13175a5bf0e2b48a042d2fc06e87c88d24 (patch)
treef517074cd603d30eb7ba7e2122d38051e4c1439c /qt_helpers.cpp
parentb76e8361909e47f0937d4a64a5a4cb5939f51eb7 (diff)
parentd83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff)
Update upstream source from tag 'upstream/3.0.2+dfsg'
Update to upstream version '3.0.2+dfsg' with Debian dir 90381fe7be9f5ea84d9b16c9cccf200a3fbe138b
Diffstat (limited to 'qt_helpers.cpp')
-rw-r--r--qt_helpers.cpp20
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 {'/'};
+}