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 2d6974a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/mumble/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/mumble/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions src/mumble/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
4 changes: 4 additions & 0 deletions src/mumble/UserModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions src/mumble/mumble_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -6204,6 +6208,10 @@ Otherwise abort and check your certificate and username.</source>
<source>View comment in editor</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>View description in editor</source>
<translation type="unfisihed"></translation>
</message>
<message>
<source>Query server for connection information for user</source>
<translation type="unfinished"></translation>
Expand Down Expand Up @@ -6957,6 +6965,10 @@ Valid options are:
<source>Vie&amp;w Comment</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Vie&amp;w Description</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&amp;Priority Speaker</source>
<translation type="unfinished"></translation>
Expand Down

0 comments on commit 2d6974a

Please sign in to comment.