Skip to content

Commit 2d6974a

Browse files
committed
FEAT(client): Add "View Description" context action to channels
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.
1 parent b75fe54 commit 2d6974a

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed

src/mumble/MainWindow.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,6 +2258,7 @@ void MainWindow::qmChannel_aboutToShow() {
22582258
qmChannel->addAction(qaChannelUnlinkAll);
22592259
qmChannel->addSeparator();
22602260
qmChannel->addAction(qaChannelCopyURL);
2261+
qmChannel->addAction(qaChannelDescriptionView);
22612262
qmChannel->addAction(qaChannelSendMessage);
22622263

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

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

2536+
void MainWindow::on_qaChannelDescriptionView_triggered() {
2537+
Channel *c = getContextMenuChannel();
2538+
// This has to be done here because UserModel could've set it.
2539+
cContextChannel.clear();
2540+
2541+
if (!c)
2542+
return;
2543+
2544+
if (!c->qbaDescHash.isEmpty() && c->qsDesc.isEmpty()) {
2545+
c->qsDesc = QString::fromUtf8(Global::get().db->blob(c->qbaDescHash));
2546+
if (c->qsDesc.isEmpty()) {
2547+
pmModel->iChannelDescription = ~static_cast< int >(c->iId);
2548+
MumbleProto::RequestBlob mprb;
2549+
mprb.add_channel_description(c->iId);
2550+
Global::get().sh->sendMessage(mprb);
2551+
return;
2552+
}
2553+
}
2554+
2555+
pmModel->seenComment(pmModel->index(c));
2556+
2557+
::TextMessage *texm = new ::TextMessage(this, tr("View description of channel %1").arg(c->qsName));
2558+
2559+
texm->rteMessage->setText(c->qsDesc, true);
2560+
texm->setAttribute(Qt::WA_DeleteOnClose, true);
2561+
texm->show();
2562+
}
2563+
25342564
/**
25352565
* This function updates the UI according to the permission of the user in the current channel.
25362566
* If possible the permissions are fetched from a cache. Otherwise they are requested by the server

src/mumble/MainWindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ public slots:
271271
void on_qaChannelHide_triggered();
272272
void on_qaChannelPin_triggered();
273273
void on_qaChannelCopyURL_triggered();
274+
void on_qaChannelDescriptionView_triggered();
274275
void on_qaAudioReset_triggered();
275276
void on_qaAudioMute_triggered();
276277
void on_qaAudioDeaf_triggered();

src/mumble/MainWindow.ui

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,14 @@ the channel's context menu.</string>
919919
<string>&amp;Pin When Filtering</string>
920920
</property>
921921
</action>
922+
<action name="qaChannelDescriptionView">
923+
<property name="text">
924+
<string>Vie&amp;w Description</string>
925+
</property>
926+
<property name="toolTip">
927+
<string>View description in editor</string>
928+
</property>
929+
</action>
922930
<action name="qaUserCommentView">
923931
<property name="text">
924932
<string>Vie&amp;w Comment</string>

src/mumble/UserModel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1271,6 +1271,10 @@ void UserModel::setComment(Channel *c, const QString &comment) {
12711271
QToolTip::showText(QCursor::pos(), data(index(c, 0), Qt::ToolTipRole).toString(),
12721272
Global::get().mw->qtvUsers);
12731273
}
1274+
} else if (c->iId == static_cast< unsigned int >(~iChannelDescription)) {
1275+
iChannelDescription = -1;
1276+
Global::get().mw->cContextChannel = c;
1277+
QTimer::singleShot(0, Global::get().mw, &MainWindow::on_qaChannelDescriptionView_triggered);
12741278
} else {
12751279
item->bCommentSeen = Global::get().db->seenComment(item->hash(), c->qbaDescHash);
12761280
newstate = item->bCommentSeen ? 2 : 1;

src/mumble/mumble_en.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5134,6 +5134,10 @@ The setting only applies for new messages, the already shown ones will retain th
51345134
<source>View comment on user %1</source>
51355135
<translation type="unfinished"></translation>
51365136
</message>
5137+
<message>
5138+
<source>View description of channel %1</source>
5139+
<translation type="unfinished"></translation>
5140+
</message>
51375141
<message>
51385142
<source>Message to channel %1</source>
51395143
<translation type="unfinished"></translation>
@@ -6204,6 +6208,10 @@ Otherwise abort and check your certificate and username.</source>
62046208
<source>View comment in editor</source>
62056209
<translation type="unfinished"></translation>
62066210
</message>
6211+
<message>
6212+
<source>View description in editor</source>
6213+
<translation type="unfisihed"></translation>
6214+
</message>
62076215
<message>
62086216
<source>Query server for connection information for user</source>
62096217
<translation type="unfinished"></translation>
@@ -6957,6 +6965,10 @@ Valid options are:
69576965
<source>Vie&amp;w Comment</source>
69586966
<translation type="unfinished"></translation>
69596967
</message>
6968+
<message>
6969+
<source>Vie&amp;w Description</source>
6970+
<translation type="unfinished"></translation>
6971+
</message>
69606972
<message>
69616973
<source>&amp;Priority Speaker</source>
69626974
<translation type="unfinished"></translation>

0 commit comments

Comments
 (0)