diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 06b585614..8f1cddf7d 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -74,7 +74,7 @@ BasePostedItem::BasePostedItem( FeedHolder *feedHolder, uint32_t feedId BasePostedItem::~BasePostedItem() { - auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(200); + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(200); while( (mIsLoadingGroup || mIsLoadingMessage || mIsLoadingComment) && std::chrono::steady_clock::now() < timeout) { diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp index 5c63ce2e9..1798bb4bc 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "retroshare/rsgxscircles.h" @@ -72,6 +73,7 @@ static const int POSTED_TABS_POSTS = 1; // #define IMAGE_COPYLINK ":/images/copyrslink.png" #define IMAGE_AUTHOR ":/images/user/personal64.png" +#define IMAGE_COPYHTTP ":/images/emblem-web.png" Q_DECLARE_METATYPE(RsPostedPost); @@ -340,7 +342,18 @@ void PostedListWidgetWithModel::postContextMenu(const QPoint& point) // 2 - generate the menu for that post. + RsPostedPost post = index.data(Qt::UserRole).value() ; + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink()))->setData(index); + + QByteArray urlarray(post.mLink.c_str()); + QUrl url = QUrl::fromEncoded(urlarray.trimmed()); + + std::cerr << "Using link: \"" << post.mLink << "\"" << std::endl; + + if(url.scheme()=="http" || url.scheme()=="https") + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYHTTP), tr("Copy http Link"), this, SLOT(copyHttpLink()))->setData(index); + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_AUTHOR), tr("Show author in People tab"), this, SLOT(showAuthorInPeople()))->setData(index); #ifdef TODO @@ -456,6 +469,31 @@ void PostedListWidgetWithModel::showAuthorInPeople() MainWindow::showWindow(MainWindow::People); idDialog->navigate(RsGxsId(post.mMeta.mAuthorId)); } +void PostedListWidgetWithModel::copyHttpLink() +{ + try + { + if (groupId().isNull()) + throw std::runtime_error("No channel currently selected!"); + + QModelIndex index = qobject_cast(QObject::sender())->data().toModelIndex(); + + 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!"); + + QApplication::clipboard()->setText(QString::fromStdString(post.mLink)) ; + QMessageBox::information(NULL,tr("information"),tr("The Retrohare link was copied to your clipboard.")) ; + } + catch(std::exception& e) + { + QMessageBox::critical(NULL,tr("Link creation error"),tr("Link could not be created: ")+e.what()); + } +} void PostedListWidgetWithModel::copyMessageLink() { try @@ -823,6 +861,7 @@ void PostedListWidgetWithModel::insertBoardDetails(const RsPostedGroup& group) ui->subscribeToolButton->setText(tr("Subscribe")); ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount)); + ui->poplabel->setText(QString::number(group.mMeta.mPop)); if(group.mMeta.mLastPost==0) ui->infoLastPost->setText(tr("Never")); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h index e6b98120a..cb7dcfd39 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.h @@ -147,6 +147,7 @@ private slots: void settingsChanged(); void postPostLoad(); void copyMessageLink(); + void copyHttpLink(); void nextPosts(); void prevPosts(); void filterItems(QString s); diff --git a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui index 2bafbc8a2..8074388dc 100644 --- a/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui +++ b/retroshare-gui/src/gui/Posted/PostedListWidgetWithModel.ui @@ -54,7 +54,7 @@ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;">Description</span></p></body></html> @@ -84,8 +84,11 @@ p, li { white-space: pre-wrap; } true + + <html><head/><body><p>Maximum number of data items (including posts, comments, votes) across friend nodes.</p></body></html> + - Contributions: + Items (at friends): @@ -179,6 +182,9 @@ p, li { white-space: pre-wrap; } true + + Number of subscribed friend nodes + Popularity: @@ -615,8 +621,8 @@ p, li { white-space: pre-wrap; } - + diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index eedb4ae20..81b026d27 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -83,6 +83,19 @@ GxsForumMsgItem::GxsForumMsgItem(FeedHolder *feedHolder, uint32_t feedId, const GxsForumMsgItem::~GxsForumMsgItem() { + auto timeout = std::chrono::steady_clock::now() + std::chrono::milliseconds(300); + + while( (mLoadingGroup || mLoadingMessage || mLoadingSetAsRead || mLoadingParentMessage) + && std::chrono::steady_clock::now() < timeout) + { + RsDbg() << __PRETTY_FUNCTION__ << " is Waiting for " + << (mLoadingGroup ? "Group " : "") + << (mLoadingMessage ? "Message " : "") + << (mLoadingParentMessage ? "Parent message " : "") + << (mLoadingSetAsRead ? "Set as read" : "") + << "loading." << std::endl; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } delete(ui); } @@ -167,6 +180,8 @@ QString GxsForumMsgItem::groupName() void GxsForumMsgItem::loadGroup() { + mLoadingGroup = true; + RsThread::async([this]() { // 1 - get group data @@ -199,6 +214,7 @@ void GxsForumMsgItem::loadGroup() * after a blocking call to RetroShare API complete */ setGroup(group); + mLoadingGroup = false; }, this ); }); @@ -210,6 +226,7 @@ void GxsForumMsgItem::loadMessage() std::cerr << "GxsForumMsgItem::loadMessage(): messageId=" << messageId() << " groupId=" << groupId() ; std::cerr << std::endl; #endif + mLoadingMessage = true; RsThread::async([this]() { @@ -244,6 +261,7 @@ void GxsForumMsgItem::loadMessage() * after a blocking call to RetroShare API complete */ setMessage(msg); + mLoadingMessage = false; }, this ); }); @@ -255,6 +273,7 @@ void GxsForumMsgItem::loadParentMessage(const RsGxsMessageId& parent_msg) std::cerr << "GxsForumMsgItem::loadParentMessage()"; std::cerr << std::endl; #endif + mLoadingParentMessage = true; RsThread::async([parent_msg,this]() { @@ -291,6 +310,8 @@ void GxsForumMsgItem::loadParentMessage(const RsGxsMessageId& parent_msg) mParentMessage = msg; fillParentMessage(); + mLoadingParentMessage = false; + }, this ); }); } @@ -480,6 +501,7 @@ void GxsForumMsgItem::setAsRead(bool doUpdate) } mCloseOnRead = false; + mLoadingSetAsRead = true; RsThread::async( [this, doUpdate]() { RsGxsGrpMsgIdPair msgPair = std::make_pair(groupId(), messageId()); @@ -489,6 +511,7 @@ void GxsForumMsgItem::setAsRead(bool doUpdate) if (doUpdate) { RsQThreadUtils::postToObject( [this]() { setReadStatus(false, true); + mLoadingSetAsRead = false; } ); } }); diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h index 34166ee59..ec933d96e 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.h @@ -87,6 +87,10 @@ private: private: bool mInFill; bool mCloseOnRead; + bool mLoadingMessage; + bool mLoadingParentMessage; + bool mLoadingGroup; + bool mLoadingSetAsRead; RsGxsForumGroup mGroup; RsGxsForumMsg mMessage; diff --git a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp index 97f128447..053590e11 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdTreeWidgetItem.cpp @@ -193,17 +193,25 @@ void GxsIdTreeItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem QStyleOptionViewItem ownOption (option); initStyleOption(&ownOption, index); - RsGxsId id(index.data(Qt::UserRole).toString().toStdString()); - QString cmt; + QString dt = index.data(Qt::UserRole).toString(); + RsGxsId id(index.data(Qt::UserRole).toString().toStdString()); - if(id.isNull()) + // This is a trick: UserRole in Mail generally is 0000...00000 when there is a notification, and is empty when there are multiple + // destinations at once. This is not so nice to do that this way, but it's a quick workaround to a more complex method involving an + // additional Qt role only to determine the number of destinations. + + if(dt == "") + ownOption.icon = FilesDefs::getIconFromQtResourcePath(":/icons/svg/people2.svg"); + else if(id.isNull()) + { + if (ownOption.icon.isNull()) + ownOption.icon = FilesDefs::getIconFromQtResourcePath(":/icons/notification.svg"); + } + else { - if (ownOption.icon.isNull()) - ownOption.icon = FilesDefs::getIconFromQtResourcePath(":/icons/notification.svg"); - } - else - { - if(! computeNameIconAndComment(id,ownOption.text,ownOption.icon,cmt)) + QString cmt; + + if(! computeNameIconAndComment(id,ownOption.text,ownOption.icon,cmt)) { if(mReloadPeriod > 3) { diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index c92057c29..ff3771075 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -15,6 +15,7 @@ icons/svg/display_options.svg icons/svg/listlayout.svg icons/svg/gridlayout.svg + icons/svg/people2.svg icons/stars/star0.png icons/stars/star1.png icons/stars/star2.png diff --git a/retroshare-gui/src/gui/msgs/MessageModel.cpp b/retroshare-gui/src/gui/msgs/MessageModel.cpp index 771fd6874..09508cad6 100644 --- a/retroshare-gui/src/gui/msgs/MessageModel.cpp +++ b/retroshare-gui/src/gui/msgs/MessageModel.cpp @@ -579,7 +579,18 @@ QVariant RsMessageModel::userRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col) { case COLUMN_THREAD_AUTHOR: return QVariant(QString::fromStdString(fmpe.from.toStdString())); case COLUMN_THREAD_MSGID: return QVariant(QString::fromStdString(fmpe.msgId)); - case COLUMN_THREAD_TO: return QVariant(QString::fromStdString(fmpe.to.toStdString())); + case COLUMN_THREAD_TO: + { + // First check if the .to field is filled. + + if(!fmpe.to.toStdString().empty()) + return QVariant(QString::fromStdString(fmpe.to.toStdString())); + + // In the Send box, .to is never filled. In this case we look into destinations. + + if(fmpe.destinations.size()==1) + return QVariant(QString::fromStdString((*fmpe.destinations.begin()).toStdString())); + } default: return QVariant(); }