-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEAT(client): Add "View Description" context action to channels #6526
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just for the record, I think here the same issue with the root channel applies that Hartmnt has found elsewhere already. |
||
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 | ||
|
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; | ||
Comment on lines
+1274
to
+1275
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole casting here looks somewhat fishy. It is probably working as expected (and I realize you replicated the same mechanism as for the user comment). time passes Haha, ok guess what. This indeed breaks for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The best thing I can think of without refactoring receiving descriptions/comments from the server is to add an extra field to If this is acceptable, I can try implementing it soon There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the problem doesn't exist in ClientUser since users never get session id 0, but using the negation of the IDs to differentiate between popup and the "view description/comment" option is hacky in both cases There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The extra field as an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am all for switching to a "proper" implementation instead of negating ids. I do not think anything will break if you remove the existing negation logic. |
||
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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.