From 765664b4f86b367c32a8143270f678ddee009e1e Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 18 Jan 2020 15:42:04 +0100 Subject: [PATCH 1/3] tried to sorted out the layout of channel item --- .../src/gui/feeds/GxsChannelPostItem.cpp | 64 +--------- .../src/gui/feeds/GxsChannelPostItem.ui | 116 ++++++++---------- 2 files changed, 55 insertions(+), 125 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 687dd2846..942532dfa 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -76,59 +76,6 @@ void GxsChannelPostItem::init(const RsGxsMessageId& messageId,const std::set v; - bool self = false; - - for(std::set::const_iterator it(post.mOlderVersions.begin());it!=post.mOlderVersions.end();++it) - { - if(*it == post.mMeta.mMsgId) - self = true ; - - v.push_back(*it) ; - } - if(!self) - v.push_back(post.mMeta.mMsgId); - - setMessageVersions(v) ; - - setup(); - - setGroup(group, false); - - setPost(post,false); - mLoaded = false ; -} - -GxsChannelPostItem::GxsChannelPostItem(FeedHolder *feedHolder, uint32_t feedId, const RsGxsChannelPost &post, bool isHome, bool autoUpdate) : - GxsFeedItem(feedHolder, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, autoUpdate) -{ -#ifdef DEBUG_ITEM - std::cerr << "GxsChannelPostItem::GxsChannelPostItem() Direct Load"; - std::cerr << std::endl; -#endif - - setup(); - - mLoaded = true ; - requestGroup(); - setPost(post); - requestComment(); -} -#endif - - void GxsChannelPostItem::paintEvent(QPaintEvent *e) { /* This method employs a trick to trigger a deferred loading. The post and group is requested only @@ -169,7 +116,6 @@ void GxsChannelPostItem::setup() /* clear ui */ ui->titleLabel->setText(tr("Loading")); - ui->subjectLabel->clear(); ui->datetimelabel->clear(); ui->filelabel->clear(); ui->newCommentLabel->hide(); @@ -208,7 +154,7 @@ void GxsChannelPostItem::setup() ui->warning_label->hide(); ui->titleLabel->setMinimumWidth(100); - ui->subjectLabel->setMinimumWidth(100); + //ui->subjectLabel->setMinimumWidth(100); ui->warning_label->setMinimumWidth(100); ui->mainFrame->setProperty("new", false); @@ -431,7 +377,7 @@ void GxsChannelPostItem::fill() ui->titleLabel->setText(title); RetroShareLink msgLink = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); - ui->subjectLabel->setText(msgLink.toHtml()); + //ui->subjectLabel->setText(msgLink.toHtml()); if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) { @@ -454,10 +400,10 @@ void GxsChannelPostItem::fill() /* subject */ ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); - uint32_t autorized_lines = (int)floor((ui->logoLabel->height() - ui->titleLabel->height() - ui->buttonHLayout->sizeHint().height())/QFontMetricsF(ui->subjectLabel->font()).height()); + //uint32_t autorized_lines = (int)floor((ui->logoLabel->height() - ui->titleLabel->height() - ui->buttonHLayout->sizeHint().height())/QFontMetricsF(ui->subjectLabel->font()).height()); // fill first 4 lines of message. (csoler) Disabled the replacement of smileys and links, because the cost is too crazy - ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + //ui->subjectLabel->setText(RsHtml().formatText(NULL, RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), autorized_lines), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); //ui->subjectLabel->setText(RsStringUtil::CopyLines(QString::fromUtf8(mPost.mMsg.c_str()), 2)) ; @@ -534,7 +480,7 @@ void GxsChannelPostItem::fill() if ( (mPost.mCount != 0) || (mPost.mSize != 0) ) { ui->filelabel->setVisible(true); - ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mCount).arg(tr("Files")).arg(misc::friendlyUnit(mPost.mSize))); + ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mCount).arg( (mPost.mCount > 1)?tr("Files"):tr("File")).arg(misc::friendlyUnit(mPost.mSize))); } else { ui->filelabel->setVisible(false); } diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui index 01d113665..b2e911a79 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui @@ -6,8 +6,8 @@ 0 0 - 1359 - 342 + 1433 + 541 @@ -50,26 +50,30 @@ - - - - 0 - 0 - - - - - - - :/images/thumb-default-video.png - - - false - - - Qt::AlignCenter - - + + + + + + 0 + 0 + + + + + + + :/images/thumb-default-video.png + + + false + + + Qt::AlignCenter + + + + @@ -117,37 +121,7 @@ - - - - - - 0 - 0 - - - - Short Description - - - true - - - true - - - - - - - fileLabel - - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - - - + @@ -282,6 +256,16 @@ + + + + fileLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + @@ -335,19 +319,6 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -387,6 +358,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + From 99a106d277a45456547935d7921a5d2817c57642 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 18 Jan 2020 17:42:28 +0100 Subject: [PATCH 2/3] moved the "new" button on top right position and file label to the right --- .../src/gui/feeds/GxsChannelPostItem.cpp | 1 + .../src/gui/feeds/GxsChannelPostItem.ui | 34 +++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 942532dfa..225f0a3ec 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -524,6 +524,7 @@ void GxsChannelPostItem::fill() void GxsChannelPostItem::fillExpandFrame() { ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); + ui->msgFrame->setVisible(!mPost.mMsg.empty()); } QString GxsChannelPostItem::messageName() diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui index b2e911a79..0e15c0a4d 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.ui @@ -118,6 +118,13 @@ + + + + New + + + @@ -208,13 +215,6 @@ - - - - New - - - @@ -256,16 +256,6 @@ - - - - fileLabel - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -339,6 +329,16 @@ + + + + fileLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + From ab2e116fd27fddcf5df5e6f44596f20ea96561f2 Mon Sep 17 00:00:00 2001 From: csoler Date: Sat, 18 Jan 2020 18:20:29 +0100 Subject: [PATCH 3/3] properly hide the msgFrame when msg is empty in channel post item --- retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index 225f0a3ec..af2116616 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -471,7 +471,13 @@ void GxsChannelPostItem::fill() voteDownButton->setEnabled(false); }*/ - ui->msgFrame->setVisible(!mPost.mMsg.empty()); + { + QTextDocument doc; + doc.setHtml( QString::fromUtf8(mPost.mMsg.c_str()) ); + + ui->msgFrame->setVisible(doc.toPlainText().length() > 0); + } + if (wasExpanded() || ui->expandFrame->isVisible()) { fillExpandFrame(); } @@ -524,7 +530,7 @@ void GxsChannelPostItem::fill() void GxsChannelPostItem::fillExpandFrame() { ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); - ui->msgFrame->setVisible(!mPost.mMsg.empty()); + } QString GxsChannelPostItem::messageName()