Skip to content

Commit

Permalink
Merge PR #3368: Change icon when muted/deafened
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebeatrici committed Mar 11, 2018
2 parents ce8fd36 + 4877327 commit 80f3686
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 9 deletions.
15 changes: 9 additions & 6 deletions src/mumble/MainWindow.cpp
Expand Up @@ -601,6 +601,12 @@ void MainWindow::updateTrayIcon() {
}
}

void MainWindow::updateUserModel()
{
UserModel *um = static_cast<UserModel *>(qtvUsers->model());
um->toggleChannelFiltered(NULL); // Force a UI refresh
}

void MainWindow::updateTransmitModeComboBox() {
switch (g.s.atTransmit) {
case Settings::Continuous:
Expand Down Expand Up @@ -2280,9 +2286,7 @@ void MainWindow::on_qaAudioReset_triggered() {

void MainWindow::on_qaFilterToggle_triggered() {
g.s.bFilterActive = qaFilterToggle->isChecked();

UserModel *um = static_cast<UserModel *>(qtvUsers->model());
um->toggleChannelFiltered(NULL); // force a UI refresh
updateUserModel();
}

void MainWindow::on_qaAudioMute_triggered() {
Expand Down Expand Up @@ -2382,9 +2386,7 @@ void MainWindow::on_qaConfigDialog_triggered() {
setupView(false);
updateTransmitModeComboBox();
updateTrayIcon();

UserModel *um = static_cast<UserModel *>(qtvUsers->model());
um->toggleChannelFiltered(NULL); // force a UI refresh
updateUserModel();

if (g.s.requireRestartToApply) {
if (g.s.requireRestartToApply && QMessageBox::question(
Expand Down Expand Up @@ -2491,6 +2493,7 @@ void MainWindow::pttReleased() {
void MainWindow::on_PushToMute_triggered(bool down, QVariant) {
g.bPushToMute = down;
updateTrayIcon();
updateUserModel();
}

void MainWindow::on_VolumeUp_triggered(bool down, QVariant) {
Expand Down
1 change: 1 addition & 0 deletions src/mumble/MainWindow.h
Expand Up @@ -116,6 +116,7 @@ class MainWindow : public QMainWindow, public MessageHandler, public Ui::MainWin
void setOnTop(bool top);
void setShowDockTitleBars(bool doShow);
void updateTrayIcon();
void updateUserModel();
void focusNextMainWidget();
void updateTransmitModeComboBox();
QPair<QByteArray, QImage> openImageFile();
Expand Down
23 changes: 21 additions & 2 deletions src/mumble/UserModel.cpp
Expand Up @@ -195,6 +195,7 @@ UserModel::UserModel(QObject *p) : QAbstractItemModel(p) {
qiTalkingWhisper=QIcon(QLatin1String("skin:talking_whisper.svg"));
qiPrioritySpeaker=QIcon(QLatin1String("skin:priority_speaker.svg"));
qiRecording=QIcon(QLatin1String("skin:actions/media-record.svg"));
qiMutedPushToMute.addFile(QLatin1String("skin:muted_pushtomute.svg"));
qiMutedSelf=QIcon(QLatin1String("skin:muted_self.svg"));
qiMutedServer=QIcon(QLatin1String("skin:muted_server.svg"));
qiMutedLocal=QIcon(QLatin1String("skin:muted_local.svg"));
Expand Down Expand Up @@ -347,7 +348,24 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
if (p) {
switch (role) {
case Qt::DecorationRole:
if (idx.column() == 0)
if (idx.column() == 0) {
ClientUser *pSelf = ClientUser::get(g.uiSession);
if (p == pSelf) {
if (g.s.bDeaf) {
return qiDeafenedSelf;
} else if (p->bDeaf) {
return qiDeafenedServer;
} else if (g.s.bMute) {
return qiMutedSelf;
} else if (p->bMute) {
return qiMutedServer;
} else if (p->bSuppress) {
return qiMutedSuppressed;
} else if (g.bPushToMute) {
return qiMutedPushToMute;
}
}

switch (p->tsState) {
case Settings::Talking:
return qiTalkingOn;
Expand All @@ -359,6 +377,7 @@ QVariant UserModel::data(const QModelIndex &idx, int role) const {
default:
return qiTalkingOff;
}
}
break;
case Qt::FontRole:
if ((idx.column() == 0) && (p->uiSession == g.uiSession)) {
Expand Down Expand Up @@ -1283,7 +1302,7 @@ void UserModel::userStateChanged() {
ClientUser *user = qobject_cast<ClientUser *>(sender());
if (user == NULL)
return;

const QModelIndex idx = index(user);
emit dataChanged(idx, idx);

Expand Down
2 changes: 1 addition & 1 deletion src/mumble/UserModel.h
Expand Up @@ -64,7 +64,7 @@ class UserModel : public QAbstractItemModel {
Q_DISABLE_COPY(UserModel)
protected:
QIcon qiTalkingOn, qiTalkingWhisper, qiTalkingShout, qiTalkingOff;
QIcon qiMutedSelf, qiMutedServer, qiMutedLocal, qiIgnoredLocal, qiMutedSuppressed;
QIcon qiMutedPushToMute, qiMutedSelf, qiMutedServer, qiMutedLocal, qiIgnoredLocal, qiMutedSuppressed;
QIcon qiPrioritySpeaker;
QIcon qiRecording;
QIcon qiDeafenedSelf, qiDeafenedServer;
Expand Down

0 comments on commit 80f3686

Please sign in to comment.