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:
authorRobert Adam <dev@robert-adam.de>2022-10-18 09:14:20 +0300
committerGitHub <noreply@github.com>2022-10-18 09:14:20 +0300
commit1b26a55ef18bcf5894efe12f9519fb2fde2650fe (patch)
tree2d921b0d65e78043b27b6b400651923baaab916a
parente0c2b37daa2aaf235f670cff6f569c47a3481e92 (diff)
parent8eb12e9a098401bc3451d27db42c0ce0f2da21a4 (diff)
Merge PR #5917: FIX(client): Fix target and permission selection in updateMenuPermissions
This commit addresses two issues within the 'updateMenuPermissions' method: First, the target selection introduced in be7ad39 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 441d06f 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
-rw-r--r--src/mumble/MainWindow.cpp49
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() {