Skip to content

Commit

Permalink
Add new tray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Jun 7, 2024
1 parent 3d8926a commit d285c2f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 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
1 change: 1 addition & 0 deletions src/mumble/Global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ void Global::migrateDataDir(const QDir &toDir) {

Global::Global(const QString &qsConfigPath) {
mw = 0;
trayIcon = 0;
db = 0;
pluginManager = 0;
nam = 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
2 changes: 2 additions & 0 deletions src/mumble/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#include <QtWidgets/QWhatsThis>

#include "widgets/SemanticSlider.h"
#include "widgets/TrayIcon.h"

#ifdef Q_OS_WIN
# include <dbt.h>
Expand Down Expand Up @@ -195,6 +196,7 @@ MainWindow::MainWindow(QWidget *p)
&PluginManager::on_serverSynchronized);

QAccessible::installFactory(AccessibleSlider::semanticSliderFactory);
Global::get().trayIcon = new TrayIcon(this);
}

void MainWindow::createActions() {
Expand Down
14 changes: 14 additions & 0 deletions src/mumble/widgets/TrayIcon.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 "../Global.h"
#include "../MainWindow.h"

TrayIcon::TrayIcon(QObject *parent) : QSystemTrayIcon(parent) {
setIcon(Global::get().mw->qiIcon);
show();
}
18 changes: 18 additions & 0 deletions src/mumble/widgets/TrayIcon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// 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>.

#ifndef MUMBLE_MUMBLE_WIDGETS_TRAYICCON_H_
#define MUMBLE_MUMBLE_WIDGETS_TRAYICCON_H_

#include <QtWidgets/QSystemTrayIcon>

class TrayIcon : public QSystemTrayIcon {
Q_OBJECT

public:
TrayIcon(QObject *parent);
};

#endif // MUMBLE_MUMBLE_WIDGETS_TRAYICCON_H_

0 comments on commit d285c2f

Please sign in to comment.