Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete rewrite of the tray icon implementation #6466

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/mumble/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ set(MUMBLE_SOURCES
"widgets/SearchDialogTree.h"
"widgets/SemanticSlider.cpp"
"widgets/SemanticSlider.h"
"widgets/TrayIcon.cpp"
"widgets/TrayIcon.h"


"${SHARED_SOURCE_DIR}/ACL.cpp"
Expand Down Expand Up @@ -572,7 +574,6 @@ if(WIN32)
target_sources(mumble_client_object_lib PRIVATE
"GlobalShortcut_win.cpp"
"GlobalShortcut_win.h"
"Log_win.cpp"
"SharedMemory_win.cpp"
"TaskList.cpp"
"UserLockFile_win.cpp"
Expand Down Expand Up @@ -657,7 +658,6 @@ else()
PRIVATE
"GlobalShortcut_unix.cpp"
"GlobalShortcut_unix.h"
"Log_unix.cpp"
"os_unix.cpp"
)

Expand All @@ -681,7 +681,6 @@ else()
"AppNap.mm"
"GlobalShortcut_macx.h"
"GlobalShortcut_macx.mm"
"Log_macx.mm"
"os_macx.mm"
)

Expand Down Expand Up @@ -1101,7 +1100,6 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
set_source_files_properties(
"AppNap.mm"
"GlobalShortcut_macx.mm"
"Log_macx.mm"
"os_macx.mm"
"TextToSpeech_macx.mm"
"Overlay_macx.mm"
Expand Down
13 changes: 7 additions & 6 deletions src/mumble/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@ void Global::migrateDataDir(const QDir &toDir) {
}

Global::Global(const QString &qsConfigPath) {
mw = 0;
db = 0;
pluginManager = 0;
nam = 0;
c = 0;
talkingUI = 0;
mw = nullptr;
trayIcon = nullptr;
db = nullptr;
pluginManager = nullptr;
nam = nullptr;
c = nullptr;
talkingUI = nullptr;
uiSession = 0;
uiDoublePush = 1000000;
iPushToTalk = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/mumble/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class OverlayClient;
class LogEmitter;
class DeveloperConsole;
class TalkingUI;
class TrayIcon;

class QNetworkAccessManager;

Expand All @@ -50,6 +51,7 @@ struct Global Q_DECL_FINAL {
static Global &get();

MainWindow *mw;
TrayIcon *trayIcon;
Settings s;
boost::shared_ptr< ServerHandler > sh;
boost::shared_ptr< AudioInput > ai;
Expand Down
71 changes: 49 additions & 22 deletions src/mumble/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "VolumeAdjustment.h"
#include "Global.h"

#include "widgets/TrayIcon.h"

#include <QSignalBlocker>
#include <QtCore/QMutexLocker>
#include <QtGui/QImageWriter>
Expand Down Expand Up @@ -812,13 +814,58 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
if (!(Global::get().mw->isActiveWindow() && Global::get().mw->qdwLog->isVisible())) {
// Message notification with window highlight
if (flags & Settings::LogHighlight) {
QApplication::alert(Global::get().mw);
Global::get().mw->highlightWindow();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be done via a signal

}

// Message notification with balloon tooltips
if (flags & Settings::LogBalloon) {
// Replace any instances of a "Object Replacement Character" from QTextDocumentFragment::toPlainText
postNotification(mt, plain.replace("\xEF\xBF\xBC", tr("[embedded content]")));
plain = plain.replace("\xEF\xBF\xBC", tr("[embedded content]"));

QSystemTrayIcon::MessageIcon msgIcon;
switch (mt) {
case DebugInfo:
case CriticalError:
msgIcon = QSystemTrayIcon::Critical;
break;
case Warning:
msgIcon = QSystemTrayIcon::Warning;
break;
case TextMessage:
case PrivateTextMessage:
msgIcon = QSystemTrayIcon::NoIcon;
break;
case Information:
case ServerConnected:
case ServerDisconnected:
case UserJoin:
case UserLeave:
case Recording:
case YouKicked:
case UserKicked:
case SelfMute:
case OtherSelfMute:
case YouMuted:
case YouMutedOther:
case OtherMutedOther:
case ChannelJoin:
case ChannelLeave:
case PermissionDenied:
case SelfUnmute:
case SelfDeaf:
case SelfUndeaf:
case UserRenamed:
case SelfChannelJoin:
case SelfChannelJoinOther:
case ChannelJoinConnect:
case ChannelLeaveDisconnect:
case ChannelListeningAdd:
case ChannelListeningRemove:
case PluginMessage:
msgIcon = QSystemTrayIcon::Information;
break;
}
Global::get().trayIcon->showMessage(msgName(mt), plain, msgIcon);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be done via a signal

}
}

Expand Down Expand Up @@ -910,26 +957,6 @@ void Log::processDeferredLogs() {
}
}

// Post a notification using the MainWindow's QSystemTrayIcon.
void Log::postQtNotification(MsgType mt, const QString &plain) {
if (Global::get().mw->qstiIcon->isSystemTrayAvailable() && Global::get().mw->qstiIcon->supportsMessages()) {
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().mw->qstiIcon->showMessage(msgName(mt), plain, msgIcon);
}
}

LogMessage::LogMessage(Log::MsgType mt, const QString &console, const QString &terse, bool ownMessage,
const QString &overrideTTS, bool ignoreTTS)
: mt(mt), console(console), terse(terse), ownMessage(ownMessage), overrideTTS(overrideTTS), ignoreTTS(ignoreTTS) {
Expand Down
2 changes: 0 additions & 2 deletions src/mumble/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ class Log : public QObject {
unsigned int uiLastId;
QDate qdDate;
static const QStringList allowedSchemes();
void postNotification(MsgType mt, const QString &plain);
void postQtNotification(MsgType mt, const QString &plain);

public:
Log(QObject *p = nullptr);
Expand Down
105 changes: 0 additions & 105 deletions src/mumble/Log_macx.mm

This file was deleted.

68 changes: 0 additions & 68 deletions src/mumble/Log_unix.cpp

This file was deleted.

10 changes: 0 additions & 10 deletions src/mumble/Log_win.cpp

This file was deleted.

11 changes: 8 additions & 3 deletions src/mumble/LookConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "SearchDialog.h"
#include "Global.h"

#include <QSystemTrayIcon>
#include <QtCore/QFileSystemWatcher>
#include <QtCore/QStack>
#include <QtCore/QTimer>
Expand All @@ -27,10 +28,14 @@ static ConfigRegistrar registrar(1100, LookConfigNew);
LookConfig::LookConfig(Settings &st) : ConfigWidget(st) {
setupUi(this);

#ifndef Q_OS_MAC
if (!QSystemTrayIcon::isSystemTrayAvailable())
#endif
if (!QSystemTrayIcon::isSystemTrayAvailable()) {
qgbTray->hide();
}

#ifdef Q_OS_MAC
// Qt can not hide the window via the native macOS hide function. This should be re-evaluated with new Qt versions.
qcbHideTray->hide();
#endif

qcbLanguage->addItem(tr("System default"));
QDir d(QLatin1String(":"), QLatin1String("mumble_*.qm"), QDir::Name, QDir::Files);
Expand Down
Loading