diff --git a/src/mumble/MainWindow.cpp b/src/mumble/MainWindow.cpp index f32428a4f40..81c4f289d13 100644 --- a/src/mumble/MainWindow.cpp +++ b/src/mumble/MainWindow.cpp @@ -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 diff --git a/src/mumble/MainWindow.h b/src/mumble/MainWindow.h index e54eab71169..a85aa33eb1d 100644 --- a/src/mumble/MainWindow.h +++ b/src/mumble/MainWindow.h @@ -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(); diff --git a/src/mumble/MainWindow.ui b/src/mumble/MainWindow.ui index da034615394..bf84cbc535e 100644 --- a/src/mumble/MainWindow.ui +++ b/src/mumble/MainWindow.ui @@ -919,6 +919,14 @@ the channel's context menu. &Pin When Filtering + + + Vie&w Description + + + View description in editor + + Vie&w Comment diff --git a/src/mumble/UserModel.cpp b/src/mumble/UserModel.cpp index 49d2fab1244..f79ae34157f 100644 --- a/src/mumble/UserModel.cpp +++ b/src/mumble/UserModel.cpp @@ -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; diff --git a/src/mumble/mumble_en.ts b/src/mumble/mumble_en.ts index 263bdf254b8..5046018a667 100644 --- a/src/mumble/mumble_en.ts +++ b/src/mumble/mumble_en.ts @@ -5134,6 +5134,10 @@ The setting only applies for new messages, the already shown ones will retain th View comment on user %1 + + View description of channel %1 + + Message to channel %1