mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T730, adjusted audio settings for new notification sounds
* utility functions, find most appropriate file * PTT blocked, removed voice rooms
This commit is contained in:
committed by
Mat Sutcliffe
parent
e33e06b21e
commit
b207c9c944
@@ -11,7 +11,9 @@
|
||||
#include <QChar>
|
||||
#include <QtGlobal>
|
||||
#include <QStringBuilder>
|
||||
#include <QDir>
|
||||
|
||||
#include "blackmisc/directoryutils.h"
|
||||
#include "blackmisc/fileutils.h"
|
||||
|
||||
using namespace BlackMisc::Audio;
|
||||
@@ -55,6 +57,22 @@ namespace BlackMisc
|
||||
m_notificationSoundDir = d;
|
||||
}
|
||||
|
||||
const QString &CSettings::getNotificationSoundDirectoryOrDefault() const
|
||||
{
|
||||
if (!m_notificationSoundDir.isEmpty())
|
||||
{
|
||||
const QDir d(m_notificationSoundDir);
|
||||
if (d.exists()) { return m_notificationSoundDir; }
|
||||
}
|
||||
return CDirectoryUtils::soundFilesDirectory();
|
||||
}
|
||||
|
||||
QString CSettings::getNotificationFilePath(const QString &fileName) const
|
||||
{
|
||||
if (fileName.isEmpty()) { return {}; }
|
||||
return CFileUtils::soundFilePathOrDefaultPath(m_notificationSoundDir, fileName);
|
||||
}
|
||||
|
||||
void CSettings::setNotificationVolume(int volume)
|
||||
{
|
||||
m_notificationVolume = volume;
|
||||
|
||||
@@ -70,6 +70,14 @@ namespace BlackMisc
|
||||
//! Notification directory
|
||||
const QString &getNotificationSoundDirectory() const { return m_notificationSoundDir; }
|
||||
|
||||
//! get existing notifcation settings directory or default swift directory
|
||||
const QString &getNotificationSoundDirectoryOrDefault() const;
|
||||
|
||||
//! Get existing file path for the given file path, either in the settings specific or default dir
|
||||
//! \remark pass file only, like "foo.wav"
|
||||
//! \return complete path like "/mydir/foo.wav" or empty if file not exists
|
||||
QString getNotificationFilePath(const QString &fileName) const;
|
||||
|
||||
//! Set volume (notifications)
|
||||
void setNotificationVolume(int volume);
|
||||
|
||||
@@ -129,7 +137,11 @@ namespace BlackMisc
|
||||
static const QString &humanReadable() { static const QString name("Audio"); return name; }
|
||||
|
||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
||||
static bool isValid(const BlackMisc::Audio::CSettings &value, QString &) { Q_UNUSED(value); return true; }
|
||||
static bool isValid(const BlackMisc::Audio::CSettings &value, QString &)
|
||||
{
|
||||
Q_UNUSED(value)
|
||||
return true;
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -28,7 +28,9 @@ namespace BlackMisc
|
||||
static const QString mentioned("cs mentioned");
|
||||
static const QString joined("room joined");
|
||||
static const QString left("room left");
|
||||
static const QString ptt("PTT click");
|
||||
static const QString pttUp("PTT click up");
|
||||
static const QString pttDown("PTT click down");
|
||||
static const QString pttBlocked("PTT blocked");
|
||||
static const QString load("load sounds");
|
||||
static const QString noaudiotx("No audio tx");
|
||||
|
||||
@@ -40,10 +42,10 @@ namespace BlackMisc
|
||||
case NotificationTextMessagePrivate: return privateMsg;
|
||||
case NotificationTextMessageSupervisor: return supMsg;
|
||||
case NotificationTextCallsignMentioned: return mentioned;
|
||||
case NotificationVoiceRoomJoined: return joined;
|
||||
case NotificationVoiceRoomLeft: return left;
|
||||
case NotificationNoAudioTransmission: return noaudiotx;
|
||||
case PTTClickKeyDown: return ptt;
|
||||
case NotificationNoAudioTransmission: return noaudiotx;
|
||||
case PTTClickKeyDown: return pttDown;
|
||||
case PTTClickKeyUp: return pttUp;
|
||||
case PTTBlocked: return pttBlocked;
|
||||
default: break;
|
||||
}
|
||||
return unknown;
|
||||
@@ -59,8 +61,9 @@ namespace BlackMisc
|
||||
if (notification.testFlag(NotificationTextMessageSupervisor)) n << flagToString(NotificationTextMessageSupervisor);
|
||||
if (notification.testFlag(NotificationTextCallsignMentioned)) n << flagToString(NotificationTextCallsignMentioned);
|
||||
if (notification.testFlag(NotificationNoAudioTransmission)) n << flagToString(NotificationNoAudioTransmission);
|
||||
if (notification.testFlag(NotificationVoiceRoomJoined)) n << flagToString(NotificationVoiceRoomJoined);
|
||||
if (notification.testFlag(NotificationVoiceRoomLeft)) n << flagToString(NotificationVoiceRoomLeft);
|
||||
if (notification.testFlag(PTTClickKeyUp)) n << flagToString(PTTClickKeyUp);
|
||||
if (notification.testFlag(PTTClickKeyDown)) n << flagToString(PTTClickKeyDown);
|
||||
if (notification.testFlag(PTTBlocked)) n << flagToString(PTTBlocked);
|
||||
return n.join(", ");
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -43,11 +43,10 @@ namespace BlackMisc
|
||||
NotificationTextMessagePrivate = 1 << 3,
|
||||
NotificationTextMessageSupervisor = 1 << 4,
|
||||
NotificationTextCallsignMentioned = 1 << 5,
|
||||
NotificationVoiceRoomJoined = 1 << 6,
|
||||
NotificationVoiceRoomLeft = 1 << 7,
|
||||
NotificationNoAudioTransmission = 1 << 8,
|
||||
PTTClickKeyDown = 1 << 9,
|
||||
PTTClickKeyUp = 1 << 10,
|
||||
NotificationNoAudioTransmission = 1 << 6,
|
||||
PTTClickKeyDown = 1 << 7,
|
||||
PTTClickKeyUp = 1 << 8,
|
||||
PTTBlocked = 1 << 9
|
||||
};
|
||||
Q_DECLARE_FLAGS(Notification, NotificationFlag)
|
||||
|
||||
@@ -57,11 +56,11 @@ namespace BlackMisc
|
||||
//! All login notification flags
|
||||
constexpr static Notification AllLoginNotifications = Notification(NotificationLogin | NotificationLogoff);
|
||||
|
||||
//! All voice room notification flags
|
||||
constexpr static Notification AllVoiceRoomNotifications = Notification(NotificationVoiceRoomJoined | NotificationVoiceRoomLeft);
|
||||
//! All PTT notification flags
|
||||
constexpr static Notification AllPTTNotifications = Notification(PTTBlocked | PTTClickKeyUp | PTTClickKeyDown);
|
||||
|
||||
//! All notification flags
|
||||
constexpr static Notification AllNotifications = Notification(NotificationError | AllTextNotifications | AllLoginNotifications | AllVoiceRoomNotifications);
|
||||
constexpr static Notification AllNotifications = Notification(NotificationError | AllTextNotifications | AllLoginNotifications | AllPTTNotifications);
|
||||
|
||||
//! Default notification flags
|
||||
constexpr static Notification DefaultNotifications = Notification(AllNotifications);
|
||||
|
||||
@@ -590,15 +590,21 @@ namespace BlackMisc
|
||||
return CFileUtils::appendFilePaths(CDirectoryUtils::soundFilesDirectory(), name);
|
||||
}
|
||||
|
||||
QUrl CFileUtils::soundFileQUrl(const QString &directory, const QString &name)
|
||||
QString CFileUtils::soundFilePathOrDefaultPath(const QString &directory, const QString &fileName)
|
||||
{
|
||||
if (name.isEmpty()) { return {}; }
|
||||
if (!directory.isEmpty())
|
||||
{
|
||||
const QString f = CFileUtils::appendFilePathsAndFixUnc(directory, name);
|
||||
const QFileInfo fi(f);
|
||||
if (fi.exists()) { return QUrl::fromLocalFile(f); }
|
||||
const QString fp = CFileUtils::appendFilePathsAndFixUnc(directory, fileName);
|
||||
const QFileInfo fi(fp);
|
||||
if (fi.exists()) { return fi.absoluteFilePath(); }
|
||||
}
|
||||
return QUrl::fromLocalFile(CFileUtils::soundFilePathAndFileName(name));
|
||||
const QString fp = CFileUtils::appendFilePathsAndFixUnc(CDirectoryUtils::soundFilesDirectory(), fileName);
|
||||
const QFileInfo fi(fp);
|
||||
return (fi.exists()) ? fi.absoluteFilePath() : QString();
|
||||
}
|
||||
|
||||
QUrl CFileUtils::soundFileQUrlOrDefault(const QString &directory, const QString &fileName)
|
||||
{
|
||||
return QUrl::fromLocalFile(soundFilePathOrDefaultPath(directory, fileName));
|
||||
}
|
||||
} // ns
|
||||
|
||||
@@ -202,8 +202,11 @@ namespace BlackMisc
|
||||
//! Returns the full path and file name for a sound file
|
||||
static QString soundFilePathAndFileName(const QString &name);
|
||||
|
||||
//! File path (with file name) of file name and
|
||||
static QString soundFilePathOrDefaultPath(const QString &directory, const QString &fileName);
|
||||
|
||||
//! QUrl of soundFilePathAndFileName
|
||||
static QUrl soundFileQUrl(const QString &directory, const QString &name);
|
||||
static QUrl soundFileQUrlOrDefault(const QString &directory, const QString &fileName);
|
||||
};
|
||||
} // ns
|
||||
|
||||
|
||||
Reference in New Issue
Block a user