mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 11:25:33 +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 <QChar>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QStringBuilder>
|
#include <QStringBuilder>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
#include "blackmisc/directoryutils.h"
|
||||||
#include "blackmisc/fileutils.h"
|
#include "blackmisc/fileutils.h"
|
||||||
|
|
||||||
using namespace BlackMisc::Audio;
|
using namespace BlackMisc::Audio;
|
||||||
@@ -55,6 +57,22 @@ namespace BlackMisc
|
|||||||
m_notificationSoundDir = d;
|
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)
|
void CSettings::setNotificationVolume(int volume)
|
||||||
{
|
{
|
||||||
m_notificationVolume = volume;
|
m_notificationVolume = volume;
|
||||||
|
|||||||
@@ -70,6 +70,14 @@ namespace BlackMisc
|
|||||||
//! Notification directory
|
//! Notification directory
|
||||||
const QString &getNotificationSoundDirectory() const { return m_notificationSoundDir; }
|
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)
|
//! Set volume (notifications)
|
||||||
void setNotificationVolume(int volume);
|
void setNotificationVolume(int volume);
|
||||||
|
|
||||||
@@ -129,7 +137,11 @@ namespace BlackMisc
|
|||||||
static const QString &humanReadable() { static const QString name("Audio"); return name; }
|
static const QString &humanReadable() { static const QString name("Audio"); return name; }
|
||||||
|
|
||||||
//! \copydoc BlackMisc::TSettingTrait::isValid
|
//! \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
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -28,7 +28,9 @@ namespace BlackMisc
|
|||||||
static const QString mentioned("cs mentioned");
|
static const QString mentioned("cs mentioned");
|
||||||
static const QString joined("room joined");
|
static const QString joined("room joined");
|
||||||
static const QString left("room left");
|
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 load("load sounds");
|
||||||
static const QString noaudiotx("No audio tx");
|
static const QString noaudiotx("No audio tx");
|
||||||
|
|
||||||
@@ -40,10 +42,10 @@ namespace BlackMisc
|
|||||||
case NotificationTextMessagePrivate: return privateMsg;
|
case NotificationTextMessagePrivate: return privateMsg;
|
||||||
case NotificationTextMessageSupervisor: return supMsg;
|
case NotificationTextMessageSupervisor: return supMsg;
|
||||||
case NotificationTextCallsignMentioned: return mentioned;
|
case NotificationTextCallsignMentioned: return mentioned;
|
||||||
case NotificationVoiceRoomJoined: return joined;
|
case NotificationNoAudioTransmission: return noaudiotx;
|
||||||
case NotificationVoiceRoomLeft: return left;
|
case PTTClickKeyDown: return pttDown;
|
||||||
case NotificationNoAudioTransmission: return noaudiotx;
|
case PTTClickKeyUp: return pttUp;
|
||||||
case PTTClickKeyDown: return ptt;
|
case PTTBlocked: return pttBlocked;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return unknown;
|
return unknown;
|
||||||
@@ -59,8 +61,9 @@ namespace BlackMisc
|
|||||||
if (notification.testFlag(NotificationTextMessageSupervisor)) n << flagToString(NotificationTextMessageSupervisor);
|
if (notification.testFlag(NotificationTextMessageSupervisor)) n << flagToString(NotificationTextMessageSupervisor);
|
||||||
if (notification.testFlag(NotificationTextCallsignMentioned)) n << flagToString(NotificationTextCallsignMentioned);
|
if (notification.testFlag(NotificationTextCallsignMentioned)) n << flagToString(NotificationTextCallsignMentioned);
|
||||||
if (notification.testFlag(NotificationNoAudioTransmission)) n << flagToString(NotificationNoAudioTransmission);
|
if (notification.testFlag(NotificationNoAudioTransmission)) n << flagToString(NotificationNoAudioTransmission);
|
||||||
if (notification.testFlag(NotificationVoiceRoomJoined)) n << flagToString(NotificationVoiceRoomJoined);
|
if (notification.testFlag(PTTClickKeyUp)) n << flagToString(PTTClickKeyUp);
|
||||||
if (notification.testFlag(NotificationVoiceRoomLeft)) n << flagToString(NotificationVoiceRoomLeft);
|
if (notification.testFlag(PTTClickKeyDown)) n << flagToString(PTTClickKeyDown);
|
||||||
|
if (notification.testFlag(PTTBlocked)) n << flagToString(PTTBlocked);
|
||||||
return n.join(", ");
|
return n.join(", ");
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -43,11 +43,10 @@ namespace BlackMisc
|
|||||||
NotificationTextMessagePrivate = 1 << 3,
|
NotificationTextMessagePrivate = 1 << 3,
|
||||||
NotificationTextMessageSupervisor = 1 << 4,
|
NotificationTextMessageSupervisor = 1 << 4,
|
||||||
NotificationTextCallsignMentioned = 1 << 5,
|
NotificationTextCallsignMentioned = 1 << 5,
|
||||||
NotificationVoiceRoomJoined = 1 << 6,
|
NotificationNoAudioTransmission = 1 << 6,
|
||||||
NotificationVoiceRoomLeft = 1 << 7,
|
PTTClickKeyDown = 1 << 7,
|
||||||
NotificationNoAudioTransmission = 1 << 8,
|
PTTClickKeyUp = 1 << 8,
|
||||||
PTTClickKeyDown = 1 << 9,
|
PTTBlocked = 1 << 9
|
||||||
PTTClickKeyUp = 1 << 10,
|
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(Notification, NotificationFlag)
|
Q_DECLARE_FLAGS(Notification, NotificationFlag)
|
||||||
|
|
||||||
@@ -57,11 +56,11 @@ namespace BlackMisc
|
|||||||
//! All login notification flags
|
//! All login notification flags
|
||||||
constexpr static Notification AllLoginNotifications = Notification(NotificationLogin | NotificationLogoff);
|
constexpr static Notification AllLoginNotifications = Notification(NotificationLogin | NotificationLogoff);
|
||||||
|
|
||||||
//! All voice room notification flags
|
//! All PTT notification flags
|
||||||
constexpr static Notification AllVoiceRoomNotifications = Notification(NotificationVoiceRoomJoined | NotificationVoiceRoomLeft);
|
constexpr static Notification AllPTTNotifications = Notification(PTTBlocked | PTTClickKeyUp | PTTClickKeyDown);
|
||||||
|
|
||||||
//! All notification flags
|
//! All notification flags
|
||||||
constexpr static Notification AllNotifications = Notification(NotificationError | AllTextNotifications | AllLoginNotifications | AllVoiceRoomNotifications);
|
constexpr static Notification AllNotifications = Notification(NotificationError | AllTextNotifications | AllLoginNotifications | AllPTTNotifications);
|
||||||
|
|
||||||
//! Default notification flags
|
//! Default notification flags
|
||||||
constexpr static Notification DefaultNotifications = Notification(AllNotifications);
|
constexpr static Notification DefaultNotifications = Notification(AllNotifications);
|
||||||
|
|||||||
@@ -590,15 +590,21 @@ namespace BlackMisc
|
|||||||
return CFileUtils::appendFilePaths(CDirectoryUtils::soundFilesDirectory(), name);
|
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())
|
if (!directory.isEmpty())
|
||||||
{
|
{
|
||||||
const QString f = CFileUtils::appendFilePathsAndFixUnc(directory, name);
|
const QString fp = CFileUtils::appendFilePathsAndFixUnc(directory, fileName);
|
||||||
const QFileInfo fi(f);
|
const QFileInfo fi(fp);
|
||||||
if (fi.exists()) { return QUrl::fromLocalFile(f); }
|
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
|
} // ns
|
||||||
|
|||||||
@@ -202,8 +202,11 @@ namespace BlackMisc
|
|||||||
//! Returns the full path and file name for a sound file
|
//! Returns the full path and file name for a sound file
|
||||||
static QString soundFilePathAndFileName(const QString &name);
|
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
|
//! QUrl of soundFilePathAndFileName
|
||||||
static QUrl soundFileQUrl(const QString &directory, const QString &name);
|
static QUrl soundFileQUrlOrDefault(const QString &directory, const QString &fileName);
|
||||||
};
|
};
|
||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user