Skip to content

Commit

Permalink
FEAT(client): Add "View Description" context action to channels
Browse files Browse the repository at this point in the history
Previously, channel descriptions could only be viewed as a pop-up which
does not allow text selection/copying and doesn't allow you to scroll
through descriptions to large to fit on your screen.

User comments already support this use case via the "View Comment"
context menu action on users which opens their comment in a separate
window.

This commit adds a "View Description" context menu action to channels
which works the same way as the "View Comment" action.
  • Loading branch information
dexgs committed Aug 6, 2024
1 parent b75fe54 commit 73c4763
Showing 5 changed files with 47 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/mumble/MainWindow.cpp
Original file line number Diff line number Diff line change
@@ -2258,6 +2258,7 @@ void MainWindow::qmChannel_aboutToShow() {
qmChannel->addAction(qaChannelUnlinkAll);
qmChannel->addSeparator();
qmChannel->addAction(qaChannelCopyURL);
qmChannel->addAction(qaChannelDescriptionView);
qmChannel->addAction(qaChannelSendMessage);

// hiding the root is nonsense
@@ -2310,6 +2311,7 @@ void MainWindow::qmChannel_aboutToShow() {
if (c) {
qaChannelHide->setChecked(c->m_filterMode == ChannelFilterMode::HIDE);
qaChannelPin->setChecked(c->m_filterMode == ChannelFilterMode::PIN);
qaChannelDescriptionView->setEnabled(!c->qbaDescHash.isEmpty());
}

qaChannelAdd->setEnabled(add);
@@ -2531,6 +2533,34 @@ void MainWindow::on_qaChannelCopyURL_triggered() {
QClipboard::Clipboard);
}

void MainWindow::on_qaChannelDescriptionView_triggered() {
Channel *c = getContextMenuChannel();
// This has to be done here because UserModel could've set it.
cContextChannel.clear();

if (!c)
return;

if (!c->qbaDescHash.isEmpty() && c->qsDesc.isEmpty()) {
c->qsDesc = QString::fromUtf8(Global::get().db->blob(c->qbaDescHash));
if (c->qsDesc.isEmpty()) {
pmModel->iChannelDescription = ~static_cast< int >(c->iId);
MumbleProto::RequestBlob mprb;
mprb.add_channel_description(c->iId);
Global::get().sh->sendMessage(mprb);
return;
}
}

pmModel->seenComment(pmModel->index(c));

::TextMessage *texm = new ::TextMessage(this, tr("View description of channel %1").arg(c->qsName));

texm->rteMessage->setText(c->qsDesc, true);
texm->setAttribute(Qt::WA_DeleteOnClose, true);
texm->show();
}

/**
* This function updates the UI according to the permission of the user in the current channel.
* If possible the permissions are fetched from a cache. Otherwise they are requested by the server
1 change: 1 addition & 0 deletions src/mumble/MainWindow.h
Original file line number Diff line number Diff line change
@@ -271,6 +271,7 @@ public slots:
void on_qaChannelHide_triggered();
void on_qaChannelPin_triggered();
void on_qaChannelCopyURL_triggered();
void on_qaChannelDescriptionView_triggered();
void on_qaAudioReset_triggered();
void on_qaAudioMute_triggered();
void on_qaAudioDeaf_triggered();
8 changes: 8 additions & 0 deletions src/mumble/MainWindow.ui
Original file line number Diff line number Diff line change
@@ -919,6 +919,14 @@ the channel's context menu.</string>
<string>&amp;Pin When Filtering</string>
</property>
</action>
<action name="qaChannelDescriptionView">
<property name="text">
<string>Vie&amp;w Description</string>
</property>
<property name="toolTip">
<string>View description in editor</string>
</property>
</action>
<action name="qaUserCommentView">
<property name="text">
<string>Vie&amp;w Comment</string>
4 changes: 4 additions & 0 deletions src/mumble/UserModel.cpp
Original file line number Diff line number Diff line change
@@ -1271,6 +1271,10 @@ void UserModel::setComment(Channel *c, const QString &comment) {
QToolTip::showText(QCursor::pos(), data(index(c, 0), Qt::ToolTipRole).toString(),
Global::get().mw->qtvUsers);
}
} else if (c->iId == static_cast< unsigned int >(~iChannelDescription)) {
iChannelDescription = -1;
Global::get().mw->cContextChannel = c;
QTimer::singleShot(0, Global::get().mw, &MainWindow::on_qaChannelDescriptionView_triggered);
} else {
item->bCommentSeen = Global::get().db->seenComment(item->hash(), c->qbaDescHash);
newstate = item->bCommentSeen ? 2 : 1;
4 changes: 4 additions & 0 deletions src/mumble/mumble_en.ts
Original file line number Diff line number Diff line change
@@ -5134,6 +5134,10 @@ The setting only applies for new messages, the already shown ones will retain th
<source>View comment on user %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>View description of channel %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Message to channel %1</source>
<translation type="unfinished"></translation>

0 comments on commit 73c4763

Please sign in to comment.