Skip to content

Commit

Permalink
Experimental Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jun 24, 2024
1 parent a47ff1c commit 751fae0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
41 changes: 21 additions & 20 deletions src/mumble/widgets/TrayIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
#include <QApplication>

TrayIcon::TrayIcon()
: QSystemTrayIcon(Global::get().mw), m_statusIcon(&Global::get().mw->qiIcon), m_currentIcon(nullptr),
m_iconLock(QReadWriteLock::NonRecursive) {
: QSystemTrayIcon(Global::get().mw), m_currentIcon(nullptr), m_iconLock(QReadWriteLock::NonRecursive) {
m_statusIcon = Global::get().mw->qiIcon;
applyIcon(m_statusIcon);

setToolTip("Mumble");

m_highlightTimer = new QTimer(this);
Expand Down Expand Up @@ -46,48 +47,48 @@ TrayIcon::TrayIcon()
}

void TrayIcon::updateIcon() {
QIcon *newIcon = nullptr;
QIcon newIcon;

ClientUser *p = ClientUser::get(Global::get().uiSession);

if (Global::get().s.bDeaf) {
newIcon = &Global::get().mw->qiIconDeafSelf;
newIcon = Global::get().mw->qiIconDeafSelf;
} else if (p && p->bDeaf) {
newIcon = &Global::get().mw->qiIconDeafServer;
newIcon = Global::get().mw->qiIconDeafServer;
} else if (Global::get().s.bMute) {
newIcon = &Global::get().mw->qiIconMuteSelf;
newIcon = Global::get().mw->qiIconMuteSelf;
} else if (p && p->bMute) {
newIcon = &Global::get().mw->qiIconMuteServer;
newIcon = Global::get().mw->qiIconMuteServer;
} else if (p && p->bSuppress) {
newIcon = &Global::get().mw->qiIconMuteSuppressed;
newIcon = Global::get().mw->qiIconMuteSuppressed;
} else if (Global::get().s.bStateInTray && Global::get().bPushToMute) {
newIcon = &Global::get().mw->qiIconMutePushToMute;
newIcon = Global::get().mw->qiIconMutePushToMute;
} else if (p && Global::get().s.bStateInTray) {
switch (p->tsState) {
case Settings::Talking:
case Settings::MutedTalking:
newIcon = &Global::get().mw->qiTalkingOn;
newIcon = Global::get().mw->qiTalkingOn;
break;
case Settings::Whispering:
newIcon = &Global::get().mw->qiTalkingWhisper;
newIcon = Global::get().mw->qiTalkingWhisper;
break;
case Settings::Shouting:
newIcon = &Global::get().mw->qiTalkingShout;
newIcon = Global::get().mw->qiTalkingShout;
break;
case Settings::Passive:
default:
newIcon = &Global::get().mw->qiTalkingOff;
newIcon = Global::get().mw->qiTalkingOff;
break;
}
} else {
newIcon = &Global::get().mw->qiIcon;
newIcon = Global::get().mw->qiIcon;
}

bool isStatusIcon;

{
QReadLocker locker(&m_iconLock);
isStatusIcon = newIcon == m_statusIcon;
isStatusIcon = &newIcon == &m_statusIcon;
}

if (!isStatusIcon) {
Expand Down Expand Up @@ -137,11 +138,11 @@ void TrayIcon::updateContextMenu() {
m_contextMenu->addAction(Global::get().mw->qaQuit);
}

void TrayIcon::applyIcon(QIcon *icon) {
void TrayIcon::applyIcon(QIcon &icon) {
QWriteLocker locker(&m_iconLock);

setIcon(*icon);
m_currentIcon = icon;
setIcon(icon);
m_currentIcon = &icon;
}

void TrayIcon::toggleShowHide() {
Expand Down Expand Up @@ -201,11 +202,11 @@ void TrayIcon::on_timer_triggered() {

{
QReadLocker locker(&m_iconLock);
isStatusIcon = m_currentIcon == m_statusIcon;
isStatusIcon = m_currentIcon == &m_statusIcon;
}

if (isStatusIcon) {
applyIcon(&Global::get().mw->iconInformation);
applyIcon(Global::get().mw->iconInformation);
m_highlightTimer->start(500);
} else {
applyIcon(m_statusIcon);
Expand Down
4 changes: 2 additions & 2 deletions src/mumble/widgets/TrayIcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public slots:
void on_hideAction_triggered();

private:
QIcon *m_statusIcon;
QIcon m_statusIcon;
QIcon *m_currentIcon;
QMenu *m_contextMenu;
QAction *m_showAction;
Expand All @@ -37,7 +37,7 @@ public slots:
QReadWriteLock m_iconLock;

void updateContextMenu();
void applyIcon(QIcon *icon);
void applyIcon(QIcon &icon);

private slots:
void on_icon_clicked(QSystemTrayIcon::ActivationReason reason);
Expand Down

0 comments on commit 751fae0

Please sign in to comment.