Skip to content
Permalink
Browse files

Merge PR #2284: Allow only one instance from UserLocalVolumeDialog pe…

…r User
  • Loading branch information...
mkrautz committed May 19, 2016
2 parents 2f34ff7 + 3be04af commit a77987097bf1f935a400c1c6f630e3e37e47a23b
Showing with 38 additions and 5 deletions.
  1. +1 −2 src/mumble/MainWindow.cpp
  2. +2 −0 src/mumble/MainWindow.h
  3. +25 −2 src/mumble/UserLocalVolumeDialog.cpp
  4. +10 −1 src/mumble/UserLocalVolumeDialog.h
@@ -1518,8 +1518,7 @@ void MainWindow::on_qaUserLocalVolume_triggered() {

void MainWindow::openUserLocalVolumeDialog(ClientUser *p) {
unsigned int session = p->uiSession;
UserLocalVolumeDialog *uservol = new UserLocalVolumeDialog(session);
uservol->show();
UserLocalVolumeDialog::present(session, &qmUserVolTracker);
}

void MainWindow::on_qaUserDeaf_triggered() {
@@ -25,6 +25,7 @@
#include "Message.h"
#include "Mumble.pb.h"
#include "Usage.h"
#include "UserLocalVolumeDialog.h"

#include "ui_MainWindow.h"

@@ -71,6 +72,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
QMenu *qmTray;
QIcon qiIcon, qiIconMuteSelf, qiIconMuteServer, qiIconDeafSelf, qiIconDeafServer, qiIconMuteSuppressed;
QIcon qiTalkingOn, qiTalkingWhisper, qiTalkingShout, qiTalkingOff;
QMap<unsigned int, UserLocalVolumeDialog *> qmUserVolTracker;

GlobalShortcut *gsPushTalk, *gsResetAudio, *gsMuteSelf, *gsDeafSelf;
GlobalShortcut *gsUnlink, *gsPushMute, *gsJoinChannel, *gsToggleOverlay;
@@ -41,9 +41,11 @@
#include "ClientUser.h"
#include "Database.h"

UserLocalVolumeDialog::UserLocalVolumeDialog(unsigned int sessionId)
UserLocalVolumeDialog::UserLocalVolumeDialog(unsigned int sessionId,
QMap<unsigned int, UserLocalVolumeDialog *> *qmUserVolTracker)
: QDialog(NULL)
, m_clientSession(sessionId) {
, m_clientSession(sessionId)
, m_qmUserVolTracker(qmUserVolTracker) {
setupUi(this);

ClientUser *user = ClientUser::get(sessionId);
@@ -55,6 +57,22 @@ UserLocalVolumeDialog::UserLocalVolumeDialog(unsigned int sessionId)
}
}

void UserLocalVolumeDialog::closeEvent(QCloseEvent *event) {
m_qmUserVolTracker->remove(m_clientSession);
event->accept();
}

void UserLocalVolumeDialog::present(unsigned int sessionId,
QMap<unsigned int, UserLocalVolumeDialog *> *qmUserVolTracker) {
if (qmUserVolTracker->contains(sessionId)) {
qmUserVolTracker->value(sessionId)->raise();
} else {
UserLocalVolumeDialog *uservol = new UserLocalVolumeDialog(sessionId, qmUserVolTracker);
uservol->show();
qmUserVolTracker->insert(sessionId, uservol);
}
}

void UserLocalVolumeDialog::on_qsUserLocalVolume_valueChanged(int value) {
qsbUserLocalVolume->setValue(value);
ClientUser *user = ClientUser::get(m_clientSession);
@@ -84,3 +102,8 @@ void UserLocalVolumeDialog::on_qbbUserLocalVolume_clicked(QAbstractButton *butto
UserLocalVolumeDialog::close();
}
}

void UserLocalVolumeDialog::reject() {
m_qmUserVolTracker->remove(m_clientSession);
UserLocalVolumeDialog::close();
}
@@ -36,6 +36,8 @@
#ifndef MUMBLE_MUMBLE_USERVOLUME_H_
#define MUMBLE_MUMBLE_USERVOLUME_H_

#include <QMap>

#include "ui_UserLocalVolumeDialog.h"
#include "ClientUser.h"

@@ -45,16 +47,23 @@ class UserLocalVolumeDialog : public QDialog, private Ui::UserLocalVolumeDialog

/// The session ID for the user that the dialog is changing the volume for.
unsigned int m_clientSession;

/// The user's original adjustment (in dB) when entering the dialog.
int m_originalVolumeAdjustmentDecibel;
QMap<unsigned int, UserLocalVolumeDialog *> *m_qmUserVolTracker;

public slots:
void closeEvent(QCloseEvent *event);
void on_qsUserLocalVolume_valueChanged(int value);
void on_qsbUserLocalVolume_valueChanged(int value);
void on_qbbUserLocalVolume_clicked(QAbstractButton *b);
void reject();

public:
UserLocalVolumeDialog(unsigned int sessionId = 0);
static void present(unsigned int sessionId,
QMap<unsigned int, UserLocalVolumeDialog *> *qmUserVolTracker);
UserLocalVolumeDialog(unsigned int sessionId,
QMap<unsigned int, UserLocalVolumeDialog *> *qmUserVolTracker);
};

#endif

0 comments on commit a779870

Please sign in to comment.
You can’t perform that action at this time.