forked from mumble-voip/mumble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
251 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,32 @@ | ||
// Copyright 2012-2023 The Mumble Developers. All rights reserved. | ||
// Copyright 2012-2024 The Mumble Developers. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file at the root of the | ||
// Mumble source tree or at <https://www.mumble.info/LICENSE>. | ||
|
||
#include "Log.h" | ||
#include "MainWindow.h" | ||
#include "Settings.h" | ||
|
||
#include <QDBusInterface> | ||
#include "widgets/TrayIcon.h" | ||
#include "Global.h" | ||
|
||
void Log::postNotification(MsgType mt, const QString &plain) { | ||
// FIXME | ||
if (mt == MsgType::TextMessage || mt == MsgType::PrivateTextMessage) { | ||
// Use custom icon for text messages | ||
Global::get().trayIcon->showMessage(msgName(mt), plain, Global::get().mw->iconComment); | ||
return; | ||
} | ||
|
||
QSystemTrayIcon::MessageIcon msgIcon; | ||
switch (mt) { | ||
case DebugInfo: | ||
case CriticalError: | ||
msgIcon = QSystemTrayIcon::Critical; | ||
break; | ||
case Warning: | ||
msgIcon = QSystemTrayIcon::Warning; | ||
break; | ||
default: | ||
msgIcon = QSystemTrayIcon::Information; | ||
break; | ||
} | ||
Global::get().trayIcon->showMessage(msgName(mt), plain, msgIcon); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
// Copyright 2012-2023 The Mumble Developers. All rights reserved. | ||
// Copyright 2012-2024 The Mumble Developers. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file at the root of the | ||
// Mumble source tree or at <https://www.mumble.info/LICENSE>. | ||
|
||
#include "Log.h" | ||
#include "MainWindow.h" | ||
#include "widgets/TrayIcon.h" | ||
#include "Global.h" | ||
|
||
void Log::postNotification(MsgType mt, const QString &plain) { | ||
// FIXME | ||
if (mt == MsgType::TextMessage || mt == MsgType::PrivateTextMessage) { | ||
// Use custom icon for text messages | ||
Global::get().trayIcon->showMessage(msgName(mt), plain, Global::get().mw->iconComment); | ||
return; | ||
} | ||
|
||
QSystemTrayIcon::MessageIcon msgIcon; | ||
switch (mt) { | ||
case DebugInfo: | ||
case CriticalError: | ||
msgIcon = QSystemTrayIcon::Critical; | ||
break; | ||
case Warning: | ||
msgIcon = QSystemTrayIcon::Warning; | ||
break; | ||
default: | ||
msgIcon = QSystemTrayIcon::Information; | ||
break; | ||
} | ||
Global::get().trayIcon->showMessage(msgName(mt), plain, msgIcon); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// Copyright 2024 The Mumble Developers. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file at the root of the | ||
// Mumble source tree or at <https://www.mumble.info/LICENSE>. | ||
|
||
#include "TrayIcon.h" | ||
|
||
#include "../ClientUser.h" | ||
#include "../MainWindow.h" | ||
#include "../Global.h" | ||
|
||
#include <QDebug> | ||
|
||
TrayIcon::TrayIcon() : QSystemTrayIcon(Global::get().mw), m_statusIcon(nullptr) { | ||
setIcon(Global::get().mw->qiIcon); | ||
setToolTip("Mumble"); | ||
|
||
QObject::connect(this, &QSystemTrayIcon::activated, this, &TrayIcon::on_icon_clicked); | ||
QObject::connect(this, &QSystemTrayIcon::messageClicked, this, &TrayIcon::on_showAction_triggered); | ||
|
||
m_showAction = new QAction(tr("Show"), Global::get().mw); | ||
QObject::connect(m_showAction, &QAction::triggered, this, &TrayIcon::on_showAction_triggered); | ||
|
||
m_hideAction = new QAction(tr("Hide"), Global::get().mw); | ||
QObject::connect(m_hideAction, &QAction::triggered, this, &TrayIcon::on_hideAction_triggered); | ||
|
||
m_contextMenu = new QMenu(Global::get().mw); | ||
QObject::connect(m_contextMenu, &QMenu::aboutToShow, this, &TrayIcon::updateContextMenu); | ||
|
||
// Some window managers hate it when a tray icon sets an empty context menu... | ||
updateContextMenu(); | ||
|
||
setContextMenu(m_contextMenu); | ||
|
||
show(); | ||
} | ||
|
||
void TrayIcon::updateIcon() { | ||
QIcon *newIcon = nullptr; | ||
|
||
ClientUser *p = ClientUser::get(Global::get().uiSession); | ||
|
||
if (Global::get().s.bDeaf) { | ||
newIcon = &Global::get().mw->qiIconDeafSelf; | ||
} else if (p && p->bDeaf) { | ||
newIcon = &Global::get().mw->qiIconDeafServer; | ||
} else if (Global::get().s.bMute) { | ||
newIcon = &Global::get().mw->qiIconMuteSelf; | ||
} else if (p && p->bMute) { | ||
newIcon = &Global::get().mw->qiIconMuteServer; | ||
} else if (p && p->bSuppress) { | ||
newIcon = &Global::get().mw->qiIconMuteSuppressed; | ||
} else if (Global::get().s.bStateInTray && Global::get().bPushToMute) { | ||
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; | ||
break; | ||
case Settings::Whispering: | ||
newIcon = &Global::get().mw->qiTalkingWhisper; | ||
break; | ||
case Settings::Shouting: | ||
newIcon = &Global::get().mw->qiTalkingShout; | ||
break; | ||
case Settings::Passive: | ||
default: | ||
newIcon = &Global::get().mw->qiTalkingOff; | ||
break; | ||
} | ||
} else { | ||
newIcon = &Global::get().mw->qiIcon; | ||
} | ||
|
||
if (newIcon != m_statusIcon) { | ||
m_statusIcon = newIcon; | ||
setIcon(*m_statusIcon); | ||
} | ||
} | ||
|
||
void TrayIcon::on_icon_clicked(QSystemTrayIcon::ActivationReason reason) { | ||
qDebug() << reason; | ||
switch (reason) { | ||
case QSystemTrayIcon::Trigger: | ||
if (Global::get().mw->isVisible() && !Global::get().mw->isMinimized()) { | ||
on_hideAction_triggered(); | ||
} else { | ||
on_showAction_triggered(); | ||
} | ||
break; | ||
case QSystemTrayIcon::Unknown: | ||
case QSystemTrayIcon::Context: | ||
case QSystemTrayIcon::DoubleClick: | ||
case QSystemTrayIcon::MiddleClick: | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
void TrayIcon::updateContextMenu() { | ||
qDebug() << "About to show..."; | ||
m_contextMenu->clear(); | ||
|
||
if (Global::get().mw->isVisible() && !Global::get().mw->isMinimized()) { | ||
m_contextMenu->addAction(m_hideAction); | ||
} else { | ||
m_contextMenu->addAction(m_showAction); | ||
} | ||
|
||
m_contextMenu->addSeparator(); | ||
m_contextMenu->addAction(Global::get().mw->qaAudioMute); | ||
m_contextMenu->addAction(Global::get().mw->qaAudioDeaf); | ||
m_contextMenu->addAction(Global::get().mw->qaTalkingUIToggle); | ||
m_contextMenu->addSeparator(); | ||
m_contextMenu->addAction(Global::get().mw->qaQuit); | ||
} | ||
|
||
void TrayIcon::on_showAction_triggered() { | ||
qDebug() << "Show window!"; | ||
Global::get().mw->showRaiseWindow(); | ||
updateContextMenu(); | ||
} | ||
|
||
void TrayIcon::on_hideAction_triggered() { | ||
qDebug() << "Hide window!"; | ||
Global::get().mw->hide(); | ||
updateContextMenu(); | ||
} |
Oops, something went wrong.