mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 07:15:34 +08:00
refs #258, notification sounds for voice room joined/left
* settings for notification sounds * wav files * changes in GUI
This commit is contained in:
@@ -29,12 +29,10 @@ void MainWindow::reloadSettings()
|
|||||||
// update hot keys
|
// update hot keys
|
||||||
this->ui->tvp_SettingsMiscHotkeys->update(this->getIContextSettings()->getHotkeys());
|
this->ui->tvp_SettingsMiscHotkeys->update(this->getIContextSettings()->getHotkeys());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// fake setting for sound notifications
|
// fake setting for sound notifications
|
||||||
this->ui->cb_SettingsAudioPlayNotificationSounds->setChecked(true);
|
this->ui->cb_SettingsAudioPlayNotificationSounds->setChecked(true);
|
||||||
this->ui->cb_SettingsAudioNotificationTextMessage->setChecked(true);
|
this->ui->cb_SettingsAudioNotificationTextMessage->setChecked(true);
|
||||||
|
this->ui->cb_SettingsAudioNotificationVoiceRoom->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -237,6 +237,5 @@ void MainWindow::playNotifcationSound(CNotificationSounds::Notification notifica
|
|||||||
{
|
{
|
||||||
if (!this->m_contextAudioAvailable) return;
|
if (!this->m_contextAudioAvailable) return;
|
||||||
if (!this->ui->cb_SettingsAudioPlayNotificationSounds->isChecked()) return;
|
if (!this->ui->cb_SettingsAudioPlayNotificationSounds->isChecked()) return;
|
||||||
if (notification == CNotificationSounds::NotificationTextMessage && !this->ui->cb_SettingsAudioNotificationTextMessage->isChecked()) return;
|
this->getIContextAudio()->playNotification(static_cast<uint>(notification), true);
|
||||||
this->getIContextAudio()->playNotification(static_cast<uint>(notification));
|
|
||||||
}
|
}
|
||||||
|
|||||||
165
src/blackmisc/setaudio.cpp
Normal file
165
src/blackmisc/setaudio.cpp
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
#include "setaudio.h"
|
||||||
|
using namespace BlackSound;
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
CSettingsAudio::CSettingsAudio()
|
||||||
|
{
|
||||||
|
this->initDefaultValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Flag
|
||||||
|
*/
|
||||||
|
bool CSettingsAudio::getNotificationFlag(CNotificationSounds::Notification notification) const
|
||||||
|
{
|
||||||
|
QChar f = m_notificationFlags.at(static_cast<int>(notification));
|
||||||
|
return '1' == f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert to string
|
||||||
|
*/
|
||||||
|
QString CSettingsAudio::convertToQString(bool i18n) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(i18n);
|
||||||
|
QString s("Notification flags:");
|
||||||
|
s.append(" ").append(m_notificationFlags);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* metaTypeId
|
||||||
|
*/
|
||||||
|
int CSettingsAudio::getMetaTypeId() const
|
||||||
|
{
|
||||||
|
return qMetaTypeId<CSettingsAudio>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* is a
|
||||||
|
*/
|
||||||
|
bool CSettingsAudio::isA(int metaTypeId) const
|
||||||
|
{
|
||||||
|
if (metaTypeId == qMetaTypeId<CSettingsAudio>()) { return true; }
|
||||||
|
return this->CValueObject::isA(metaTypeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare
|
||||||
|
*/
|
||||||
|
int CSettingsAudio::compareImpl(const CValueObject &otherBase) const
|
||||||
|
{
|
||||||
|
const auto &other = static_cast<const CSettingsAudio &>(otherBase);
|
||||||
|
return compare(TupleConverter<CSettingsAudio>::toTuple(*this), TupleConverter<CSettingsAudio>::toTuple(other));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Marshall
|
||||||
|
*/
|
||||||
|
void CSettingsAudio::marshallToDbus(QDBusArgument &argument) const
|
||||||
|
{
|
||||||
|
argument << TupleConverter<CSettingsAudio>::toTuple(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unmarshall
|
||||||
|
*/
|
||||||
|
void CSettingsAudio::unmarshallFromDbus(const QDBusArgument &argument)
|
||||||
|
{
|
||||||
|
argument >> TupleConverter<CSettingsAudio>::toTuple(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Equal?
|
||||||
|
*/
|
||||||
|
bool CSettingsAudio::operator ==(const CSettingsAudio &other) const
|
||||||
|
{
|
||||||
|
if (this == &other) return true;
|
||||||
|
return compare(*this, other) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unequal?
|
||||||
|
*/
|
||||||
|
bool CSettingsAudio::operator !=(const CSettingsAudio &other) const
|
||||||
|
{
|
||||||
|
return !((*this) == other);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hash
|
||||||
|
*/
|
||||||
|
uint CSettingsAudio::getValueHash() const
|
||||||
|
{
|
||||||
|
return qHash(TupleConverter<CSettingsAudio>::toTuple(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To JSON
|
||||||
|
*/
|
||||||
|
QJsonObject CSettingsAudio::toJson() const
|
||||||
|
{
|
||||||
|
return BlackMisc::serializeJson(CSettingsAudio::jsonMembers(), TupleConverter<CSettingsAudio>::toTuple(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* From JSON
|
||||||
|
*/
|
||||||
|
void CSettingsAudio::fromJson(const QJsonObject &json)
|
||||||
|
{
|
||||||
|
BlackMisc::deserializeJson(json, CSettingsAudio::jsonMembers(), TupleConverter<CSettingsAudio>::toTuple(*this));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Members
|
||||||
|
*/
|
||||||
|
const QStringList &CSettingsAudio::jsonMembers()
|
||||||
|
{
|
||||||
|
return TupleConverter<CSettingsAudio>::jsonMembers();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default values
|
||||||
|
*/
|
||||||
|
void CSettingsAudio::initDefaultValues()
|
||||||
|
{
|
||||||
|
this->m_notificationFlags = QString(1 + static_cast<int>(CNotificationSounds::Notification::NotificationsLoadSounds), '1');
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register metadata
|
||||||
|
*/
|
||||||
|
void CSettingsAudio::registerMetadata()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<CSettingsAudio>();
|
||||||
|
qDBusRegisterMetaType<CSettingsAudio>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Value
|
||||||
|
*/
|
||||||
|
BlackMisc::CStatusMessageList CSettingsAudio::value(const QString &path, const QString &command, const QVariant &value, bool &changedFlag)
|
||||||
|
{
|
||||||
|
// TODO: This needs to be refactored to a smarter way to delegate commands
|
||||||
|
changedFlag = false;
|
||||||
|
CStatusMessageList msgs;
|
||||||
|
if (path == CSettingsAudio::ValueNotificationFlag())
|
||||||
|
{
|
||||||
|
if (command == CSettingUtilities::CmdSetTrue() || command == CSettingUtilities::CmdSetFalse())
|
||||||
|
{
|
||||||
|
CNotificationSounds::Notification index = static_cast<CNotificationSounds::Notification>(value.toInt());
|
||||||
|
char value = (command == CSettingUtilities::CmdSetTrue()) ? '1' : '0' ;
|
||||||
|
this->m_notificationFlags.replace(index, 1, value);
|
||||||
|
return msgs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return CSettingUtilities::wrongPathMessages(path);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
105
src/blackmisc/setaudio.h
Normal file
105
src/blackmisc/setaudio.h
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
/* Copyright (C) 2013 VATSIM Community / authors
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef BLACKMISC_SETTINGS_AUDIO_H
|
||||||
|
#define BLACKMISC_SETTINGS_AUDIO_H
|
||||||
|
|
||||||
|
#include "valueobject.h"
|
||||||
|
#include "statusmessagelist.h"
|
||||||
|
#include "settingutilities.h"
|
||||||
|
#include "notificationsounds.h"
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
//! Value object encapsulating information of audio related settings.
|
||||||
|
class CSettingsAudio : public BlackMisc::CValueObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Default constructor.
|
||||||
|
CSettingsAudio();
|
||||||
|
|
||||||
|
//! Destructor.
|
||||||
|
virtual ~CSettingsAudio() {}
|
||||||
|
|
||||||
|
//! Path
|
||||||
|
static const QString &ValueNotificationFlag()
|
||||||
|
{
|
||||||
|
static const QString value("notificationflag");
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toQVariant()
|
||||||
|
virtual QVariant toQVariant() const override
|
||||||
|
{
|
||||||
|
return QVariant::fromValue(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Notification flag (play notification?)
|
||||||
|
bool getNotificationFlag(BlackSound::CNotificationSounds::Notification notification) const;
|
||||||
|
|
||||||
|
//! Notification flag (play notification?)
|
||||||
|
void setNotificationFlag(BlackSound::CNotificationSounds::Notification notification, bool value);
|
||||||
|
|
||||||
|
//! Equal operator ==
|
||||||
|
bool operator ==(const CSettingsAudio &other) const;
|
||||||
|
|
||||||
|
//! Unequal operator !=
|
||||||
|
bool operator !=(const CSettingsAudio &other) const;
|
||||||
|
|
||||||
|
//! \copydoc BlackCore::IContextSettings
|
||||||
|
virtual BlackMisc::CStatusMessageList value(const QString &path, const QString &command, const QVariant &value, bool &changedFlag);
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::getValueHash
|
||||||
|
virtual uint getValueHash() const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::toJson
|
||||||
|
virtual QJsonObject toJson() const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::fromJson
|
||||||
|
virtual void fromJson(const QJsonObject &json) override;
|
||||||
|
|
||||||
|
//! Init with meaningful default values
|
||||||
|
void initDefaultValues();
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::registerMetadata
|
||||||
|
static void registerMetadata();
|
||||||
|
|
||||||
|
//! \copydoc TupleConverter<>::jsonMembers()
|
||||||
|
static const QStringList &jsonMembers();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \copydoc CValueObject::convertToQString
|
||||||
|
virtual QString convertToQString(bool i18n = false) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::getMetaTypeId
|
||||||
|
virtual int getMetaTypeId() const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::isA
|
||||||
|
virtual bool isA(int metaTypeId) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::compareImpl
|
||||||
|
virtual int compareImpl(const CValueObject &other) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::marshallToDbus
|
||||||
|
virtual void marshallToDbus(QDBusArgument &argument) const override;
|
||||||
|
|
||||||
|
//! \copydoc CValueObject::unmarshallFromDbus
|
||||||
|
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
BLACK_ENABLE_TUPLE_CONVERSION(CSettingsAudio)
|
||||||
|
QString m_notificationFlags; //!< play notification for notification x, a little trick to use a string here (streamable, hashable, ..)
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackMisc::Settings::CSettingsAudio)
|
||||||
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Settings::CSettingsAudio, (o.m_notificationFlags))
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -7,5 +7,6 @@
|
|||||||
#define BLACKMISC_SETTINGSALLCLASSES_H
|
#define BLACKMISC_SETTINGSALLCLASSES_H
|
||||||
|
|
||||||
#include "blackmisc/setnetwork.h"
|
#include "blackmisc/setnetwork.h"
|
||||||
|
#include "blackmisc/setaudio.h"
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Settings
|
namespace Settings
|
||||||
{
|
{
|
||||||
//! \brief Helper / utility methods for settings
|
//! Helper / utility methods for settings
|
||||||
class CSettingUtilities
|
class CSettingUtilities
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@@ -43,6 +43,20 @@ namespace BlackMisc
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Command Set boolean value true
|
||||||
|
static const QString &CmdSetTrue()
|
||||||
|
{
|
||||||
|
static const QString cmd("set:true");
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Command Set boolean value false
|
||||||
|
static const QString &CmdSetFalse()
|
||||||
|
{
|
||||||
|
static const QString cmd("set:false");
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
//! \brief Wrong path message
|
//! \brief Wrong path message
|
||||||
static BlackMisc::CStatusMessage wrongPathMessage(const QString &path = "");
|
static BlackMisc::CStatusMessage wrongPathMessage(const QString &path = "");
|
||||||
|
|
||||||
|
|||||||
@@ -474,10 +474,14 @@ namespace BlackSound
|
|||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/login.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/login.wav"))) && success;
|
||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/logoff.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/logoff.wav"))) && success;
|
||||||
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/privatemessage.wav"))) && success;
|
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/privatemessage.wav"))) && success;
|
||||||
|
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/voiceroomjoined.wav"))) && success;
|
||||||
|
success = playlist->addMedia(QUrl::fromLocalFile(QCoreApplication::applicationDirPath().append("/sounds/voiceroomleft.wav"))) && success;
|
||||||
|
|
||||||
Q_ASSERT(success);
|
Q_ASSERT(success);
|
||||||
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
|
playlist->setPlaybackMode(QMediaPlaylist::CurrentItemOnce);
|
||||||
mediaPlayer->setPlaylist(playlist);
|
mediaPlayer->setPlaylist(playlist);
|
||||||
}
|
}
|
||||||
|
if (notification == CNotificationSounds::NotificationsLoadSounds) return;
|
||||||
int index = static_cast<int>(notification);
|
int index = static_cast<int>(notification);
|
||||||
playlist->setCurrentIndex(index);
|
playlist->setCurrentIndex(index);
|
||||||
mediaPlayer->setVolume(volume); // 0-100
|
mediaPlayer->setVolume(volume); // 0-100
|
||||||
|
|||||||
BIN
src/blacksound/sounds/voiceroomjoined.wav
Normal file
BIN
src/blacksound/sounds/voiceroomjoined.wav
Normal file
Binary file not shown.
BIN
src/blacksound/sounds/voiceroomleft.wav
Normal file
BIN
src/blacksound/sounds/voiceroomleft.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user