Skip to content

Commit

Permalink
Self muted/deafened message seperated into self muted, self unmuted, …
Browse files Browse the repository at this point in the history
…self deafened, self undeafened.

Grants an audio feedback what mute/deaf-state is active. (global keys)

Moved the new message-events to the back of the message-list to prevent old config files becoming imcompatible.

Added an array that allows to choose the order of the messages in the settingsscreen
  • Loading branch information
Marscho authored and hacst committed Sep 20, 2014
1 parent 90925af commit f0fc66b
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 17 deletions.
46 changes: 40 additions & 6 deletions src/mumble/Log.cpp
Expand Up @@ -68,11 +68,13 @@ LogConfig::LogConfig(Settings &st) : ConfigWidget(st) {

QTreeWidgetItem *twi;
for (int i = Log::firstMsgType; i <= Log::lastMsgType; ++i) {
Log::MsgType t = static_cast<Log::MsgType>(i);
int iListIndex = Log::msgOrder[i]; //- Order messages according to array

Log::MsgType t = static_cast<Log::MsgType>(iListIndex);
const QString messageName = g.l->msgName(t);

twi = new QTreeWidgetItem(qtwMessages);
twi->setData(ColMessage, Qt::UserRole, i);
twi->setData(ColMessage, Qt::UserRole, iListIndex);
twi->setText(ColMessage, messageName);
twi->setCheckState(ColConsole, Qt::Unchecked);
twi->setCheckState(ColNotification, Qt::Unchecked);
Expand Down Expand Up @@ -103,6 +105,7 @@ QIcon LogConfig::icon() const {

void LogConfig::load(const Settings &r) {
QList<QTreeWidgetItem *> qlItems = qtwMessages->findItems(QString(), Qt::MatchContains);

foreach(QTreeWidgetItem *i, qlItems) {
Log::MsgType mt = static_cast<Log::MsgType>(i->data(ColMessage, Qt::UserRole).toInt());
Settings::MessageLog ml = static_cast<Settings::MessageLog>(r.qmMessages.value(mt));
Expand All @@ -113,6 +116,7 @@ void LogConfig::load(const Settings &r) {
i->setCheckState(ColStaticSound, (ml & Settings::LogSoundfile) ? Qt::Checked : Qt::Unchecked);
i->setText(ColStaticSoundPath, r.qmMessageSounds.value(mt));
}

qsbMaxBlocks->setValue(r.iMaxLogBlocks);

loadSlider(qsVolume, r.iTTSVolume);
Expand Down Expand Up @@ -205,6 +209,33 @@ Log::Log(QObject *p) : QObject(p) {
qdDate = QDate::currentDate();
}

//- Displayorder in settingsscreen, allows to insert new events without breaking config-compatibility with older versions (Top = 0)
const int Log::msgOrder[] = {
0, //- DebugInfo
1, //- CriticalError
2, //- Warning
3, //- Information
4, //- ServerConnected
5, //- ServerDisconnected
6, //- UserJoin
7, //- UserLeave
8, //- Recording
9, //- YouKicked
10, //- UserKicked
11, //- SelfMute
20, //- SelfUnmute
21, //- SelfDeaf
22, //- SelfUndeaf
12, //- OtherSelfMute
13, //- YouMuted
14, //- YouMutedOther
15, //- OtherMutedOther
16, //- ChannelJoin
17, //- ChannelLeave
18, //- PermissionDenied
19 //- TextMessage
};

const char *Log::msgNames[] = {
QT_TRANSLATE_NOOP("Log", "Debug"),
QT_TRANSLATE_NOOP("Log", "Critical"),
Expand All @@ -217,15 +248,18 @@ const char *Log::msgNames[] = {
QT_TRANSLATE_NOOP("Log", "User recording state changed"),
QT_TRANSLATE_NOOP("Log", "User kicked (you or by you)"),
QT_TRANSLATE_NOOP("Log", "User kicked"),
QT_TRANSLATE_NOOP("Log", "You self-muted/deafened"),
QT_TRANSLATE_NOOP("Log", "You self-muted"),
QT_TRANSLATE_NOOP("Log", "Other self-muted/deafened"),
QT_TRANSLATE_NOOP("Log", "User muted (you)"),
QT_TRANSLATE_NOOP("Log", "User muted (by you)"),
QT_TRANSLATE_NOOP("Log", "User muted (other)"),
QT_TRANSLATE_NOOP("Log", "User Joined Channel"),
QT_TRANSLATE_NOOP("Log", "User Left Channel"),
QT_TRANSLATE_NOOP("Log", "Permission Denied"),
QT_TRANSLATE_NOOP("Log", "Text Message")
QT_TRANSLATE_NOOP("Log", "Text Message"),
QT_TRANSLATE_NOOP("Log", "You self-unmuted"),
QT_TRANSLATE_NOOP("Log", "You self-deafened"),
QT_TRANSLATE_NOOP("Log", "You self-undeafened")
};

QString Log::msgName(MsgType t) const {
Expand Down Expand Up @@ -488,8 +522,8 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
if ((flags & Settings::LogBalloon) && !(g.mw->isActiveWindow() && g.mw->qdwLog->isVisible()))
postNotification(mt, console, plain);

// Don't make any noise if we are self deafened
if (g.s.bDeaf)
// Don't make any noise if we are self deafened (Unless it is the sound for activating self deaf)
if (g.s.bDeaf && mt != Log::SelfDeaf)
return;

// Message notification with static sounds
Expand Down
8 changes: 6 additions & 2 deletions src/mumble/Log.h
Expand Up @@ -71,10 +71,14 @@ class Log : public QObject {
Q_OBJECT
Q_DISABLE_COPY(Log)
public:
enum MsgType { DebugInfo, CriticalError, Warning, Information, ServerConnected, ServerDisconnected, UserJoin, UserLeave, Recording, YouKicked, UserKicked, SelfMute, OtherSelfMute, YouMuted, YouMutedOther, OtherMutedOther, ChannelJoin, ChannelLeave, PermissionDenied, TextMessage };
enum MsgType { DebugInfo, CriticalError, Warning, Information, ServerConnected, ServerDisconnected, UserJoin, UserLeave, Recording, YouKicked, UserKicked, SelfMute, OtherSelfMute, YouMuted, YouMutedOther, OtherMutedOther, ChannelJoin, ChannelLeave, PermissionDenied, TextMessage, SelfUnmute, SelfDeaf, SelfUndeaf };
enum LogColorType { Time, Server, Privilege, Source, Target };
static const MsgType firstMsgType = DebugInfo;
static const MsgType lastMsgType = TextMessage;
static const MsgType lastMsgType = SelfUndeaf;

//- Displayorder in settingsscreen, allows to insert new events without breaking config-compatibility with older versions (Top = 0)
static const int msgOrder[];

protected:
QHash<MsgType, int> qmIgnore;
static const char *msgNames[];
Expand Down
10 changes: 5 additions & 5 deletions src/mumble/MainWindow.cpp
Expand Up @@ -1994,9 +1994,9 @@ void MainWindow::on_qaAudioMute_triggered() {
if (! g.s.bMute && g.s.bDeaf) {
g.s.bDeaf = false;
qaAudioDeaf->setChecked(false);
g.l->log(Log::SelfMute, tr("Unmuted and undeafened."));
g.l->log(Log::SelfUndeaf, tr("Unmuted and undeafened."));
} else if (! g.s.bMute) {
g.l->log(Log::SelfMute, tr("Unmuted."));
g.l->log(Log::SelfUnmute, tr("Unmuted."));
} else {
g.l->log(Log::SelfMute, tr("Muted."));
}
Expand Down Expand Up @@ -2029,12 +2029,12 @@ void MainWindow::on_qaAudioDeaf_triggered() {
bAutoUnmute = true;
g.s.bMute = true;
qaAudioMute->setChecked(true);
g.l->log(Log::SelfMute, tr("Muted and deafened."));
g.l->log(Log::SelfDeaf, tr("Muted and deafened."));
} else if (g.s.bDeaf) {
g.l->log(Log::SelfMute, tr("Deafened."));
g.l->log(Log::SelfDeaf, tr("Deafened."));
bAutoUnmute = false;
} else {
g.l->log(Log::SelfMute, tr("Undeafened."));
g.l->log(Log::SelfUndeaf, tr("Undeafened."));
}

if (g.sh) {
Expand Down
10 changes: 6 additions & 4 deletions src/mumble/Settings.cpp
Expand Up @@ -405,16 +405,18 @@ Settings::Settings() {

bShortcutEnable = true;
bSuppressMacEventTapWarning = false;

for (int i=Log::firstMsgType; i<=Log::lastMsgType; ++i)
for (int i=Log::firstMsgType; i<=Log::lastMsgType; ++i) {
qmMessages.insert(i, Settings::LogConsole | Settings::LogBalloon | Settings::LogTTS);

for (int i=Log::firstMsgType; i<=Log::lastMsgType; ++i)
qmMessageSounds.insert(i, QString());
}

qmMessageSounds[Log::CriticalError] = QLatin1String(":/Critical.ogg");
qmMessageSounds[Log::PermissionDenied] = QLatin1String(":/PermissionDenied.ogg");
qmMessageSounds[Log::SelfMute] = QLatin1String(":/SelfMutedDeafened.ogg");
qmMessageSounds[Log::SelfUnmute] = QLatin1String(":/SelfMutedDeafened.ogg");
qmMessageSounds[Log::SelfDeaf] = QLatin1String(":/SelfMutedDeafened.ogg");
qmMessageSounds[Log::SelfUndeaf] = QLatin1String(":/SelfMutedDeafened.ogg");
qmMessageSounds[Log::ServerConnected] = QLatin1String(":/ServerConnected.ogg");
qmMessageSounds[Log::ServerDisconnected] = QLatin1String(":/ServerDisconnected.ogg");
qmMessageSounds[Log::TextMessage] = QLatin1String(":/TextMessage.ogg");
Expand Down

0 comments on commit f0fc66b

Please sign in to comment.