diff options
author | Hartmnt <hartmunt@protonmail.com> | 2022-10-07 14:46:53 +0300 |
---|---|---|
committer | Hartmnt <hartmunt@protonmail.com> | 2022-10-17 16:19:53 +0300 |
commit | 8eb12e9a098401bc3451d27db42c0ce0f2da21a4 (patch) | |
tree | 2d921b0d65e78043b27b6b400651923baaab916a /src/mumble | |
parent | e0c2b37daa2aaf235f670cff6f569c47a3481e92 (diff) |
FIX(client): Fix target and permission selection in updateMenuPermissions
This commit addresses two issues within the 'updateMenuPermissions'
method:
First, the target selection introduced in be7ad39fd was suffering
from the same problem as described in #3090 where selected tree items
were not preferred for determining targets. This issue caused the
chat bar to be erroneously disabled in certain situations, for example
when connecting to a channel with "Text Message" permission disabled
and switching to a different by left-clicking.
The second issue is an oversight in 441d06f6d where the 'Use selected
item as the chat bar target' option was introduced. The permission
check in 'updateMenuPermissions' was not updated to take the new
option into account and therefore always used the selected target
for the permission query independent of the state of the option.
The fix consists of using the unified 'getContextMenuTargets' for
target selection and adding a special case for handling the enabled
state of the chat bar by taking the new option into account.
Fixes #1799
Diffstat (limited to 'src/mumble')
-rw-r--r-- | src/mumble/MainWindow.cpp | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index 47be29e12..21e024fa1 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -2502,32 +2502,22 @@ void MainWindow::on_qaChannelCopyURL_triggered() { * @see MainWindow::msgPermissionQuery(const MumbleProto::PermissionQuery &msg) */ void MainWindow::updateMenuPermissions() { - ClientUser *cu = nullptr; - Channel *c = nullptr; + ContextMenuTarget target = getContextMenuTargets(); - if (Global::get().uiSession) { - cu = getContextMenuUser(); - if (!cu) - cu = pmModel->getUser(qtvUsers->currentIndex()); - - c = cu ? cu->cChannel : getContextMenuChannel(); - if (!c) - c = pmModel->getChannel(qtvUsers->currentIndex()); - } - - ChanACL::Permissions p = c ? static_cast< ChanACL::Permissions >(c->uiPermissions) : ChanACL::None; + ChanACL::Permissions p = + target.channel ? static_cast< ChanACL::Permissions >(target.channel->uiPermissions) : ChanACL::None; - if (c && !p) { - Global::get().sh->requestChannelPermissions(c->iId); - if (c->iId == 0) + if (target.channel && !p) { + Global::get().sh->requestChannelPermissions(target.channel->iId); + if (target.channel->iId == 0) p = Global::get().pPermissions; else p = ChanACL::All; - c->uiPermissions = p; + target.channel->uiPermissions = p; } - Channel *cparent = c ? c->cParent : nullptr; + Channel *cparent = target.channel ? target.channel->cParent : nullptr; ChanACL::Permissions pparent = cparent ? static_cast< ChanACL::Permissions >(cparent->uiPermissions) : ChanACL::None; @@ -2555,14 +2545,15 @@ void MainWindow::updateMenuPermissions() { homec->uiPermissions = homep; } - if (cu) { + if (target.user) { qaUserMute->setEnabled(p & (ChanACL::Write | ChanACL::MuteDeafen) - && ((cu != user) || cu->bMute || cu->bSuppress)); - qaUserDeaf->setEnabled(p & (ChanACL::Write | ChanACL::MuteDeafen) && ((cu != user) || cu->bDeaf)); + && ((target.user != user) || target.user->bMute || target.user->bSuppress)); + qaUserDeaf->setEnabled(p & (ChanACL::Write | ChanACL::MuteDeafen) + && ((target.user != user) || target.user->bDeaf)); qaUserPrioritySpeaker->setEnabled(p & (ChanACL::Write | ChanACL::MuteDeafen)); qaUserTextMessage->setEnabled(p & (ChanACL::Write | ChanACL::TextMessage)); qaUserInformation->setEnabled((Global::get().pPermissions & (ChanACL::Write | ChanACL::Register)) - || (p & (ChanACL::Write | ChanACL::Enter)) || (cu == user)); + || (p & (ChanACL::Write | ChanACL::Enter)) || (target.user == user)); } else { qaUserMute->setEnabled(false); qaUserDeaf->setEnabled(false); @@ -2582,11 +2573,19 @@ void MainWindow::updateMenuPermissions() { qaChannelUnlink->setEnabled((p & (ChanACL::Write | ChanACL::LinkChannel)) || (homep & (ChanACL::Write | ChanACL::LinkChannel))); qaChannelUnlinkAll->setEnabled(p & (ChanACL::Write | ChanACL::LinkChannel)); - - qaChannelCopyURL->setEnabled(c); + qaChannelCopyURL->setEnabled(target.channel); qaChannelSendMessage->setEnabled(p & (ChanACL::Write | ChanACL::TextMessage)); qaChannelFilter->setEnabled(true); - qteChat->setEnabled(p & (ChanACL::Write | ChanACL::TextMessage)); + + bool chatBarEnabled = false; + if (Global::get().uiSession) { + if (Global::get().s.bChatBarUseSelection && (target.channel || target.user)) { + chatBarEnabled = p & (ChanACL::Write | ChanACL::TextMessage); + } else if (homec) { + chatBarEnabled = homep & (ChanACL::Write | ChanACL::TextMessage); + } + } + qteChat->setEnabled(chatBarEnabled); } void MainWindow::userStateChanged() { |