From 4b891ddd90343b8790cc18d8c860a0a899b31e74 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Thu, 25 Jun 2020 17:26:55 +0300 Subject: [PATCH 01/64] service descriptions in permission matrix --- .../gui/settings/RSPermissionMatrixWidget.cpp | 67 ++++++++++++++++++- .../gui/settings/RSPermissionMatrixWidget.h | 1 + 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp index 0cca26d18..188fa5ee3 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp @@ -35,6 +35,8 @@ #include #include #include +#include "rsitems/rsserviceids.h" +#include #define NOT_IMPLEMENTED std::cerr << __PRETTY_FUNCTION__ << ": not yet implemented." << std::endl; @@ -531,6 +533,40 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) _max_height = S*fMATRIX_START_Y + (peer_ids.size()+3) * S*fROW_SIZE ; _max_width = matrix_start_x + (service_ids.size()+3) * S*fCOL_SIZE ; + if(n_row_selected == -1) + { + for(uint32_t i=0;i> 8); + QString service_name = "Service: 0x"+ QString::number(serviceOrig,16) + " " + QString::fromStdString(rsServiceControl->getServiceName(service_ids[i])); + QBrush brush ; + brush.setColor(QColor::fromHsvF(0.0f,0.0f,1.0f,0.8f)); + brush.setStyle(Qt::SolidPattern) ; + QPen pen ; + pen.setWidth(1) ; + pen.setBrush(FOREGROUND_COLOR) ; + _painter->setPen(pen) ; + QRect position = computeNodePosition(0,0,false) ; + int popup_x = position.x() + (50 * S / 14.0); + int popup_y = position.y() - (10 * S / 14.0) + line_height; + int popup_width = _max_width * 3 / 4; + int popup_height = line_height * 5; + QRect info_pos(popup_x, popup_y, popup_width, popup_height) ; + _painter->fillRect(info_pos,brush) ; + _painter->drawRect(info_pos) ; + float x = info_pos.x() + 5*S/14.0 ; + float y = info_pos.y() + line_height + 1*S/14.0 ; + _painter->drawText(QPointF(x,y), service_name) ; y += line_height ; + _painter->translate(QPointF(popup_x+S, popup_y+2*line_height)); + QTextDocument td; + td.setHtml(ServiceDescription(serviceOrig)); + td.drawContents(_painter); + } + } + } + /* Stop the painter */ _painter->end(); } @@ -611,4 +647,33 @@ void RSPermissionMatrixWidget::userPermissionSwitched(uint32_t /* ServiceId */,c NOT_IMPLEMENTED ; } - +QString RSPermissionMatrixWidget::ServiceDescription(uint16_t serviceid) +{ + switch(serviceid) + { + case RS_SERVICE_TYPE_DISC: return tr("Location info exchange between friends. Helps to find actual address in case of dynamic IPs
Without it you will have to rely on DHT only for getting fresh addresses"); + case RS_SERVICE_TYPE_CHAT: return tr("Used by direct F2F chat, distant chat and chat lobbies"); + case RS_SERVICE_TYPE_MSG: return tr("Mailing service. Also required for direct f2f chat"); + case RS_SERVICE_TYPE_TURTLE: return tr("Anonymous routing. Used by file transfers and file search,
distant chat, distant mail and distant channels/etc sync"); + case RS_SERVICE_TYPE_HEARTBEAT: return tr("Checks if peers alive"); + case RS_SERVICE_TYPE_FILE_TRANSFER: return tr("File transfer. If you kill it - you won't be able to dl files from friend shares. Anonymous access unnaffected"); + case RS_SERVICE_TYPE_GROUTER: return tr("Used by distant mail for immediate delivery using anonymous tunnels (turtle router)"); + case RS_SERVICE_TYPE_FILE_DATABASE: return tr("Exchange shared directories info, aka browsable(visible) files"); + case RS_SERVICE_TYPE_SERVICEINFO: return tr("Allows your node to tell to your friends which service are ON on your side, and vice-versa"); + case RS_SERVICE_TYPE_BWCTRL: return tr("Speed management"); + case RS_SERVICE_TYPE_GXS_TUNNEL: return tr("Used by distant chat, distant mail, and distant channels sync for transfer data using anonymous tunnels"); + case RS_SERVICE_TYPE_BANLIST: return tr("IP filter lists exchange"); + case RS_SERVICE_TYPE_STATUS: return tr("Share user status like online, away, busy with friends"); + case RS_SERVICE_GXS_TYPE_GXSID: return tr("Identity data exchange. Required by all identities-related functions like chats, forums, mail, etc"); + case RS_SERVICE_GXS_TYPE_PHOTO: return tr("RS_SERVICE_GXS_TYPE_PHOTO"); + case RS_SERVICE_GXS_TYPE_WIKI: return tr("RS_SERVICE_GXS_TYPE_WIKI"); + case RS_SERVICE_GXS_TYPE_FORUMS: return tr("Transfer Forums"); + case RS_SERVICE_GXS_TYPE_POSTED: return tr("Transfer Posted"); + case RS_SERVICE_GXS_TYPE_CHANNELS: return tr("Transfer Channels"); + case RS_SERVICE_GXS_TYPE_GXSCIRCLE: return tr("Transfer Circles"); + case RS_SERVICE_GXS_TYPE_REPUTATION:return tr("Votes exchange - bans/upvotes for Identities"); + case RS_SERVICE_TYPE_GXS_TRANS: return tr("Used by distant mail for deferred delivery - stored at friends when target offline"); + case RS_SERVICE_TYPE_RTT: return tr("Measures the Round Trip Time between you and your friends"); + default: return tr("unknown"); + } +} diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h index 6b64150cb..ffc9a32b0 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.h @@ -59,6 +59,7 @@ class RSPermissionMatrixWidget: public QFrame public: RSPermissionMatrixWidget(QWidget *parent=NULL); virtual ~RSPermissionMatrixWidget() ; + QString ServiceDescription(uint16_t serviceid); public slots: void setHideOffline(bool hide); From 0f1890813e629e0ddd6613672735d7fd1c7386e7 Mon Sep 17 00:00:00 2001 From: RetroPooh Date: Tue, 30 Jun 2020 11:53:13 +0300 Subject: [PATCH 02/64] popup dynamic size and pos --- .../gui/settings/RSPermissionMatrixWidget.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp index 188fa5ee3..7d869ab57 100644 --- a/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp +++ b/retroshare-gui/src/gui/settings/RSPermissionMatrixWidget.cpp @@ -539,7 +539,10 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) { if(_current_service_id == service_ids[i]) { - uint16_t serviceOrig = (uint16_t)((service_ids[i] - (((uint32_t)RS_PKT_VERSION_SERVICE) << 24) ) >> 8); + //uint16_t serviceOrig = (uint16_t)((service_ids[i] - (((uint32_t)RS_PKT_VERSION_SERVICE) << 24) ) >> 8); + uint16_t serviceOrig=(service_ids[i]>>8) & 0xffff; + QTextDocument td; + td.setHtml(ServiceDescription(serviceOrig)); QString service_name = "Service: 0x"+ QString::number(serviceOrig,16) + " " + QString::fromStdString(rsServiceControl->getServiceName(service_ids[i])); QBrush brush ; brush.setColor(QColor::fromHsvF(0.0f,0.0f,1.0f,0.8f)); @@ -548,20 +551,22 @@ void RSPermissionMatrixWidget::paintEvent(QPaintEvent *) pen.setWidth(1) ; pen.setBrush(FOREGROUND_COLOR) ; _painter->setPen(pen) ; - QRect position = computeNodePosition(0,0,false) ; + QRect position = computeNodePosition(0,i,false) ; int popup_x = position.x() + (50 * S / 14.0); int popup_y = position.y() - (10 * S / 14.0) + line_height; - int popup_width = _max_width * 3 / 4; - int popup_height = line_height * 5; + int popup_width = std::max((int)td.size().width(), fm.width(service_name)) + S; + int popup_height = td.size().height() + line_height*2; + while (popup_x + popup_width > _max_width) + popup_x -= S; + if (popup_y + popup_height > _max_height) + popup_y -= popup_height; QRect info_pos(popup_x, popup_y, popup_width, popup_height) ; _painter->fillRect(info_pos,brush) ; _painter->drawRect(info_pos) ; float x = info_pos.x() + 5*S/14.0 ; float y = info_pos.y() + line_height + 1*S/14.0 ; _painter->drawText(QPointF(x,y), service_name) ; y += line_height ; - _painter->translate(QPointF(popup_x+S, popup_y+2*line_height)); - QTextDocument td; - td.setHtml(ServiceDescription(serviceOrig)); + _painter->translate(QPointF(popup_x, popup_y+2*line_height)); td.drawContents(_painter); } } From 958d13951cf39c297900a7f28e9dce62448e038a Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 1 Jul 2020 04:23:20 +0900 Subject: [PATCH 03/64] gxsforums: add expand subtree button to context menu --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 28 ++++++++++++++++++- .../src/gui/gxsforums/GxsForumThreadWidget.h | 4 +++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 29cfa5b44..2d0a79825 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -596,6 +596,11 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) QAction* expandAll = new QAction(tr("Expand all"), &contextMnu); connect(expandAll, SIGNAL(triggered()), ui->threadTreeWidget, SLOT(expandAll())); +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) + QAction* expandSubtree = new QAction(tr("Expand subtree"), &contextMnu); + connect(expandSubtree, SIGNAL(triggered()), this, SLOT(expandSubtree())); +#endif + QAction* collapseAll = new QAction(tr( "Collapse all"), &contextMnu); connect(collapseAll, SIGNAL(triggered()), ui->threadTreeWidget, SLOT(collapseAll())); @@ -630,6 +635,10 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) markMsgAsUnreadChildren->setDisabled(true); replyAct->setDisabled (true); replyauthorAct->setDisabled (true); +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) + expandSubtree->setDisabled(true); + expandSubtree->setVisible(false); +#endif } if(has_current_post) @@ -663,7 +672,7 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) } contextMnu.addAction(replyAct); - contextMnu.addAction(newthreadAct); + contextMnu.addAction(newthreadAct); QAction* action = contextMnu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); action->setEnabled(!groupId().isNull() && !mThreadId.isNull()); contextMnu.addSeparator(); @@ -673,6 +682,9 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) contextMnu.addAction(markMsgAsUnreadChildren); contextMnu.addSeparator(); contextMnu.addAction(expandAll); +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) + contextMnu.addAction(expandSubtree); +#endif contextMnu.addAction(collapseAll); if(has_current_post) @@ -1325,6 +1337,20 @@ void GxsForumThreadWidget::setAllMessagesReadDo(bool read, uint32_t &/*token*/) markMsgAsReadUnread(read, true, true); } +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) +void GxsForumThreadWidget::expandSubtree() { + QAction* the_action = qobject_cast(sender()); + if (!the_action) { + return; + } + const QModelIndex current_index = ui->threadTreeWidget->currentIndex(); + if (!current_index.isValid()) { + return; + } + ui->threadTreeWidget->expandRecursively(current_index); +} +#endif + bool GxsForumThreadWidget::navigate(const RsGxsMessageId &msgId) { QModelIndex source_index = mThreadModel->getIndexOfMessage(msgId); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index a071e5416..0a87a683a 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -144,6 +144,10 @@ private slots: void filterColumnChanged(int column); void filterItems(const QString &text); + +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) + void expandSubtree(); +#endif private: void insertMessageData(const RsGxsForumMsg &msg); bool getCurrentPost(ForumModelPostEntry& fmpe) const ; From cbfcb2c7fb3c3252da5e25c9e0f4eb8f8a3b335e Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 1 Jul 2020 16:42:35 +0900 Subject: [PATCH 04/64] gxsforums: resurrect the header context menu --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 49 +++++++++++++++++++ .../src/gui/gxsforums/GxsForumThreadWidget.h | 2 + 2 files changed, 51 insertions(+) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 2d0a79825..8ea70849b 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -316,6 +316,9 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget ttheader->hideSection (RsGxsForumModel::COLUMN_THREAD_MSGID); ttheader->hideSection (RsGxsForumModel::COLUMN_THREAD_DATA); + ttheader->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ttheader, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint))); + ui->progressBar->hide(); ui->progressText->hide(); @@ -736,6 +739,52 @@ void GxsForumThreadWidget::contextMenuTextBrowser(QPoint point) delete(contextMnu); } +void GxsForumThreadWidget::headerContextMenuRequested(const QPoint &pos) +{ + QMenu* header_context_menu = new QMenu(tr("Show column"), this); + + QAction* title = header_context_menu->addAction(QIcon(), tr("Title")); + title->setCheckable(true); + title->setChecked(!ui->threadTreeWidget->isColumnHidden(RsGxsForumModel::COLUMN_THREAD_TITLE)); + title->setData(RsGxsForumModel::COLUMN_THREAD_TITLE); + connect(title, SIGNAL(toggled(bool)), this, SLOT(changeHeaderColumnVisibility(bool))); + + QAction* read = header_context_menu->addAction(QIcon(), tr("Read")); + read->setCheckable(true); + read->setChecked(!ui->threadTreeWidget->isColumnHidden(RsGxsForumModel::COLUMN_THREAD_READ)); + read->setData(RsGxsForumModel::COLUMN_THREAD_READ); + connect(read, SIGNAL(toggled(bool)), this, SLOT(changeHeaderColumnVisibility(bool))); + + QAction* date = header_context_menu->addAction(QIcon(), tr("Date")); + date->setCheckable(true); + date->setChecked(!ui->threadTreeWidget->isColumnHidden(RsGxsForumModel::COLUMN_THREAD_DATE)); + date->setData(RsGxsForumModel::COLUMN_THREAD_DATE); + connect(date, SIGNAL(toggled(bool)), this, SLOT(changeHeaderColumnVisibility(bool))); + + QAction* distribution = header_context_menu->addAction(QIcon(), tr("Distribution")); + distribution->setCheckable(true); + distribution->setChecked(!ui->threadTreeWidget->isColumnHidden(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION)); + distribution->setData(RsGxsForumModel::COLUMN_THREAD_DISTRIBUTION); + connect(distribution, SIGNAL(toggled(bool)), this, SLOT(changeHeaderColumnVisibility(bool))); + + // QAction* author = header_context_menu->addAction(QIcon(), tr("Author")); + // author->setCheckable(true); + // author->setChecked(!ui->threadTreeWidget->isColumnHidden(RsGxsForumModel::COLUMN_THREAD_AUTHOR)); + // author->setData(RsGxsForumModel::COLUMN_THREAD_AUTHOR); + // connect(author, SIGNAL(toggled(bool)), this, SLOT(changeHeaderColumnVisibility(bool))); + + header_context_menu->exec(mapToGlobal(pos)); + delete(header_context_menu); +} + +void GxsForumThreadWidget::changeHeaderColumnVisibility(bool visibility) { + QAction* the_action = qobject_cast(sender()); + if ( !the_action ) { + return; + } + ui->threadTreeWidget->setColumnHidden(the_action->data().toInt(), !visibility); +} + #ifdef TODO bool GxsForumThreadWidget::eventFilter(QObject *obj, QEvent *event) { diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index 0a87a683a..579cc15fd 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -97,6 +97,7 @@ private slots: /** Create the context popup menu and it's submenus */ void threadListCustomPopupMenu(QPoint point); void contextMenuTextBrowser(QPoint point); + void headerContextMenuRequested(const QPoint& pos); void changedSelection(const QModelIndex &, const QModelIndex &); void changedThread(QModelIndex index); @@ -148,6 +149,7 @@ private slots: #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) void expandSubtree(); #endif + void changeHeaderColumnVisibility(bool visibility); private: void insertMessageData(const RsGxsForumMsg &msg); bool getCurrentPost(ForumModelPostEntry& fmpe) const ; From 43ef74b4cabb4bb08eabec942bc50d9aa4a4bc44 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 1 Jul 2020 16:54:09 +0900 Subject: [PATCH 05/64] gxsforums: disable visibility for childless actions at context menu --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 8ea70849b..51c14c276 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -622,11 +622,19 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) QAction *showinpeopleAct = new QAction(FilesDefs::getIconFromQtResourcePath(":/images/info16.png"), tr("Show author in people tab"), &contextMnu); connect(showinpeopleAct, SIGNAL(triggered()), this, SLOT(showInPeopleTab())); + bool has_children = false; + if (has_current_post) { + has_children = !current_post.mChildren.empty(); + } + if (IS_GROUP_SUBSCRIBED(mForumGroup.mMeta.mSubscribeFlags)) { markMsgAsReadChildren->setEnabled(current_post.mPostFlags & ForumModelPostEntry::FLAG_POST_HAS_UNREAD_CHILDREN); markMsgAsUnreadChildren->setEnabled(current_post.mPostFlags & ForumModelPostEntry::FLAG_POST_HAS_READ_CHILDREN); +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) + expandSubtree->setEnabled(has_children); +#endif replyAct->setEnabled (true); replyauthorAct->setEnabled (true); } @@ -644,6 +652,19 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) #endif } + // disable visibility for childless + if (has_current_post) { + replyAct->setVisible(has_children); + // still no setEnabled + markMsgAsRead->setVisible(IS_MSG_UNREAD(current_post.mMsgStatus)); + markMsgAsUnread->setVisible(!IS_MSG_UNREAD(current_post.mMsgStatus)); +#if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) + expandSubtree->setVisible(has_children); +#endif + markMsgAsReadChildren->setVisible(has_children); + markMsgAsUnreadChildren->setVisible(has_children); + } + if(has_current_post) { bool is_pinned = mForumGroup.mPinnedPosts.ids.find( current_post.mMsgId ) != mForumGroup.mPinnedPosts.ids.end(); From db978e147ba711219e364346d6196a28e7cca037 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 1 Jul 2020 16:59:55 +0900 Subject: [PATCH 06/64] gxsforums: hide some leftovers after switching onto next forum at place for buttons and such (above post content) --- retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 51c14c276..d34dcb77c 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -983,6 +983,9 @@ void GxsForumThreadWidget::updateForumDescription(bool success) if (!mThreadId.isNull()) return; + // still call it to not left leftovers from previous post if any + blankPost(); + RsIdentityDetails details; rsIdentity->getIdDetails(mForumGroup.mMeta.mAuthorId,details); From 4a4adc354f934a2b8894ac8cf3dfc67dfd3335e7 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 1 Jul 2020 17:12:34 +0900 Subject: [PATCH 07/64] gxsforums: add separate text color for pinned posts --- retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp | 7 +++++-- retroshare-gui/src/gui/gxsforums/GxsForumModel.h | 2 ++ retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp | 2 ++ retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h | 4 ++++ retroshare-gui/src/gui/qss/stylesheet/qss.default | 1 + retroshare-gui/src/qss/qdarkstyle.qss | 1 + 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index f72649dfc..af62f5a91 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -445,10 +445,13 @@ QVariant RsGxsForumModel::textColorRole(const ForumModelPostEntry& fmpe,int /*co if( (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_MISSING)) return QVariant(mTextColorMissing); - if(IS_MSG_UNREAD(fmpe.mMsgStatus) || (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_PINNED)) + if(IS_MSG_UNREAD(fmpe.mMsgStatus)) return QVariant(mTextColorUnread); else - return QVariant(mTextColorRead); + if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_PINNED) + return QVariant(mTextColorPinned); + else + return QVariant(mTextColorRead); return QVariant(); } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h index cdbed3b0b..0dc9c6898 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h @@ -116,6 +116,7 @@ public: void setTextColorUnreadChildren(QColor color) { mTextColorUnreadChildren = color;} void setTextColorNotSubscribed (QColor color) { mTextColorNotSubscribed = color;} void setTextColorMissing (QColor color) { mTextColorMissing = color;} + void setTextColorPinned (QColor color) { mTextColorPinned = color;} void setMsgReadStatus(const QModelIndex &i, bool read_status, bool with_children); void setFilter(int column, const QStringList &strings, uint32_t &count) ; @@ -202,6 +203,7 @@ private: QColor mTextColorUnreadChildren; QColor mTextColorNotSubscribed ; QColor mTextColorMissing ; + QColor mTextColorPinned ; friend class const_iterator; }; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index d34dcb77c..c632b380f 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -216,6 +216,8 @@ void GxsForumThreadWidget::setTextColorUnread (QColor color) { mTextColor void GxsForumThreadWidget::setTextColorUnreadChildren(QColor color) { mTextColorUnreadChildren = color; mThreadModel->setTextColorUnreadChildren(color);} void GxsForumThreadWidget::setTextColorNotSubscribed (QColor color) { mTextColorNotSubscribed = color; mThreadModel->setTextColorNotSubscribed (color);} void GxsForumThreadWidget::setTextColorMissing (QColor color) { mTextColorMissing = color; mThreadModel->setTextColorMissing (color);} +// Suppose to be different from unread one +void GxsForumThreadWidget::setTextColorPinned (QColor color) { mTextColorPinned = color; mThreadModel->setTextColorPinned (color);} GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent) : GxsMessageFrameWidget(rsGxsForums, parent), diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index 579cc15fd..919c755a9 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -52,6 +52,7 @@ class GxsForumThreadWidget : public GxsMessageFrameWidget Q_PROPERTY(QColor textColorUnreadChildren READ textColorUnreadChildren WRITE setTextColorUnreadChildren) Q_PROPERTY(QColor textColorNotSubscribed READ textColorNotSubscribed WRITE setTextColorNotSubscribed) Q_PROPERTY(QColor textColorMissing READ textColorMissing WRITE setTextColorMissing) + Q_PROPERTY(QColor textColorPinned READ textColorPinned WRITE setTextColorPinned) public: explicit GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent = NULL); @@ -62,12 +63,14 @@ public: QColor textColorUnreadChildren() const { return mTextColorUnreadChildren; } QColor textColorNotSubscribed() const { return mTextColorNotSubscribed; } QColor textColorMissing() const { return mTextColorMissing; } + QColor textColorPinned() const { return mTextColorPinned; } void setTextColorRead (QColor color) ; void setTextColorUnread (QColor color) ; void setTextColorUnreadChildren(QColor color) ; void setTextColorNotSubscribed (QColor color) ; void setTextColorMissing (QColor color) ; + void setTextColorPinned (QColor color) ; /* GxsMessageFrameWidget */ virtual void groupIdChanged(); @@ -205,6 +208,7 @@ private: QColor mTextColorUnreadChildren; QColor mTextColorNotSubscribed; QColor mTextColorMissing; + QColor mTextColorPinned; RsGxsMessageId mNavigatePendingMsgId; QList mIgnoredMsgId; diff --git a/retroshare-gui/src/gui/qss/stylesheet/qss.default b/retroshare-gui/src/gui/qss/stylesheet/qss.default index b4e20120a..3a9072058 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/qss.default +++ b/retroshare-gui/src/gui/qss/stylesheet/qss.default @@ -138,6 +138,7 @@ ForumsDialog, GxsForumThreadWidget qproperty-textColorUnreadChildren: darkgray; qproperty-textColorNotSubscribed: black; qproperty-textColorMissing: darkRed; + qproperty-textColorPinned: darkOrange; } GroupTreeWidget diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index b50eb9aa1..fda8d04a0 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -93,6 +93,7 @@ ForumsDialog, GxsForumThreadWidget qproperty-textColorUnreadChildren: red; qproperty-textColorNotSubscribed: white; qproperty-textColorMissing: darkred; + qproperty-textColorPinned: darkOrange; } QMenuBar From bbcb605974a4029312d2a0658c82b6a103d33a16 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Thu, 2 Jul 2020 03:20:09 +0900 Subject: [PATCH 08/64] gxsforums: make possibility to see posts from banned persons --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 39 ++++++++++++++++--- .../src/gui/gxsforums/GxsForumThreadWidget.h | 2 + 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index c632b380f..3cef99a85 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -795,6 +795,11 @@ void GxsForumThreadWidget::headerContextMenuRequested(const QPoint &pos) // author->setChecked(!ui->threadTreeWidget->isColumnHidden(RsGxsForumModel::COLUMN_THREAD_AUTHOR)); // author->setData(RsGxsForumModel::COLUMN_THREAD_AUTHOR); // connect(author, SIGNAL(toggled(bool)), this, SLOT(changeHeaderColumnVisibility(bool))); + + QAction* show_text_from_banned = header_context_menu->addAction(QIcon(), tr("Show text from banned persons")); + show_text_from_banned->setCheckable(true); + show_text_from_banned->setChecked(mDisplayBannedText); + connect(show_text_from_banned, SIGNAL(toggled(bool)), this, SLOT(showBannedText(bool))); header_context_menu->exec(mapToGlobal(pos)); delete(header_context_menu); @@ -808,6 +813,13 @@ void GxsForumThreadWidget::changeHeaderColumnVisibility(bool visibility) { ui->threadTreeWidget->setColumnHidden(the_action->data().toInt(), !visibility); } +void GxsForumThreadWidget::showBannedText(bool display) { + mDisplayBannedText = display; + if (!mThreadId.isNull()) { + updateMessageData(mThreadId); + } +} + #ifdef TODO bool GxsForumThreadWidget::eventFilter(QObject *obj, QEvent *event) { @@ -1239,13 +1251,28 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg) ui->by_label->show(); ui->threadTreeWidget->setFocus(); + QString banned_text_info = ""; if(redacted) { - QString extraTxt = tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(msg.mMeta.mAuthorId.toStdString())) ; - extraTxt += tr( "

  • Messages from this author are not forwarded.
  • ") ; - extraTxt += tr( "
  • Messages from this author are replaced by this text.
") ; - extraTxt += tr( "

You can force the visibility and forwarding of messages by setting a different opinion for that Id in People's tab.

") ; + ui->downloadButton->setDisabled(true); + if (!mDisplayBannedText) { + QString extraTxt = tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(msg.mMeta.mAuthorId.toStdString())) ; + extraTxt += tr( "

  • Messages from this author are not forwarded.
  • ") ; + extraTxt += tr( "
  • Messages from this author are replaced by this text.
") ; + extraTxt += tr( "

You can force the visibility and forwarding of messages by setting a different opinion for that Id in People's tab.

") ; + + ui->postText->setHtml(extraTxt) ; + return; + } + else { + RsIdentityDetails details; + rsIdentity->getIdDetails(msg.mMeta.mAuthorId, details); + QString name = GxsIdDetails::getName(details); + + banned_text_info += "

" + tr( "The author of this message (with ID %1) is banned. And named by name ( %2 )").arg(QString::fromStdString(msg.mMeta.mAuthorId.toStdString()), name) + ""; + banned_text_info += "

  • " + tr( "Messages from this author are not forwarded.") + "
"; + banned_text_info += "

" + tr( "You can force the visibility and forwarding of messages by setting a different opinion for that Id in People's tab.") + "


"; + } - ui->postText->setHtml(extraTxt) ; } else { uint32_t flags = RSHTML_FORMATTEXT_EMBED_LINKS; if(Settings->getForumLoadEmoticons()) @@ -1258,7 +1285,7 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg) int desiredMinimumFontSize = Settings->valueFromGroup("Forum", "MinimumFontSize", 10).toInt(); - QString extraTxt = RsHtml().formatText(ui->postText->document(), + QString extraTxt = banned_text_info + RsHtml().formatText(ui->postText->document(), QString::fromUtf8(msg.mMsg.c_str()), flags , backgroundColor, desiredContrast, desiredMinimumFontSize ); diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index 919c755a9..cc3342344 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -153,6 +153,7 @@ private slots: void expandSubtree(); #endif void changeHeaderColumnVisibility(bool visibility); + void showBannedText(bool display); private: void insertMessageData(const RsGxsForumMsg &msg); bool getCurrentPost(ForumModelPostEntry& fmpe) const ; @@ -201,6 +202,7 @@ private: GxsForumsFillThread *mFillThread; unsigned int mUnreadCount; unsigned int mNewCount; + bool mDisplayBannedText; /* Color definitions (for standard see qss.default) */ QColor mTextColorRead; From ee967c2bc01c989315f32298945645664deae33d Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Mon, 6 Jul 2020 00:12:23 +0900 Subject: [PATCH 09/64] gxsforums: add id to forum's popup --- retroshare-gui/src/gui/common/GroupTreeWidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp index fa12ebf54..a4137bfef 100644 --- a/retroshare-gui/src/gui/common/GroupTreeWidget.cpp +++ b/retroshare-gui/src/gui/common/GroupTreeWidget.cpp @@ -502,6 +502,8 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList< tooltip += "\n" + tr("Description") + ": " + itemInfo.description; + tooltip += "\n" + tr("Id") + ": " + itemInfo.id; + item->setToolTip(COLUMN_NAME, tooltip); item->setToolTip(COLUMN_UNREAD, tooltip); item->setToolTip(COLUMN_POPULARITY, tooltip); From 98cf944f92586418faf1186a687213ae614829f0 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Mon, 6 Jul 2020 03:59:21 +0900 Subject: [PATCH 10/64] gxsforums: enable next unread button even for blank (missing) post --- retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 3cef99a85..4af17cc0f 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -1126,6 +1126,7 @@ void GxsForumThreadWidget::insertMessage() /* blank text, incase we get nothing */ blankPost(); + ui->nextUnreadButton->setEnabled(true); // We use this instead of getCurrentIndex() because right here the currentIndex() is not set yet. @@ -1241,7 +1242,8 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg) rsReputations->overallReputationLevel(msg.mMeta.mAuthorId); bool redacted = (overall_reputation == RsReputationLevel::LOCALLY_NEGATIVE); - + + // TODO enabled even when there are no new message ui->nextUnreadButton->setEnabled(true); ui->lineLeft->show(); ui->time_label->setText(DateTime::formatLongDateTime(msg.mMeta.mPublishTs)); From b265cdf284daf8ddc66123f5690c28b134536ddd Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Mon, 6 Jul 2020 13:18:45 +0900 Subject: [PATCH 11/64] gxsforums: add background color for pinned and filtered posts into qss --- retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp | 4 ++-- retroshare-gui/src/gui/gxsforums/GxsForumModel.h | 6 ++++++ .../src/gui/gxsforums/GxsForumThreadWidget.cpp | 3 +++ .../src/gui/gxsforums/GxsForumThreadWidget.h | 12 ++++++++++++ retroshare-gui/src/gui/qss/stylesheet/qss.default | 3 +++ retroshare-gui/src/qss/qdarkstyle.qss | 3 +++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index af62f5a91..ef09a9c8d 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -596,10 +596,10 @@ QVariant RsGxsForumModel::pinnedRole(const ForumModelPostEntry& fmpe,int /*colum QVariant RsGxsForumModel::backgroundRole(const ForumModelPostEntry& fmpe,int /*column*/) const { if(fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_IS_PINNED) - return QVariant(QBrush(QColor(255,200,180))); + return QVariant(QBrush(mBackgroundColorPinned)); if(mFilteringEnabled && (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_PASSES_FILTER)) - return QVariant(QBrush(QColor(255,240,210))); + return QVariant(QBrush(mBackgroundColorFiltered)); return QVariant(); } diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h index 0dc9c6898..50de234fa 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.h @@ -118,6 +118,9 @@ public: void setTextColorMissing (QColor color) { mTextColorMissing = color;} void setTextColorPinned (QColor color) { mTextColorPinned = color;} + void setBackgroundColorPinned (QColor color) { mBackgroundColorPinned = color;} + void setBackgroundColorFiltered (QColor color) { mBackgroundColorFiltered = color;} + void setMsgReadStatus(const QModelIndex &i, bool read_status, bool with_children); void setFilter(int column, const QStringList &strings, uint32_t &count) ; void setAuthorOpinion(const QModelIndex& indx,RsOpinion op); @@ -205,5 +208,8 @@ private: QColor mTextColorMissing ; QColor mTextColorPinned ; + QColor mBackgroundColorPinned; + QColor mBackgroundColorFiltered; + friend class const_iterator; }; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 4af17cc0f..87daafc50 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -219,6 +219,9 @@ void GxsForumThreadWidget::setTextColorMissing (QColor color) { mTextColor // Suppose to be different from unread one void GxsForumThreadWidget::setTextColorPinned (QColor color) { mTextColorPinned = color; mThreadModel->setTextColorPinned (color);} +void GxsForumThreadWidget::setBackgroundColorPinned (QColor color) { mBackgroundColorPinned = color; mThreadModel->setBackgroundColorPinned (color);} +void GxsForumThreadWidget::setBackgroundColorFiltered(QColor color) { mBackgroundColorFiltered = color; mThreadModel->setBackgroundColorFiltered (color);} + GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent) : GxsMessageFrameWidget(rsGxsForums, parent), ui(new Ui::GxsForumThreadWidget) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h index cc3342344..22aa2ecc3 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.h @@ -54,6 +54,9 @@ class GxsForumThreadWidget : public GxsMessageFrameWidget Q_PROPERTY(QColor textColorMissing READ textColorMissing WRITE setTextColorMissing) Q_PROPERTY(QColor textColorPinned READ textColorPinned WRITE setTextColorPinned) + Q_PROPERTY(QColor backgroundColorPinned READ backgroundColorPinned WRITE setBackgroundColorPinned) + Q_PROPERTY(QColor backgroundColorFiltered READ backgroundColorFiltered WRITE setBackgroundColorFiltered) + public: explicit GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget *parent = NULL); ~GxsForumThreadWidget(); @@ -65,6 +68,9 @@ public: QColor textColorMissing() const { return mTextColorMissing; } QColor textColorPinned() const { return mTextColorPinned; } + QColor backgroundColorPinned() const { return mBackgroundColorPinned; } + QColor backgroundColorFiltered() const { return mBackgroundColorFiltered; } + void setTextColorRead (QColor color) ; void setTextColorUnread (QColor color) ; void setTextColorUnreadChildren(QColor color) ; @@ -72,6 +78,9 @@ public: void setTextColorMissing (QColor color) ; void setTextColorPinned (QColor color) ; + void setBackgroundColorPinned (QColor color); + void setBackgroundColorFiltered (QColor color); + /* GxsMessageFrameWidget */ virtual void groupIdChanged(); virtual QString groupName(bool withUnreadCount); @@ -212,6 +221,9 @@ private: QColor mTextColorMissing; QColor mTextColorPinned; + QColor mBackgroundColorPinned; + QColor mBackgroundColorFiltered; + RsGxsMessageId mNavigatePendingMsgId; QList mIgnoredMsgId; diff --git a/retroshare-gui/src/gui/qss/stylesheet/qss.default b/retroshare-gui/src/gui/qss/stylesheet/qss.default index 3a9072058..d55011bee 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/qss.default +++ b/retroshare-gui/src/gui/qss/stylesheet/qss.default @@ -139,6 +139,9 @@ ForumsDialog, GxsForumThreadWidget qproperty-textColorNotSubscribed: black; qproperty-textColorMissing: darkRed; qproperty-textColorPinned: darkOrange; + + qproperty-backgroundColorPinned: rgb(255, 200, 180); + qproperty-backgroundColorFiltered: rgb(255, 240, 210); } GroupTreeWidget diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index fda8d04a0..d226dc8c8 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -94,6 +94,9 @@ ForumsDialog, GxsForumThreadWidget qproperty-textColorNotSubscribed: white; qproperty-textColorMissing: darkred; qproperty-textColorPinned: darkOrange; + + qproperty-backgroundColorPinned: black; + qproperty-backgroundColorFiltered: darkGreen; } QMenuBar From 2c03deaa336760ea7989cc014f0f5767731d93e7 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Thu, 9 Jul 2020 02:33:38 +0900 Subject: [PATCH 12/64] gxsforums: restore post's selection after clearing search filter --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 87daafc50..486e05a99 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -1801,10 +1801,26 @@ void GxsForumThreadWidget::filterItems(const QString& text) // We do this in order to trigger a new filtering action in the proxy model. mThreadProxyModel->setFilterRegExp(QRegExp(QString(RsGxsForumModel::FilterString))) ; - if(!lst.empty()) + if(!lst.empty()) ui->threadTreeWidget->expandAll(); - else + else { + // currentIndex() not on the clicked message, so not this way + // if (!mThreadId.isNull()) { + // an_index = mThreadProxyModel->mapToSource(ui->threadTreeWidget->currentIndex()); + // } ui->threadTreeWidget->collapseAll(); + if (!mThreadId.isNull()) { + // ...but this one + QModelIndex an_index = mThreadModel->getIndexOfMessage(mThreadId); + if (an_index.isValid()) { + QModelIndex the_index = mThreadProxyModel->mapFromSource(an_index); + ui->threadTreeWidget->setCurrentIndex(the_index); + ui->threadTreeWidget->scrollTo(the_index); + // don't change focus + // ui->threadTreeWidget->setFocus(); + } + } + } if(count > 0) ui->filterLineEdit->setToolTip(tr("No result.")) ; From 6b174ede8ebf314c329a58fac1df41fdc310ddb1 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Sun, 16 Aug 2020 16:22:10 +0900 Subject: [PATCH 13/64] gxsforums: undo leftover of invisible reply menu action for last post in thread my bad --- retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 486e05a99..fed1ddb7e 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -659,7 +659,6 @@ void GxsForumThreadWidget::threadListCustomPopupMenu(QPoint /*point*/) // disable visibility for childless if (has_current_post) { - replyAct->setVisible(has_children); // still no setEnabled markMsgAsRead->setVisible(IS_MSG_UNREAD(current_post.mMsgStatus)); markMsgAsUnread->setVisible(!IS_MSG_UNREAD(current_post.mMsgStatus)); From aad8bf01343988258739e7a96ac8454697eef46d Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Sun, 16 Aug 2020 18:48:57 +0900 Subject: [PATCH 14/64] gxsforums: fixed wrong branch for displaying text from banned persons add default to false for mdisplaybannedtext --- .../gui/gxsforums/GxsForumThreadWidget.cpp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index fed1ddb7e..5bd41d273 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -336,6 +336,8 @@ GxsForumThreadWidget::GxsForumThreadWidget(const RsGxsGroupId &forumId, QWidget // load settings processSettings(true); + mDisplayBannedText = false; + blankPost(); ui->subscribeToolButton->setToolTip(tr( "

Subscribing to the forum will gather \ @@ -1276,26 +1278,25 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg) banned_text_info += "

  • " + tr( "Messages from this author are not forwarded.") + "
"; banned_text_info += "

" + tr( "You can force the visibility and forwarding of messages by setting a different opinion for that Id in People's tab.") + "


"; } - - } else { - uint32_t flags = RSHTML_FORMATTEXT_EMBED_LINKS; - if(Settings->getForumLoadEmoticons()) - flags |= RSHTML_FORMATTEXT_EMBED_SMILEYS ; - flags |= RSHTML_OPTIMIZEHTML_MASK; - - QColor backgroundColor = ui->postText->palette().base().color(); - qreal desiredContrast = Settings->valueFromGroup("Forum", - "MinimumContrast", 4.5).toDouble(); - int desiredMinimumFontSize = Settings->valueFromGroup("Forum", - "MinimumFontSize", 10).toInt(); - - QString extraTxt = banned_text_info + RsHtml().formatText(ui->postText->document(), - QString::fromUtf8(msg.mMsg.c_str()), flags - , backgroundColor, desiredContrast, desiredMinimumFontSize - ); - ui->postText->setHtml(extraTxt); } + uint32_t flags = RSHTML_FORMATTEXT_EMBED_LINKS; + if(Settings->getForumLoadEmoticons()) + flags |= RSHTML_FORMATTEXT_EMBED_SMILEYS ; + flags |= RSHTML_OPTIMIZEHTML_MASK; + + QColor backgroundColor = ui->postText->palette().base().color(); + qreal desiredContrast = Settings->valueFromGroup("Forum", + "MinimumContrast", 4.5).toDouble(); + int desiredMinimumFontSize = Settings->valueFromGroup("Forum", + "MinimumFontSize", 10).toInt(); + + QString extraTxt = banned_text_info + RsHtml().formatText(ui->postText->document(), + QString::fromUtf8(msg.mMsg.c_str()), flags + , backgroundColor, desiredContrast, desiredMinimumFontSize + ); + ui->postText->setHtml(extraTxt); + QStringList urls; RsHtml::findAnchors(ui->postText->toHtml(), urls); ui->downloadButton->setEnabled(urls.count() > 0); From dd5c337c2adbaa9972f7ad30b0e8308a85f28609 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Sun, 16 Aug 2020 18:54:08 +0900 Subject: [PATCH 15/64] qss: gxsforums: change colors for pinned posts in qdarkstyle darkorange (ff8c00) is too bright, let's use d07000 instead. i hope different background color (202020) for pinned posts is not too bad (default - 302f2f) --- retroshare-gui/src/qss/qdarkstyle.qss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index d226dc8c8..3638b5cc0 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -93,9 +93,9 @@ ForumsDialog, GxsForumThreadWidget qproperty-textColorUnreadChildren: red; qproperty-textColorNotSubscribed: white; qproperty-textColorMissing: darkred; - qproperty-textColorPinned: darkOrange; + qproperty-textColorPinned: #D07000; - qproperty-backgroundColorPinned: black; + qproperty-backgroundColorPinned: #202020; qproperty-backgroundColorFiltered: darkGreen; } From cffd0a71af67c2ddc50ebfadc24186a600c169e1 Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 21 Aug 2020 22:41:34 +0200 Subject: [PATCH 16/64] removed hardcoded stylesheets from the frames --- retroshare-gui/src/gui/TheWire/PulseReply.ui | 5 +---- retroshare-gui/src/gui/TheWire/PulseTopLevel.ui | 5 +---- retroshare-gui/src/gui/TheWire/PulseViewGroup.ui | 5 +---- retroshare-gui/src/gui/qss/stylesheet/Standard.qss | 6 ++++++ 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/TheWire/PulseReply.ui b/retroshare-gui/src/gui/TheWire/PulseReply.ui index 582ceb269..9925d19bd 100644 --- a/retroshare-gui/src/gui/TheWire/PulseReply.ui +++ b/retroshare-gui/src/gui/TheWire/PulseReply.ui @@ -40,10 +40,7 @@ - QFrame#frame{border: 2px solid #CCCCCC; -background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #EEEEEE, stop: 1 #CCCCCC); -border-radius: 10px} + QFrame::StyledPanel diff --git a/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui b/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui index 77d32218a..f3365825a 100644 --- a/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui +++ b/retroshare-gui/src/gui/TheWire/PulseTopLevel.ui @@ -40,10 +40,7 @@ - QFrame#frame{border: 2px solid #CCCCCC; -background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #EEEEEE, stop: 1 #CCCCCC); -border-radius: 10px} + QFrame::StyledPanel diff --git a/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui b/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui index 7f808dd44..c2f209a19 100644 --- a/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui +++ b/retroshare-gui/src/gui/TheWire/PulseViewGroup.ui @@ -40,10 +40,7 @@ - QFrame#frame{border: 2px solid #CCCCCC; -background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, - stop: 0 #EEEEEE, stop: 1 #CCCCCC); -border-radius: 10px} + QFrame::StyledPanel diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index eb12e6551..7ab47c667 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -928,3 +928,9 @@ MessagesDialog QWidget#messageTreeWidget::item:hover { GxsForumThreadWidget QWidget#threadTreeWidget::item { padding: 2px; } + +PulseTopLevel QFrame#frame, PulseViewGroup QFrame#frame, PulseReply QFrame#frame { + border: 2px solid #7ecbfb; + border-radius: 6px; + background: white; +} From 047f51c824167caff90b0c4e0c75e0b691ee4596 Mon Sep 17 00:00:00 2001 From: defnax Date: Sun, 23 Aug 2020 17:20:52 +0200 Subject: [PATCH 17/64] update dark stylesheets --- retroshare-gui/src/qss/qdarkstyle-v2.qss | 9 +++++++-- retroshare-gui/src/qss/qdarkstyle.qss | 11 +++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/qss/qdarkstyle-v2.qss b/retroshare-gui/src/qss/qdarkstyle-v2.qss index cb573d765..4f6ee1cae 100644 --- a/retroshare-gui/src/qss/qdarkstyle-v2.qss +++ b/retroshare-gui/src/qss/qdarkstyle-v2.qss @@ -2143,8 +2143,8 @@ PostedCardView > QFrame#mainFrame[new=true] { background-color: #005000; } -WireGroupItem QFrame#frame{ - background: transparent; +WireGroupItem QFrame#wire_frame{ + background: transparent; } GxsChannelDialog GroupTreeWidget QTreeWidget#treeWidget::item{ @@ -2157,3 +2157,8 @@ RSTextBrowser, MimeTextEdit /*qproperty-textColorQuote: rgb(125, 125, 255);*/ qproperty-textColorQuotes: ColorList(#789922 #039bd5 #800000 #800080 #008080 #b10dc9 #85144b #3d9970); } + +PulseTopLevel QFrame#frame, PulseViewGroup QFrame#frame, PulseReply QFrame#frame { + border: 2px solid #38444d; + border-radius: 6px; +} diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index b50eb9aa1..64404cc45 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -1295,7 +1295,9 @@ PostedCardView > QFrame#mainFrame[new=true] { background-color: #005000; } -WireGroupItem QFrame#frame{ +WireGroupItem QFrame#wire_frame +{ + border: 1px solid #38444d; background: transparent; } @@ -1307,5 +1309,10 @@ RSTextBrowser, MimeTextEdit ChatWidget QFrame#pluginTitleFrame { - background: transparent; + background: transparent; +} + +PulseTopLevel QFrame#frame, PulseViewGroup QFrame#frame, PulseReply QFrame#frame { + border: 2px solid #38444d; + border-radius: 6px; } From 262d36cc82d7654bcf528c652ce9b54428c55d94 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 25 Aug 2020 11:49:45 +0200 Subject: [PATCH 18/64] added missing override --- .../src/gui/gxschannels/GxsChannelDialog.h | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h index 63b6ba38a..7dab607be 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelDialog.h @@ -35,9 +35,9 @@ public: /** Default Destructor */ ~GxsChannelDialog(); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_GXSCHANNELS) ; } //MainPage - virtual QString pageName() const { return tr("Channels") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage + virtual QIcon iconPixmap() const override { return QIcon(IMAGE_GXSCHANNELS) ; } //MainPage + virtual QString pageName() const override { return tr("Channels") ; } //MainPage + virtual QString helpText() const override { return ""; } //MainPage void shareOnChannel(const RsGxsGroupId& channel_id, const QList& file_link) ; @@ -69,17 +69,17 @@ private slots: private: /* GxsGroupFrameDialog */ - virtual QString text(TextType type); - virtual QString icon(IconType type); - virtual QString settingsGroupName() { return "ChannelDialog"; } - virtual GxsGroupDialog *createNewGroupDialog(); - virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId); - virtual int shareKeyType(); - virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId); - virtual void groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList &actions); - virtual RsGxsCommentService *getCommentService(); - virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId); - virtual uint32_t requestGroupSummaryType() { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data + virtual QString text(TextType type) override; + virtual QString icon(IconType type) override; + virtual QString settingsGroupName() override { return "ChannelDialog"; } + virtual GxsGroupDialog *createNewGroupDialog() override; + virtual GxsGroupDialog *createGroupDialog(GxsGroupDialog::Mode mode, RsGxsGroupId groupId) override; + virtual int shareKeyType() override; + virtual GxsMessageFrameWidget *createMessageFrameWidget(const RsGxsGroupId &groupId) override; + virtual void groupTreeCustomActions(RsGxsGroupId grpId, int subscribeFlags, QList &actions) override; + virtual RsGxsCommentService *getCommentService() override; + virtual QWidget *createCommentHeaderWidget(const RsGxsGroupId &grpId, const RsGxsMessageId &msgId) override; + virtual uint32_t requestGroupSummaryType() override { return GXS_REQUEST_TYPE_GROUP_DATA; } // request complete group data void handleEvent_main_thread(std::shared_ptr event); From 9e20c04e3f52ddc6c298ae1b7a4a4e5cf10726d0 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 25 Aug 2020 11:50:12 +0200 Subject: [PATCH 19/64] added system to clamp the text in thumbnails --- .../src/gui/gxschannels/GxsChannelPostThumbnail.h | 13 +++++++++++-- .../gxschannels/GxsChannelPostsWidgetWithModel.cpp | 2 +- .../gxschannels/GxsChannelPostsWidgetWithModel.ui | 4 ++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index 4a0ae5855..f9ce488a0 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -98,7 +98,7 @@ public: lb->setFixedSize(W,H); lb->setPixmap(thumbnail); - lt->setText(msg); + setText(msg); QFont font = lt->font(); @@ -116,7 +116,16 @@ public: } void setPixmap(const QPixmap& p) { lb->setPixmap(p); } - void setText(const QString& s) { lt->setText(s); } + void setText(const QString& s) + { + QString ss; + if(s.length() > 30) + ss = s.left(30)+"..."; + else + ss =s; + + lt->setText(ss); + } private: QLabel *lb; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 093c5b12c..1265f531f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -262,7 +262,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->postTime_LB->hide(); ui->postLogo_LB->hide(); - ui->postDetails_TE->setPlaceholderText(tr("No post selected")); + ui->postDetails_TE->setPlaceholderText(tr("No text to display")); // Set initial size of the splitter ui->splitter->setStretchFactor(0, 1); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index 2886e8dbe..e20b1413b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -161,7 +161,7 @@ - 0 + 1 @@ -526,7 +526,7 @@ p, li { white-space: pre-wrap; } - Files + All files From 4472f1cef4c09a416e032edfa353ee75ea4ab7d6 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 26 Aug 2020 22:29:49 +0200 Subject: [PATCH 20/64] added pan/zoom for channel post image --- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 4 +- .../gxschannels/GxsChannelPostThumbnail.cpp | 189 ++++++++++++++++++ .../gui/gxschannels/GxsChannelPostThumbnail.h | 101 ++++------ retroshare-gui/src/retroshare-gui.pro | 3 +- retroshare-gui/src/util/misc.cpp | 6 +- 5 files changed, 234 insertions(+), 69 deletions(-) create mode 100644 retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 177289f09..98d144c1d 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -688,7 +688,7 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str // send chan image buffer.open(QIODevice::WriteOnly); - picture.save(&buffer, "PNG"); // writes image into ba in PNG format + preview_W->getCroppedScaledPicture().save(&buffer, "PNG"); // writes image into ba in PNG format post.mThumbnail.copy((uint8_t *) ba.data(), ba.size()); } @@ -723,7 +723,7 @@ void CreateGxsChannelMsg::sendMessage(const std::string &subject, const std::str void CreateGxsChannelMsg::addThumbnail() { - QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load thumbnail picture"), 107,156); // these absolute sizes are terrible + QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load thumbnail picture"), 0,0); // 0,0 means: no scale. if (img.isNull()) return; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp new file mode 100644 index 000000000..09b9e9038 --- /dev/null +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -0,0 +1,189 @@ +/******************************************************************************* + * retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp * + * * + * Copyright 2020 by Retroshare Team * + * * + * This program is free software: you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation, either version 3 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Affero General Public License for more details. * + * * + * You should have received a copy of the GNU Affero General Public License * + * along with this program. If not, see . * + * * + *******************************************************************************/ + +#include + +#include "gui/common/FilesDefs.h" +#include "gui/gxschannels/GxsChannelPostThumbnail.h" + +ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,QWidget *parent) + : QWidget(parent) +{ + // now fill the data + + QPixmap thumbnail; + + if(post.mThumbnail.mSize > 0) + GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, thumbnail,GxsIdDetails::ORIGINAL); + else if(post.mMeta.mPublishTs > 0) // this is for testing that the post is not an empty post (happens at the end of the last row) + thumbnail = FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE); + + init(thumbnail, QString::fromUtf8(post.mMeta.mMsgName.c_str()), IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus) ); +} + +ChannelPostThumbnailView::ChannelPostThumbnailView(QWidget *parent) + : QWidget(parent) +{ + init(FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE), QString("New post"),false); +} + +ChannelPostThumbnailView::~ChannelPostThumbnailView() +{ + delete lb; + delete lt; +} + +void ChannelPostThumbnailView::init(const QPixmap& thumbnail,const QString& msg,bool is_msg_new) +{ + QVBoxLayout *layout = new QVBoxLayout(this); + + lb = new ZoomableLabel(this); + lb->setScaledContents(true); + lb->setToolTip(tr("Use mouse to center and zoom into the image")); + layout->addWidget(lb); + + lt = new QLabel(this); + layout->addWidget(lt); + + setLayout(layout); + + setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); + + QFontMetricsF fm(font()); + int W = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_W * fm.height() ; + int H = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_H * fm.height() ; + + lb->setFixedSize(W,H); + lb->setPicture(thumbnail); + + setText(msg); + + QFont font = lt->font(); + + if(is_msg_new) + { + font.setBold(true); + lt->setFont(font); + } + + lt->setMaximumWidth(W); + lt->setWordWrap(true); + + adjustSize(); + update(); +} + +void ZoomableLabel::mouseMoveEvent(QMouseEvent *me) +{ + float new_center_x = mCenterX - (me->x() - mLastX); + float new_center_y = mCenterY - (me->y() - mLastY); + + mLastX = me->x(); + mLastY = me->y(); + + if(new_center_x - 0.5 * width()*mZoomFactor < 0) return; + if(new_center_y - 0.5 *height()*mZoomFactor < 0) return; + + if(new_center_x + 0.5 * width()*mZoomFactor >= mFullImage.width()) return; + if(new_center_y + 0.5 *height()*mZoomFactor >=mFullImage.height()) return; + + mCenterX = new_center_x; + mCenterY = new_center_y; + + updateView(); +} +void ZoomableLabel::mousePressEvent(QMouseEvent *me) +{ + mMoving = true; + mLastX = me->x(); + mLastY = me->y(); +} +void ZoomableLabel::mouseReleaseEvent(QMouseEvent *) +{ + mMoving = false; +} +void ZoomableLabel::wheelEvent(QWheelEvent *me) +{ + float new_zoom_factor = (me->delta() > 0)?(mZoomFactor*1.05):(mZoomFactor/1.05); + float new_center_x = mCenterX; + float new_center_y = mCenterY; + + // Try to find centerX and centerY so that the crop does not overlap the original image + + float min_x = 0.5 * width()*new_zoom_factor; + float max_x = mFullImage.width() - 0.5 * width()*new_zoom_factor; + float min_y = 0.5 * height()*new_zoom_factor; + float max_y = mFullImage.height() - 0.5 * height()*new_zoom_factor; + + if(min_x >= max_x) return; + if(min_y >= max_y) return; + + if(new_center_x < min_x) new_center_x = min_x; + if(new_center_y < min_y) new_center_y = min_y; + if(new_center_x > max_x) new_center_x = max_x; + if(new_center_y > max_y) new_center_y = max_y; + + mZoomFactor = new_zoom_factor; + mCenterX = new_center_x; + mCenterY = new_center_y; + + updateView(); +} + +QPixmap ZoomableLabel::extractCroppedScaledPicture() const +{ + QRect rect(mCenterX - 0.5 * width()*mZoomFactor, mCenterY - 0.5 * height()*mZoomFactor, width()*mZoomFactor, height()*mZoomFactor); + QPixmap pix = mFullImage.copy(rect).scaledToHeight(height(),Qt::SmoothTransformation); + + return pix; +} + +void ZoomableLabel::setPicture(const QPixmap& pix) +{ + mFullImage = pix; + + mCenterX = pix.width()/2.0; + mCenterY = pix.height()/2.0; + + updateView(); +} +void ZoomableLabel::resizeEvent(QResizeEvent *e) +{ + QLabel::resizeEvent(e); + + updateView(); +} + +void ZoomableLabel::updateView() +{ + // The new image will be cropped from the original image, using the following rules: + // - first the cropped image size is computed + // - then center is calculated so that + // - the original center is preferred + // - if the crop overlaps the image border, the center is moved. + + QRect rect(mCenterX - 0.5 * width()*mZoomFactor, mCenterY - 0.5 * height()*mZoomFactor, width()*mZoomFactor, height()*mZoomFactor); + QLabel::setPixmap(mFullImage.copy(rect)); +} + + + + + diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index f9ce488a0..72fc960e5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -32,6 +32,35 @@ #include "gui/gxs/GxsIdDetails.h" #include "gui/common/FilesDefs.h" +// Class to provide a label in which the image can be zoomed/moved. The widget size is fixed by the GUI and the user can move/zoom the image +// inside the window formed by the widget. When happy, the view-able part of the image can be extracted. + +class ZoomableLabel: public QLabel +{ +public: + ZoomableLabel(QWidget *parent): QLabel(parent),mZoomFactor(1.0),mCenterX(0.0),mCenterY(0.0) {} + + void setPicture(const QPixmap& pix); + QPixmap extractCroppedScaledPicture() const; + +protected: + void mousePressEvent(QMouseEvent *ev) override; + void mouseReleaseEvent(QMouseEvent *ev) override; + void mouseMoveEvent(QMouseEvent *ev) override; + void resizeEvent(QResizeEvent *ev) override; + void wheelEvent(QWheelEvent *me) override; + + void updateView(); + + QPixmap mFullImage; + + float mCenterX; + float mCenterY; + float mZoomFactor; + int mLastX,mLastY; + bool mMoving; +}; + // Class to paint the thumbnails with title class ChannelPostThumbnailView: public QWidget @@ -49,73 +78,15 @@ public: static constexpr char *CHAN_DEFAULT_IMAGE = ":images/thumb-default-video.png"; - virtual ~ChannelPostThumbnailView() - { - delete lb; - delete lt; - } + virtual ~ChannelPostThumbnailView(); + ChannelPostThumbnailView(QWidget *parent=NULL); + ChannelPostThumbnailView(const RsGxsChannelPost& post,QWidget *parent=NULL); - ChannelPostThumbnailView(QWidget *parent=NULL): QWidget(parent) - { - init(FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE), QString("New post"),false); - } + void init(const QPixmap& thumbnail,const QString& msg,bool is_msg_new); - ChannelPostThumbnailView(const RsGxsChannelPost& post,QWidget *parent=NULL) - : QWidget(parent) - { - // now fill the data + void setPixmap(const QPixmap& p) { lb->setPicture(p); } + QPixmap getCroppedScaledPicture() const { return lb->extractCroppedScaledPicture() ; } - QPixmap thumbnail; - - if(post.mThumbnail.mSize > 0) - GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, thumbnail,GxsIdDetails::ORIGINAL); - else if(post.mMeta.mPublishTs > 0) // this is for testing that the post is not an empty post (happens at the end of the last row) - thumbnail = FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE); - - init(thumbnail, QString::fromUtf8(post.mMeta.mMsgName.c_str()), IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus) ); - - } - - void init(const QPixmap& thumbnail,const QString& msg,bool is_msg_new) - { - QVBoxLayout *layout = new QVBoxLayout(this); - - lb = new QLabel(this); - lb->setScaledContents(true); - layout->addWidget(lb); - - lt = new QLabel(this); - layout->addWidget(lt); - - setLayout(layout); - - setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); - - QFontMetricsF fm(font()); - int W = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_W * fm.height() ; - int H = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_H * fm.height() ; - - lb->setFixedSize(W,H); - lb->setPixmap(thumbnail); - - setText(msg); - - QFont font = lt->font(); - - if(is_msg_new) - { - font.setBold(true); - lt->setFont(font); - } - - lt->setMaximumWidth(W); - lt->setWordWrap(true); - - adjustSize(); - update(); - } - - void setPixmap(const QPixmap& p) { lb->setPixmap(p); } void setText(const QString& s) { QString ss; @@ -128,7 +99,7 @@ public: } private: - QLabel *lb; + ZoomableLabel *lb; QLabel *lt; }; diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index fbb600013..cafc34ef4 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -1382,7 +1382,8 @@ gxschannels { gui/gxschannels/GxsChannelPostsModel.cpp \ gui/gxschannels/GxsChannelPostFilesModel.cpp \ gui/gxschannels/GxsChannelFilesWidget.cpp \ - gui/gxschannels/GxsChannelFilesStatusWidget.cpp \ + gui/gxschannels/GxsChannelPostThumbnail.cpp \ + gui/gxschannels/GxsChannelFilesStatusWidget.cpp \ gui/gxschannels/GxsChannelGroupDialog.cpp \ gui/gxschannels/CreateGxsChannelMsg.cpp \ gui/feeds/GxsChannelGroupItem.cpp \ diff --git a/retroshare-gui/src/util/misc.cpp b/retroshare-gui/src/util/misc.cpp index 9539ebd5a..e83f4a704 100644 --- a/retroshare-gui/src/util/misc.cpp +++ b/retroshare-gui/src/util/misc.cpp @@ -307,7 +307,11 @@ QPixmap misc::getOpenThumbnailedPicture(QWidget *parent, const QString &caption, if (!getOpenFileName(parent, RshareSettings::LASTDIR_IMAGES, caption, tr("Pictures (*.png *.jpeg *.xpm *.jpg *.tiff *.gif)"), fileName)) return QPixmap(); - return QPixmap(fileName).scaledToHeight(height, Qt::SmoothTransformation).copy( 0, 0, width, height); + if(width > 0 && height > 0) + return QPixmap(fileName).scaledToHeight(height, Qt::SmoothTransformation).copy( 0, 0, width, height); + else + return QPixmap(fileName); + //return QPixmap(fileName).scaledToHeight(width, height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); } From 38f1df2b361b410fa259dd42206c9246c0b1c6e7 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Aug 2020 17:14:55 +0200 Subject: [PATCH 21/64] added switch between grid and list views in channels. --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 17 +++--- .../gui/gxschannels/GxsChannelPostsModel.h | 6 ++- .../GxsChannelPostsWidgetWithModel.cpp | 54 ++++++++++++++----- .../GxsChannelPostsWidgetWithModel.h | 6 ++- 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 58715e48d..f4e0a5696 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -44,7 +44,7 @@ Q_DECLARE_METATYPE(RsGxsChannelPost) std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere RsGxsChannelPostsModel::RsGxsChannelPostsModel(QObject *parent) - : QAbstractItemModel(parent), mTreeMode(TREE_MODE_PLAIN), mColumns(6) + : QAbstractItemModel(parent), mTreeMode(RsGxsChannelPostsModel::TREE_MODE_GRID), mColumns(6) { initEmptyHierarchy(); @@ -62,6 +62,15 @@ RsGxsChannelPostsModel::~RsGxsChannelPostsModel() rsEvents->unregisterEventsHandler(mEventHandlerId); } +void RsGxsChannelPostsModel::setMode(TreeMode mode) +{ + mTreeMode = mode; + + if(mode == TREE_MODE_LIST) + setNumColumns(1); + + // needs some update here +} void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr event) { const RsGxsChannelEvent *e = dynamic_cast(event.get()); @@ -124,18 +133,12 @@ void RsGxsChannelPostsModel::initEmptyHierarchy() mPosts.clear(); mFilteredPosts.clear(); -// mPosts.resize(1); // adds a sentinel item -// mPosts[0].mMeta.mMsgName = "Root sentinel post" ; -// mFilteredPosts.resize(1); -// mFilteredPosts[0] = 1; postMods(); } void RsGxsChannelPostsModel::preMods() { - //emit layoutAboutToBeChanged(); //Generate SIGSEGV when click on button move next/prev. - beginResetModel(); } void RsGxsChannelPostsModel::postMods() diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index 47e0caee5..75464368e 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -92,8 +92,8 @@ public: #endif enum TreeMode{ TREE_MODE_UNKWN = 0x00, - TREE_MODE_PLAIN = 0x01, - TREE_MODE_FILES = 0x02, + TREE_MODE_GRID = 0x01, + TREE_MODE_LIST = 0x02, }; #ifdef TODO @@ -112,6 +112,8 @@ public: const RsGxsGroupId& currentGroupId() const; void setNumColumns(int n); + void setMode(TreeMode mode); + TreeMode getMode() const { return mTreeMode; } // Retrieve the full list of files for all posts. diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 1265f531f..35d37ef0b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -74,11 +74,16 @@ static const int CHANNEL_TABS_FILES = 2; #define STAR_OVERLAY_IMAGE ":icons/star_overlay_128.png" #define IMAGE_COPYLINK ":/images/copyrslink.png" +#define IMAGE_GRID_VIEW ":icons/png/menu.png" Q_DECLARE_METATYPE(ChannelPostFileInfo) // Delegate used to paint into the table of thumbnails +//===============================================================================================================================================// +//=== ChannelPostDelegate ===// +//===============================================================================================================================================// + int ChannelPostDelegate::cellSize(const QFont& font) const { return mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height(); @@ -126,16 +131,6 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); } - // debug - // if(index.row()==0 && index.column()==0) - // { - // QFile file("yourFile.png"); - // file.open(QIODevice::WriteOnly); - // pixmap.save(&file, "PNG"); - // std::cerr << "Saved pxmap to png" << std::endl; - // } - //std::cerr << "option.rect = " << option.rect.width() << "x" << option.rect.height() << ". fm.height()=" << QFontMetricsF(option.font).height() << std::endl; - painter->drawPixmap(option.rect.topLeft(), pixmap.scaled(option.rect.width(),option.rect.width()*w.height()/(float)w.width(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); } @@ -146,9 +141,21 @@ QSize ChannelPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QM QFontMetricsF fm(option.font); - return QSize(mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); + if(mUseGrid) + return QSize(mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); + else + return QSize(option.rect.width(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); } +void ChannelPostDelegate::setWidgetGrid(bool use_grid) +{ + mUseGrid = use_grid; +} + +//===============================================================================================================================================// +//=== ChannelPostFilesDelegate ===// +//===============================================================================================================================================// + QWidget *ChannelPostFilesDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex& index) const { ChannelPostFileInfo file = index.data(Qt::UserRole).value() ; @@ -222,6 +229,10 @@ QSize ChannelPostFilesDelegate::sizeHint(const QStyleOptionViewItem& option, con } } +//===============================================================================================================================================// +//=== GxsChannelPostWidgetWithModel ===// +//===============================================================================================================================================// + /** Constructor */ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupId &channelId, QWidget *parent) : GxsMessageFrameWidget(rsGxsChannels, parent), @@ -366,7 +377,13 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&) { QMenu menu(this); - menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); + if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GRID_VIEW), tr("Switch to list view"), this, SLOT(switchView())); + else + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GRID_VIEW), tr("Switch to grid view"), this, SLOT(switchView())); + + menu.addSeparator(); + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost())); @@ -374,6 +391,19 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&) menu.exec(QCursor::pos()); } +void GxsChannelPostsWidgetWithModel::switchView() +{ + if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) + { + mChannelPostsDelegate->setWidgetGrid(false); + mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST); + } + else + { + mChannelPostsDelegate->setWidgetGrid(true); + mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID); + } +} void GxsChannelPostsWidgetWithModel::copyMessageLink() { try diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 5fb04bb6f..8b1ca56a8 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -68,13 +68,16 @@ class ChannelPostDelegate: public QAbstractItemDelegate int cellSize(const QFont& font) const; void zoom(bool zoom_or_unzoom) ; - private: + void setWidgetGrid(bool use_grid) ; + + private: static constexpr float IMAGE_MARGIN_FACTOR = 1.0; static constexpr float IMAGE_SIZE_FACTOR_W = 4.0 ; static constexpr float IMAGE_SIZE_FACTOR_H = 6.0 ; static constexpr float IMAGE_ZOOM_FACTOR = 1.0; float mZoom; // zoom factor for the whole thumbnail + bool mUseGrid; // wether we use the grid widget or the list widget }; class GxsChannelPostsWidgetWithModel: public GxsMessageFrameWidget @@ -147,6 +150,7 @@ private slots: void postContextMenu(const QPoint&); void copyMessageLink(); void updateZoomFactor(bool zoom_or_unzoom); + void switchView(); public slots: void sortColumnFiles(int col,Qt::SortOrder so); From f76264b170785a145b4b81e377aea65d6833d6a1 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Aug 2020 18:53:39 +0200 Subject: [PATCH 22/64] more work on list view in channels --- .../gxschannels/GxsChannelPostThumbnail.cpp | 104 ++++++++++++------ .../gui/gxschannels/GxsChannelPostThumbnail.h | 27 +++-- .../GxsChannelPostsWidgetWithModel.cpp | 20 ++-- .../GxsChannelPostsWidgetWithModel.h | 2 +- 4 files changed, 101 insertions(+), 52 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index 09b9e9038..f907a8593 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -19,49 +19,77 @@ *******************************************************************************/ #include +#include #include "gui/common/FilesDefs.h" #include "gui/gxschannels/GxsChannelPostThumbnail.h" -ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,QWidget *parent) - : QWidget(parent) +ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent) + : QWidget(parent),mFlags(flags) { // now fill the data - QPixmap thumbnail; - - if(post.mThumbnail.mSize > 0) - GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, thumbnail,GxsIdDetails::ORIGINAL); - else if(post.mMeta.mPublishTs > 0) // this is for testing that the post is not an empty post (happens at the end of the last row) - thumbnail = FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE); - - init(thumbnail, QString::fromUtf8(post.mMeta.mMsgName.c_str()), IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus) ); + init(post); } -ChannelPostThumbnailView::ChannelPostThumbnailView(QWidget *parent) - : QWidget(parent) +ChannelPostThumbnailView::ChannelPostThumbnailView(QWidget *parent,uint32_t flags) + : QWidget(parent),mFlags(flags) { - init(FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE), QString("New post"),false); + init(RsGxsChannelPost()); } ChannelPostThumbnailView::~ChannelPostThumbnailView() { - delete lb; - delete lt; + delete mPostImage; } -void ChannelPostThumbnailView::init(const QPixmap& thumbnail,const QString& msg,bool is_msg_new) +void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) { + QString msg = QString::fromUtf8(post.mMeta.mMsgName.c_str()); + bool is_msg_new = IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus); + + QPixmap thumbnail; + + if(post.mThumbnail.mSize > 0) + GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, thumbnail,GxsIdDetails::ORIGINAL); + else if(post.mMeta.mPublishTs > 0) // this is for testing that the post is not an empty post (happens at the end of the last row) + thumbnail = FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE); + + mPostImage = new ZoomableLabel(this); + mPostImage->setEnableZoom(mFlags & FLAG_ALLOW_PAN); + mPostImage->setScaledContents(true); + mPostImage->setPicture(thumbnail); + + if(mFlags & FLAG_ALLOW_PAN) + mPostImage->setToolTip(tr("Use mouse to center and zoom into the image")); + + mPostTitle = new QLabel(this); + + if(mFlags & FLAG_SHOW_TEXT) + { + QBoxLayout *layout = new QHBoxLayout(this); + + layout->addWidget(mPostImage); + + QVBoxLayout *vlayout = new QVBoxLayout(this); + + mPostTitle->setText(msg); + vlayout->addWidget(mPostTitle); + + QLabel *date_label = new QLabel(this); + date_label->setText(QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString()); + vlayout->addWidget(date_label); + + vlayout->addStretch(); + layout->addLayout(vlayout); + setLayout(layout); + } + else + { QVBoxLayout *layout = new QVBoxLayout(this); - lb = new ZoomableLabel(this); - lb->setScaledContents(true); - lb->setToolTip(tr("Use mouse to center and zoom into the image")); - layout->addWidget(lb); - - lt = new QLabel(this); - layout->addWidget(lt); - + layout->addWidget(mPostImage); + layout->addWidget(mPostTitle); setLayout(layout); setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); @@ -70,28 +98,33 @@ void ChannelPostThumbnailView::init(const QPixmap& thumbnail,const QString& msg, int W = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_W * fm.height() ; int H = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_H * fm.height() ; - lb->setFixedSize(W,H); - lb->setPicture(thumbnail); + mPostImage->setFixedSize(W,H); - setText(msg); + QString ss = (msg.length() > 30)? (msg.left(30)+"..."):msg; - QFont font = lt->font(); + mPostTitle->setText(ss); + + QFont font = mPostTitle->font(); if(is_msg_new) { - font.setBold(true); - lt->setFont(font); + font.setBold(true); + mPostTitle->setFont(font); } - lt->setMaximumWidth(W); - lt->setWordWrap(true); + mPostTitle->setMaximumWidth(W); + mPostTitle->setWordWrap(true); + } - adjustSize(); - update(); + adjustSize(); + update(); } void ZoomableLabel::mouseMoveEvent(QMouseEvent *me) { + if(!mZoomEnabled) + return; + float new_center_x = mCenterX - (me->x() - mLastX); float new_center_y = mCenterY - (me->y() - mLastY); @@ -121,6 +154,9 @@ void ZoomableLabel::mouseReleaseEvent(QMouseEvent *) } void ZoomableLabel::wheelEvent(QWheelEvent *me) { + if(!mZoomEnabled) + return; + float new_zoom_factor = (me->delta() > 0)?(mZoomFactor*1.05):(mZoomFactor/1.05); float new_center_x = mCenterX; float new_center_y = mCenterY; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index 72fc960e5..0d7d1018d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -38,9 +38,10 @@ class ZoomableLabel: public QLabel { public: - ZoomableLabel(QWidget *parent): QLabel(parent),mZoomFactor(1.0),mCenterX(0.0),mCenterY(0.0) {} + ZoomableLabel(QWidget *parent): QLabel(parent),mZoomFactor(1.0),mCenterX(0.0),mCenterY(0.0),mZoomEnabled(true) {} void setPicture(const QPixmap& pix); + void setEnableZoom(bool b) { mZoomEnabled = b; } QPixmap extractCroppedScaledPicture() const; protected: @@ -57,8 +58,9 @@ protected: float mCenterX; float mCenterY; float mZoomFactor; - int mLastX,mLastY; + int mLastX,mLastY; bool mMoving; + bool mZoomEnabled; }; // Class to paint the thumbnails with title @@ -71,6 +73,10 @@ public: // This variable determines the zoom factor on the text below thumbnails. 2.0 is mostly correct for all screen. static constexpr float THUMBNAIL_OVERSAMPLE_FACTOR = 2.0; + static constexpr uint32_t FLAG_NONE = 0x00; + static constexpr uint32_t FLAG_SHOW_TEXT = 0x01; + static constexpr uint32_t FLAG_ALLOW_PAN = 0x02; + // Size of thumbnails as a function of the height of the font. An aspect ratio of 3/4 is good. static const int THUMBNAIL_W = 4; @@ -79,13 +85,13 @@ public: static constexpr char *CHAN_DEFAULT_IMAGE = ":images/thumb-default-video.png"; virtual ~ChannelPostThumbnailView(); - ChannelPostThumbnailView(QWidget *parent=NULL); - ChannelPostThumbnailView(const RsGxsChannelPost& post,QWidget *parent=NULL); + ChannelPostThumbnailView(QWidget *parent=NULL,uint32_t flags=FLAG_ALLOW_PAN); + ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent=NULL); - void init(const QPixmap& thumbnail,const QString& msg,bool is_msg_new); + void init(const RsGxsChannelPost& post); - void setPixmap(const QPixmap& p) { lb->setPicture(p); } - QPixmap getCroppedScaledPicture() const { return lb->extractCroppedScaledPicture() ; } + void setPixmap(const QPixmap& p) { mPostImage->setPicture(p); } + QPixmap getCroppedScaledPicture() const { return mPostImage->extractCroppedScaledPicture() ; } void setText(const QString& s) { @@ -95,11 +101,12 @@ public: else ss =s; - lt->setText(ss); + mPostTitle->setText(ss); } private: - ZoomableLabel *lb; - QLabel *lt; + ZoomableLabel *mPostImage; + QLabel *mPostTitle; + uint32_t mFlags; }; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 35d37ef0b..bd23bd041 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -84,9 +84,12 @@ Q_DECLARE_METATYPE(ChannelPostFileInfo) //=== ChannelPostDelegate ===// //===============================================================================================================================================// -int ChannelPostDelegate::cellSize(const QFont& font) const +int ChannelPostDelegate::cellSize(const QFont& font,uint32_t parent_width) const { - return mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height(); + if(mUseGrid) + return mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height(); + else + return parent_width; } void ChannelPostDelegate::zoom(bool zoom_or_unzoom) @@ -110,7 +113,8 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->fillRect( option.rect, option.backgroundBrush); painter->restore(); - ChannelPostThumbnailView w(post); + uint32_t flags = (mUseGrid)?0:(ChannelPostThumbnailView::FLAG_SHOW_TEXT); + ChannelPostThumbnailView w(post,flags); QPixmap pixmap(w.size()); @@ -282,7 +286,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI QFontMetricsF fm(font()); for(int i=0;icolumnCount();++i) - ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font())); + ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())); /* Setup UI helper */ @@ -350,11 +354,11 @@ void GxsChannelPostsWidgetWithModel::updateZoomFactor(bool zoom_or_unzoom) mChannelPostsDelegate->zoom(zoom_or_unzoom); for(int i=0;icolumnCount();++i) - ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font())); + ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())); QSize s = ui->postsTree->size(); - int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(font())))); + int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(font(),s.width())))); std::cerr << "nb columns: " << n_columns << std::endl; mChannelPostsModel->setNumColumns(n_columns); // forces the update @@ -402,6 +406,8 @@ void GxsChannelPostsWidgetWithModel::switchView() { mChannelPostsDelegate->setWidgetGrid(true); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID); + + handlePostsTreeSizeChange(ui->postsTree->size()); } } void GxsChannelPostsWidgetWithModel::copyMessageLink() @@ -447,7 +453,7 @@ void GxsChannelPostsWidgetWithModel::editPost() void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s) { - int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(font())))); + int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())))); std::cerr << "nb columns: " << n_columns << std::endl; if(n_columns != mChannelPostsModel->columnCount()) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 8b1ca56a8..485a7fe50 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -66,7 +66,7 @@ class ChannelPostDelegate: public QAbstractItemDelegate void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; - int cellSize(const QFont& font) const; + int cellSize(const QFont& font,uint32_t parent_width) const; void zoom(bool zoom_or_unzoom) ; void setWidgetGrid(bool use_grid) ; From 931c1a728684113b060d58aa2d08e37289b44157 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Aug 2020 21:11:20 +0200 Subject: [PATCH 23/64] approaching solution for sizes --- .../gxschannels/GxsChannelPostThumbnail.cpp | 1 + .../GxsChannelPostsWidgetWithModel.cpp | 79 ++++++++++++++----- 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index f907a8593..d5da6d84f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -82,6 +82,7 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) vlayout->addStretch(); layout->addLayout(vlayout); + layout->addSpacing(Qt::Horizontal); setLayout(layout); } else diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index bd23bd041..1f6434eb5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -116,27 +116,49 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & uint32_t flags = (mUseGrid)?0:(ChannelPostThumbnailView::FLAG_SHOW_TEXT); ChannelPostThumbnailView w(post,flags); - QPixmap pixmap(w.size()); + if(mUseGrid) + { + QPixmap pixmap(w.size()); - if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) - pixmap.fill(QRgb(0xff308dc7)); // I dont know how to grab the backgroud color for selected objects automatically. - else - pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background + if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) + pixmap.fill(QRgb(0xff308dc7)); // I dont know how to grab the backgroud color for selected objects automatically. + else + pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background - w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background - if(mZoom != 1.0) - pixmap = pixmap.scaled(mZoom*pixmap.size(),Qt::KeepAspectRatio,Qt::SmoothTransformation); + if(mUseGrid) + { + if(mZoom != 1.0) + pixmap = pixmap.scaled(mZoom*pixmap.size(),Qt::KeepAspectRatio,Qt::SmoothTransformation); - if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) - { - QPainter p(&pixmap); - QFontMetricsF fm(option.font); - p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); - } + if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) + { + QPainter p(&pixmap); + QFontMetricsF fm(option.font); + p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); + } + } - painter->drawPixmap(option.rect.topLeft(), - pixmap.scaled(option.rect.width(),option.rect.width()*w.height()/(float)w.width(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); + painter->drawPixmap(option.rect.topLeft(), + pixmap.scaled(option.rect.width(),option.rect.width()*w.height()/(float)w.width(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); + } + else + { + QPixmap pixmap(option.rect.size()); + + if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) + pixmap.fill(QRgb(0xff308dc7)); // I dont know how to grab the backgroud color for selected objects automatically. + else + pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background + + w.setFixedSize(option.rect.size()); + w.update(); + + w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + + painter->drawPixmap(option.rect.topLeft(), pixmap) ; + } } QSize ChannelPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const @@ -148,7 +170,12 @@ QSize ChannelPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QM if(mUseGrid) return QSize(mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); else - return QSize(option.rect.width(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); + { + RsGxsChannelPost post = index.data(Qt::UserRole).value() ; + uint32_t flags = (mUseGrid)?0:(ChannelPostThumbnailView::FLAG_SHOW_TEXT); + + return QSize(option.rect.width(),ChannelPostThumbnailView(post,flags).height()); + } } void ChannelPostDelegate::setWidgetGrid(bool use_grid) @@ -285,8 +312,11 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI QFontMetricsF fm(font()); - for(int i=0;icolumnCount();++i) - ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())); + if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) + for(int i=0;icolumnCount();++i) + ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())); + else + ui->postsTree->setColumnWidth(0,ui->postsTree->width()); /* Setup UI helper */ @@ -351,6 +381,9 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI void GxsChannelPostsWidgetWithModel::updateZoomFactor(bool zoom_or_unzoom) { + if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_LIST) + return; + mChannelPostsDelegate->zoom(zoom_or_unzoom); for(int i=0;icolumnCount();++i) @@ -401,12 +434,20 @@ void GxsChannelPostsWidgetWithModel::switchView() { mChannelPostsDelegate->setWidgetGrid(false); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST); + + ui->postsTree->setColumnWidth(0,ui->postsTree->width()); + ui->postsTree->setUniformRowHeights(true); } else { mChannelPostsDelegate->setWidgetGrid(true); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID); + for(int i=0;icolumnCount();++i) + ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())); + + ui->postsTree->setUniformRowHeights(false); + handlePostsTreeSizeChange(ui->postsTree->size()); } } From e7ece78673c4e2f103d690e44bd593bc18eb6239 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Aug 2020 22:04:09 +0200 Subject: [PATCH 24/64] fixed sizes --- .../gxschannels/GxsChannelPostThumbnail.cpp | 46 ++++------- .../gui/gxschannels/GxsChannelPostsModel.cpp | 30 ++++--- .../GxsChannelPostsWidgetWithModel.cpp | 78 +++++++++---------- .../GxsChannelPostsWidgetWithModel.h | 2 +- 4 files changed, 73 insertions(+), 83 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index d5da6d84f..f54e2aab2 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -63,43 +63,22 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) if(mFlags & FLAG_ALLOW_PAN) mPostImage->setToolTip(tr("Use mouse to center and zoom into the image")); - mPostTitle = new QLabel(this); + QVBoxLayout *layout = new QVBoxLayout(this); + + layout->addWidget(mPostImage); + + setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); + + QFontMetricsF fm(font()); + int W = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_W * fm.height() ; + int H = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_H * fm.height() ; + + mPostImage->setFixedSize(W,H); if(mFlags & FLAG_SHOW_TEXT) { - QBoxLayout *layout = new QHBoxLayout(this); - - layout->addWidget(mPostImage); - - QVBoxLayout *vlayout = new QVBoxLayout(this); - - mPostTitle->setText(msg); - vlayout->addWidget(mPostTitle); - - QLabel *date_label = new QLabel(this); - date_label->setText(QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString()); - vlayout->addWidget(date_label); - - vlayout->addStretch(); - layout->addLayout(vlayout); - layout->addSpacing(Qt::Horizontal); - setLayout(layout); - } - else - { - QVBoxLayout *layout = new QVBoxLayout(this); - - layout->addWidget(mPostImage); + mPostTitle = new QLabel(this); layout->addWidget(mPostTitle); - setLayout(layout); - - setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); - - QFontMetricsF fm(font()); - int W = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_W * fm.height() ; - int H = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_H * fm.height() ; - - mPostImage->setFixedSize(W,H); QString ss = (msg.length() > 30)? (msg.left(30)+"..."):msg; @@ -117,6 +96,7 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) mPostTitle->setWordWrap(true); } + setLayout(layout); adjustSize(); update(); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index f4e0a5696..f45efd720 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -67,7 +67,7 @@ void RsGxsChannelPostsModel::setMode(TreeMode mode) mTreeMode = mode; if(mode == TREE_MODE_LIST) - setNumColumns(1); + setNumColumns(2); // needs some update here } @@ -212,7 +212,10 @@ int RsGxsChannelPostsModel::rowCount(const QModelIndex& parent) const return 0; if(!parent.isValid()) - return (mFilteredPosts.size() + mColumns-1)/mColumns; // mFilteredPosts always has an item at 0, so size()>=1, and mColumn>=1 + if(mTreeMode == TREE_MODE_GRID) + return (mFilteredPosts.size() + mColumns-1)/mColumns; // mFilteredPosts always has an item at 0, so size()>=1, and mColumn>=1 + else + return mFilteredPosts.size(); RsErr() << __PRETTY_FUNCTION__ << " rowCount cannot figure out the porper number of rows." << std::endl; return 0; @@ -220,7 +223,10 @@ int RsGxsChannelPostsModel::rowCount(const QModelIndex& parent) const int RsGxsChannelPostsModel::columnCount(const QModelIndex &/*parent*/) const { - return std::min((int)mFilteredPosts.size(),(int)mColumns) ; + if(mTreeMode == TREE_MODE_GRID) + return std::min((int)mFilteredPosts.size(),(int)mColumns) ; + else + return 2; } bool RsGxsChannelPostsModel::getPostData(const QModelIndex& i,RsGxsChannelPost& fmpe) const @@ -287,7 +293,7 @@ QModelIndex RsGxsChannelPostsModel::index(int row, int column, const QModelIndex if(row < 0 || column < 0 || column >= (int)mColumns) return QModelIndex(); - quintptr ref = getChildRef(parent.internalId(),column + row*mColumns); + quintptr ref = getChildRef(parent.internalId(),(mTreeMode == TREE_MODE_GRID)?(column + row*mColumns):row); #ifdef DEBUG_CHANNEL_MODEL std::cerr << "index-3(" << row << "," << column << " parent=" << parent << ") : " << createIndex(row,column,ref) << std::endl; @@ -723,15 +729,18 @@ QModelIndex RsGxsChannelPostsModel::getIndexOfMessage(const RsGxsMessageId& mid) for(uint32_t i=0;isave(); - painter->setClipRect(option.rect); + // prepare + painter->save(); + painter->setClipRect(option.rect); - RsGxsChannelPost post = index.data(Qt::UserRole).value() ; + RsGxsChannelPost post = index.data(Qt::UserRole).value() ; painter->fillRect( option.rect, option.backgroundBrush); painter->restore(); - uint32_t flags = (mUseGrid)?0:(ChannelPostThumbnailView::FLAG_SHOW_TEXT); - ChannelPostThumbnailView w(post,flags); - - if(mUseGrid) + if(mUseGrid || index.column()==0) { + uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0; + ChannelPostThumbnailView w(post,flags); + QPixmap pixmap(w.size()); if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) @@ -127,7 +127,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background - if(mUseGrid) + if(mUseGrid || index.column()==0) { if(mZoom != 1.0) pixmap = pixmap.scaled(mZoom*pixmap.size(),Qt::KeepAspectRatio,Qt::SmoothTransformation); @@ -145,19 +145,27 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & } else { - QPixmap pixmap(option.rect.size()); + // We're drawing the text on the second column - if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) - pixmap.fill(QRgb(0xff308dc7)); // I dont know how to grab the backgroud color for selected objects automatically. - else - pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background + uint32_t font_height = QFontMetricsF(option.font).height(); + QPoint p = option.rect.topLeft(); + float y = p.y() + font_height; - w.setFixedSize(option.rect.size()); - w.update(); + painter->save(); - w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) + { + QFont font(option.font); + font.setBold(true); + painter->setFont(font); + } + painter->drawText(QPoint(p.x(),y),QString::fromUtf8(post.mMeta.mMsgName.c_str())); + y += font_height; - painter->drawPixmap(option.rect.topLeft(), pixmap) ; + painter->drawText(QPoint(p.x(),y),QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString()); + y += font_height; + + painter->restore(); } } @@ -167,15 +175,10 @@ QSize ChannelPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QM QFontMetricsF fm(option.font); - if(mUseGrid) + if(mUseGrid || index.column()==0) return QSize(mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); else - { - RsGxsChannelPost post = index.data(Qt::UserRole).value() ; - uint32_t flags = (mUseGrid)?0:(ChannelPostThumbnailView::FLAG_SHOW_TEXT); - - return QSize(option.rect.width(),ChannelPostThumbnailView(post,flags).height()); - } + return QSize(option.rect.width()-mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); } void ChannelPostDelegate::setWidgetGrid(bool use_grid) @@ -314,9 +317,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) for(int i=0;icolumnCount();++i) - ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())); - else - ui->postsTree->setColumnWidth(0,ui->postsTree->width()); + ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(i,font(),ui->postsTree->width())); /* Setup UI helper */ @@ -381,17 +382,14 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI void GxsChannelPostsWidgetWithModel::updateZoomFactor(bool zoom_or_unzoom) { - if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_LIST) - return; - mChannelPostsDelegate->zoom(zoom_or_unzoom); for(int i=0;icolumnCount();++i) - ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())); + ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(i,font(),ui->postsTree->width())); QSize s = ui->postsTree->size(); - int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(font(),s.width())))); + int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),s.width())))); std::cerr << "nb columns: " << n_columns << std::endl; mChannelPostsModel->setNumColumns(n_columns); // forces the update @@ -436,7 +434,7 @@ void GxsChannelPostsWidgetWithModel::switchView() mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST); ui->postsTree->setColumnWidth(0,ui->postsTree->width()); - ui->postsTree->setUniformRowHeights(true); + //ui->postsTree->setUniformRowHeights(true); } else { @@ -444,9 +442,9 @@ void GxsChannelPostsWidgetWithModel::switchView() mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID); for(int i=0;icolumnCount();++i) - ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())); + ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(i,font(),ui->postsTree->width())); - ui->postsTree->setUniformRowHeights(false); + //ui->postsTree->setUniformRowHeights(false); handlePostsTreeSizeChange(ui->postsTree->size()); } @@ -494,7 +492,7 @@ void GxsChannelPostsWidgetWithModel::editPost() void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s) { - int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(font(),ui->postsTree->width())))); + int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),ui->postsTree->width())))); std::cerr << "nb columns: " << n_columns << std::endl; if(n_columns != mChannelPostsModel->columnCount()) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 485a7fe50..2bf11ebaa 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -66,7 +66,7 @@ class ChannelPostDelegate: public QAbstractItemDelegate void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; - int cellSize(const QFont& font,uint32_t parent_width) const; + int cellSize(int col, const QFont& font, uint32_t parent_width) const; void zoom(bool zoom_or_unzoom) ; void setWidgetGrid(bool use_grid) ; From 81e08d0004d2c1a8872758e87ab1e346432d8a9a Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 27 Aug 2020 22:06:25 +0200 Subject: [PATCH 25/64] added small shift on text --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 3b18bb469..442aaee3c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -159,10 +159,10 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & font.setBold(true); painter->setFont(font); } - painter->drawText(QPoint(p.x(),y),QString::fromUtf8(post.mMeta.mMsgName.c_str())); + painter->drawText(QPoint(p.x()+0.5*font_height,y),QString::fromUtf8(post.mMeta.mMsgName.c_str())); y += font_height; - painter->drawText(QPoint(p.x(),y),QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString()); + painter->drawText(QPoint(p.x()+0.5*font_height,y),QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString()); y += font_height; painter->restore(); From 03ac2eb53cee9ac26fae51d7cbc327008b4516e2 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 28 Aug 2020 14:07:32 +0200 Subject: [PATCH 26/64] fixed update of sizes in channel list view --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 7 +++--- .../GxsChannelPostsWidgetWithModel.cpp | 22 +++++++++---------- .../GxsChannelPostsWidgetWithModel.h | 2 +- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index f45efd720..be603891d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -69,8 +69,9 @@ void RsGxsChannelPostsModel::setMode(TreeMode mode) if(mode == TREE_MODE_LIST) setNumColumns(2); - // needs some update here + emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL)); } + void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr event) { const RsGxsChannelEvent *e = dynamic_cast(event.get()); @@ -115,7 +116,7 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr& files) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 442aaee3c..106a20140 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -89,7 +89,7 @@ int ChannelPostDelegate::cellSize(int col,const QFont& font,uint32_t parent_widt if(mUseGrid || col==0) return mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height(); else - return parent_width - mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height(); + return 0.8*parent_width - mZoom*COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font).height(); } void ChannelPostDelegate::zoom(bool zoom_or_unzoom) @@ -432,23 +432,21 @@ void GxsChannelPostsWidgetWithModel::switchView() { mChannelPostsDelegate->setWidgetGrid(false); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST); - - ui->postsTree->setColumnWidth(0,ui->postsTree->width()); - //ui->postsTree->setUniformRowHeights(true); } else { mChannelPostsDelegate->setWidgetGrid(true); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID); - for(int i=0;icolumnCount();++i) - ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(i,font(),ui->postsTree->width())); - - //ui->postsTree->setUniformRowHeights(false); - - handlePostsTreeSizeChange(ui->postsTree->size()); + handlePostsTreeSizeChange(ui->postsTree->size(),true); } + + for(int i=0;icolumnCount();++i) + ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(i,font(),ui->postsTree->width())); + + ui->postsTree->dataChanged(QModelIndex(),QModelIndex()); // forces update of the whole tree } + void GxsChannelPostsWidgetWithModel::copyMessageLink() { try @@ -490,10 +488,10 @@ void GxsChannelPostsWidgetWithModel::editPost() msgDialog->show(); } -void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s) +void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s,bool force) { int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),ui->postsTree->width())))); - std::cerr << "nb columns: " << n_columns << std::endl; + std::cerr << "nb columns: " << n_columns << " current count=" << mChannelPostsModel->columnCount() << std::endl; if(n_columns != mChannelPostsModel->columnCount()) mChannelPostsModel->setNumColumns(n_columns); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 2bf11ebaa..5105e7cb5 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -144,7 +144,7 @@ private slots: void filterChanged(QString); void setViewMode(int viewMode); void settingsChanged(); - void handlePostsTreeSizeChange(QSize s); + void handlePostsTreeSizeChange(QSize s, bool force=false); void postChannelPostLoad(); void editPost(); void postContextMenu(const QPoint&); From 503aa9929f1f27516eea290bc87e93b8b42e9de6 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 28 Aug 2020 14:48:06 +0200 Subject: [PATCH 27/64] added DL menu entry --- .../GxsChannelPostsWidgetWithModel.cpp | 53 ++++++++++++++++++- .../GxsChannelPostsWidgetWithModel.h | 3 +- .../GxsChannelPostsWidgetWithModel.ui | 6 +-- 3 files changed, 55 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 106a20140..f92a864e9 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -75,6 +75,7 @@ static const int CHANNEL_TABS_FILES = 2; #define STAR_OVERLAY_IMAGE ":icons/star_overlay_128.png" #define IMAGE_COPYLINK ":/images/copyrslink.png" #define IMAGE_GRID_VIEW ":icons/png/menu.png" +#define IMAGE_DOWNLOAD ":icons/png/download.png" Q_DECLARE_METATYPE(ChannelPostFileInfo) @@ -99,6 +100,11 @@ void ChannelPostDelegate::zoom(bool zoom_or_unzoom) else mZoom /= 1.02; + if(mZoom < 0.5) + mZoom = 0.5; + if(mZoom > 2.0) + mZoom = 2.0; + std::cerr << "zoom factor: " << mZoom << std::endl; } @@ -115,6 +121,8 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & if(mUseGrid || index.column()==0) { + // Draw a thumnail + uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0; ChannelPostThumbnailView w(post,flags); @@ -136,7 +144,11 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & { QPainter p(&pixmap); QFontMetricsF fm(option.font); - p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); + + if(mUseGrid) + p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); + else + p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.5*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); } } @@ -162,7 +174,10 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->drawText(QPoint(p.x()+0.5*font_height,y),QString::fromUtf8(post.mMeta.mMsgName.c_str())); y += font_height; - painter->drawText(QPoint(p.x()+0.5*font_height,y),QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString()); + painter->drawText(QPoint(p.x()+0.5*font_height,y),QDateTime::fromSecsSinceEpoch(post.mMeta.mPublishTs).toString(Qt::DefaultLocaleShortDate)); + y += font_height; + + painter->drawText(QPoint(p.x()+0.5*font_height,y),QString::number(post.mCount)+ " " +((post.mCount>1)?tr("files"):tr("file")) + " (" + QString::number(post.mSize) + " " + tr("bytes") + ")" ); y += font_height; painter->restore(); @@ -418,6 +433,16 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&) menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GRID_VIEW), tr("Switch to grid view"), this, SLOT(switchView())); menu.addSeparator(); + + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + + if(index.isValid()) + { + RsGxsChannelPost post = index.data(Qt::UserRole).value() ; + + if(!post.mFiles.empty()) + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOAD), tr("Download files"), this, SLOT(download())); + } menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) @@ -478,6 +503,30 @@ void GxsChannelPostsWidgetWithModel::copyMessageLink() QMessageBox::critical(NULL,tr("Link creation error"),tr("Link could not be created: ")+e.what()); } } +void GxsChannelPostsWidgetWithModel::download() +{ + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + RsGxsChannelPost post = index.data(Qt::UserRole).value() ; + + std::string destination; + rsGxsChannels->getChannelDownloadDirectory(mGroup.mMeta.mGroupId,destination); + + for(auto file:post.mFiles) + { + std::list sources; + std::string destination; + + // Add possible direct sources. + FileInfo fileInfo; + rsFiles->FileDetails(file.mHash, RS_FILE_HINTS_REMOTE, fileInfo); + + for(std::vector::const_iterator it = fileInfo.peers.begin(); it != fileInfo.peers.end(); ++it) { + sources.push_back((*it).peerId); + } + + rsFiles->FileRequest(file.mName, file.mHash, file.mSize, destination, RS_FILE_REQ_ANONYMOUS_ROUTING, sources); + } +} void GxsChannelPostsWidgetWithModel::editPost() { diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 5105e7cb5..6e645642a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -138,7 +138,8 @@ protected: private slots: void showPostDetails(); void updateGroupData(); - void createMsg(); + void download(); + void createMsg(); void toggleAutoDownload(); void subscribeGroup(bool subscribe); void filterChanged(QString); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index e20b1413b..9ad063092 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -87,7 +87,7 @@ Add new post - + :/icons/png/add.png:/icons/png/add.png @@ -594,8 +594,6 @@ p, li { white-space: pre-wrap; }
gui/common/LineEditClear.h
- - - + From bfee7a026605421e34c92f506450057727c7dd55 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 28 Aug 2020 21:53:24 +0200 Subject: [PATCH 28/64] replaced context menu by grid/list toolbuttons --- .../GxsChannelPostsWidgetWithModel.cpp | 14 ++++++++++++- .../GxsChannelPostsWidgetWithModel.ui | 20 +++++++++++++++++++ retroshare-gui/src/gui/icons.qrc | 2 ++ .../src/gui/icons/svg/gridlayout.svg | 11 ++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 retroshare-gui/src/gui/icons/svg/gridlayout.svg diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index f92a864e9..a5a91d6aa 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -290,7 +290,13 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI /* Invoke the Qt Designer generated object setup routine */ ui->setupUi(this); - ui->postsTree->setModel(mChannelPostsModel = new RsGxsChannelPostsModel()); + ui->list_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":Posted/images/classic.png")); + ui->grid_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg")); + + connect(ui->list_TB,SIGNAL(clicked()),this,SLOT(switchView())); + connect(ui->grid_TB,SIGNAL(clicked()),this,SLOT(switchView())); + + ui->postsTree->setModel(mChannelPostsModel = new RsGxsChannelPostsModel()); ui->postsTree->setItemDelegate(mChannelPostsDelegate = new ChannelPostDelegate()); ui->postsTree->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // prevents bug on w10, since row size depends on widget width ui->postsTree->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);// more beautiful if we scroll at pixel level @@ -455,11 +461,17 @@ void GxsChannelPostsWidgetWithModel::switchView() { if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) { + whileBlocking(ui->list_TB)->setChecked(true); + whileBlocking(ui->grid_TB)->setChecked(false); + mChannelPostsDelegate->setWidgetGrid(false); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST); } else { + whileBlocking(ui->list_TB)->setChecked(false); + whileBlocking(ui->grid_TB)->setChecked(true); + mChannelPostsDelegate->setWidgetGrid(true); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index 9ad063092..bc01e768c 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -120,6 +120,26 @@
+ + + + ... + + + true + + + + + + + ... + + + true + + + diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index 656cdc7fd..1360bae35 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -4,6 +4,8 @@ icons/svg/hidden.svg icons/svg/randomness.svg icons/svg/password.svg + Posted/images/classic.png + icons/svg/gridlayout.svg icons/stars/star0.png icons/stars/star1.png icons/stars/star2.png diff --git a/retroshare-gui/src/gui/icons/svg/gridlayout.svg b/retroshare-gui/src/gui/icons/svg/gridlayout.svg new file mode 100644 index 000000000..96e7089ec --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/gridlayout.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + From f17fae451949b5ca93db0ed55cb6042b9789ed96 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 28 Aug 2020 22:39:48 +0200 Subject: [PATCH 29/64] switch to svg icon for list layout --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 5 ++++- retroshare-gui/src/gui/icons.qrc | 2 +- retroshare-gui/src/gui/icons/svg/listlayout.svg | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 retroshare-gui/src/gui/icons/svg/listlayout.svg diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index a5a91d6aa..bd3a45d8d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -290,8 +290,9 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI /* Invoke the Qt Designer generated object setup routine */ ui->setupUi(this); - ui->list_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":Posted/images/classic.png")); + ui->list_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/listlayout.svg")); ui->grid_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg")); + whileBlocking(ui->grid_TB)->setChecked(true); connect(ui->list_TB,SIGNAL(clicked()),this,SLOT(switchView())); connect(ui->grid_TB,SIGNAL(clicked()),this,SLOT(switchView())); @@ -433,12 +434,14 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&) { QMenu menu(this); +#ifdef TO_REMOVE if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GRID_VIEW), tr("Switch to list view"), this, SLOT(switchView())); else menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_GRID_VIEW), tr("Switch to grid view"), this, SLOT(switchView())); menu.addSeparator(); +#endif QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index 1360bae35..71a5015a1 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -4,7 +4,7 @@ icons/svg/hidden.svg icons/svg/randomness.svg icons/svg/password.svg - Posted/images/classic.png + icons/svg/listlayout.svg icons/svg/gridlayout.svg icons/stars/star0.png icons/stars/star1.png diff --git a/retroshare-gui/src/gui/icons/svg/listlayout.svg b/retroshare-gui/src/gui/icons/svg/listlayout.svg new file mode 100644 index 000000000..153862285 --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/listlayout.svg @@ -0,0 +1,2 @@ + + From 11ecd6fbd15b45038fa88d206531216154a22517 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Aug 2020 14:13:03 +0200 Subject: [PATCH 30/64] keep focus on current item when changing view mode --- .../GxsChannelPostsWidgetWithModel.cpp | 24 +++++++++++++++++++ .../GxsChannelPostsWidgetWithModel.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index bd3a45d8d..380d9467b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -460,8 +460,29 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&) menu.exec(QCursor::pos()); } +RsGxsMessageId GxsChannelPostsWidgetWithModel::getCurrentItemId() const +{ + RsGxsMessageId selected_msg_id ; + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + + if(index.isValid()) + selected_msg_id = index.data(Qt::UserRole).value().mMeta.mMsgId ; + + return selected_msg_id; +} + +void GxsChannelPostsWidgetWithModel::selectItem(const RsGxsMessageId& msg_id) +{ + auto index = mChannelPostsModel->getIndexOfMessage(msg_id); + + ui->postsTree->selectionModel()->setCurrentIndex(index,QItemSelectionModel::ClearAndSelect); + ui->postsTree->scrollTo(index);//May change if model reloaded +} + void GxsChannelPostsWidgetWithModel::switchView() { + auto msg_id = getCurrentItemId(); + if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) { whileBlocking(ui->list_TB)->setChecked(true); @@ -484,6 +505,9 @@ void GxsChannelPostsWidgetWithModel::switchView() for(int i=0;icolumnCount();++i) ui->postsTree->setColumnWidth(i,mChannelPostsDelegate->cellSize(i,font(),ui->postsTree->width())); + selectItem(msg_id); + ui->postsTree->setFocus(); + ui->postsTree->dataChanged(QModelIndex(),QModelIndex()); // forces update of the whole tree } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 6e645642a..095db9698 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -159,6 +159,8 @@ public slots: private: void processSettings(bool load); + RsGxsMessageId getCurrentItemId() const; + void selectItem(const RsGxsMessageId& msg_id); void setAutoDownload(bool autoDl); static bool filterItem(FeedItem *feedItem, const QString &text, int filter); From 3ba9a1eb5d34a63004ef04d96e5e5999ef6e78b0 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Aug 2020 14:46:35 +0200 Subject: [PATCH 31/64] auto clear of search field and fixed bug causing some lines not to update --- .../src/gui/gxschannels/GxsChannelPostsModel.cpp | 8 ++++++-- retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h | 2 ++ .../gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index be603891d..41129d538 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -69,7 +69,7 @@ void RsGxsChannelPostsModel::setMode(TreeMode mode) if(mode == TREE_MODE_LIST) setNumColumns(2); - emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,mColumns-1,(void*)NULL)); + triggerViewUpdate(); } void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr event) @@ -116,7 +116,7 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptrpostsTree->setFocus(); - ui->postsTree->dataChanged(QModelIndex(),QModelIndex()); // forces update of the whole tree + mChannelPostsModel->triggerViewUpdate(); // This is already called by setMode(), but the model cannot know how many + // columns is actually has until we call handlePostsTreeSizeChange(), so + // we have to call it again here. } void GxsChannelPostsWidgetWithModel::copyMessageLink() @@ -581,7 +583,7 @@ void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s,bool forc int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),ui->postsTree->width())))); std::cerr << "nb columns: " << n_columns << " current count=" << mChannelPostsModel->columnCount() << std::endl; - if(n_columns != mChannelPostsModel->columnCount()) + if(force || (n_columns != mChannelPostsModel->columnCount())) mChannelPostsModel->setNumColumns(n_columns); } @@ -714,6 +716,7 @@ void GxsChannelPostsWidgetWithModel::updateGroupData() { mGroup = group; mChannelPostsModel->updateChannel(groupId()); + ui->filterLineEdit->clear(); insertChannelDetails(mGroup); From 89444537b198da1d9d4eea9ec761f1a7ebbfe51a Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Aug 2020 17:31:48 +0200 Subject: [PATCH 32/64] added show unread only button. Merged list/grid buttons --- .../gxschannels/GxsChannelPostFilesModel.cpp | 4 +-- .../gui/gxschannels/GxsChannelPostsModel.cpp | 33 ++++++++---------- .../gui/gxschannels/GxsChannelPostsModel.h | 4 +-- .../GxsChannelPostsWidgetWithModel.cpp | 34 ++++++++++--------- .../GxsChannelPostsWidgetWithModel.h | 1 + .../GxsChannelPostsWidgetWithModel.ui | 6 ++-- 6 files changed, 39 insertions(+), 43 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp index 987144162..dd19f600d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp @@ -306,7 +306,7 @@ void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t& if(strings.empty()) { mFilteredFiles.clear(); - for(int i=0;i& files) files.push_back(it.second); } -void RsGxsChannelPostsModel::setFilter(const QStringList& strings, uint32_t& count) +void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unread, uint32_t& count) { preMods(); beginRemoveRows(QModelIndex(),0,rowCount()-1); endRemoveRows(); - if(strings.empty()) + mFilteredPosts.clear(); + //mFilteredPosts.push_back(0); + + for(size_t i=0;i mFilteredPosts; // stores the list of displayes indices due to filtering. std::vector mPosts ; // store the list of posts updated from rsForums. - //std::map > > mPostVersions; // stores versions of posts - QColor mTextColorRead ; QColor mTextColorUnread ; QColor mTextColorUnreadChildren; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 47964bab7..7246aef19 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -290,12 +290,14 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI /* Invoke the Qt Designer generated object setup routine */ ui->setupUi(this); - ui->list_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/listlayout.svg")); - ui->grid_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg")); - whileBlocking(ui->grid_TB)->setChecked(true); + ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg")); + ui->viewType_TB->setToolTip(tr("Click to switch to list view")); + connect(ui->viewType_TB,SIGNAL(clicked()),this,SLOT(switchView())); - connect(ui->list_TB,SIGNAL(clicked()),this,SLOT(switchView())); - connect(ui->grid_TB,SIGNAL(clicked()),this,SLOT(switchView())); + ui->showUnread_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png")); + ui->showUnread_TB->setChecked(false); + ui->showUnread_TB->setToolTip(tr("Show unread posts only")); + connect(ui->showUnread_TB,SIGNAL(toggled(bool)),this,SLOT(switchOnlyUnread(bool))); ui->postsTree->setModel(mChannelPostsModel = new RsGxsChannelPostsModel()); ui->postsTree->setItemDelegate(mChannelPostsDelegate = new ChannelPostDelegate()); @@ -485,16 +487,16 @@ void GxsChannelPostsWidgetWithModel::switchView() if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID) { - whileBlocking(ui->list_TB)->setChecked(true); - whileBlocking(ui->grid_TB)->setChecked(false); + ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/listlayout.svg")); + ui->viewType_TB->setToolTip(tr("Click to switch to grid view")); mChannelPostsDelegate->setWidgetGrid(false); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST); } else { - whileBlocking(ui->list_TB)->setChecked(false); - whileBlocking(ui->grid_TB)->setChecked(true); + ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg")); + ui->viewType_TB->setToolTip(tr("Click to switch to list view")); mChannelPostsDelegate->setWidgetGrid(true); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID); @@ -749,10 +751,8 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad() mChannelPostsModel->getFilesList(files); mChannelFilesModel->setFiles(files); - //ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE); - //ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE); ui->channelFiles_TV->setAutoSelect(true); - + ui->channelFiles_TV->sortByColumn(0, Qt::AscendingOrder); } void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete) @@ -1057,15 +1057,17 @@ void GxsChannelPostsWidgetWithModel::setViewMode(int viewMode) #endif } +void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool) +{ + filterChanged(ui->filterLineEdit->text()); + std::cerr << "Switched to unread/read"<< std::endl; +} void GxsChannelPostsWidgetWithModel::filterChanged(QString s) { QStringList ql = s.split(' ',QString::SkipEmptyParts); uint32_t count; - mChannelPostsModel->setFilter(ql,count); + mChannelPostsModel->setFilter(ql,ui->showUnread_TB->isChecked(),count); mChannelFilesModel->setFilter(ql,count); - - //mChannelPostFilesProxyModel->setFilterKeyColumn(RsGxsChannelPostFilesModel::COLUMN_FILES_NAME); - //mChannelPostFilesProxyModel->setFilterRegExp(s) ;// triggers a re-display. s is actually not used. } #ifdef TODO diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 095db9698..cefb6cb09 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -152,6 +152,7 @@ private slots: void copyMessageLink(); void updateZoomFactor(bool zoom_or_unzoom); void switchView(); + void switchOnlyUnread(bool b); public slots: void sortColumnFiles(int col,Qt::SortOrder so); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index bc01e768c..ffdc04022 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -121,7 +121,7 @@ - + ... @@ -131,12 +131,12 @@ - + ... - true + false From ca49232ff1de053c2a3ccb4a7230ac9ac449d096 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Aug 2020 18:40:13 +0200 Subject: [PATCH 33/64] only switch read/unread status when necessary --- .../src/gui/gxschannels/GxsChannelPostsModel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 75c621260..4fc53e1ce 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -701,7 +701,12 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) RsThread::async([this, read_status]() { for(uint32_t i=0;imarkRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status); + { + bool post_status = (IS_MSG_UNREAD(mPosts[i].mMeta.mMsgStatus) || IS_MSG_NEW(mPosts[i].mMeta.mMsgStatus)); + + if(post_status != read_status) + rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status); + } }); } From 9652654b6ac4169d704133128af7f3fb037a6914 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 29 Aug 2020 19:45:35 +0200 Subject: [PATCH 34/64] fixed unitialized memory read causing unexpected behavior in thumbnails --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index cefb6cb09..f7d37a214 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -60,7 +60,7 @@ class ChannelPostDelegate: public QAbstractItemDelegate Q_OBJECT public: - ChannelPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent), mZoom(1.0){} + ChannelPostDelegate(QObject *parent=0) : QAbstractItemDelegate(parent), mZoom(1.0), mUseGrid(true){} virtual ~ChannelPostDelegate(){} void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const override; From cbb3b4cd6df56a8123c983d8be89f6630a1b4629 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 30 Aug 2020 10:59:28 +0200 Subject: [PATCH 35/64] clear showOnlyUnread button when switching channels --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 7246aef19..b006471e6 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -718,7 +718,8 @@ void GxsChannelPostsWidgetWithModel::updateGroupData() { mGroup = group; mChannelPostsModel->updateChannel(groupId()); - ui->filterLineEdit->clear(); + whileBlocking(ui->filterLineEdit)->clear(); + whileBlocking(ui->showUnread_TB)->setChecked(false); insertChannelDetails(mGroup); From b40c3295967c0e7250aaf2363e70a18e61e88a5c Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 30 Aug 2020 11:20:13 +0200 Subject: [PATCH 36/64] improved layout of items in list view --- .../gxschannels/GxsChannelPostsWidgetWithModel.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index b006471e6..1fb8c9c75 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -104,8 +104,6 @@ void ChannelPostDelegate::zoom(bool zoom_or_unzoom) mZoom = 0.5; if(mZoom > 2.0) mZoom = 2.0; - - std::cerr << "zoom factor: " << mZoom << std::endl; } void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const @@ -148,7 +146,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & if(mUseGrid) p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); else - p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.5*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); + p.drawPixmap(mZoom*QPoint(6.3*fm.height(),-3.7*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); } } @@ -190,10 +188,12 @@ QSize ChannelPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QM QFontMetricsF fm(option.font); + uint32_t size_diff = mUseGrid?0:(2*fm.height()); + if(mUseGrid || index.column()==0) - return QSize(mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); + return QSize(mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()-size_diff); else - return QSize(option.rect.width()-mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()); + return QSize(option.rect.width()-mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()-size_diff); } void ChannelPostDelegate::setWidgetGrid(bool use_grid) @@ -414,7 +414,6 @@ void GxsChannelPostsWidgetWithModel::updateZoomFactor(bool zoom_or_unzoom) QSize s = ui->postsTree->size(); int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),s.width())))); - std::cerr << "nb columns: " << n_columns << std::endl; mChannelPostsModel->setNumColumns(n_columns); // forces the update From b093848789b9918f6b28aff1b8a630a6fd5d6328 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 31 Aug 2020 21:56:58 +0200 Subject: [PATCH 37/64] Update bdbood.txt plus add a script to keep it fresh --- libbitdht/src/bitdht/bdboot.txt | 1470 +++++++++++++++-------- libbitdht/src/bitdht/bdboot_generate.sh | 55 + 2 files changed, 1042 insertions(+), 483 deletions(-) create mode 100755 libbitdht/src/bitdht/bdboot_generate.sh diff --git a/libbitdht/src/bitdht/bdboot.txt b/libbitdht/src/bitdht/bdboot.txt index 26fa614f6..6729c6218 100644 --- a/libbitdht/src/bitdht/bdboot.txt +++ b/libbitdht/src/bitdht/bdboot.txt @@ -1,500 +1,1004 @@ -61.81.86.213 50071 -2.89.235.12 18179 -139.192.128.54 54575 -61.224.74.1 45106 -76.189.15.171 28937 -80.98.74.161 54545 -110.137.230.187 1024 -118.10.139.25 15548 -174.2.19.15 11071 -124.106.250.65 2322 -94.208.10.154 52432 -176.9.35.88 2036 -47.9.158.37 2049 -88.174.58.215 51413 -78.60.4.214 6881 -78.119.213.102 44822 -189.150.157.153 16610 -88.217.31.208 7813 -125.1.181.171 22749 -210.136.215.55 6881 -151.236.7.73 57559 -105.227.47.34 35549 -211.47.87.58 62348 -175.152.60.168 16138 -85.195.226.115 5888 -46.191.196.157 49001 -118.200.194.97 6881 -151.70.147.15 58783 -95.150.185.164 6882 -163.44.160.81 6881 -88.149.179.95 6881 -121.176.181.60 58387 -52.40.120.56 6892 -51.175.237.18 15937 -178.204.71.144 48016 -95.31.49.9 9425 -108.196.87.74 24929 -77.37.160.170 1242 -135.0.8.24 57673 -150.242.197.4 39025 -202.231.169.253 21947 -1.36.227.158 9979 -60.130.54.195 26585 -92.39.216.40 23585 -104.208.36.117 50215 -79.253.173.153 58428 -178.45.90.225 26330 -210.139.186.89 22645 -151.49.55.78 51413 -2.32.208.156 51413 -51.255.58.0 51412 -23.88.236.63 51413 -13.69.158.91 45168 -92.134.139.162 10004 -24.75.160.81 53965 -98.202.170.205 41731 -62.76.100.235 22948 -79.100.105.242 14363 -175.156.161.33 22696 101.161.11.165 40232 -134.255.216.133 46771 -195.88.15.161 7743 -59.133.235.34 12525 -105.179.0.54 12806 -175.207.170.224 51967 -174.99.71.36 53440 -109.182.250.11 24255 -126.12.199.252 27499 -176.9.62.3 29342 -158.181.69.37 6881 -153.174.200.3 48948 -122.116.3.18 26552 -5.51.197.239 6881 -93.84.33.191 55762 -78.46.147.99 51413 -101.184.93.144 51413 -85.25.218.207 6888 -37.15.161.58 51413 -84.245.120.26 51413 -37.204.196.34 42929 -92.233.185.151 51413 -212.77.130.215 51413 -41.189.37.70 28295 -128.68.14.3 17098 -124.190.99.84 9648 -91.219.237.220 4087 -90.126.31.47 50000 -109.200.44.44 50321 -79.189.118.198 6881 -118.6.183.223 22360 -24.226.116.194 8547 -69.146.24.229 34202 -62.101.135.20 1029 -82.240.4.144 16729 -157.48.187.25 50321 -24.211.171.122 10349 -78.31.66.180 5307 -94.180.0.78 23879 -74.76.197.221 29154 -88.169.1.120 59258 -73.15.30.22 44905 -123.114.190.10 6881 -151.80.42.103 51413 -80.140.156.164 37500 -71.84.138.32 52296 -95.92.232.20 51413 -81.93.207.145 20963 -218.215.67.196 39700 -115.164.89.228 16588 -80.234.86.220 60386 -31.42.125.83 46470 -220.123.202.121 50427 -176.53.233.37 28697 -88.165.34.61 41708 -104.208.36.117 53133 -95.90.215.112 37742 -78.131.13.232 55633 -37.113.129.221 36551 -52.169.220.77 37717 -73.173.111.92 63666 -223.16.73.77 22303 -211.133.97.200 10467 -122.106.249.6 6881 -136.0.2.148 51413 -5.140.20.202 11609 -78.253.242.10 59410 -61.63.158.180 48321 -79.101.160.169 1453 -42.124.217.110 7789 -174.53.251.142 38400 -114.47.108.52 24637 -61.62.186.193 8442 -87.97.253.69 50649 -62.76.100.235 41047 -23.96.202.54 54203 -91.216.66.81 36678 -96.237.181.232 7915 -178.88.8.9 49001 -92.131.55.187 40332 -149.154.157.153 56789 -124.244.71.126 23173 -106.161.218.95 24577 -111.220.54.30 12861 -186.118.170.98 41824 -128.76.148.62 27027 -171.6.243.206 19401 -94.244.35.192 51413 -93.78.138.118 50567 -79.100.51.243 18404 -85.59.159.50 49001 -46.191.226.4 28344 -178.132.253.156 51413 101.175.156.170 61680 -76.125.33.68 54526 -77.135.115.253 9050 -50.191.160.70 20789 -107.184.38.87 43033 -2.138.139.164 62284 -95.25.229.186 6889 -213.127.73.24 4985 -162.224.188.31 7565 -76.22.35.229 16612 -96.49.182.210 21859 -83.240.93.202 51413 -65.95.73.182 42970 -42.2.41.156 24462 -135.23.129.163 61896 -188.194.127.171 39980 -84.75.22.54 51413 -212.50.134.32 49382 -147.32.203.245 55093 -91.89.196.37 61799 -2.26.160.4 26398 -95.222.150.218 38337 -60.248.95.76 6881 -216.126.213.67 25513 -62.235.217.73 61835 -176.50.116.149 17994 -66.8.165.71 16020 -74.140.153.59 59286 -81.153.207.27 51413 -203.219.80.229 54622 -58.168.124.241 3750 -86.237.133.79 51413 -178.253.199.55 1367 -46.19.85.245 50321 -194.199.26.8 43287 -118.8.19.13 6881 -37.222.221.222 8621 -37.131.222.30 21517 -87.78.153.16 5011 -46.127.246.32 40085 -24.6.186.56 34502 -161.184.231.117 6882 +101.184.93.144 51413 101.186.180.208 51413 -37.49.169.66 28133 -218.252.251.52 17648 -70.48.173.172 3504 -94.23.5.218 6881 -85.64.151.207 44822 -173.164.232.205 51413 -41.246.76.233 42181 -89.27.163.34 55315 -88.24.180.250 6249 -153.179.97.18 16218 -180.129.113.209 48695 -151.21.4.28 53210 -46.191.226.4 59982 -37.204.23.144 44822 -78.149.99.103 22683 -119.51.164.126 8568 -79.160.104.5 2513 -68.59.158.23 39460 -72.176.18.24 6881 -81.23.7.233 9224 -94.30.170.21 7105 -126.57.10.151 22962 -112.186.123.102 51413 -94.236.246.217 15554 -175.160.193.44 51413 -5.198.60.36 49007 -177.239.14.15 23036 -23.102.24.179 37253 -76.103.53.99 40573 -220.239.238.43 51413 -185.34.3.150 6881 -80.98.17.100 51413 +103.197.33.53 14354 +103.27.109.109 6884 +103.50.76.50 11623 +103.51.54.19 59914 +104.208.36.117 50215 +104.208.36.117 53133 +105.104.153.96 56532 +105.179.0.54 12806 +105.227.47.34 35549 +105.236.34.74 43961 +106.161.218.95 24577 +107.184.38.87 43033 +107.185.79.233 10278 +107.9.243.80 24112 +108.160.185.132 31530 +108.196.87.74 24929 +108.242.252.38 39304 +108.254.5.66 58192 +109.11.38.68 61722 +109.124.197.42 31559 +109.130.31.27 11460 109.168.199.53 6881 -213.46.132.81 50321 -31.185.5.4 10733 -188.37.221.51 50321 -5.18.182.29 51653 +109.174.3.81 51413 +109.182.250.11 24255 +109.184.163.146 11789 +109.187.114.190 49001 +109.194.234.36 14342 +109.197.191.45 19604 +109.200.44.44 50321 +109.209.40.17 55542 +109.211.143.205 13722 +109.214.57.82 1042 +109.28.82.4 33620 109.64.128.248 50321 -86.46.36.146 10124 -194.154.216.89 50321 -213.83.135.109 50321 -213.57.219.99 50321 -31.223.216.83 50321 -37.104.125.16 50321 -64.25.21.15 37321 -85.107.174.75 50321 -62.140.137.49 3706 -85.25.237.46 6887 -92.90.21.108 49760 -85.25.218.207 6884 -85.25.237.46 6882 +109.72.144.240 41290 +109.8.154.28 19120 +110.137.230.187 1024 +111.15.147.164 16001 +111.184.247.170 19087 +111.220.54.30 12861 +111.242.54.149 15979 +111.250.149.202 25863 +112.120.144.128 60152 +112.173.11.227 63314 +112.186.123.102 51413 +112.196.147.151 16425 +112.203.171.200 25932 +112.206.13.117 41825 +112.209.16.158 19102 +112.234.202.158 16001 +113.161.204.192 6881 +113.162.247.40 3800 +113.83.226.37 51413 +114.185.184.10 23151 +114.224.40.181 51413 +114.32.184.15 25962 +114.32.211.85 30116 +114.32.76.93 51413 +114.34.239.242 22647 +114.34.46.63 6881 +114.37.154.22 16120 +114.38.14.84 16958 +114.38.21.113 7694 +114.40.109.55 7841 +114.42.47.178 9089 +114.47.108.52 24637 +114.79.138.158 60635 +115.164.89.228 16588 +115.240.98.113 51413 +1.161.107.196 31811 +116.98.141.220 44824 +1.172.161.190 17526 +118.10.139.25 15548 +118.160.199.38 51532 +118.160.199.38 51651 +118.160.199.38 59277 +118.160.199.38 60134 +118.160.199.38 61182 +118.160.199.38 63151 +118.160.199.38 63400 +118.160.199.38 63619 +118.163.92.217 6881 +118.173.219.156 12148 +118.184.27.144 6881 +118.189.195.210 51413 +118.200.194.97 6881 +118.32.175.216 49802 +118.6.183.223 22360 +118.8.19.13 6881 +119.131.41.152 1231 +119.196.44.47 51763 +119.201.103.241 62715 +119.202.178.119 45249 +119.47.150.27 51294 +119.51.164.126 8568 +119.74.54.94 6881 +119.96.130.9 12038 +120.146.228.149 6881 +120.208.30.229 16001 +121.141.14.57 30323 +121.176.181.60 58387 +121.214.57.226 51413 +121.219.232.47 65073 +121.223.47.224 41563 +121.75.175.91 10146 +122.106.249.6 6881 +122.116.3.18 26552 +122.134.166.111 7105 +122.135.89.118 25051 +122.150.64.247 17132 +122.174.156.164 15004 +122.252.197.103 32378 +123.110.104.200 29499 +123.114.190.10 6881 +123.139.45.71 16001 +123.195.214.39 20846 +123.50.62.239 9433 +124.106.250.65 2322 +124.149.151.181 33603 +124.181.64.21 24406 +124.190.99.84 9648 +124.244.71.126 23173 +124.45.37.197 21084 +125.1.181.171 22749 +125.193.100.191 21802 +126.12.199.252 27499 +126.57.10.151 22962 +126.57.182.134 16514 +128.68.106.214 36595 +128.68.14.3 17098 +128.76.148.62 27027 +129.21.122.81 32785 130.193.244.41 15090 -85.25.218.207 6886 -202.62.94.74 39272 +130.43.29.146 52526 +130.89.165.24 10110 +132.147.102.21 1024 +133.130.90.125 6883 +134.236.242.96 1024 +134.255.216.133 46771 +135.0.8.24 57673 +135.23.129.163 57581 +135.23.129.163 61896 +135.23.129.163 61982 +136.0.2.148 51413 +1.36.227.158 9979 +13.69.158.91 45168 137.97.231.32 50321 +138.199.66.212 26174 +13.89.52.33 51409 +139.192.128.54 54575 +141.105.71.92 6881 +14.133.76.62 8771 +14.162.199.2 3800 +142.161.41.171 41788 +142.163.53.182 58144 +142.59.218.136 11300 +147.32.203.245 55093 +149.154.157.153 56789 +150.242.197.4 39025 +151.21.4.28 53210 +151.229.110.52 11163 +151.236.7.73 57559 +151.237.43.164 59133 +151.25.110.226 49289 +151.49.55.78 51413 +151.62.32.183 51413 +151.70.147.15 58783 +151.80.42.103 51413 +153.174.200.3 48948 +153.179.56.36 51413 +153.179.97.18 16218 +157.48.187.25 50321 157.49.171.10 50321 -45.76.69.49 6881 -178.32.216.187 6881 -77.180.216.131 24988 +157.7.109.77 6881 +158.181.69.37 6881 +158.193.227.67 8621 +161.184.231.117 6882 +162.224.188.31 7565 +163.44.160.81 6881 +164.215.87.224 57073 +165.132.236.14 25390 +169.149.196.18 50321 +171.6.243.206 19401 +171.97.173.243 9327 172.10.50.156 51413 172.56.7.143 18972 -89.248.171.137 6881 -185.34.3.103 6881 -185.34.3.20 6881 -185.34.3.172 6881 -68.227.56.45 57278 -122.252.197.103 32378 -112.196.147.151 16425 -90.27.140.90 1347 -176.241.133.130 49001 -23.252.55.56 29633 -36.225.186.145 25184 -14.162.199.2 3800 -62.76.100.235 34251 -42.126.157.252 22033 -95.111.46.227 18466 -68.0.53.95 11464 -213.111.37.228 9858 -37.208.66.86 30260 -91.105.156.125 1025 -116.98.141.220 44824 -183.82.1.44 59818 -41.210.224.40 11953 -114.40.109.55 7841 -51.141.3.234 31256 -81.45.175.39 33652 -62.76.100.235 40077 -80.249.65.131 9800 -94.233.110.175 49001 -61.57.113.156 1028 -92.46.228.108 26675 -46.101.56.83 30264 -87.110.236.117 64810 -62.76.100.235 33748 -91.121.136.132 59001 -61.89.6.203 19474 -23.102.24.179 33961 -78.73.38.9 11423 -40.117.89.72 24427 -52.228.47.105 39376 -67.188.183.70 41082 -62.76.100.235 39415 -92.234.58.147 13285 -62.76.100.235 43085 -213.152.161.101 34261 -124.181.64.21 24406 -103.51.54.19 59914 -62.76.100.235 28212 -69.175.34.187 28566 -27.194.238.27 6881 -194.176.114.54 28436 -77.28.66.239 15514 -113.162.247.40 3800 -92.58.106.183 8621 -61.57.118.157 25147 -90.31.140.85 16185 -126.57.182.134 16514 -219.251.128.233 50506 -52.43.139.55 6992 -89.78.249.54 49001 -90.116.231.10 33026 -5.187.143.52 6889 -124.45.37.197 21084 -39.84.172.237 6881 -190.29.115.127 10006 -86.252.48.255 59566 -27.117.108.178 56753 -60.128.90.71 15510 -128.68.106.214 36595 -92.45.192.16 22222 -135.23.129.163 61982 +172.87.31.56 6884 +173.164.232.205 51413 +173.31.76.104 21757 173.68.196.23 60073 -93.84.33.191 22071 -192.253.252.34 6881 -178.150.91.123 37787 -67.197.217.74 52624 -82.211.130.137 29777 -181.168.56.109 19567 -61.178.110.205 16001 -178.48.170.64 62331 -89.110.53.186 41210 -151.237.43.164 59133 -109.187.114.190 49001 -213.136.83.168 20024 -60.138.177.136 47243 -52.40.120.56 6992 -83.9.248.251 51413 -52.43.139.55 6892 -92.156.86.247 56432 -45.32.254.211 6881 -52.49.71.160 6892 -76.66.171.131 15021 -218.173.174.50 27069 -134.236.242.96 1024 -52.57.20.58 6992 -27.130.112.202 25477 +173.73.46.92 52828 +174.100.51.253 44460 +174.101.153.252 38195 +174.117.49.59 13052 +174.119.150.115 17065 +174.2.19.15 11071 +174.48.201.143 41918 +174.53.251.142 38400 +174.71.20.57 52193 +174.99.71.36 53440 175.138.57.51 18065 -95.31.49.9 9424 -52.40.7.160 6892 -52.57.140.142 6892 +175.151.131.80 16001 +175.152.60.168 16138 +175.156.161.33 22696 +175.156.223.157 22300 +175.160.193.44 51413 +175.207.170.224 51967 +176.104.214.178 59611 +176.108.146.88 6881 +176.212.60.108 60378 +176.214.214.73 64892 +176.214.76.87 7047 +176.226.153.243 61967 +176.241.133.130 49001 +176.31.109.159 24586 +176.31.248.87 6338 +176.49.172.107 49001 +176.50.116.149 17994 +176.53.233.37 28697 +176.9.113.77 61059 +176.9.35.88 2036 +176.9.62.3 29342 +176.97.212.163 22523 +177.239.14.15 23036 +177.32.251.226 27655 +177.5.36.152 12588 +178.120.85.170 24550 +178.122.199.251 16480 +178.132.253.156 51413 +178.137.112.35 14571 +178.140.169.137 22922 +178.148.68.18 53318 +178.150.91.123 37787 +178.150.91.123 8314 +178.168.58.44 23476 +178.185.98.43 12420 +178.204.71.144 26612 +178.204.71.144 48016 +178.219.38.34 1024 +178.221.81.112 59014 +178.253.199.55 1367 +178.32.185.12 6544 +178.32.216.187 6881 +178.35.204.111 6881 +178.36.198.215 22849 +178.44.187.32 52209 +178.45.159.135 31825 +178.45.90.225 26330 +178.48.170.64 62331 +178.72.159.43 47954 +178.88.3.227 33031 +178.88.8.9 49001 +178.89.100.227 6881 +180.129.113.209 48695 +180.183.213.112 11823 +180.18.98.235 29543 +180.64.39.48 14708 +181.168.56.109 19567 +182.177.228.43 31532 +182.210.49.84 11993 +182.53.45.3 14895 +183.109.112.49 58359 +183.82.1.44 59818 +183.89.3.101 10618 +184.145.109.37 31067 +184.146.76.179 13586 +184.147.116.143 49025 +184.166.72.229 63472 +184.18.8.33 8784 +184.41.75.34 57537 +184.89.243.73 43344 +185.157.221.247 25401 +185.21.217.59 37045 +185.34.3.103 6881 +185.34.3.150 6881 +185.34.3.172 6881 +185.34.3.20 6881 +186.118.170.98 41824 +186.254.61.185 40200 +186.4.42.27 20837 +186.54.1.246 38354 +188.121.244.133 10980 +188.142.164.252 43063 +188.164.212.104 28566 +188.168.14.169 1376 +188.176.218.22 35407 +188.186.13.95 21313 +188.187.45.126 43757 +188.194.127.171 39980 +188.224.10.109 46059 +188.231.143.20 6881 +188.232.61.83 6881 +188.235.149.202 63083 +188.25.246.130 16313 +188.37.221.51 50321 +188.49.25.79 46883 +188.72.98.36 15503 +188.77.246.133 35496 +189.150.157.153 16610 +189.5.22.202 52412 +189.54.195.49 50555 +190.29.115.127 10006 +190.60.48.165 41301 +190.88.179.253 20701 +192.253.252.34 6881 +193.160.224.34 29787 +193.253.220.184 6881 +193.77.159.24 43611 +194.154.216.89 50321 +194.176.114.54 28436 +194.199.26.8 43287 +195.154.136.170 55040 +195.222.95.57 51413 +195.234.21.119 6881 +195.240.45.224 6881 +195.245.221.35 36132 +195.88.15.161 7743 +197.87.68.102 25317 +199.127.250.15 29015 +201.252.144.11 15506 +201.53.229.60 1041 +201.83.71.123 50579 +202.231.169.253 21947 +202.62.94.74 39272 +203.198.141.201 7453 +203.213.94.200 14161 +203.219.80.229 54622 +203.87.14.9 51413 +205.209.160.171 6881 +207.224.196.66 10731 +207.255.112.154 6881 +208.101.109.128 53329 +209.195.77.83 34603 +210.136.215.55 6881 +210.139.186.89 22645 +210.195.47.196 19861 +211.133.168.214 44631 +211.133.97.200 10467 +211.14.227.69 23292 +211.217.2.251 41870 +211.47.87.58 62348 +2.1.187.15 50269 +212.129.33.50 6881 +212.129.33.59 6881 +212.21.13.209 56909 +212.45.81.173 16427 +212.49.47.32 19949 +212.50.134.32 49382 +212.74.222.13 38345 +212.77.130.215 51413 +213.111.37.228 9858 +213.112.177.129 43304 +213.114.48.42 38511 +213.127.73.24 4985 +213.136.83.168 20024 +213.152.161.101 34261 +213.167.206.125 38106 +213.174.60.46 17919 +213.231.145.208 12306 +213.245.41.143 40018 +213.251.184.146 64347 +213.26.96.117 27807 +213.27.20.223 53410 +213.46.132.81 50321 +213.57.219.99 50321 +2.138.139.164 62284 +213.83.135.109 50321 +216.126.213.67 25513 +216.151.180.79 3575 +217.12.220.238 51413 +217.165.53.221 24579 +217.209.125.15 26155 +217.29.187.23 62523 +217.76.184.18 51413 +218.161.29.209 20472 +218.173.174.50 27069 +218.215.67.196 39700 +218.252.251.52 17648 +219.251.128.233 50506 +219.84.184.204 61337 +220.100.126.4 24435 +220.120.236.151 11393 +220.123.202.121 50427 +220.136.37.144 27075 +220.143.1.39 19780 +220.161.21.128 6881 +220.18.72.3 64774 +220.239.238.43 51413 +221.118.191.176 17563 +221.127.216.99 21461 +221.217.171.96 28947 +221.76.232.11 51413 +223.16.68.18 6881 +223.16.73.77 22303 +223.18.249.29 7221 +223.219.73.227 17107 +223.247.194.12 16001 +2.26.160.4 26398 +23.102.24.179 33961 +23.102.24.179 37253 +23.16.200.217 51413 +2.32.208.156 51413 +23.252.167.81 6881 +23.252.55.56 29633 +23.27.125.26 3124 +23.88.236.63 51413 +23.96.202.54 54203 +24.128.39.166 5223 +24.144.184.102 14888 +24.211.171.122 10349 +24.226.116.194 8547 +24.6.186.56 34502 +24.75.160.81 53965 +24.78.8.98 6884 +2.51.116.185 63433 +27.117.108.178 56753 +27.130.112.202 25477 +27.194.238.27 6881 +2.89.235.12 18179 +2.94.72.90 27587 +31.147.61.11 23853 +31.185.5.4 10733 +31.220.168.41 35190 +31.223.216.83 50321 +31.35.57.129 13924 +31.42.125.83 46470 +31.8.136.66 11996 +31.8.71.71 10170 +36.225.186.145 25184 +37.104.125.16 50321 +37.107.121.203 18429 +37.110.127.110 6881 +37.113.129.221 36551 +37.131.222.30 21517 +37.15.161.58 51413 +37.201.195.67 26515 +37.204.196.34 42929 +37.204.23.144 44822 +37.208.66.86 30260 +37.218.190.131 35691 +37.222.221.222 8621 +37.229.60.103 6881 +37.235.150.240 47003 +37.235.207.247 30166 +37.49.169.66 28133 +37.59.55.58 51413 +38.132.51.41 53369 +39.84.172.237 6881 +40.117.89.72 24427 +41.189.37.70 28295 +41.210.224.40 11953 +41.212.221.164 33050 +41.246.76.233 42181 +41.45.41.123 18636 +42.124.217.110 7789 +42.126.157.252 22033 +42.2.41.156 24462 +43.255.188.4 6881 +45.242.102.235 10588 +45.32.254.211 6881 +45.63.55.106 6884 +45.63.57.15 6881 +45.76.69.49 6881 +46.101.56.83 30264 +46.103.53.38 61299 +46.108.17.98 10419 +46.116.177.103 22754 +46.118.116.209 20711 +46.118.83.183 12324 +46.119.196.109 19075 +46.127.246.32 40085 +46.138.37.148 59039 +46.180.245.79 53580 +46.187.88.219 48529 +46.188.32.80 65535 +46.191.196.157 49001 +46.191.225.36 14692 +46.191.226.4 28344 +46.191.226.4 59982 +46.19.85.245 50321 +46.211.113.5 49001 +46.22.234.12 14916 +46.29.147.201 20232 +46.37.83.122 37389 +46.41.109.26 39584 +46.42.23.240 53559 +46.48.90.11 55025 +46.61.12.234 49001 +46.8.136.196 57085 +47.145.143.92 24585 +47.9.158.37 2049 +49.145.59.194 38935 +49.213.154.99 10087 +50.0.146.178 51413 +50.113.92.209 6881 +50.191.160.70 20789 +50.201.138.122 10228 +50.43.117.21 42660 +50.53.143.88 57568 +50.71.135.98 20332 +50.72.81.218 6881 +50.83.34.19 23846 +51.141.3.234 31256 +51.175.237.18 15937 +5.12.126.206 34538 +51.235.58.9 16552 +51.255.58.0 51412 +5.13.18.103 24121 +5.140.20.202 11609 +5.149.211.210 22277 +5.165.66.132 63326 +5.18.182.29 51653 +5.187.143.52 6889 +5.198.60.36 49007 +52.10.254.137 6992 +52.169.220.77 27456 +52.169.220.77 37717 +52.187.56.29 27076 +52.228.47.105 39376 +5.227.122.6 3751 +52.29.243.196 6892 52.29.58.236 6892 52.29.58.236 6992 -132.147.102.21 1024 -91.151.203.4 21833 -77.203.253.126 33334 -52.49.71.160 6992 -62.117.149.142 20425 -80.8.119.70 48082 -122.135.89.118 25051 -86.241.109.212 1024 -52.30.149.135 6992 -64.34.187.221 4926 -78.57.193.191 46040 -118.163.92.217 6881 -220.143.1.39 19780 -217.12.220.238 51413 -89.110.53.186 49787 -103.27.109.109 6884 -99.255.185.162 912 -109.11.38.68 61722 -211.14.227.69 23292 -78.224.174.190 3908 -46.103.53.38 61299 -178.204.71.144 26612 -79.251.43.82 56107 -90.79.215.246 63040 -151.229.110.52 11163 -122.134.166.111 7105 -87.191.160.44 61212 -73.19.47.61 15685 -93.188.8.35 43842 52.30.149.135 6892 -221.217.171.96 28947 -51.235.58.9 16552 -169.149.196.18 50321 -158.193.227.67 8621 -223.247.194.12 16001 -5.227.122.6 3751 -89.3.231.151 45960 -212.129.33.50 6881 -91.241.236.6 49001 -90.207.148.109 51413 -119.47.150.27 51294 -52.187.56.29 27076 -46.108.17.98 10419 -185.21.217.59 37045 -178.32.185.12 6544 -176.214.76.87 7047 -91.222.89.195 49001 -45.242.102.235 10588 -81.75.221.92 49855 -173.31.76.104 21757 -176.104.214.178 59611 -118.32.175.216 49802 -218.161.29.209 20472 -103.197.33.53 14354 -113.83.226.37 51413 -95.208.144.94 6881 -52.57.140.142 6992 -83.252.149.71 42945 -125.193.100.191 21802 -85.17.127.168 38557 -52.169.220.77 27456 -77.239.87.77 10344 -85.74.189.101 53149 -95.76.164.90 64529 -175.156.223.157 22300 -59.25.226.139 52413 -213.26.96.117 27807 -107.185.79.233 10278 -203.87.14.9 51413 -61.219.68.63 15465 -37.201.195.67 26515 -92.238.93.208 53280 -111.250.149.202 25863 -178.150.91.123 8314 -122.150.64.247 17132 -220.100.126.4 24435 -47.145.143.92 24585 -153.179.56.36 51413 -91.121.16.72 51413 -98.234.210.209 51413 -178.221.81.112 59014 -121.75.175.91 10146 -195.154.136.170 55040 -95.47.197.189 49001 -85.26.92.236 29761 -107.9.243.80 24112 -62.210.90.181 6881 -82.224.22.64 15190 -92.37.142.2 62290 -195.245.221.35 36132 -72.188.223.147 41910 -13.89.52.33 51409 -95.84.255.47 51413 -90.231.4.40 6881 -151.62.32.183 51413 -114.224.40.181 51413 -65.95.195.245 49706 -52.10.254.137 6992 -93.21.41.89 58623 -123.50.62.239 9433 -103.50.76.50 11623 -118.189.195.210 51413 -79.52.149.182 6881 -50.72.81.218 6881 -52.57.20.58 6892 -223.16.68.18 6881 -111.184.247.170 19087 -193.160.224.34 29787 -188.168.14.169 1376 -14.133.76.62 8771 -114.32.76.93 51413 -141.105.71.92 6881 -90.65.17.120 24080 -216.151.180.79 3575 -135.23.129.163 57581 -77.180.216.131 5249 -52.29.243.196 6892 -37.235.150.240 47003 -46.191.225.36 14692 +52.30.149.135 6992 +52.40.120.56 6892 +52.40.120.56 6992 +52.40.7.160 6892 +52.43.139.55 6892 +52.43.139.55 6992 52.48.137.241 6992 -81.21.216.18 22828 -178.219.38.34 1024 -43.255.188.4 6881 -221.76.232.11 51413 -49.213.154.99 10087 -105.104.153.96 56532 -93.90.227.17 49001 -71.233.72.165 39789 -118.184.27.144 6881 -58.94.255.72 25896 -118.173.219.156 12148 -38.132.51.41 53369 -205.209.160.171 6881 -45.63.55.106 6884 -157.7.109.77 6881 -172.87.31.56 6884 -23.252.167.81 6881 -45.63.57.15 6881 -220.161.21.128 6881 -133.130.90.125 6883 +52.49.71.160 6892 +52.49.71.160 6992 +52.57.140.142 6892 +52.57.140.142 6992 +52.57.20.58 6892 +52.57.20.58 6992 +5.2.58.49 49001 52.78.176.27 6881 -23.27.125.26 3124 -46.188.32.80 65535 +5.51.197.239 6881 +58.168.124.241 3750 +58.7.210.130 51413 +58.94.255.72 25896 +59.133.235.34 12525 +59.25.226.139 52413 +60.128.90.71 15510 +60.130.54.195 26585 +60.138.177.136 47243 +60.241.209.107 57588 +60.241.87.17 24478 +60.248.95.76 6881 +61.178.110.205 16001 +61.219.68.63 15465 +61.224.74.1 45106 +61.57.113.156 1028 +61.57.118.157 25147 +61.62.186.193 8442 +61.63.158.180 48321 +61.81.86.213 50071 +61.89.6.203 19474 +62.101.135.20 1029 +62.117.149.142 20425 +62.140.137.49 3706 +62.169.127.9 26665 +62.210.90.181 6881 +62.235.217.73 61835 +62.65.216.158 13414 +62.76.100.235 22948 +62.76.100.235 28212 +62.76.100.235 33748 +62.76.100.235 34251 +62.76.100.235 39415 +62.76.100.235 40077 +62.76.100.235 41047 +62.76.100.235 43085 +62.83.111.85 36398 +62.93.99.6 28010 +64.113.125.178 61127 +64.121.118.201 61270 +64.25.21.15 37321 +64.34.187.221 4926 +65.95.191.51 51413 +65.95.195.245 49706 +65.95.73.182 42970 +66.197.135.74 9870 +66.8.165.71 16020 +67.128.168.196 11524 +67.164.23.233 7119 +67.167.180.162 11451 +67.173.33.90 33134 +67.185.95.9 32173 +67.188.183.70 41082 +67.197.217.74 52624 +67.215.246.10 6881 +67.242.169.143 6886 +67.71.140.245 15582 +67.8.141.69 63990 +67.86.174.199 33605 +68.0.53.95 11464 +68.106.225.140 47417 +68.192.162.202 31159 +68.209.239.148 50375 +68.227.56.45 57278 +68.59.158.23 39460 +68.82.32.238 18307 +68.98.108.234 24290 +69.146.24.229 34202 +69.175.34.187 28566 +69.176.171.40 11254 +69.181.169.181 7313 +70.113.2.167 45645 +70.114.155.3 34892 +70.48.173.172 3504 +70.83.35.78 31982 +71.187.209.2 22274 +71.232.195.149 56530 +71.233.72.165 39789 +71.237.6.246 41304 +71.63.225.31 21053 +71.84.138.32 52296 +72.176.18.24 6881 +72.188.223.147 41910 +72.192.215.39 30028 +72.223.102.189 11614 +72.230.75.87 21095 +73.15.30.22 44905 +73.173.111.92 63666 +73.19.47.61 15685 +74.140.153.59 59286 +74.219.135.69 30239 +74.76.197.221 29154 +74.96.156.188 31749 +75.142.21.2 56117 +75.185.11.189 23993 +75.187.202.104 44822 +75.40.21.238 51413 +75.69.72.31 51413 +75.70.84.67 52856 +76.103.53.99 40573 +76.103.79.28 36151 +76.121.38.23 58982 +76.125.33.68 54526 +76.174.205.156 8605 +76.181.135.146 17016 +76.189.15.171 28937 +76.22.35.229 16612 +76.30.131.83 49366 +76.66.171.131 15021 +76.7.214.210 35875 +76.88.254.191 27137 +77.101.130.178 61762 +77.135.115.253 9050 +77.180.216.131 24988 +77.180.216.131 5249 +77.196.18.56 22750 +77.203.253.126 33334 +77.232.162.51 14257 +77.239.87.77 10344 +77.249.124.77 49187 +77.28.66.239 15514 +77.34.44.71 35691 +77.37.160.170 1242 +77.46.26.128 38127 +77.71.220.234 62357 +77.71.69.65 12087 +77.73.46.124 28966 +77.84.97.16 31837 +78.105.105.87 42127 +78.106.178.64 46183 +78.119.193.151 55227 +78.119.213.102 44822 +78.128.52.177 24574 +78.131.13.232 55633 +78.141.127.164 55618 +78.149.99.103 22683 +78.163.181.120 16519 +78.163.220.242 31758 +78.173.175.56 53453 +78.213.113.102 9182 +78.220.115.99 49482 +78.222.160.139 37995 +78.224.174.190 3908 +78.227.88.161 23191 +78.228.230.130 12577 +78.236.77.65 32026 +78.237.111.89 45254 +78.241.70.65 22014 +78.242.168.94 34153 +78.24.231.166 6881 +78.247.176.4 18105 +78.253.242.10 59410 +78.29.75.248 6881 +78.31.66.180 5307 +78.43.137.174 10409 +78.46.147.99 51413 +78.55.114.191 42839 +78.57.193.191 46040 +78.60.4.214 6881 +78.73.38.9 11423 +79.100.105.242 14363 +79.100.51.243 18404 +79.101.160.169 1453 +79.114.14.206 4602 +79.114.193.207 17966 +79.136.243.46 46486 +79.138.67.151 47942 +79.153.101.234 11154 +79.160.104.5 2513 +79.168.31.62 2622 +79.169.77.54 63189 +79.175.106.234 12684 +79.176.173.50 33043 +79.18.246.192 20356 +79.189.118.198 6881 +79.226.190.78 18189 +79.251.43.82 56107 +79.253.173.153 58428 +79.52.149.182 6881 +79.82.130.49 20757 +79.9.144.222 29037 +79.93.218.69 28681 +79.95.171.102 11092 +80.103.109.43 55260 +80.140.156.164 37500 +80.14.161.164 51789 +80.234.86.220 60386 +80.249.65.131 9800 +80.42.246.251 20502 +80.57.45.239 28239 +80.8.119.70 48082 +80.83.245.36 6993 +80.98.106.227 9773 +80.98.158.177 29436 +80.98.17.100 51413 +80.98.74.161 54545 +81.13.253.217 46370 +81.153.207.27 51413 +81.21.216.18 22828 +81.221.84.77 20214 +81.23.7.233 9224 +81.249.29.121 7812 +81.45.175.39 33652 +81.51.97.133 40039 +81.75.221.92 49855 +81.93.207.145 20963 +82.136.113.22 6881 +82.137.118.90 26474 +82.178.114.74 50836 +82.192.32.151 58864 +82.211.130.137 29777 +82.224.22.64 15190 +82.232.212.66 55826 +82.235.101.26 7816 +82.237.40.39 39052 +82.240.4.144 16729 +82.47.63.231 26035 +82.7.124.219 12334 +83.110.225.79 17257 +83.134.60.207 10267 +83.155.218.188 51413 +83.157.77.228 7812 +83.202.163.16 6881 +83.213.185.157 43235 +83.240.93.202 51413 +83.252.149.71 42945 +83.252.23.84 10699 +83.49.197.212 61627 +83.6.22.221 52512 +83.87.5.5 43317 +83.9.248.251 51413 +84.123.4.247 29043 +84.123.59.159 13963 +84.151.248.98 61500 +84.154.235.198 59678 +84.217.43.156 45620 +84.245.120.26 51413 +84.40.80.3 6890 +84.52.169.26 10838 +84.75.22.54 51413 +85.107.174.75 50321 +85.107.182.248 19486 +85.114.60.149 17582 +85.138.230.74 56197 +85.167.249.218 55649 +85.17.127.168 38557 +85.195.226.115 5888 +85.219.118.111 27483 +85.220.66.170 35131 +85.246.109.226 6890 +85.250.43.217 41490 +85.25.218.207 6884 +85.25.218.207 6886 +85.25.218.207 6888 +85.25.237.46 6882 +85.25.237.46 6887 +85.26.92.236 29761 +85.54.211.184 17283 +85.59.159.50 49001 +85.64.151.207 44822 +85.74.189.101 53149 +86.100.227.142 50497 +86.145.211.200 49330 +86.168.167.166 55451 +86.169.117.185 51938 +86.194.215.166 14316 +86.237.133.79 51413 +86.241.109.212 1024 +86.252.48.255 59566 +86.29.220.199 28527 +86.46.36.146 10124 +87.106.187.29 20277 +87.110.236.117 64810 +87.16.197.67 20787 +87.191.160.44 61212 +87.244.169.128 55807 +87.253.26.85 45934 +87.2.74.180 6783 +87.78.153.16 5011 +87.97.253.69 50649 +87.98.162.88 6881 +88.148.233.194 38081 +88.149.179.95 6881 +88.155.36.246 15856 +88.165.34.61 41708 +88.169.1.120 59258 +88.169.60.195 17108 +88.170.61.126 32761 +88.174.167.76 30032 +88.174.176.173 56969 +88.174.58.215 51413 +88.186.230.88 12048 +88.217.31.208 7813 +88.217.36.182 2924 +88.230.184.110 25432 +88.233.167.39 20620 +88.24.180.250 6249 +88.245.188.55 28097 +88.3.236.194 10926 +88.84.191.25 30536 +89.110.53.186 41210 +89.110.53.186 49787 +89.132.181.63 61498 +89.133.89.51 55846 +89.143.138.33 64606 +89.204.110.192 6881 +89.209.82.248 12425 +89.224.149.142 25365 +89.248.171.137 6881 +89.27.163.34 55315 +89.3.231.151 45960 +89.33.72.233 1398 +89.78.249.54 49001 +89.92.251.113 16946 +90.116.231.10 33026 +90.126.31.47 50000 +90.149.227.168 49241 +90.16.53.195 31338 +90.184.93.164 22828 +90.204.42.12 48402 +90.207.148.109 51413 +90.225.103.241 40066 +90.231.4.40 6881 +90.27.140.90 1347 +90.29.226.250 14329 +90.31.140.85 16185 +90.38.76.72 4699 +90.41.206.239 30502 +90.65.17.120 24080 +90.79.215.246 63040 +91.105.156.125 1025 +91.121.114.171 58846 +91.121.136.132 59001 +91.121.16.72 51413 +91.137.168.238 27616 +91.148.14.62 11206 +91.151.203.4 21833 +91.157.230.16 1885 +91.216.66.81 36678 +91.219.237.220 4087 +91.222.89.195 49001 +91.241.236.6 49001 +91.247.142.205 58199 +91.67.129.216 1210 +91.74.119.134 49246 +91.89.196.37 61799 +92.125.17.239 25548 +92.131.55.187 40332 +92.134.139.162 10004 +92.137.208.191 29253 +92.139.252.16 36535 +92.156.86.247 56432 +92.2.212.97 15078 +92.233.185.151 51413 +92.234.58.147 13285 +92.238.93.208 53280 +92.246.22.40 33576 +92.247.248.50 23666 +92.255.208.221 34798 +92.37.142.2 62290 +92.37.27.83 37375 +92.39.216.40 23585 +92.43.189.45 3140 +92.45.192.16 22222 +92.46.228.108 26675 +92.49.5.186 38678 +92.58.106.183 8621 +92.80.201.189 20026 +92.83.188.95 10477 +92.87.167.73 55624 +92.90.21.108 49760 +92.96.51.71 56237 +92.98.171.108 51413 +92.99.221.105 51405 +93.105.81.215 21000 +93.109.84.235 21443 +93.11.175.201 41027 +93.124.97.171 49001 +93.181.201.89 54631 +93.186.192.165 39020 +93.188.8.35 43842 +93.21.41.89 58623 +93.58.14.83 51413 +93.77.32.187 57408 +93.78.138.118 50567 +93.80.96.134 23683 +93.81.126.53 6881 +93.84.33.191 22071 +93.84.33.191 55762 +93.90.227.17 49001 +93.95.160.156 13118 +93.96.13.136 12181 +94.103.196.139 54378 +94.155.59.112 57833 +94.180.0.78 23879 +94.190.105.157 6881 +94.208.10.154 52432 +94.21.30.143 63448 +94.21.70.206 50541 +94.23.0.84 51582 +94.233.110.175 49001 +94.23.49.143 8000 +94.23.5.218 6881 +94.236.246.217 15554 +94.244.35.192 51413 +94.245.153.136 23040 +94.30.170.21 7105 +94.41.249.131 10613 +94.44.164.74 60966 +94.62.25.152 39020 +94.68.144.118 10009 +94.96.112.204 35187 +94.96.167.130 64130 +95.104.80.193 6881 +95.111.0.20 34295 +95.111.46.227 18466 +95.135.101.164 55829 +95.150.185.164 6882 +95.153.169.40 19697 +95.188.23.129 42927 +95.196.203.111 59402 +95.208.144.94 6881 +95.222.150.218 38337 +95.239.56.106 62200 +95.24.101.211 6881 +95.25.229.186 6889 +95.26.91.94 6881 +95.31.49.9 9424 +95.31.49.9 9425 +95.32.187.214 14778 +95.37.162.145 14476 +95.37.18.51 59118 +95.47.197.189 49001 +95.54.76.150 56930 +95.76.164.90 64529 +95.84.208.14 9372 +95.84.255.47 51413 +95.90.215.112 37742 +95.90.236.216 41463 +95.92.232.20 51413 +96.237.181.232 7915 +96.49.182.210 21859 +96.63.15.208 34651 +97.106.156.54 63552 +97.85.86.199 6890 +98.119.4.86 1024 +98.127.163.114 53062 +98.194.6.21 51413 +98.197.42.116 19866 +98.199.98.228 32970 +98.200.252.137 18502 +98.202.170.205 41731 +98.214.166.21 38072 +98.225.11.98 51769 +98.232.199.100 29721 +98.234.210.209 51413 +99.192.77.139 33333 +99.242.88.203 21704 +99.255.185.162 912 +99.59.129.46 26141 +99.60.78.40 18894 diff --git a/libbitdht/src/bitdht/bdboot_generate.sh b/libbitdht/src/bitdht/bdboot_generate.sh new file mode 100755 index 000000000..97618f0df --- /dev/null +++ b/libbitdht/src/bitdht/bdboot_generate.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +< + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . + +LICENSE + +< bdboot.txt +-------------------------------- +README + +function check_dht_host() +{ + mHost="$1" + mPort="$2" + + sudo nmap -oG - -sU -p $mPort $mHost | grep open | \ + awk '{print $2" "$5}' | awk -F/ '{print $1}' +} + +cat | while read line; do + hostIP="$(echo $line | awk '{print $1}')" + hostPort="$(echo $line | awk '{print $2}')" + check_dht_host $hostIP $hostPort +done + +check_dht_host router.utorrent.com 6881 +check_dht_host router.bittorrent.com 6881 +check_dht_host dht.libtorrent.org 25401 +check_dht_host dht.transmissionbt.com 6881 + From 162028abd0dcb84bc774f67694f35b2e1e1ec2fb Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 1 Sep 2020 12:01:38 +0200 Subject: [PATCH 38/64] Remove a bunch of deadcode --- libretroshare/src/gxs/rsgxsdata.cc | 1 - libretroshare/src/gxs/rsgxsdata.h | 2 -- libretroshare/src/gxs/rsgxsutil.h | 28 +------------------ .../libretroshare/gxs/common/data_support.cc | 1 - 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/libretroshare/src/gxs/rsgxsdata.cc b/libretroshare/src/gxs/rsgxsdata.cc index c3c9b9f08..b83096575 100644 --- a/libretroshare/src/gxs/rsgxsdata.cc +++ b/libretroshare/src/gxs/rsgxsdata.cc @@ -196,7 +196,6 @@ bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize) return ok; } -int RsGxsMsgMetaData::refcount = 0; RsGxsMsgMetaData::RsGxsMsgMetaData(){ clear(); diff --git a/libretroshare/src/gxs/rsgxsdata.h b/libretroshare/src/gxs/rsgxsdata.h index 2102a8254..acc0c71d8 100644 --- a/libretroshare/src/gxs/rsgxsdata.h +++ b/libretroshare/src/gxs/rsgxsdata.h @@ -99,8 +99,6 @@ public: void clear(); void operator =(const RsMsgMetaData& rMeta); - static int refcount; - //Sort data in same order than serialiser and deserializer RsGxsGroupId mGroupId; RsGxsMessageId mMsgId; diff --git a/libretroshare/src/gxs/rsgxsutil.h b/libretroshare/src/gxs/rsgxsutil.h index f8782d861..50e749f3a 100644 --- a/libretroshare/src/gxs/rsgxsutil.h +++ b/libretroshare/src/gxs/rsgxsutil.h @@ -111,27 +111,6 @@ typedef t_RsGxsGenericDataTemporaryMapVector RsNxsMsgDa typedef t_RsGxsGenericDataTemporaryList RsNxsGrpDataTemporaryList ; typedef t_RsGxsGenericDataTemporaryList RsNxsMsgDataTemporaryList ; -#ifdef UNUSED -template -class RsGxsMetaDataTemporaryMapVector: public std::vector -{ -public: - virtual ~RsGxsMetaDataTemporaryMapVector() - { - clear() ; - } - - virtual void clear() - { - for(typename RsGxsMetaDataTemporaryMapVector::iterator it = this->begin();it!=this->end();++it) - if(it->second != NULL) - delete it->second ; - std::vector::clear() ; - } -}; -#endif - - inline RsGxsGrpMsgIdPair getMsgIdPair(RsNxsMsg& msg) { return RsGxsGrpMsgIdPair(std::make_pair(msg.grpId, msg.msgId)); @@ -146,7 +125,7 @@ inline RsGxsGrpMsgIdPair getMsgIdPair(RsGxsMsgItem& msg) * Does message clean up based on individual group expirations first * if avialable. If not then deletion s */ -class RsGxsMessageCleanUp //: public RsThread +class RsGxsMessageCleanUp { public: @@ -166,11 +145,6 @@ public: */ bool clean(); - /*! - * TODO: Rather than manual progressions consider running through a thread - */ - //virtual void data_tick(){} - private: RsGeneralDataService* const mDs; diff --git a/tests/unittests/libretroshare/gxs/common/data_support.cc b/tests/unittests/libretroshare/gxs/common/data_support.cc index bad481de9..332dcd128 100644 --- a/tests/unittests/libretroshare/gxs/common/data_support.cc +++ b/tests/unittests/libretroshare/gxs/common/data_support.cc @@ -146,7 +146,6 @@ void init_item(RsGxsMsgMetaData* metaMsg) init_random(metaMsg->mGroupId) ; init_random(metaMsg->mMsgId) ; - metaMsg->refcount = 1; init_random(metaMsg->mThreadId) ; init_random(metaMsg->mParentId) ; init_random(metaMsg->mOrigMsgId) ; From 4a81f7f5db72a9b03b3bd4183ee209a8ae277e0e Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 1 Sep 2020 15:36:47 +0200 Subject: [PATCH 39/64] Remove documentation for param which doesn't exists anymore --- libretroshare/src/retroshare/rsevents.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libretroshare/src/retroshare/rsevents.h b/libretroshare/src/retroshare/rsevents.h index 65e0e8557..2498a7712 100644 --- a/libretroshare/src/retroshare/rsevents.h +++ b/libretroshare/src/retroshare/rsevents.h @@ -195,8 +195,6 @@ public: /** * @brief Post event to the event queue. * @param[in] event - * @param[out] errorMessage Optional storage for error messsage, meaningful - * only on failure. * @return Success or error details. */ virtual std::error_condition postEvent( @@ -206,8 +204,6 @@ public: * @brief Send event directly to handlers. Blocking API * The handlers get exectuded on the caller thread. * @param[in] event - * @param[out] errorMessage Optional storage for error messsage, meaningful - * only on failure. * @return Success or error details. */ virtual std::error_condition sendEvent( From 06d8476120ba0762c8e9104e4f33d24989cd947c Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 1 Sep 2020 16:15:49 +0200 Subject: [PATCH 40/64] Forum add API to mark a post to be kept forever This way the post never get deleted even when older then parent group maximum storage time --- libretroshare/src/gxs/rsgenexchange.cc | 2 +- libretroshare/src/gxs/rsgxsutil.cc | 2 +- libretroshare/src/retroshare/rsgxsflags.h | 3 +- libretroshare/src/retroshare/rsgxsforums.h | 15 +++++++++- libretroshare/src/services/p3gxsforums.cc | 34 ++++++++++++++++++++++ libretroshare/src/services/p3gxsforums.h | 5 ++++ 6 files changed, 57 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index bd51875c8..543b50f05 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -282,7 +282,7 @@ bool RsGenExchange::messagePublicationTest(const RsGxsMsgMetaData& meta) rstime_t storageTimeLimit = meta.mPublishTs + st; - return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP || st == 0 || storageTimeLimit >= time(NULL); + return meta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER || st == 0 || storageTimeLimit >= time(NULL); } bool RsGenExchange::acknowledgeTokenMsg(const uint32_t& token, diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index 79ae187bd..491c6e3c2 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -107,7 +107,7 @@ bool RsGxsMessageCleanUp::clean() bool remove = store_period > 0 && ((meta->mPublishTs + store_period) < now) && !have_kids; // check client does not want the message kept regardless of age - remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP); + remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER); // if not subscribed remove messages (can optimise this really) remove = remove || (grpMeta->mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_NOT_SUBSCRIBED); diff --git a/libretroshare/src/retroshare/rsgxsflags.h b/libretroshare/src/retroshare/rsgxsflags.h index 261173af4..10357118a 100644 --- a/libretroshare/src/retroshare/rsgxsflags.h +++ b/libretroshare/src/retroshare/rsgxsflags.h @@ -107,7 +107,8 @@ namespace GXS_SERV { static const uint32_t GXS_MSG_STATUS_UNPROCESSED = 0x00000001; // Flags to store the read/process status of group messages. static const uint32_t GXS_MSG_STATUS_GUI_UNREAD = 0x00000002; // The actual meaning may depend on the type of service. static const uint32_t GXS_MSG_STATUS_GUI_NEW = 0x00000004; // - static const uint32_t GXS_MSG_STATUS_KEEP = 0x00000008; // + /** Do not delete message even if older then group maximum storage time */ + static const uint32_t GXS_MSG_STATUS_KEEP_FOREVER = 0x00000008; static const uint32_t GXS_MSG_STATUS_DELETE = 0x00000020; // /** END GXS Msg status flags **/ diff --git a/libretroshare/src/retroshare/rsgxsforums.h b/libretroshare/src/retroshare/rsgxsforums.h index 7bec23b6c..da79a03a5 100644 --- a/libretroshare/src/retroshare/rsgxsforums.h +++ b/libretroshare/src/retroshare/rsgxsforums.h @@ -363,12 +363,25 @@ public: * @param[in] parentId id of the post of which child posts (aka replies) * are requested. * @param[out] childPosts storage for the child posts - * @return false if something failed, true otherwhise + * @return Success or error details */ virtual std::error_condition getChildPosts( const RsGxsGroupId& forumId, const RsGxsMessageId& parentId, std::vector& childPosts ) = 0; + /** + * @brief Set keep forever flag on a post so it is not deleted even if older + * then group maximum storage time + * @jsonapi{development} + * @param[in] forumId id of the forum of which the post pertain + * @param[in] postId id of the post on which to set the flag + * @param[in] keepForever true to set the flag, false to unset it + * @return Success or error details + */ + virtual std::error_condition setPostKeepForever( + const RsGxsGroupId& forumId, const RsGxsMessageId& postId, + bool keepForever ) = 0; + /** * @brief Create forum. Blocking API. * @jsonapi{development} diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 409293831..988abb667 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -919,6 +919,9 @@ void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& setMsgStatusFlags(token, msgId, status, mask); + /* WARNING: The event may be received before the operation is completed! + * TODO: move notification to blocking method markRead(...) which wait the + * operation to complete */ if (rsEvents) { auto ev = std::make_shared(); @@ -933,6 +936,37 @@ void p3GxsForums::setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& /********************************************************************************************/ /********************************************************************************************/ +std::error_condition p3GxsForums::setPostKeepForever( + const RsGxsGroupId& forumId, const RsGxsMessageId& postId, + bool keepForever ) +{ + if(forumId.isNull() || postId.isNull()) return std::errc::invalid_argument; + + uint32_t mask = GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER; + uint32_t status = keepForever ? GXS_SERV::GXS_MSG_STATUS_KEEP_FOREVER : 0; + + uint32_t token; + setMsgStatusFlags(token, RsGxsGrpMsgIdPair(forumId, postId), status, mask); + + switch(waitToken(token)) + { + case RsTokenService::PENDING: // [[fallthrough]]; + case RsTokenService::PARTIAL: return std::errc::timed_out; + case RsTokenService::COMPLETE: // [[fallthrough]]; + case RsTokenService::DONE: + { + auto ev = std::make_shared(); + ev->mForumGroupId = forumId; + ev->mForumMsgId = postId; + ev->mForumEventCode = RsForumEventCode::UPDATED_MESSAGE; + rsEvents->postEvent(ev); + return std::error_condition(); + } + case RsTokenService::CANCELLED: return std::errc::operation_canceled; + default: return std::errc::bad_message; + } +} + /* so we need the same tick idea as wiki for generating dummy forums */ diff --git a/libretroshare/src/services/p3gxsforums.h b/libretroshare/src/services/p3gxsforums.h index 39416b46d..5ddce2ea2 100644 --- a/libretroshare/src/services/p3gxsforums.h +++ b/libretroshare/src/services/p3gxsforums.h @@ -137,6 +137,11 @@ public: const RsGxsGroupId& forumId, const RsGxsMessageId& parentId, std::vector& childPosts ) override; + /// @see RsGxsForums + std::error_condition setPostKeepForever( + const RsGxsGroupId& forumId, const RsGxsMessageId& postId, + bool keepForever ); + /// implementation of rsGxsGorums /// bool getGroupData(const uint32_t &token, std::vector &groups) override; From 97762093ce79a622aba12af151e41d373cb4490e Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 30 Aug 2020 18:01:58 +0200 Subject: [PATCH 41/64] added missing initialization of write-only pointer that causes error in RsTypeSerializer --- libretroshare/src/gxs/rsgxsnettunnel.cc | 7 ++++++- retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/gxs/rsgxsnettunnel.cc b/libretroshare/src/gxs/rsgxsnettunnel.cc index eabf21e7e..968ab0b6f 100644 --- a/libretroshare/src/gxs/rsgxsnettunnel.cc +++ b/libretroshare/src/gxs/rsgxsnettunnel.cc @@ -167,7 +167,12 @@ public: class RsGxsNetTunnelTurtleSearchGroupDataItem: public RsGxsNetTunnelItem { public: - explicit RsGxsNetTunnelTurtleSearchGroupDataItem(): RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA) {} + explicit RsGxsNetTunnelTurtleSearchGroupDataItem() + : RsGxsNetTunnelItem(RS_PKT_SUBTYPE_GXS_NET_TUNNEL_TURTLE_SEARCH_GROUP_DATA), + encrypted_group_data(NULL), + encrypted_group_data_len(0) + {} + virtual ~RsGxsNetTunnelTurtleSearchGroupDataItem() {} uint16_t service ; diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 1021a3937..9cc924a33 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -312,6 +312,12 @@ void GxsGroupFrameDialog::updateSearchResults(const TurtleRequestId& sid) auto it2 = mSearchGroupsItems.find(sid); + if(it2 == mSearchGroupsItems.end()) + { + std::cerr << "(EE) received a channel group turtle search result with ID " << sid << " but no item is known for this search" << std::endl; + return; + } + QList group_items ; for(auto it3(group_infos.begin());it3!=group_infos.end();++it3) From 05daa0387b081dfe199905a6cd8ad5a2bdc92fe3 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 3 Sep 2020 20:53:57 +0200 Subject: [PATCH 42/64] added some debug info in p3gxschannels.cc --- libretroshare/src/gxs/rsgenexchange.cc | 2 +- libretroshare/src/services/p3gxschannels.cc | 28 +++++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 543b50f05..2d77e6da7 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -61,7 +61,7 @@ static const uint32_t INDEX_AUTHEN_ADMIN = 0x00000040; // admin key #define GXS_MASK "GXS_MASK_HACK" -//#define GEN_EXCH_DEBUG 1 +#define GEN_EXCH_DEBUG 1 static const uint32_t MSG_CLEANUP_PERIOD = 60*59; // 59 minutes static const uint32_t INTEGRITY_CHECK_PERIOD = 60*31; // 31 minutes diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index bdb1f9981..ab5990bae 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -237,11 +237,10 @@ RsGenExchange::ServiceCreate_Return p3GxsChannels::service_CreateGroup(RsGxsGrpI void p3GxsChannels::notifyChanges(std::vector &changes) { -#ifdef GXSCHANNELS_DEBUG - std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl; +#ifdef GXSCHANNEL_DEBUG + RsDbg() << " Processing " << changes.size() << " channel changes..." << std::endl; #endif - - /* iterate through and grab any new messages */ + /* iterate through and grab any new messages */ std::set unprocessedGroups; std::vector::iterator it; @@ -295,6 +294,10 @@ void p3GxsChannels::notifyChanges(std::vector &changes) if (grpChange && rsEvents) { +#ifdef GXSCHANNEL_DEBUG + RsDbg() << " Grp Change Event or type " << grpChange->getType() << ":" << std::endl; +#endif + switch (grpChange->getType()) { case RsGxsNotify::TYPE_PROCESSED: // happens when the group is subscribed @@ -322,18 +325,27 @@ void p3GxsChannels::notifyChanges(std::vector &changes) RS_STACK_MUTEX(mKnownChannelsMutex); - if(mKnownChannels.find(grpChange->mGroupId) == mKnownChannels.end()) +#ifdef GXSCHANNEL_DEBUG + RsDbg() << " Type = Published/New " << std::endl; +#endif + if(mKnownChannels.find(grpChange->mGroupId) == mKnownChannels.end()) { - mKnownChannels.insert(std::make_pair(grpChange->mGroupId,time(NULL))) ; +#ifdef GXSCHANNEL_DEBUG + RsDbg() << " Status: unknown. Sending notification event." << std::endl; +#endif + + mKnownChannels.insert(std::make_pair(grpChange->mGroupId,time(NULL))) ; IndicateConfigChanged(); auto ev = std::make_shared(); ev->mChannelGroupId = grpChange->mGroupId; ev->mChannelEventCode = RsChannelEventCode::NEW_CHANNEL; rsEvents->postEvent(ev); - } + } +#ifdef GXSCHANNEL_DEBUG else - std::cerr << "(II) Not notifying already known channel " << grpChange->mGroupId << std::endl; + RsDbg() << " Not notifying already known channel " << grpChange->mGroupId << std::endl; +#endif } break; From 9005f22395ff1388d8b3a4f26b8aa16926d91cab Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 4 Sep 2020 14:50:12 +0200 Subject: [PATCH 43/64] added # of posts at friends and locally in channels --- .../gui/gxschannels/GxsChannelPostsModel.h | 2 + .../GxsChannelPostsWidgetWithModel.cpp | 3 + .../GxsChannelPostsWidgetWithModel.ui | 101 +++++++++--------- 3 files changed, 58 insertions(+), 48 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index 46413179f..263e23059 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -107,6 +107,8 @@ public: std::vector > getPostVersions(const RsGxsMessageId& mid) const; + uint32_t getNumberOfPosts() { return mPosts.size() ; } + // This method will asynchroneously update the data void updateChannel(const RsGxsGroupId& channel_group_id); const RsGxsGroupId& currentGroupId() const; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 1fb8c9c75..2147812de 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -753,6 +753,8 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad() ui->channelFiles_TV->setAutoSelect(true); ui->channelFiles_TV->sortByColumn(0, Qt::AscendingOrder); + + ui->infoPosts->setText(QString::number(mChannelPostsModel->getNumberOfPosts()) + " / " + QString::number(mGroup.mMeta.mVisibleMsgCount)); } void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete) @@ -953,6 +955,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou ui->infoPosts->setText(QString::number(group.mMeta.mVisibleMsgCount)); + if(group.mMeta.mLastPost==0) ui->infoLastPost->setText(tr("Never")); else diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index ffdc04022..b14dfa556 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -87,7 +87,7 @@ Add new post - + :/icons/png/add.png:/icons/png/add.png @@ -181,7 +181,7 @@ - 1 + 0 @@ -219,26 +219,6 @@ - - - - unknown - - - - - - - - 75 - true - - - - Created: - - - @@ -249,26 +229,6 @@ - - - - - 75 - true - - - - Distribution: - - - - - - - 0 - - - @@ -288,8 +248,8 @@ - - + + unknown @@ -308,8 +268,48 @@ - - + + + + unknown + + + + + + + + 75 + true + + + + Distribution: + + + + + + + + 75 + true + + + + Created: + + + + + + + 0 + + + + + unknown @@ -329,8 +329,11 @@ true
+ + <html><head/><body><p align="justify">The number of posts at friends is progressively updated.</p><p align="justify">The new numbers will show next time you load this channel.</p><p align="justify">The two numbers differ depending on your friends synchronization</p><p>time limits as well as yours.</p></body></html> + - Posts: + Posts (locally / at friends): @@ -614,6 +617,8 @@ p, li { white-space: pre-wrap; }
gui/common/LineEditClear.h
- + + + From ab9507c80ad23ac334a2af4112dbde80063554f7 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 4 Sep 2020 14:05:19 +0200 Subject: [PATCH 44/64] make channel contact author a link only when it is not null --- .../gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 2147812de..10af429e8 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -935,8 +935,6 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou rsGxsChannels->getChannelAutoDownload(group.mMeta.mGroupId,autoDownload); setAutoDownload(autoDownload); - RetroShareLink link; - if (IS_GROUP_SUBSCRIBED(group.mMeta.mSubscribeFlags)) { ui->subscribeToolButton->setText(tr("Subscribed") + " " + QString::number(group.mMeta.mPop) ); @@ -975,8 +973,11 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou ui->infoAdministrator->setId(group.mMeta.mAuthorId) ; - link = RetroShareLink::createMessage(group.mMeta.mAuthorId, ""); - ui->infoAdministrator->setText(link.toHtml()); + if(!group.mMeta.mAuthorId.isNull()) + { + RetroShareLink link = RetroShareLink::createMessage(group.mMeta.mAuthorId, ""); + ui->infoAdministrator->setText(link.toHtml()); + } ui->infoCreated->setText(DateTime::formatLongDateTime(group.mMeta.mPublishTs)); From 80875dddd7f7342e73886d9be3df958ef4236d27 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 4 Sep 2020 15:15:45 +0200 Subject: [PATCH 45/64] fixed default flags/picture on channel post creation --- retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp | 5 ++++- .../src/gui/gxschannels/GxsChannelPostThumbnail.cpp | 2 +- retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 98d144c1d..9cfccee76 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -81,7 +81,10 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId generateSpinBox->setEnabled(false); - thumbNailCb->setVisible(false); + preview_W->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE)); + preview_W->setText("[Text preview]"); + + thumbNailCb->setVisible(false); thumbNailCb->setEnabled(false); #ifdef CHANNELS_FRAME_CATCHER fCatcher = new framecatcher(); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index f54e2aab2..f8d752d9b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -25,7 +25,7 @@ #include "gui/gxschannels/GxsChannelPostThumbnail.h" ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent) - : QWidget(parent),mFlags(flags) + : QWidget(parent),mFlags(flags),mPostTitle(nullptr) { // now fill the data diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index 0d7d1018d..5c5a1a56f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -85,7 +85,7 @@ public: static constexpr char *CHAN_DEFAULT_IMAGE = ":images/thumb-default-video.png"; virtual ~ChannelPostThumbnailView(); - ChannelPostThumbnailView(QWidget *parent=NULL,uint32_t flags=FLAG_ALLOW_PAN); + ChannelPostThumbnailView(QWidget *parent=NULL,uint32_t flags=FLAG_ALLOW_PAN | FLAG_SHOW_TEXT); ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent=NULL); void init(const RsGxsChannelPost& post); @@ -101,7 +101,8 @@ public: else ss =s; - mPostTitle->setText(ss); + if(mPostTitle != NULL) + mPostTitle->setText(ss); } private: From bebc9f286346e09233be2fb84a0541cdfea17d4e Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 4 Sep 2020 19:45:06 +0200 Subject: [PATCH 46/64] added selection of thumbnail aspect ratio --- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 21 ++++- .../src/gui/gxschannels/CreateGxsChannelMsg.h | 1 + .../gui/gxschannels/CreateGxsChannelMsg.ui | 72 +++++++++------ .../gxschannels/GxsChannelPostThumbnail.cpp | 91 ++++++++++++++++++- .../gui/gxschannels/GxsChannelPostThumbnail.h | 31 ++++--- 5 files changed, 168 insertions(+), 48 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 9cfccee76..198076d84 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -78,10 +78,11 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool))); connect(stackedWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint))); connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool))); + connect(aspectRatio_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(changeAspectRatio(int))); generateSpinBox->setEnabled(false); - preview_W->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE)); + preview_W->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE),true); preview_W->setText("[Text preview]"); thumbNailCb->setVisible(false); @@ -110,6 +111,19 @@ CreateGxsChannelMsg::~CreateGxsChannelMsg() #endif } +void CreateGxsChannelMsg::changeAspectRatio(int s) +{ + switch(s) + { + case 0: break; + case 1: preview_W->setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_1_1); + break; + case 2: preview_W->setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_2_3); + break; + case 3: preview_W->setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_16_9); + break; + } +} void CreateGxsChannelMsg::contextMenu(QPoint /*point*/) { QList links ; @@ -734,7 +748,8 @@ void CreateGxsChannelMsg::addThumbnail() picture = img; // to show the selected - preview_W->setPixmap(picture); + preview_W->setPixmap(picture, aspectRatio_CB->currentIndex()==0); + } void CreateGxsChannelMsg::loadOriginalChannelPostInfo() @@ -778,7 +793,7 @@ void CreateGxsChannelMsg::loadOriginalChannelPostInfo() if(post.mThumbnail.mData != NULL) { GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData,post.mThumbnail.mSize,picture,GxsIdDetails::ORIGINAL); - preview_W->setPixmap(picture); + preview_W->setPixmap(picture,true); } diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h index 44d867ba2..f33a83ad0 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h @@ -64,6 +64,7 @@ private slots: void sendMsg(); void pasteLink() ; void contextMenu(QPoint) ; + void changeAspectRatio(int s); void addThumbnail(); void allowAutoMediaThumbNail(bool); diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index c0d28ac5f..76f6bf515 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -6,8 +6,8 @@ 0 0 - 736 - 271 + 881 + 383 @@ -79,32 +79,28 @@ 0 - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - + - - 6 - - - QLayout::SetFixedSize - - + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + @@ -179,6 +175,30 @@ p, li { white-space: pre-wrap; } + + + + + Auto + + + + + 1:1 + + + + + 3:4 + + + + + 16:9 + + + + @@ -309,7 +329,7 @@ p, li { white-space: pre-wrap; } 0 0 - 81 + 84 24 diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index f8d752d9b..b0d958f9b 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -25,7 +25,7 @@ #include "gui/gxschannels/GxsChannelPostThumbnail.h" ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent) - : QWidget(parent),mFlags(flags),mPostTitle(nullptr) + : QWidget(parent),mPostTitle(nullptr),mFlags(flags), mAspectRatio(ASPECT_RATIO_2_3) { // now fill the data @@ -33,7 +33,7 @@ ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post, } ChannelPostThumbnailView::ChannelPostThumbnailView(QWidget *parent,uint32_t flags) - : QWidget(parent),mFlags(flags) + : QWidget(parent),mFlags(flags), mAspectRatio(ASPECT_RATIO_2_3) { init(RsGxsChannelPost()); } @@ -43,6 +43,54 @@ ChannelPostThumbnailView::~ChannelPostThumbnailView() delete mPostImage; } +void ChannelPostThumbnailView::setText(const QString& s) +{ + if(mPostTitle == NULL) + { + std::cerr << "(EE) calling setText on a ChannelPostThumbnailView without SHOW_TEXT flag!"<< std::endl; + return; + } + + QString ss; + if(s.length() > 30) + ss = s.left(30)+"..."; + else + ss =s; + + mPostTitle->setText(ss); +} + +void ChannelPostThumbnailView::setPixmap(const QPixmap& p, bool guess_aspect_ratio) +{ + mPostImage->setPicture(p); + + if(guess_aspect_ratio)// aspect ratio is automatically guessed. + { + // compute closest aspect ratio + float r = p.width()/(float)p.height(); + + if(r < 0.8) + setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_2_3); + else if(r < 1.15) + setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_1_1); + else + setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_16_9); + } +} + +void ChannelPostThumbnailView::setAspectRatio(AspectRatio r) +{ + mAspectRatio = r; + + QFontMetricsF fm(font()); + int W = THUMBNAIL_OVERSAMPLE_FACTOR * thumbnail_w() * fm.height() ; + int H = THUMBNAIL_OVERSAMPLE_FACTOR * thumbnail_h() * fm.height() ; + + mPostImage->setFixedSize(W,H); + mPostImage->reset(); + mPostImage->updateView(); +} + void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) { QString msg = QString::fromUtf8(post.mMeta.mMsgName.c_str()); @@ -70,8 +118,8 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); QFontMetricsF fm(font()); - int W = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_W * fm.height() ; - int H = THUMBNAIL_OVERSAMPLE_FACTOR * THUMBNAIL_H * fm.height() ; + int W = THUMBNAIL_OVERSAMPLE_FACTOR * thumbnail_w() * fm.height() ; + int H = THUMBNAIL_OVERSAMPLE_FACTOR * thumbnail_h() * fm.height() ; mPostImage->setFixedSize(W,H); @@ -101,6 +149,39 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) update(); } +float ChannelPostThumbnailView::thumbnail_w() const +{ + switch(mAspectRatio) + { + default: + case ASPECT_RATIO_1_1: + case ASPECT_RATIO_UNKNOWN: return 5; + + case ASPECT_RATIO_2_3: return 4; + case ASPECT_RATIO_16_9: return 5 * 16.0/9.0; + } +} +float ChannelPostThumbnailView::thumbnail_h() const +{ + switch(mAspectRatio) + { + default: + case ASPECT_RATIO_1_1: + case ASPECT_RATIO_UNKNOWN: return 5; + + case ASPECT_RATIO_2_3: return 6; + case ASPECT_RATIO_16_9: return 5; + } +} + +void ZoomableLabel::reset() +{ + mCenterX = mFullImage.width()/2.0; + mCenterX = mFullImage.height()/2.0; + mZoomFactor = 1.0/std::max(width() / (float)mFullImage.width(), height()/(float)mFullImage.height()); + + updateView(); +} void ZoomableLabel::mouseMoveEvent(QMouseEvent *me) { if(!mZoomEnabled) @@ -204,3 +285,5 @@ void ZoomableLabel::updateView() + + diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index 5c5a1a56f..46acb95bf 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -42,7 +42,9 @@ public: void setPicture(const QPixmap& pix); void setEnableZoom(bool b) { mZoomEnabled = b; } + void reset(); QPixmap extractCroppedScaledPicture() const; + void updateView(); protected: void mousePressEvent(QMouseEvent *ev) override; @@ -51,8 +53,6 @@ protected: void resizeEvent(QResizeEvent *ev) override; void wheelEvent(QWheelEvent *me) override; - void updateView(); - QPixmap mFullImage; float mCenterX; @@ -70,6 +70,13 @@ class ChannelPostThumbnailView: public QWidget Q_OBJECT public: + typedef enum { + ASPECT_RATIO_UNKNOWN = 0x00, + ASPECT_RATIO_2_3 = 0x01, + ASPECT_RATIO_1_1 = 0x02, + ASPECT_RATIO_16_9 = 0x03, + } AspectRatio; + // This variable determines the zoom factor on the text below thumbnails. 2.0 is mostly correct for all screen. static constexpr float THUMBNAIL_OVERSAMPLE_FACTOR = 2.0; @@ -90,24 +97,18 @@ public: void init(const RsGxsChannelPost& post); - void setPixmap(const QPixmap& p) { mPostImage->setPicture(p); } + void setAspectRatio(AspectRatio r); + void setPixmap(const QPixmap& p,bool guess_aspect_ratio) ; QPixmap getCroppedScaledPicture() const { return mPostImage->extractCroppedScaledPicture() ; } - void setText(const QString& s) - { - QString ss; - if(s.length() > 30) - ss = s.left(30)+"..."; - else - ss =s; - - if(mPostTitle != NULL) - mPostTitle->setText(ss); - } - + void setText(const QString& s); private: + float thumbnail_w() const; + float thumbnail_h() const; + ZoomableLabel *mPostImage; QLabel *mPostTitle; uint32_t mFlags; + AspectRatio mAspectRatio; }; From af1665978371443de1332c882f03ea3fcba16647 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 4 Sep 2020 23:36:41 +0200 Subject: [PATCH 47/64] added possibility to change the aspect ratio of thumbnails and replaced image warping by largest centered cropping --- .../gxschannels/GxsChannelPostThumbnail.cpp | 53 +++++++++++++------ .../gui/gxschannels/GxsChannelPostThumbnail.h | 10 +++- .../GxsChannelPostsWidgetWithModel.cpp | 50 +++++++++++++---- .../GxsChannelPostsWidgetWithModel.h | 4 ++ .../GxsChannelPostsWidgetWithModel.ui | 2 +- 5 files changed, 93 insertions(+), 26 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index b0d958f9b..8ec55ad64 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -24,6 +24,8 @@ #include "gui/common/FilesDefs.h" #include "gui/gxschannels/GxsChannelPostThumbnail.h" +const float ChannelPostThumbnailView::DEFAULT_SIZE_IN_FONT_HEIGHT = 5.0; + ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent) : QWidget(parent),mPostTitle(nullptr),mFlags(flags), mAspectRatio(ASPECT_RATIO_2_3) { @@ -115,8 +117,6 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) layout->addWidget(mPostImage); - setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum); - QFontMetricsF fm(font()); int W = THUMBNAIL_OVERSAMPLE_FACTOR * thumbnail_w() * fm.height() ; int H = THUMBNAIL_OVERSAMPLE_FACTOR * thumbnail_h() * fm.height() ; @@ -134,31 +134,56 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) QFont font = mPostTitle->font(); + font.setPointSizeF(DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF()); + if(is_msg_new) - { font.setBold(true); - mPostTitle->setFont(font); - } + + mPostTitle->setFont(font); mPostTitle->setMaximumWidth(W); + mPostTitle->setMaximumHeight(3*fm.height()); mPostTitle->setWordWrap(true); + mPostTitle->adjustSize(); + + setMinimumHeight(H + mPostTitle->height() + 0.5*fm.height()); + setMaximumHeight(H + mPostTitle->height() + 0.5*fm.height()); } + setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); + + layout->addStretch(); setLayout(layout); adjustSize(); update(); } +QSize ChannelPostThumbnailView::actualSize() const +{ + QFontMetricsF fm(font()); + + if(mPostTitle != nullptr) + { + QMargins cm = layout()->contentsMargins(); + + return QSize(width(), + mPostTitle->height() + mPostImage->height() + 0.5*fm.height() + + cm.top() + cm.bottom() + layout()->spacing()); + } + else + return size(); +} + float ChannelPostThumbnailView::thumbnail_w() const { switch(mAspectRatio) { default: case ASPECT_RATIO_1_1: - case ASPECT_RATIO_UNKNOWN: return 5; + case ASPECT_RATIO_UNKNOWN: return DEFAULT_SIZE_IN_FONT_HEIGHT; - case ASPECT_RATIO_2_3: return 4; - case ASPECT_RATIO_16_9: return 5 * 16.0/9.0; + case ASPECT_RATIO_2_3: return DEFAULT_SIZE_IN_FONT_HEIGHT; + case ASPECT_RATIO_16_9: return DEFAULT_SIZE_IN_FONT_HEIGHT; } } float ChannelPostThumbnailView::thumbnail_h() const @@ -167,17 +192,17 @@ float ChannelPostThumbnailView::thumbnail_h() const { default: case ASPECT_RATIO_1_1: - case ASPECT_RATIO_UNKNOWN: return 5; + case ASPECT_RATIO_UNKNOWN: return DEFAULT_SIZE_IN_FONT_HEIGHT; - case ASPECT_RATIO_2_3: return 6; - case ASPECT_RATIO_16_9: return 5; + case ASPECT_RATIO_2_3: return DEFAULT_SIZE_IN_FONT_HEIGHT * 3.0/2.0; + case ASPECT_RATIO_16_9: return DEFAULT_SIZE_IN_FONT_HEIGHT * 9.0/16.0; } } void ZoomableLabel::reset() { mCenterX = mFullImage.width()/2.0; - mCenterX = mFullImage.height()/2.0; + mCenterY = mFullImage.height()/2.0; mZoomFactor = 1.0/std::max(width() / (float)mFullImage.width(), height()/(float)mFullImage.height()); updateView(); @@ -257,9 +282,7 @@ void ZoomableLabel::setPicture(const QPixmap& pix) { mFullImage = pix; - mCenterX = pix.width()/2.0; - mCenterY = pix.height()/2.0; - + reset(); updateView(); } void ZoomableLabel::resizeEvent(QResizeEvent *e) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index 46acb95bf..bdf56af0e 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -78,7 +78,7 @@ public: } AspectRatio; // This variable determines the zoom factor on the text below thumbnails. 2.0 is mostly correct for all screen. - static constexpr float THUMBNAIL_OVERSAMPLE_FACTOR = 2.0; + static constexpr float THUMBNAIL_OVERSAMPLE_FACTOR = 2.0; static constexpr uint32_t FLAG_NONE = 0x00; static constexpr uint32_t FLAG_SHOW_TEXT = 0x01; @@ -102,7 +102,15 @@ public: QPixmap getCroppedScaledPicture() const { return mPostImage->extractCroppedScaledPicture() ; } void setText(const QString& s); + + // This is used to allow to render the widget into a pixmap without the white space that Qt adds vertically. There is *no way* apparently + // to get rid of that bloody space. It depends on the aspect ratio of the image and it only shows up when the text label is shown. + // The label however has a correct size. It seems that Qt doesn't like widgets with horizontal aspect ratio and forces the size accordingly. + + QSize actualSize() const ; private: + static const float DEFAULT_SIZE_IN_FONT_HEIGHT ; + float thumbnail_w() const; float thumbnail_h() const; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 10af429e8..1c6687226 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -106,6 +106,10 @@ void ChannelPostDelegate::zoom(bool zoom_or_unzoom) mZoom = 2.0; } +void ChannelPostDelegate::setAspectRatio(ChannelPostThumbnailView::AspectRatio r) +{ + mAspectRatio = r; +} void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const { // prepare @@ -119,10 +123,13 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & if(mUseGrid || index.column()==0) { - // Draw a thumnail + // Draw a thumbnail uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0; ChannelPostThumbnailView w(post,flags); + w.setAspectRatio(mAspectRatio); + w.updateGeometry(); + w.adjustSize(); QPixmap pixmap(w.size()); @@ -133,6 +140,19 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & w.render(&pixmap,QPoint(),QRegion(),QWidget::DrawChildren );// draw the widgets, not the background + // We extract from the pixmap the part of the widget that we want. Saddly enough, Qt adds some white space + // below the widget and there is no way to control that. + + pixmap = pixmap.copy(QRect(0,0,w.actualSize().width(),w.actualSize().height())); + + if(index.row()==0 && index.column()==0) + { + QFile file("yourFile.png"); + file.open(QIODevice::WriteOnly); + pixmap.save(&file, "PNG"); + file.close(); + } + if(mUseGrid || index.column()==0) { if(mZoom != 1.0) @@ -143,15 +163,12 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & QPainter p(&pixmap); QFontMetricsF fm(option.font); - if(mUseGrid) - p.drawPixmap(mZoom*QPoint(6.2*fm.height(),6.9*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); - else - p.drawPixmap(mZoom*QPoint(6.3*fm.height(),-3.7*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); + p.drawPixmap(mZoom*QPoint(0.1*fm.height(),-3.6*fm.height()),FilesDefs::getPixmapFromQtResourcePath(STAR_OVERLAY_IMAGE).scaled(mZoom*7*fm.height(),mZoom*7*fm.height(),Qt::KeepAspectRatio,Qt::SmoothTransformation)); } } painter->drawPixmap(option.rect.topLeft(), - pixmap.scaled(option.rect.width(),option.rect.width()*w.height()/(float)w.width(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); + pixmap.scaled(option.rect.width(),option.rect.width()*pixmap.height()/(float)pixmap.width(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation)); } else { @@ -188,12 +205,25 @@ QSize ChannelPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QM QFontMetricsF fm(option.font); - uint32_t size_diff = mUseGrid?0:(2*fm.height()); + RsGxsChannelPost post = index.data(Qt::UserRole).value() ; + uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0; + + ChannelPostThumbnailView w(post,flags); + w.setAspectRatio(mAspectRatio); + w.updateGeometry(); + w.adjustSize(); + + //std::cerr << "w.size(): " << w.width() << " x " << w.height() << ". Actual size: " << w.actualSize().width() << " x " << w.actualSize().height() << std::endl; + + float aspect_ratio = w.actualSize().height()/(float)w.actualSize().width(); + + float cell_width = mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(); + float cell_height = mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height()*aspect_ratio; if(mUseGrid || index.column()==0) - return QSize(mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()-size_diff); + return QSize(cell_width,cell_height); else - return QSize(option.rect.width()-mZoom*COLUMN_SIZE_FONT_FACTOR_W*fm.height(),mZoom*COLUMN_SIZE_FONT_FACTOR_H*fm.height()-size_diff); + return QSize(option.rect.width()-cell_width,cell_height); } void ChannelPostDelegate::setWidgetGrid(bool use_grid) @@ -305,6 +335,8 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI ui->postsTree->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);// more beautiful if we scroll at pixel level ui->postsTree->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); + mChannelPostsDelegate->setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_16_9); + connect(ui->postsTree,SIGNAL(zoomRequested(bool)),this,SLOT(updateZoomFactor(bool))); ui->channelPostFiles_TV->setModel(mChannelPostFilesModel = new RsGxsChannelPostFilesModel(this)); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index f7d37a214..05afe9019 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -28,6 +28,8 @@ #include "gui/gxs/GxsMessageFramePostWidget.h" #include "gui/feeds/FeedHolder.h" +#include "GxsChannelPostThumbnail.h" + namespace Ui { class GxsChannelPostsWidgetWithModel; } @@ -69,6 +71,7 @@ class ChannelPostDelegate: public QAbstractItemDelegate int cellSize(int col, const QFont& font, uint32_t parent_width) const; void zoom(bool zoom_or_unzoom) ; void setWidgetGrid(bool use_grid) ; + void setAspectRatio(ChannelPostThumbnailView::AspectRatio r) ; private: static constexpr float IMAGE_MARGIN_FACTOR = 1.0; @@ -78,6 +81,7 @@ class ChannelPostDelegate: public QAbstractItemDelegate float mZoom; // zoom factor for the whole thumbnail bool mUseGrid; // wether we use the grid widget or the list widget + ChannelPostThumbnailView::AspectRatio mAspectRatio; }; class GxsChannelPostsWidgetWithModel: public GxsMessageFrameWidget diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index b14dfa556..fb7c7c487 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -181,7 +181,7 @@ - 0 + 1 From a4d38485471f9deb64d6e92130f042c516922472 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 5 Sep 2020 10:29:12 +0200 Subject: [PATCH 48/64] Hidden nodes always drop IP information from normal nodes. --- libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc b/libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc index fc1c17f85..caaea0e86 100644 --- a/libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc +++ b/libretroshare/src/gossipdiscovery/p3gossipdiscovery.cc @@ -388,7 +388,12 @@ void p3discovery2::recvOwnContactInfo(const RsPeerId &fromId, const RsDiscContac setPeerVersion(fromId, item->version); - updatePeerAddresses(item); + // Hidden nodes do not need IP information. So that information is dropped. + // However, that doesn't mean hidden nodes do not know that information. Normally + // normal nodes should not send it, but old nodes still do. + + if(!mPeerMgr->isHiddenNode(rsPeers->getOwnId())) + updatePeerAddresses(item); // if the peer is not validated, we stop the exchange here From 062f0eb1955dd864802a00e362857f6a573b8ea7 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 5 Sep 2020 13:57:40 +0200 Subject: [PATCH 49/64] added auto-selection of aspect ratio in posts view --- .../gxschannels/GxsChannelPostThumbnail.cpp | 14 ++++++++ .../gui/gxschannels/GxsChannelPostThumbnail.h | 9 +++++ .../gui/gxschannels/GxsChannelPostsModel.h | 1 + .../GxsChannelPostsWidgetWithModel.cpp | 33 +++++++++++++++---- 4 files changed, 50 insertions(+), 7 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index 8ec55ad64..4a547602d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -158,6 +158,20 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) update(); } +ChannelPostThumbnailView::AspectRatio ChannelPostThumbnailView::bestAspectRatio() +{ + if(mPostImage->originalImage().isNull()) + return ASPECT_RATIO_1_1; + + float as = mPostImage->originalImage().height() / (float)mPostImage->originalImage().width() ; + + if(as < 0.8) + return ASPECT_RATIO_16_9; + else if(as < 1.15) + return ASPECT_RATIO_1_1; + else + return ASPECT_RATIO_2_3; +} QSize ChannelPostThumbnailView::actualSize() const { QFontMetricsF fm(font()); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index bdf56af0e..f8c0f4650 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -46,6 +46,8 @@ public: QPixmap extractCroppedScaledPicture() const; void updateView(); + const QPixmap& originalImage() const { return mFullImage ; } + protected: void mousePressEvent(QMouseEvent *ev) override; void mouseReleaseEvent(QMouseEvent *ev) override; @@ -108,6 +110,13 @@ public: // The label however has a correct size. It seems that Qt doesn't like widgets with horizontal aspect ratio and forces the size accordingly. QSize actualSize() const ; + + /*! + * \brief bestAspectRatio + * Computes the preferred aspect ratio for the image in the post. The default is 1:1. + * \return the prefered aspect ratio + */ + AspectRatio bestAspectRatio() ; private: static const float DEFAULT_SIZE_IN_FONT_HEIGHT ; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h index 263e23059..931135840 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.h @@ -108,6 +108,7 @@ public: std::vector > getPostVersions(const RsGxsMessageId& mid) const; uint32_t getNumberOfPosts() { return mPosts.size() ; } + const RsGxsChannelPost& post(uint32_t i) const { return mPosts[i]; } // This method will asynchroneously update the data void updateChannel(const RsGxsGroupId& channel_group_id); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 1c6687226..b692e133a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -145,13 +145,13 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & pixmap = pixmap.copy(QRect(0,0,w.actualSize().width(),w.actualSize().height())); - if(index.row()==0 && index.column()==0) - { - QFile file("yourFile.png"); - file.open(QIODevice::WriteOnly); - pixmap.save(&file, "PNG"); - file.close(); - } +// if(index.row()==0 && index.column()==0) +// { +// QFile file("yourFile.png"); +// file.open(QIODevice::WriteOnly); +// pixmap.save(&file, "PNG"); +// file.close(); +// } if(mUseGrid || index.column()==0) { @@ -787,6 +787,25 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad() ui->channelFiles_TV->sortByColumn(0, Qt::AscendingOrder); ui->infoPosts->setText(QString::number(mChannelPostsModel->getNumberOfPosts()) + " / " + QString::number(mGroup.mMeta.mVisibleMsgCount)); + + // now compute aspect ratio for posts. We do that by looking at the 5 latest posts and compute the best aspect ratio for them. + + std::vector ar_votes(3,0); + + for(uint32_t i=0;igetNumberOfPosts(),5u);++i) + { + const RsGxsChannelPost& post = mChannelPostsModel->post(i); + ChannelPostThumbnailView v(post,ChannelPostThumbnailView::FLAG_SHOW_TEXT); + + ++ar_votes[ static_cast( v.bestAspectRatio() )]; + } + int best=0; + for(uint32_t i=0;i<3;++i) + if(ar_votes[i] > ar_votes[best]) + best = i; + + mChannelPostsDelegate->setAspectRatio(static_cast(best)); + mChannelPostsModel->triggerViewUpdate(); } void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete) From b8c14d6bc4a8b2cf634a33b4d4754ac5d9144dc2 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 5 Sep 2020 14:24:39 +0200 Subject: [PATCH 50/64] fixed bug in auto-determination of aspect ratio and update of geometry --- .../src/gui/gxschannels/GxsChannelPostThumbnail.cpp | 2 +- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index 4a547602d..4c1c782ee 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -165,7 +165,7 @@ ChannelPostThumbnailView::AspectRatio ChannelPostThumbnailView::bestAspectRatio( float as = mPostImage->originalImage().height() / (float)mPostImage->originalImage().width() ; - if(as < 0.8) + if(as <= 0.8) return ASPECT_RATIO_16_9; else if(as < 1.15) return ASPECT_RATIO_1_1; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index b692e133a..72e18684e 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -790,7 +790,7 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad() // now compute aspect ratio for posts. We do that by looking at the 5 latest posts and compute the best aspect ratio for them. - std::vector ar_votes(3,0); + std::vector ar_votes(4,0); for(uint32_t i=0;igetNumberOfPosts(),5u);++i) { @@ -800,12 +800,13 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad() ++ar_votes[ static_cast( v.bestAspectRatio() )]; } int best=0; - for(uint32_t i=0;i<3;++i) + for(uint32_t i=0;i<4;++i) if(ar_votes[i] > ar_votes[best]) best = i; mChannelPostsDelegate->setAspectRatio(static_cast(best)); mChannelPostsModel->triggerViewUpdate(); + handlePostsTreeSizeChange(ui->postsTree->size(),true); // force the update } void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete) From 943bd9b50e8e69d7fae81ad0190414faa025cd91 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 6 Sep 2020 17:27:33 +0200 Subject: [PATCH 51/64] removed explicit maximum size that is not needed anymore and causes a bug on some Qt implementations --- .../gui/gxschannels/GxsChannelPostThumbnail.cpp | 6 ------ .../gxschannels/GxsChannelPostsWidgetWithModel.cpp | 14 +++++++------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index 4c1c782ee..66dc02e34 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -140,14 +140,8 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) font.setBold(true); mPostTitle->setFont(font); - mPostTitle->setMaximumWidth(W); - mPostTitle->setMaximumHeight(3*fm.height()); mPostTitle->setWordWrap(true); - mPostTitle->adjustSize(); - - setMinimumHeight(H + mPostTitle->height() + 0.5*fm.height()); - setMaximumHeight(H + mPostTitle->height() + 0.5*fm.height()); } setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 72e18684e..8bc1c0250 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -145,13 +145,13 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & pixmap = pixmap.copy(QRect(0,0,w.actualSize().width(),w.actualSize().height())); -// if(index.row()==0 && index.column()==0) -// { -// QFile file("yourFile.png"); -// file.open(QIODevice::WriteOnly); -// pixmap.save(&file, "PNG"); -// file.close(); -// } +// if(index.row()==0 && index.column()==0) +// { +// QFile file("yourFile.png"); +// file.open(QIODevice::WriteOnly); +// pixmap.save(&file, "PNG"); +// file.close(); +// } if(mUseGrid || index.column()==0) { From 149b2c0fbe8e5185360a7115731f6b54e28e2fb8 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 7 Sep 2020 18:21:07 +0200 Subject: [PATCH 52/64] fixed bug causing selection to fail in list mode --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 8bc1c0250..2e9808a13 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -613,6 +613,9 @@ void GxsChannelPostsWidgetWithModel::editPost() void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s,bool force) { + if(mChannelPostsModel->getMode() != RsGxsChannelPostsModel::TREE_MODE_GRID) + return; + int n_columns = std::max(1,(int)floor(s.width() / (mChannelPostsDelegate->cellSize(0,font(),ui->postsTree->width())))); std::cerr << "nb columns: " << n_columns << " current count=" << mChannelPostsModel->columnCount() << std::endl; From 660b1c402507ffef475ad8d066e1b38a3d04d28f Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 7 Sep 2020 20:49:13 +0200 Subject: [PATCH 53/64] added a factor to scale the font --- .../src/gui/gxschannels/GxsChannelPostThumbnail.cpp | 6 +++++- .../src/gui/gxschannels/GxsChannelPostThumbnail.h | 2 ++ .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index 66dc02e34..2aeb31e1f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -25,6 +25,7 @@ #include "gui/gxschannels/GxsChannelPostThumbnail.h" const float ChannelPostThumbnailView::DEFAULT_SIZE_IN_FONT_HEIGHT = 5.0; +const float ChannelPostThumbnailView::FONT_SCALE_FACTOR = 2.0; ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent) : QWidget(parent),mPostTitle(nullptr),mFlags(flags), mAspectRatio(ASPECT_RATIO_2_3) @@ -134,7 +135,10 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) QFont font = mPostTitle->font(); - font.setPointSizeF(DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF()); + if(mFlags & ChannelPostThumbnailView::FLAG_SCALE_FONT) + font.setPointSizeF(FONT_SCALE_FACTOR * DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF()); + else + font.setPointSizeF(FONT_SCALE_FACTOR * DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF()); if(is_msg_new) font.setBold(true); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index f8c0f4650..b7a68e19f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -85,6 +85,7 @@ public: static constexpr uint32_t FLAG_NONE = 0x00; static constexpr uint32_t FLAG_SHOW_TEXT = 0x01; static constexpr uint32_t FLAG_ALLOW_PAN = 0x02; + static constexpr uint32_t FLAG_SCALE_FONT= 0x04; // Size of thumbnails as a function of the height of the font. An aspect ratio of 3/4 is good. @@ -119,6 +120,7 @@ public: AspectRatio bestAspectRatio() ; private: static const float DEFAULT_SIZE_IN_FONT_HEIGHT ; + static const float FONT_SCALE_FACTOR ; float thumbnail_w() const; float thumbnail_h() const; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 2e9808a13..804aeac7a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -125,7 +125,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & { // Draw a thumbnail - uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0; + uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT | ChannelPostThumbnailView::FLAG_SCALE_FONT):0; ChannelPostThumbnailView w(post,flags); w.setAspectRatio(mAspectRatio); w.updateGeometry(); @@ -206,7 +206,7 @@ QSize ChannelPostDelegate::sizeHint(const QStyleOptionViewItem& option, const QM QFontMetricsF fm(option.font); RsGxsChannelPost post = index.data(Qt::UserRole).value() ; - uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT):0; + uint32_t flags = (mUseGrid)?(ChannelPostThumbnailView::FLAG_SHOW_TEXT | ChannelPostThumbnailView::FLAG_SCALE_FONT):0; ChannelPostThumbnailView w(post,flags); w.setAspectRatio(mAspectRatio); @@ -798,7 +798,7 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad() for(uint32_t i=0;igetNumberOfPosts(),5u);++i) { const RsGxsChannelPost& post = mChannelPostsModel->post(i); - ChannelPostThumbnailView v(post,ChannelPostThumbnailView::FLAG_SHOW_TEXT); + ChannelPostThumbnailView v(post,ChannelPostThumbnailView::FLAG_SHOW_TEXT | ChannelPostThumbnailView::FLAG_SCALE_FONT); ++ar_votes[ static_cast( v.bestAspectRatio() )]; } From 9c11b21ee724dd473071a3e7d779e808fda47293 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 7 Sep 2020 20:55:01 +0200 Subject: [PATCH 54/64] using font scale of 1.5 --- .../src/gui/gxschannels/GxsChannelPostThumbnail.cpp | 4 ++-- retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index 2aeb31e1f..7c4bc62da 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -25,7 +25,7 @@ #include "gui/gxschannels/GxsChannelPostThumbnail.h" const float ChannelPostThumbnailView::DEFAULT_SIZE_IN_FONT_HEIGHT = 5.0; -const float ChannelPostThumbnailView::FONT_SCALE_FACTOR = 2.0; +const float ChannelPostThumbnailView::FONT_SCALE_FACTOR = 1.5; ChannelPostThumbnailView::ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent) : QWidget(parent),mPostTitle(nullptr),mFlags(flags), mAspectRatio(ASPECT_RATIO_2_3) @@ -138,7 +138,7 @@ void ChannelPostThumbnailView::init(const RsGxsChannelPost& post) if(mFlags & ChannelPostThumbnailView::FLAG_SCALE_FONT) font.setPointSizeF(FONT_SCALE_FACTOR * DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF()); else - font.setPointSizeF(FONT_SCALE_FACTOR * DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF()); + font.setPointSizeF(DEFAULT_SIZE_IN_FONT_HEIGHT / 5.0 * font.pointSizeF()); if(is_msg_new) font.setBold(true); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index b7a68e19f..b231fbe0a 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -95,7 +95,7 @@ public: static constexpr char *CHAN_DEFAULT_IMAGE = ":images/thumb-default-video.png"; virtual ~ChannelPostThumbnailView(); - ChannelPostThumbnailView(QWidget *parent=NULL,uint32_t flags=FLAG_ALLOW_PAN | FLAG_SHOW_TEXT); + ChannelPostThumbnailView(QWidget *parent=NULL,uint32_t flags=FLAG_ALLOW_PAN | FLAG_SHOW_TEXT | FLAG_SCALE_FONT); ChannelPostThumbnailView(const RsGxsChannelPost& post,uint32_t flags,QWidget *parent=NULL); void init(const RsGxsChannelPost& post); From d691454d574f6435a2bcdac69f88c75e312c687c Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 8 Sep 2020 21:04:35 +0200 Subject: [PATCH 55/64] removed "Load Channel In Background" button that is now irrelevant --- retroshare-gui/src/gui/settings/ChannelPage.cpp | 8 -------- retroshare-gui/src/gui/settings/ChannelPage.h | 3 --- retroshare-gui/src/gui/settings/ChannelPage.ui | 7 ------- 3 files changed, 18 deletions(-) diff --git a/retroshare-gui/src/gui/settings/ChannelPage.cpp b/retroshare-gui/src/gui/settings/ChannelPage.cpp index 2cebb8848..ef2fa6307 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.cpp +++ b/retroshare-gui/src/gui/settings/ChannelPage.cpp @@ -33,17 +33,10 @@ ChannelPage::ChannelPage(QWidget * parent, Qt::WindowFlags flags) ui.groupFrameSettingsWidget->setOpenAllInNewTabText(tr("Open each channel in a new tab")); ui.groupFrameSettingsWidget->setType(GroupFrameSettings::Channel) ; - connect(ui.loadThreadCheckBox,SIGNAL(toggled(bool)),this,SLOT(updateLoadThread())) ; connect(ui.emoteicon_checkBox,SIGNAL(toggled(bool)),this,SLOT(updateEmotes())) ; } -void ChannelPage::updateLoadThread() -{ - Settings->setChannelLoadThread(ui.loadThreadCheckBox->isChecked()); - NotifyQt::getInstance()->notifySettingsChanged(); -} - ChannelPage::~ChannelPage() { } @@ -51,7 +44,6 @@ ChannelPage::~ChannelPage() /** Loads the settings for this page */ void ChannelPage::load() { - whileBlocking(ui.loadThreadCheckBox)->setChecked(Settings->getChannelLoadThread()); ui.groupFrameSettingsWidget->loadSettings(GroupFrameSettings::Channel); Settings->beginGroup(QString("ChannelPostsWidget")); diff --git a/retroshare-gui/src/gui/settings/ChannelPage.h b/retroshare-gui/src/gui/settings/ChannelPage.h index 6e684ead0..6887ebe0a 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.h +++ b/retroshare-gui/src/gui/settings/ChannelPage.h @@ -42,9 +42,6 @@ public: private slots: void updateEmotes(); -protected slots: - void updateLoadThread() ; - private: Ui::ChannelPage ui; }; diff --git a/retroshare-gui/src/gui/settings/ChannelPage.ui b/retroshare-gui/src/gui/settings/ChannelPage.ui index cd0533552..5e75e442e 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.ui +++ b/retroshare-gui/src/gui/settings/ChannelPage.ui @@ -29,13 +29,6 @@ General - - - - Load posts in background (Thread) - - - From 74d762d67c63a977da13f69433613fce60a6738a Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 8 Sep 2020 21:26:16 +0200 Subject: [PATCH 56/64] moved post title to top (deprecates #2052) --- .../GxsChannelPostsWidgetWithModel.cpp | 2 +- .../GxsChannelPostsWidgetWithModel.ui | 34 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 804aeac7a..382a624f2 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -705,7 +705,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() 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); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index fb7c7c487..38b7c4902 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -435,9 +435,6 @@ p, li { white-space: pre-wrap; } Details - - 3 - @@ -456,16 +453,6 @@ p, li { white-space: pre-wrap; } - - - - TextLabel - - - true - - - @@ -489,11 +476,22 @@ p, li { white-space: pre-wrap; } - - - true - - + + + + + TextLabel + + + + + + + true + + + + From 384cacfccd82b6d4f10c895ff2ed52c43753f881 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 8 Sep 2020 21:45:04 +0200 Subject: [PATCH 57/64] fixed overlapping text in msg creation window --- .../src/gui/gxschannels/CreateGxsChannelMsg.ui | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index 76f6bf515..30d316329 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -85,7 +85,14 @@ - + + + + 0 + 0 + + + @@ -329,7 +336,7 @@ p, li { white-space: pre-wrap; } 0 0 - 84 + 98 24 From c01392bfc3fa5d68acf636157614b549fecdf41e Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 9 Sep 2020 20:35:52 +0200 Subject: [PATCH 58/64] added icons for aspect ratio --- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 5 + .../gui/gxschannels/CreateGxsChannelMsg.ui | 19 ++-- retroshare-gui/src/gui/icons.qrc | 4 + .../src/gui/icons/svg/ratio-1-1.svg | 97 +++++++++++++++++++ .../src/gui/icons/svg/ratio-16-9.svg | 2 + .../src/gui/icons/svg/ratio-3-4.svg | 2 + .../src/gui/icons/svg/ratio-auto.svg | 14 +++ 7 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 retroshare-gui/src/gui/icons/svg/ratio-1-1.svg create mode 100644 retroshare-gui/src/gui/icons/svg/ratio-16-9.svg create mode 100644 retroshare-gui/src/gui/icons/svg/ratio-3-4.svg create mode 100644 retroshare-gui/src/gui/icons/svg/ratio-auto.svg diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index 198076d84..588bff379 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -80,6 +80,11 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool))); connect(aspectRatio_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(changeAspectRatio(int))); + aspectRatio_CB->setItemIcon(0,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-auto.svg")); + aspectRatio_CB->setItemIcon(1,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-1-1.svg")); + aspectRatio_CB->setItemIcon(2,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-3-4.svg")); + aspectRatio_CB->setItemIcon(3,FilesDefs::getIconFromQtResourcePath(":/icons/svg/ratio-16-9.svg")); + generateSpinBox->setEnabled(false); preview_W->setPixmap(FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE),true); diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui index 30d316329..6041dc13e 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui @@ -171,7 +171,7 @@ p, li { white-space: pre-wrap; } Add Channel Thumbnail - + :/icons/png/add-image.png:/icons/png/add-image.png @@ -184,6 +184,12 @@ p, li { white-space: pre-wrap; } + + + 24 + 24 + + Auto @@ -212,7 +218,7 @@ p, li { white-space: pre-wrap; } Add File to Attach - + :/icons/png/add-file.png:/icons/png/add-file.png @@ -312,7 +318,7 @@ p, li { white-space: pre-wrap; } - + :/icons/png/add-file.png:/icons/png/add-file.png @@ -336,7 +342,7 @@ p, li { white-space: pre-wrap; } 0 0 - 98 + 84 24 @@ -416,7 +422,7 @@ p, li { white-space: pre-wrap; } Channel Post - + :/icons/png/comment.png:/icons/png/comment.png @@ -446,7 +452,7 @@ p, li { white-space: pre-wrap; } Attachments - + :/icons/png/attachements.png:/icons/png/attachements.png @@ -518,7 +524,6 @@ p, li { white-space: pre-wrap; } - diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index 71a5015a1..a66c98cf5 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -2,6 +2,10 @@ icons/onion.png icons/svg/hidden.svg + icons/svg/ratio-auto.svg + icons/svg/ratio-1-1.svg + icons/svg/ratio-3-4.svg + icons/svg/ratio-16-9.svg icons/svg/randomness.svg icons/svg/password.svg icons/svg/listlayout.svg diff --git a/retroshare-gui/src/gui/icons/svg/ratio-1-1.svg b/retroshare-gui/src/gui/icons/svg/ratio-1-1.svg new file mode 100644 index 000000000..07dd49dc7 --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/ratio-1-1.svg @@ -0,0 +1,97 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/retroshare-gui/src/gui/icons/svg/ratio-16-9.svg b/retroshare-gui/src/gui/icons/svg/ratio-16-9.svg new file mode 100644 index 000000000..d7e3526c4 --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/ratio-16-9.svg @@ -0,0 +1,2 @@ + + diff --git a/retroshare-gui/src/gui/icons/svg/ratio-3-4.svg b/retroshare-gui/src/gui/icons/svg/ratio-3-4.svg new file mode 100644 index 000000000..8a94fe380 --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/ratio-3-4.svg @@ -0,0 +1,2 @@ + + diff --git a/retroshare-gui/src/gui/icons/svg/ratio-auto.svg b/retroshare-gui/src/gui/icons/svg/ratio-auto.svg new file mode 100644 index 000000000..f995555ad --- /dev/null +++ b/retroshare-gui/src/gui/icons/svg/ratio-auto.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + From e234cb933d2c9c6c93a41859f0f0047548d08570 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 9 Sep 2020 21:31:08 +0200 Subject: [PATCH 59/64] added color marker for selection --- .../src/gui/gxschannels/GxsChannelPostsModel.cpp | 3 ++- .../gxschannels/GxsChannelPostsWidgetWithModel.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 4fc53e1ce..5c64731da 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -705,7 +705,8 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) bool post_status = (IS_MSG_UNREAD(mPosts[i].mMeta.mMsgStatus) || IS_MSG_NEW(mPosts[i].mMeta.mMsgStatus)); if(post_status != read_status) - rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status); + if(!rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status)) + RsErr() << "setAllMsgReadStatus: failed to change status of msg " << mPosts[i].mMeta.mMsgId << " in group " << mPosts[i].mMeta.mGroupId << " to status " << read_status << std::endl; } }); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 382a624f2..61a69cbbc 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -61,6 +61,8 @@ static const int CHANNEL_TABS_DETAILS= 0; static const int CHANNEL_TABS_POSTS = 1; static const int CHANNEL_TABS_FILES = 2; +QColor SelectedColor = QRgb(0xff308dc7); + /* View mode */ #define VIEW_MODE_FEEDS 1 #define VIEW_MODE_FILES 2 @@ -134,7 +136,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & QPixmap pixmap(w.size()); if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) - pixmap.fill(QRgb(0xff308dc7)); // I dont know how to grab the backgroud color for selected objects automatically. + pixmap.fill(SelectedColor); // I dont know how to grab the backgroud color for selected objects automatically. else pixmap.fill(QRgb(0x00ffffff)); // choose a fully transparent background @@ -180,6 +182,9 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & painter->save(); + if((option.state & QStyle::State_Selected) && post.mMeta.mPublishTs > 0) // check if post is selected and is not empty (end of last row) + painter->setPen(SelectedColor); + if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus)) { QFont font(option.font); @@ -521,6 +526,8 @@ void GxsChannelPostsWidgetWithModel::switchView() ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/listlayout.svg")); ui->viewType_TB->setToolTip(tr("Click to switch to grid view")); + ui->postsTree->setSelectionBehavior(QAbstractItemView::SelectRows); + mChannelPostsDelegate->setWidgetGrid(false); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST); } @@ -529,6 +536,8 @@ void GxsChannelPostsWidgetWithModel::switchView() ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg")); ui->viewType_TB->setToolTip(tr("Click to switch to list view")); + ui->postsTree->setSelectionBehavior(QAbstractItemView::SelectItems); + mChannelPostsDelegate->setWidgetGrid(true); mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID); From 4d934993f344bb2b058cfda1fc38b60b5c27ef21 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 9 Sep 2020 23:14:20 +0200 Subject: [PATCH 60/64] added comment count to details --- .../src/gui/gxs/GxsCommentDialog.cpp | 6 +++++ retroshare-gui/src/gui/gxs/GxsCommentDialog.h | 4 +++ .../src/gui/gxs/GxsCommentTreeWidget.cpp | 26 +++++++++++++++++++ .../src/gui/gxs/GxsCommentTreeWidget.h | 3 +++ .../GxsChannelPostsWidgetWithModel.cpp | 8 ++++++ .../GxsChannelPostsWidgetWithModel.h | 1 + 6 files changed, 48 insertions(+) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp index 6512c0c54..43dc43d13 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.cpp @@ -52,6 +52,7 @@ void GxsCommentDialog::init() connect(ui->refreshButton, SIGNAL(clicked()), this, SLOT(refresh())); connect(ui->idChooser, SIGNAL(currentIndexChanged( int )), this, SLOT(voterSelectionChanged( int ))); connect(ui->idChooser, SIGNAL(idsLoaded()), this, SLOT(idChooserReady())); + connect(ui->treeWidget,SIGNAL(commentsLoaded(int)),this,SLOT(notifyCommentsLoaded(int))); connect(ui->commentButton, SIGNAL(clicked()), ui->treeWidget, SLOT(makeComment())); connect(ui->sortBox, SIGNAL(currentIndexChanged(int)), this, SLOT(sortComments(int))); @@ -95,6 +96,11 @@ void GxsCommentDialog::commentLoad(const RsGxsGroupId &grpId, const std::settreeWidget->requestComments(mGrpId,msg_versions,most_recent_msgId); } +void GxsCommentDialog::notifyCommentsLoaded(int n) +{ + emit commentsLoaded(n); +} + void GxsCommentDialog::refresh() { std::cerr << "GxsCommentDialog::refresh()"; diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h index 4c506dd21..00982fdbb 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.h @@ -48,6 +48,10 @@ private slots: void idChooserReady(); void voterSelectionChanged( int index ); void sortComments(int); + void notifyCommentsLoaded(int n); + +signals: + void commentsLoaded(int); private: void init(); diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index dfdd9bd04..f73126d53 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -489,6 +489,30 @@ void GxsCommentTreeWidget::addItem(RsGxsMessageId itemId, RsGxsMessageId parentI } } +int treeCount(QTreeWidget *tree, QTreeWidgetItem *parent = 0) +{ + int count = 0; + if (parent == 0) { + int topCount = tree->topLevelItemCount(); + for (int i = 0; i < topCount; i++) { + QTreeWidgetItem *item = tree->topLevelItem(i); + if (item->isExpanded()) { + count += treeCount(tree, item); + } + } + count += topCount; + } else { + int childCount = parent->childCount(); + for (int i = 0; i < childCount; i++) { + QTreeWidgetItem *item = parent->child(i); + if (item->isExpanded()) { + count += treeCount(tree, item); + } + } + count += childCount; + } + return count; +} void GxsCommentTreeWidget::loadThread(const uint32_t &token) { clearItems(); @@ -496,6 +520,8 @@ void GxsCommentTreeWidget::loadThread(const uint32_t &token) service_loadThread(token); completeItems(); + + emit commentsLoaded(treeCount(this)); } void GxsCommentTreeWidget::acknowledgeComment(const uint32_t &token) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h index a1977ab93..cdf6063af 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h @@ -80,6 +80,9 @@ public slots: void markSpammer(); void banUser(); +signals: + void commentsLoaded(int); + protected: void vote(const RsGxsGroupId &groupId, const RsGxsMessageId &threadId, diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 61a69cbbc..b397ea493 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -343,6 +343,7 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI mChannelPostsDelegate->setAspectRatio(ChannelPostThumbnailView::ASPECT_RATIO_16_9); connect(ui->postsTree,SIGNAL(zoomRequested(bool)),this,SLOT(updateZoomFactor(bool))); + connect(ui->commentsDialog,SIGNAL(commentsLoaded(int)),this,SLOT(updateCommentsCount(int))); ui->channelPostFiles_TV->setModel(mChannelPostFilesModel = new RsGxsChannelPostFilesModel(this)); ui->channelPostFiles_TV->setItemDelegate(new ChannelPostFilesDelegate()); @@ -734,6 +735,13 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() } } +void GxsChannelPostsWidgetWithModel::updateCommentsCount(int n) +{ + if(n > 0) + ui->details_TW->setTabText(2,tr("Comments (%1)").arg(n)); + else + ui->details_TW->setTabText(2,tr("Comments")); +} void GxsChannelPostsWidgetWithModel::updateGroupData() { if(groupId().isNull()) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 05afe9019..27ec15045 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -161,6 +161,7 @@ private slots: public slots: void sortColumnFiles(int col,Qt::SortOrder so); void sortColumnPostFiles(int col,Qt::SortOrder so); + void updateCommentsCount(int n); private: void processSettings(bool load); From 96a8c23f1e15c7b7dc40935f2c27e93aba58e9e0 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 9 Sep 2020 23:19:36 +0200 Subject: [PATCH 61/64] disable post details when no post is selected (prevents posting comments to empty post) --- .../src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index b397ea493..85e13560f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -670,10 +670,12 @@ void GxsChannelPostsWidgetWithModel::showPostDetails() ui->postLogo_LB->hide(); ui->postName_LB->hide(); ui->postTime_LB->hide(); - mChannelPostFilesModel->clear(); + mChannelPostFilesModel->clear(); + ui->details_TW->setEnabled(false); return; } + ui->details_TW->setEnabled(true); ui->postLogo_LB->show(); ui->postName_LB->show(); @@ -1090,6 +1092,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou #endif ui->subscribeToolButton->setText(tr("Subscribe ") + " " + QString::number(group.mMeta.mPop) ); + showPostDetails(); } #ifdef TODO From 8d6bd1a0b88c47de5e1cdfa82cfdb3d808053149 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 10 Sep 2020 20:07:13 +0200 Subject: [PATCH 62/64] added menu entry to switch single post as unread, and fixed the setAllMsgAsRead function --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 6 +++- .../GxsChannelPostsWidgetWithModel.cpp | 29 +++++++------------ .../GxsChannelPostsWidgetWithModel.h | 1 + 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 5c64731da..6bb708ffd 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -702,11 +702,15 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) { for(uint32_t i=0;imarkRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status)) RsErr() << "setAllMsgReadStatus: failed to change status of msg " << mPosts[i].mMeta.mMsgId << " in group " << mPosts[i].mMeta.mGroupId << " to status " << read_status << std::endl; + } } }); } diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 85e13560f..0e6c8fc84 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -490,6 +490,9 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&) if(!post.mFiles.empty()) menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_DOWNLOAD), tr("Download files"), this, SLOT(download())); + + if(!IS_MSG_UNREAD(post.mMeta.mMsgStatus) && !IS_MSG_NEW(post.mMeta.mMsgStatus)) + menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Mark as unread"), this, SLOT(markMessageUnread())); } menu.addAction(FilesDefs::getIconFromQtResourcePath(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyMessageLink())); @@ -499,6 +502,13 @@ void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&) menu.exec(QCursor::pos()); } +void GxsChannelPostsWidgetWithModel::markMessageUnread() +{ + QModelIndex index = ui->postsTree->selectionModel()->currentIndex(); + + mChannelPostsModel->setMsgReadStatus(index,false); +} + RsGxsMessageId GxsChannelPostsWidgetWithModel::getCurrentItemId() const { RsGxsMessageId selected_msg_id ; @@ -1393,25 +1403,6 @@ public: uint32_t mLastToken; }; -#ifdef TO_REMOVE -static void setAllMessagesReadCallback(FeedItem *feedItem, void *data) -{ - GxsChannelPostItem *channelPostItem = dynamic_cast(feedItem); - if (!channelPostItem) { - return; - } - - GxsChannelPostsReadData *readData = (GxsChannelPostsReadData*) data; - bool isRead = !channelPostItem->isUnread() ; - - if(channelPostItem->isLoaded() && (isRead == readData->mRead)) - return ; - - RsGxsGrpMsgIdPair msgPair = std::make_pair(channelPostItem->groupId(), channelPostItem->messageId()); - rsGxsChannels->setMessageReadStatus(readData->mLastToken, msgPair, readData->mRead); -} -#endif - void GxsChannelPostsWidgetWithModel::setAllMessagesReadDo(bool read, uint32_t& /*token*/) { if (groupId().isNull() || !IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 27ec15045..daf2aedfb 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -157,6 +157,7 @@ private slots: void updateZoomFactor(bool zoom_or_unzoom); void switchView(); void switchOnlyUnread(bool b); + void markMessageUnread(); public slots: void sortColumnFiles(int col,Qt::SortOrder so); From d74c113e92ace99031afe42ea26cda39420b3775 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 10 Sep 2020 20:16:10 +0200 Subject: [PATCH 63/64] removed some debug output and some compiler warnings --- .../src/gui/gxs/GxsCommentTreeWidget.cpp | 56 ++++++++++++++----- .../gui/gxschannels/GxsChannelPostsModel.cpp | 14 ++--- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index f73126d53..cc2087044 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -228,8 +228,10 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/) void GxsCommentTreeWidget::voteUp() { - std::cerr << "GxsCommentTreeWidget::voteUp()"; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::voteUp()"; std::cerr << std::endl; +#endif vote(mGroupId, mLatestMsgId, mCurrentCommentMsgId, mVoterId, true); } @@ -237,8 +239,10 @@ void GxsCommentTreeWidget::voteUp() void GxsCommentTreeWidget::voteDown() { - std::cerr << "GxsCommentTreeWidget::voteDown()"; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::voteDown()"; std::cerr << std::endl; +#endif vote(mGroupId, mLatestMsgId, mCurrentCommentMsgId, mVoterId, false); } @@ -246,8 +250,10 @@ void GxsCommentTreeWidget::voteDown() void GxsCommentTreeWidget::setVoteId(const RsGxsId &voterId) { mVoterId = voterId; - std::cerr << "GxsCommentTreeWidget::setVoterId(" << mVoterId << ")"; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::setVoterId(" << mVoterId << ")"; std::cerr << std::endl; +#endif } @@ -270,6 +276,7 @@ void GxsCommentTreeWidget::vote(const RsGxsGroupId &groupId, const RsGxsMessageI vote.mVoteType = GXS_VOTE_DOWN; } +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET std::cerr << "GxsCommentTreeWidget::vote()"; std::cerr << std::endl; @@ -277,6 +284,7 @@ void GxsCommentTreeWidget::vote(const RsGxsGroupId &groupId, const RsGxsMessageI std::cerr << "ThreadId : " << vote.mMeta.mThreadId << std::endl; std::cerr << "ParentId : " << vote.mMeta.mParentId << std::endl; std::cerr << "AuthorId : " << vote.mMeta.mAuthorId << std::endl; +#endif uint32_t token; mCommentService->createNewVote(token, vote); @@ -361,13 +369,17 @@ void GxsCommentTreeWidget::requestComments(const RsGxsGroupId& group, const std: void GxsCommentTreeWidget::service_requestComments(const RsGxsGroupId& group_id,const std::set & msgIds) { /* request comments */ - std::cerr << "GxsCommentTreeWidget::service_requestComments for group " << group_id << std::endl; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::service_requestComments for group " << group_id << std::endl; +#endif std::vector ids_to_ask; for(std::set::const_iterator it(msgIds.begin());it!=msgIds.end();++it) { - std::cerr << " asking for msg " << *it << std::endl; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << " asking for msg " << *it << std::endl; +#endif ids_to_ask.push_back(std::make_pair(group_id,*it)); } @@ -399,14 +411,18 @@ void GxsCommentTreeWidget::completeItems() std::map::iterator lit; std::multimap::iterator pit; - std::cerr << "GxsCommentTreeWidget::completeItems() " << mPendingInsertMap.size(); +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::completeItems() " << mPendingInsertMap.size(); std::cerr << " PendingItems"; std::cerr << std::endl; +#endif for(pit = mPendingInsertMap.begin(); pit != mPendingInsertMap.end(); ++pit) { - std::cerr << "GxsCommentTreeWidget::completeItems() item->parent: " << pit->first; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::completeItems() item->parent: " << pit->first; std::cerr << std::endl; +#endif if (pit->first != parentId) { @@ -425,15 +441,19 @@ void GxsCommentTreeWidget::completeItems() if (parent) { - std::cerr << "GxsCommentTreeWidget::completeItems() Added to Parent"; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::completeItems() Added to Parent"; std::cerr << std::endl; +#endif parent->addChild(pit->second); } else if (mMsgVersions.find(parentId) != mMsgVersions.end()) { - std::cerr << "GxsCommentTreeWidget::completeItems() Added to topLevelItems"; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::completeItems() Added to topLevelItems"; std::cerr << std::endl; +#endif topLevelItems.append(pit->second); } @@ -443,8 +463,10 @@ void GxsCommentTreeWidget::completeItems() /* missing parent -> insert At Top Level */ QTreeWidgetItem *missingItem = service_createMissingItem(pit->first); - std::cerr << "GxsCommentTreeWidget::completeItems() Added MissingItem"; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::completeItems() Added MissingItem"; std::cerr << std::endl; +#endif parent = missingItem; parent->addChild(pit->second); @@ -464,9 +486,11 @@ void GxsCommentTreeWidget::completeItems() void GxsCommentTreeWidget::addItem(RsGxsMessageId itemId, RsGxsMessageId parentId, QTreeWidgetItem *item) { - std::cerr << "GxsCommentTreeWidget::addItem() Id: " << itemId; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::addItem() Id: " << itemId; std::cerr << " ParentId: " << parentId; std::cerr << std::endl; +#endif /* store in map -> for children */ mLoadingMap[itemId] = item; @@ -475,15 +499,19 @@ void GxsCommentTreeWidget::addItem(RsGxsMessageId itemId, RsGxsMessageId parentI it = mLoadingMap.find(parentId); if (it != mLoadingMap.end()) { - std::cerr << "GxsCommentTreeWidget::addItem() Added to Parent"; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::addItem() Added to Parent"; std::cerr << std::endl; +#endif it->second->addChild(item); } else { - std::cerr << "GxsCommentTreeWidget::addItem() Added to Pending List"; +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET + std::cerr << "GxsCommentTreeWidget::addItem() Added to Pending List"; std::cerr << std::endl; +#endif mPendingInsertMap.insert(std::make_pair(parentId, item)); } @@ -641,8 +669,10 @@ QTreeWidgetItem *GxsCommentTreeWidget::service_createMissingItem(const RsGxsMess void GxsCommentTreeWidget::loadRequest(const TokenQueue *queue, const TokenRequest &req) { +#ifdef DEBUG_GXSCOMMENT_TREEWIDGET std::cerr << "GxsCommentTreeWidget::loadRequest() UserType: " << req.mUserType; std::cerr << std::endl; +#endif if (queue != mTokenQueue) { diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index 6bb708ffd..a21d6ff90 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -212,10 +212,12 @@ int RsGxsChannelPostsModel::rowCount(const QModelIndex& parent) const return 0; if(!parent.isValid()) + { if(mTreeMode == TREE_MODE_GRID) return (mFilteredPosts.size() + mColumns-1)/mColumns; // mFilteredPosts always has an item at 0, so size()>=1, and mColumn>=1 else return mFilteredPosts.size(); + } RsErr() << __PRETTY_FUNCTION__ << " rowCount cannot figure out the porper number of rows." << std::endl; return 0; @@ -372,8 +374,6 @@ quintptr RsGxsChannelPostsModel::getParentRow(quintptr ref,int& row) const int RsGxsChannelPostsModel::getChildrenCount(quintptr ref) const { - uint32_t entry = 0 ; - if(ref == quintptr(0)) return rowCount()-1; @@ -430,7 +430,7 @@ QVariant RsGxsChannelPostsModel::data(const QModelIndex &index, int role) const } } -QVariant RsGxsChannelPostsModel::sizeHintRole(int col) const +QVariant RsGxsChannelPostsModel::sizeHintRole(int /* col */) const { float factor = QFontMetricsF(QApplication::font()).height()/14.0f ; @@ -502,7 +502,7 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto std::sort(mPosts.begin(),mPosts.end()); mFilteredPosts.clear(); - for(int i=0;i& e1,const std::pair& e2) { return e2.first < e1.first ; } - void RsGxsChannelPostsModel::createPostsArray(std::vector& posts) { // collect new versions of posts if any @@ -705,12 +703,8 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) bool post_status = !((IS_MSG_UNREAD(mPosts[i].mMeta.mMsgStatus) || IS_MSG_NEW(mPosts[i].mMeta.mMsgStatus))); if(post_status != read_status) - { - std::cerr << "Switch read status of post " << mPosts[i].mMeta.mMsgId << std::endl; - if(!rsGxsChannels->markRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status)) RsErr() << "setAllMsgReadStatus: failed to change status of msg " << mPosts[i].mMeta.mMsgId << " in group " << mPosts[i].mMeta.mGroupId << " to status " << read_status << std::endl; - } } }); } From 138cff65470a2fd76d745159dbe7523127ef4f66 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 10 Sep 2020 21:02:06 +0200 Subject: [PATCH 64/64] fixed async inconsistency causing markAllAsRead to fail when switching channels --- .../gui/gxschannels/GxsChannelPostsModel.cpp | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp index a21d6ff90..797b2fb6f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsModel.cpp @@ -696,16 +696,25 @@ void RsGxsChannelPostsModel::setAllMsgReadStatus(bool read_status) // No need to call preMods()/postMods() here because we're not changing the model // All operations below are done async - RsThread::async([this, read_status]() - { - for(uint32_t i=0;imarkRead(RsGxsGrpMsgIdPair(mPosts[i].mMeta.mGroupId,mPosts[i].mMeta.mMsgId),read_status)) - RsErr() << "setAllMsgReadStatus: failed to change status of msg " << mPosts[i].mMeta.mMsgId << " in group " << mPosts[i].mMeta.mGroupId << " to status " << read_status << std::endl; - } + std::vector pairs; + + for(uint32_t i=0;imarkRead(pairs[i],read_status)) + RsErr() << "setAllMsgReadStatus: failed to change status of msg " << pairs[i].first << " in group " << pairs[i].second << " to status " << read_status << std::endl; }); }