mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
Merge pull request #2716 from csoler/v0.6-BugFixing_28
fixed right-click menu on board posts
This commit is contained in:
commit
7d70ecdd65
@ -43,6 +43,7 @@
|
||||
|
||||
#define LINK_IMAGE ":/images/thumb-link.png"
|
||||
|
||||
|
||||
// #ifdef DEBUG_BOARDPOSTDISPLAYWIDGET 1
|
||||
|
||||
/** Constructor */
|
||||
@ -58,6 +59,7 @@ BoardPostDisplayWidgetBase::BoardPostDisplayWidgetBase(const RsPostedPost& post,
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void BoardPostDisplayWidgetBase::setCommentsSize(int comNb)
|
||||
{
|
||||
QString sComButText = tr("Comment");
|
||||
@ -168,6 +170,7 @@ void BoardPostDisplayWidgetBase::baseSetup()
|
||||
|
||||
readButton()->setChecked(false);
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
QMenu *menu = new QMenu();
|
||||
menu->addAction(CopyLinkAction);
|
||||
menu->addSeparator();
|
||||
@ -175,6 +178,7 @@ void BoardPostDisplayWidgetBase::baseSetup()
|
||||
shareButton()->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
connect(menu,SIGNAL(aboutToShow()),this,SLOT(handleShareButtonClicked()));
|
||||
#endif
|
||||
|
||||
RsReputationLevel overall_reputation = rsReputations->overallReputationLevel(mPost.mMeta.mAuthorId);
|
||||
bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE);
|
||||
@ -182,7 +186,9 @@ void BoardPostDisplayWidgetBase::baseSetup()
|
||||
if(redacted)
|
||||
{
|
||||
commentButton()->setDisabled(true);
|
||||
#ifdef TO_REMOVE
|
||||
shareButton()->setDisabled(true);
|
||||
#endif
|
||||
voteUpButton()->setDisabled(true);
|
||||
voteDownButton()->setDisabled(true);
|
||||
fromLabel()->setId(mPost.mMeta.mAuthorId);
|
||||
@ -275,6 +281,7 @@ void BoardPostDisplayWidgetBase::baseSetup()
|
||||
emit sizeChanged(this);
|
||||
#endif
|
||||
}
|
||||
#ifdef TO_REMOVE
|
||||
void BoardPostDisplayWidgetBase::handleShareButtonClicked()
|
||||
{
|
||||
emit shareButtonClicked();
|
||||
@ -284,6 +291,8 @@ void BoardPostDisplayWidgetBase::handleCopyLinkClicked()
|
||||
{
|
||||
emit copylinkClicked();
|
||||
}
|
||||
#endif
|
||||
|
||||
//===================================================================================================================================
|
||||
//== class BoardPostDisplayWidget ==
|
||||
//===================================================================================================================================
|
||||
@ -292,6 +301,7 @@ BoardPostDisplayWidget_compact::BoardPostDisplayWidget_compact(const RsPostedPos
|
||||
: BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_compact())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->shareButton->hide();
|
||||
BoardPostDisplayWidget_compact::setup();
|
||||
}
|
||||
|
||||
@ -403,7 +413,7 @@ QLabel *BoardPostDisplayWidget_compact::dateLabel() { return ui->da
|
||||
ElidedLabel *BoardPostDisplayWidget_compact::titleLabel() { return ui->titleLabel; }
|
||||
QLabel *BoardPostDisplayWidget_compact::scoreLabel() { return ui->scoreLabel; }
|
||||
QLabel *BoardPostDisplayWidget_compact::notes() { return ui->notes; }
|
||||
QToolButton *BoardPostDisplayWidget_compact::shareButton() { return ui->shareButton; }
|
||||
//QToolButton *BoardPostDisplayWidget_compact::shareButton() { return ui->shareButton; }
|
||||
QLabel *BoardPostDisplayWidget_compact::pictureLabel() { return ui->pictureLabel; }
|
||||
QFrame *BoardPostDisplayWidget_compact::feedFrame() { return ui->feedFrame; }
|
||||
|
||||
@ -415,7 +425,8 @@ BoardPostDisplayWidget_card::BoardPostDisplayWidget_card(const RsPostedPost& pos
|
||||
: BoardPostDisplayWidgetBase(post,display_flags,parent), ui(new Ui::BoardPostDisplayWidget_card())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
BoardPostDisplayWidget_card::setup();
|
||||
ui->shareButton->hide();
|
||||
BoardPostDisplayWidget_card::setup();
|
||||
}
|
||||
|
||||
BoardPostDisplayWidget_card::~BoardPostDisplayWidget_card()
|
||||
@ -472,7 +483,7 @@ QLabel *BoardPostDisplayWidget_card::dateLabel() { return ui->dateL
|
||||
ElidedLabel *BoardPostDisplayWidget_card::titleLabel() { return ui->titleLabel; }
|
||||
QLabel *BoardPostDisplayWidget_card::scoreLabel() { return ui->scoreLabel; }
|
||||
QLabel *BoardPostDisplayWidget_card::notes() { return ui->notes; }
|
||||
QToolButton *BoardPostDisplayWidget_card::shareButton() { return ui->shareButton; }
|
||||
//QToolButton *BoardPostDisplayWidget_card::shareButton() { return ui->shareButton; }
|
||||
QLabel *BoardPostDisplayWidget_card::pictureLabel() { return ui->pictureLabel; }
|
||||
QFrame *BoardPostDisplayWidget_card::feedFrame() { return ui->feedFrame; }
|
||||
|
||||
|
@ -80,7 +80,7 @@ protected:
|
||||
virtual QLabel *notes() =0;
|
||||
virtual QLabel *pictureLabel()=0;
|
||||
virtual QToolButton *readButton() =0;
|
||||
virtual QToolButton *shareButton() =0;
|
||||
// virtual QToolButton *shareButton() =0;
|
||||
virtual QFrame *feedFrame() =0;
|
||||
|
||||
protected slots:
|
||||
@ -90,9 +90,10 @@ protected slots:
|
||||
void makeUpVote() ;
|
||||
void makeDownVote() ;
|
||||
void setCommentsSize(int comNb) ;
|
||||
#ifdef TO_REMOVE
|
||||
void handleShareButtonClicked() ;
|
||||
void handleCopyLinkClicked() ;
|
||||
|
||||
#endif
|
||||
|
||||
signals:
|
||||
void changeReadStatusRequested(const RsGxsMessageId&,bool);
|
||||
@ -100,8 +101,8 @@ signals:
|
||||
void expand(RsGxsMessageId,bool);
|
||||
void commentsRequested(const RsGxsMessageId&,bool);
|
||||
void thumbnailOpenned();
|
||||
void shareButtonClicked();
|
||||
void copylinkClicked();
|
||||
// void shareButtonClicked();
|
||||
// void copylinkClicked();
|
||||
|
||||
protected:
|
||||
RsPostedPost mPost;
|
||||
@ -129,7 +130,9 @@ public:
|
||||
QLabel *notes() override;
|
||||
QLabel *pictureLabel() override;
|
||||
QToolButton *readButton() override;
|
||||
#ifdef TO_REMOVE
|
||||
QToolButton *shareButton() override;
|
||||
#endif
|
||||
QFrame *feedFrame() override;
|
||||
|
||||
public slots:
|
||||
@ -167,7 +170,7 @@ public:
|
||||
QLabel *scoreLabel() override;
|
||||
QLabel *notes() override;
|
||||
QToolButton *readButton() override;
|
||||
QToolButton *shareButton() override;
|
||||
// QToolButton *shareButton() override;
|
||||
QLabel *pictureLabel() override;
|
||||
QFrame *feedFrame() override;
|
||||
|
||||
|
@ -219,7 +219,7 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
|
||||
else
|
||||
w = new BoardPostDisplayWidget_card(post,displayFlags(post.mMeta.mMsgId),parent);
|
||||
|
||||
QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool)));
|
||||
QObject::connect(w,SIGNAL(vote(RsGxsGrpMsgIdPair,bool)),mPostListWidget,SLOT(voteMsg(RsGxsGrpMsgIdPair,bool)));
|
||||
QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(expandItem(RsGxsMessageId,bool)));
|
||||
QObject::connect(w,SIGNAL(commentsRequested(RsGxsMessageId,bool)),mPostListWidget,SLOT(openComments(RsGxsMessageId)));
|
||||
QObject::connect(w,SIGNAL(changeReadStatusRequested(RsGxsMessageId,bool)),mPostListWidget,SLOT(changeReadStatus(RsGxsMessageId,bool)));
|
||||
@ -230,7 +230,6 @@ QWidget *PostedPostDelegate::createEditor(QWidget *parent, const QStyleOptionVie
|
||||
QObject::connect(w,SIGNAL(expand(RsGxsMessageId,bool)),this,SLOT(markCurrentPostAsRead()));
|
||||
QObject::connect(w,SIGNAL(commentsRequested(RsGxsMessageId,bool)),mPostListWidget,SLOT(markCurrentPostAsRead()));
|
||||
QObject::connect(w,SIGNAL(shareButtonClicked()),mPostListWidget,SLOT(markCurrentPostAsRead()));
|
||||
QObject::connect(w,SIGNAL(copylinkClicked()),mPostListWidget,SLOT(copyMessageLink()));
|
||||
|
||||
w->setGeometry(option.rect);
|
||||
w->adjustSize();
|
||||
@ -277,7 +276,6 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||
connect(ui->nextButton,SIGNAL(clicked()),this,SLOT(nextPosts()));
|
||||
connect(ui->prevButton,SIGNAL(clicked()),this,SLOT(prevPosts()));
|
||||
|
||||
connect(ui->postsTree,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(postContextMenu(QPoint)));
|
||||
connect(ui->viewModeButton,SIGNAL(clicked()),this,SLOT(switchDisplayMode()));
|
||||
|
||||
connect(mPostedPostsModel,SIGNAL(boardPostsLoaded()),this,SLOT(postPostLoad()));
|
||||
@ -296,7 +294,11 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||
|
||||
connect(ui->postsTree,SIGNAL(sizeChanged(QSize)),this,SLOT(handlePostsTreeSizeChange(QSize)));
|
||||
|
||||
/* load settings */
|
||||
ui->postsTree->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
//QObject::connect(this,SIGNAL(copylinkClicked()),this,SLOT(copyMessageLink()));
|
||||
connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&)));
|
||||
|
||||
/* load settings */
|
||||
processSettings(true);
|
||||
|
||||
/* Initialize subscribe button */
|
||||
@ -325,6 +327,32 @@ PostedListWidgetWithModel::PostedListWidgetWithModel(const RsGxsGroupId& postedI
|
||||
}, mEventHandlerId, RsEventType::GXS_POSTED );
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::postContextMenu(const QPoint& point)
|
||||
{
|
||||
QMenu menu(this);
|
||||
|
||||
// 1 - check that we are clicking on a post
|
||||
|
||||
QModelIndex index = ui->postsTree->indexAt(point);
|
||||
|
||||
if(!index.isValid())
|
||||
return;
|
||||
|
||||
// 2 - generate the menu for that post.
|
||||
|
||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()))->setData(index);
|
||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR), tr("Show author in People tab"), this, SLOT(showAuthorInPeople()))->setData(index);
|
||||
|
||||
#ifdef TODO
|
||||
// This feature is not implemented yet in libretroshare.
|
||||
|
||||
if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags))
|
||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost()));
|
||||
#endif
|
||||
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::switchDisplayMode()
|
||||
{
|
||||
if(mPostedPostsDelegate->getDisplayMode() == BoardPostDisplayWidget_compact::DISPLAY_MODE_CARD)
|
||||
@ -403,7 +431,7 @@ void PostedListWidgetWithModel::prevPosts()
|
||||
|
||||
void PostedListWidgetWithModel::showAuthorInPeople()
|
||||
{
|
||||
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||
QModelIndex index = qobject_cast<QAction*>(QObject::sender())->data().toModelIndex();
|
||||
|
||||
if(!index.isValid())
|
||||
throw std::runtime_error("No post under mouse!");
|
||||
@ -428,23 +456,6 @@ void PostedListWidgetWithModel::showAuthorInPeople()
|
||||
MainWindow::showWindow(MainWindow::People);
|
||||
idDialog->navigate(RsGxsId(post.mMeta.mAuthorId));
|
||||
}
|
||||
void PostedListWidgetWithModel::postContextMenu(const QPoint&)
|
||||
{
|
||||
QMenu menu(this);
|
||||
|
||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()));
|
||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR), tr("Show author in People tab"), this, SLOT(showAuthorInPeople()));
|
||||
|
||||
#ifdef TODO
|
||||
// This feature is not implemented yet in libretroshare.
|
||||
|
||||
if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags))
|
||||
menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost()));
|
||||
#endif
|
||||
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
void PostedListWidgetWithModel::copyMessageLink()
|
||||
{
|
||||
try
|
||||
@ -452,7 +463,7 @@ void PostedListWidgetWithModel::copyMessageLink()
|
||||
if (groupId().isNull())
|
||||
throw std::runtime_error("No channel currently selected!");
|
||||
|
||||
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||
QModelIndex index = qobject_cast<QAction*>(QObject::sender())->data().toModelIndex();
|
||||
|
||||
if(!index.isValid())
|
||||
throw std::runtime_error("No post under mouse!");
|
||||
@ -528,87 +539,6 @@ void PostedListWidgetWithModel::handleEvent_main_thread(std::shared_ptr<const Rs
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void PostedListWidgetWithModel::showPostDetails()
|
||||
{
|
||||
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||
RsPostedPost post = index.data(Qt::UserRole).value<RsPostedPost>() ;
|
||||
|
||||
QTextDocument doc;
|
||||
doc.setHtml(post.mMsg.c_str());
|
||||
|
||||
if(post.mMeta.mPublishTs == 0)
|
||||
{
|
||||
ui->postDetails_TE->clear();
|
||||
ui->postLogo_LB->hide();
|
||||
ui->postName_LB->hide();
|
||||
ui->postTime_LB->hide();
|
||||
mChannelPostFilesModel->clear();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ui->postLogo_LB->show();
|
||||
ui->postName_LB->show();
|
||||
ui->postTime_LB->show();
|
||||
|
||||
if(index.row()==0 && index.column()==0)
|
||||
std::cerr << "here" << std::endl;
|
||||
|
||||
std::cerr << "showPostDetails: setting mLastSelectedPosts[groupId()] to current post Id " << post.mMeta.mMsgId << ". Previous value: " << mLastSelectedPosts[groupId()] << std::endl;
|
||||
mLastSelectedPosts[groupId()] = post.mMeta.mMsgId;
|
||||
|
||||
std::list<ChannelPostFileInfo> files;
|
||||
for(auto& file:post.mFiles)
|
||||
files.push_back(ChannelPostFileInfo(file,post.mMeta.mPublishTs));
|
||||
|
||||
mChannelPostFilesModel->setFiles(files);
|
||||
|
||||
auto all_msgs_versions(post.mOlderVersions);
|
||||
all_msgs_versions.insert(post.mMeta.mMsgId);
|
||||
|
||||
ui->commentsDialog->commentLoad(post.mMeta.mGroupId, all_msgs_versions, post.mMeta.mMsgId);
|
||||
|
||||
std::cerr << "Showing details about selected index : "<< index.row() << "," << index.column() << std::endl;
|
||||
|
||||
ui->postDetails_TE->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), /* RSHTML_FORMATTEXT_EMBED_SMILEYS |*/ RSHTML_FORMATTEXT_EMBED_LINKS));
|
||||
|
||||
QPixmap postImage;
|
||||
|
||||
if (post.mThumbnail.mData != NULL)
|
||||
GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, postImage,GxsIdDetails::ORIGINAL);
|
||||
else
|
||||
postImage = FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE);
|
||||
|
||||
int W = QFontMetricsF(font()).height() * 8;
|
||||
|
||||
// Using fixed width so that the post will not displace the text when we browse.
|
||||
|
||||
ui->postLogo_LB->setPixmap(postImage);
|
||||
ui->postLogo_LB->setFixedSize(W,postImage.height()/(float)postImage.width()*W);
|
||||
|
||||
ui->postName_LB->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
|
||||
ui->postName_LB->setFixedWidth(W);
|
||||
ui->postTime_LB->setText(QDateTime::fromMSecsSinceEpoch(post.mMeta.mPublishTs*1000).toString("MM/dd/yyyy, hh:mm"));
|
||||
ui->postTime_LB->setFixedWidth(W);
|
||||
|
||||
//ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
|
||||
//ui->channelPostFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
|
||||
ui->channelPostFiles_TV->setAutoSelect(true);
|
||||
|
||||
// Now also set the post as read
|
||||
|
||||
if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
|
||||
{
|
||||
RsGxsGrpMsgIdPair postId;
|
||||
postId.second = post.mMeta.mMsgId;
|
||||
postId.first = post.mMeta.mGroupId;
|
||||
|
||||
RsThread::async([postId]() { rsGxsChannels->markRead(postId, true) ; } );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void PostedListWidgetWithModel::updateGroupData()
|
||||
{
|
||||
if(groupId().isNull())
|
||||
|
@ -136,6 +136,7 @@ private slots:
|
||||
#ifdef TO_REMOVE
|
||||
void showPostDetails();
|
||||
#endif
|
||||
void postContextMenu(const QPoint&);
|
||||
void showAuthorInPeople();
|
||||
void tabCloseRequested(int index);
|
||||
void updateSorting(int);
|
||||
@ -145,7 +146,6 @@ private slots:
|
||||
void subscribeGroup(bool subscribe);
|
||||
void settingsChanged();
|
||||
void postPostLoad();
|
||||
void postContextMenu(const QPoint&);
|
||||
void copyMessageLink();
|
||||
void nextPosts();
|
||||
void prevPosts();
|
||||
|
@ -1278,8 +1278,8 @@ void RsGxsForumModel::recursSetMsgReadStatus(ForumModelIndex i,bool read_status,
|
||||
void *ref ;
|
||||
convertTabEntryToRefPointer(i,ref); // we dont use i+1 here because i is not a row, but an index in the mPosts tab
|
||||
|
||||
QModelIndex itemIndex = createIndex(i - 1, 0, ref);
|
||||
emit dataChanged(itemIndex, itemIndex);
|
||||
QModelIndex itemIndex = (mTreeMode == TREE_MODE_FLAT)?createIndex(i - 1, 0, ref):createIndex(mPosts[i].prow,0,ref);
|
||||
emit dataChanged(itemIndex, itemIndex);
|
||||
}
|
||||
|
||||
if(!with_children)
|
||||
|
Loading…
Reference in New Issue
Block a user