From 725c000ce7d031e1c0a2db60876809d4e921bfd4 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 9 Oct 2020 23:27:44 +0200 Subject: [PATCH] moved showAuthorInPeople to PostedListWidgetWithModel, out of share menu, and disabled edit for now --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 21 ----------- .../src/gui/Posted/BoardPostDisplayWidget.h | 1 - .../gui/Posted/PostedListWidgetWithModel.cpp | 36 +++++++++++++++++++ .../gui/Posted/PostedListWidgetWithModel.h | 1 + 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index d24bf2242..40e50685e 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -147,23 +147,6 @@ void BoardPostDisplayWidgetBase::readToggled() emit changeReadStatusRequested(mPost.mMeta.mMsgId,s); } -void BoardPostDisplayWidgetBase::showAuthorInPeople() -{ - if(mPost.mMeta.mAuthorId.isNull()) - { - std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data..."; - std::cerr << std::endl; - } - - /* window will destroy itself! */ - IdDialog *idDialog = dynamic_cast(MainWindow::getPage(MainWindow::People)); - - if (!idDialog) - return ; - - MainWindow::showWindow(MainWindow::People); - idDialog->navigate(RsGxsId(mPost.mMeta.mAuthorId)); -} void BoardPostDisplayWidgetBase::setup() { @@ -188,9 +171,6 @@ void BoardPostDisplayWidgetBase::setup() QAction *CopyLinkAction = new QAction(QIcon(""),tr("Copy RetroShare Link"), this); connect(CopyLinkAction, SIGNAL(triggered()), this, SLOT(handleCopyLinkClicked())); - QAction *showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); - connect(showInPeopleAct, SIGNAL(triggered()), this, SLOT(showAuthorInPeople())); - int S = QFontMetricsF(font()).height() ; readButton()->setChecked(false); @@ -198,7 +178,6 @@ void BoardPostDisplayWidgetBase::setup() QMenu *menu = new QMenu(); menu->addAction(CopyLinkAction); menu->addSeparator(); - menu->addAction(showInPeopleAct); shareButton()->setMenu(menu); connect(shareButton(),SIGNAL(pressed()),this,SLOT(handleShareButtonClicked())); diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index 2016ff678..30720d692 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -83,7 +83,6 @@ protected slots: virtual QFrame *mainFrame() =0; void loadComments(bool e); - void showAuthorInPeople(); void readToggled(); void setReadStatus(bool isNew, bool isUnread) ; void makeUpVote() ; diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 387b271eb..4a5164834 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -37,12 +37,15 @@ #include "gui/settings/rsharesettings.h" #include "gui/feeds/SubFileItem.h" #include "gui/notifyqt.h" +#include "gui/Identity/IdDialog.h" #include "gui/RetroShareLink.h" #include "util/HandleRichText.h" #include "util/DateTime.h" #include "util/qtthreadsutils.h" #include "gui/common/FilesDefs.h" +#include "gui/MainWindow.h" + #include "PostedListWidgetWithModel.h" #include "PostedPostsModel.h" #include "BoardPostDisplayWidget.h" @@ -64,6 +67,7 @@ // // #define IMAGE_COPYLINK ":/images/copyrslink.png" +#define IMAGE_AUTHOR ":/images/user/personal64.png" Q_DECLARE_METATYPE(RsPostedPost); @@ -369,14 +373,46 @@ void PostedListWidgetWithModel::prev10Posts() } } +void PostedListWidgetWithModel::showAuthorInPeople() +{ + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + + if(!index.isValid()) + throw std::runtime_error("No post under mouse!"); + + RsPostedPost post = index.data(Qt::UserRole).value() ; + + if(post.mMeta.mMsgId.isNull()) + throw std::runtime_error("Post has empty MsgId!"); + + if(post.mMeta.mAuthorId.isNull()) + { + std::cerr << "(EE) GxsForumThreadWidget::loadMsgData_showAuthorInPeople() ERROR Missing Message Data..."; + std::cerr << std::endl; + } + + /* window will destroy itself! */ + IdDialog *idDialog = dynamic_cast(MainWindow::getPage(MainWindow::People)); + + if (!idDialog) + return ; + + 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()); } diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index 63dcbf9e1..3b8ebc7df 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -132,6 +132,7 @@ protected: virtual void setAllMessagesReadDo(bool read, uint32_t &token) override; private slots: + void showAuthorInPeople(); void tabCloseRequested(int index); void updateSorting(int); void switchDisplayMode();