Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorvald Natvig <slicer@users.sourceforge.net>2007-07-13 21:10:33 +0400
committerThorvald Natvig <slicer@users.sourceforge.net>2007-07-13 21:10:33 +0400
commitb0a7f04de1474dced4f7976419effc801bd15d1a (patch)
treea1e68b8f8220ddc3fd2232853a4506e9545def5e /src/murmur/Tray.cpp
parentcc7e2f283979978fa21796209377bd189c6dc38d (diff)
Textlogger for murmur win32.
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@590 05730e5d-ab1b-0410-a4ac-84af385074fa
Diffstat (limited to 'src/murmur/Tray.cpp')
-rw-r--r--src/murmur/Tray.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/murmur/Tray.cpp b/src/murmur/Tray.cpp
new file mode 100644
index 000000000..5ec15b03b
--- /dev/null
+++ b/src/murmur/Tray.cpp
@@ -0,0 +1,97 @@
+/* Copyright (C) 2005-2007, Thorvald Natvig <thorvald@natvig.com>
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ - Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ - Neither the name of the Mumble Developers nor the names of its
+ contributors may be used to endorse or promote products derived from this
+ software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "Tray.h"
+#include "Server.h"
+
+Tray::Tray(QObject *p, LogEmitter *logger) : QObject(p) {
+ le = logger;
+
+ qsti = new QSystemTrayIcon(qApp->windowIcon(), this);
+ qsti->setObjectName(QLatin1String("Tray"));
+ qsti->setToolTip(tr("Murmur"));
+
+ qaQuit = new QAction(tr("&Quit Murmur"), this);
+ qaQuit->setShortcut(tr("Ctrl+Q", "Quit"));
+ qaQuit->setObjectName(QLatin1String("Quit"));
+
+ qaShowLog = new QAction(tr("&Show Log"), this);
+ qaShowLog->setShortcut(tr("Ctrl+L", "Quit"));
+ qaShowLog->setObjectName(QLatin1String("ShowLog"));
+
+ // Can't construct a QMenu which decends from QObject, and qsti is a QObject.
+ // Qt bug?
+ qm = new QMenu(tr("Murmur"), NULL);
+ qm->addAction(qaQuit);
+ qm->addSeparator();
+ qm->addAction(qaShowLog);
+ qsti->setContextMenu(qm);
+
+ qsti->show();
+
+ connect(le, SIGNAL(newLogEntry(const QString &)), this, SLOT(addLogMessage(const QString &)));
+
+ QMetaObject::connectSlotsByName(this);
+}
+
+void Tray::on_Tray_activated(QSystemTrayIcon::ActivationReason r) {
+ if (r == QSystemTrayIcon::Trigger) {
+ int numclients = g_sServer->qmConnections.count();
+ int port = g_sp.iPort;
+ qsti->showMessage(tr("Murmur"), tr("Server running on port %1 with %2 conencted clients.").arg(port).arg(numclients), QSystemTrayIcon::Information, 5000);
+ }
+}
+
+void Tray::on_Quit_triggered() {
+ if (QMessageBox::question(NULL, tr("Murmur"), tr("Are you sure you wish to quit murmur?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
+ qApp->quit();
+ }
+}
+
+void Tray::on_ShowLog_triggered() {
+ QMainWindow *mw = new QMainWindow();
+ mw->setAttribute(Qt::WA_DeleteOnClose);
+ QTextBrowser *tb = new QTextBrowser();
+ mw->setCentralWidget(tb);
+
+ connect(le, SIGNAL(newLogEntry(const QString &)), tb, SLOT(append(const QString &)));
+
+ foreach(const QString &m, qlLog)
+ tb->append(m);
+
+ mw->show();
+}
+
+void Tray::addLogMessage(const QString &msg) {
+ if (qlLog.count() >= 100)
+ qlLog.removeFirst();
+
+ qlLog.append(msg);
+}