diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp
index 56c910237..ef1a6271e 100644
--- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp
+++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp
@@ -72,7 +72,8 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
-
+ connect(subjectEdit,SIGNAL(textChanged(const QString&)),this,SLOT(updatePreviewText(const QString&)));
+
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool)));
connect(stackedWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
@@ -605,6 +606,11 @@ void CreateGxsChannelMsg::saveChannelInfo(const RsGroupMetaData &meta)
subjectEdit->setFocus();
}
+void CreateGxsChannelMsg::updatePreviewText(const QString& s)
+{
+ preview_W->setText(s);
+}
+
void CreateGxsChannelMsg::sendMsg()
{
#ifdef DEBUG_CREATE_GXS_MSG
@@ -717,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"), 156, 107);
+ QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load thumbnail picture"), 107,156); // these absolute sizes are terrible
if (img.isNull())
return;
@@ -725,7 +731,7 @@ void CreateGxsChannelMsg::addThumbnail()
picture = img;
// to show the selected
- thumbnail_label->setPixmap(picture);
+ preview_W->setPixmap(picture);
}
void CreateGxsChannelMsg::loadOriginalChannelPostInfo()
@@ -769,7 +775,7 @@ void CreateGxsChannelMsg::loadOriginalChannelPostInfo()
if(post.mThumbnail.mData != NULL)
{
GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData,post.mThumbnail.mSize,picture,GxsIdDetails::ORIGINAL);
- thumbnail_label->setPixmap(picture);
+ preview_W->setPixmap(picture);
}
diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h
index 7c1058695..44d867ba2 100644
--- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h
+++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.h
@@ -58,6 +58,7 @@ private slots:
void addExtraFile();
void checkAttachmentReady();
void deleteAttachment();
+ void updatePreviewText(const QString &);
void cancelMsg();
void sendMsg();
diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui
index 703f43bb1..d8baaba24 100644
--- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui
+++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.ui
@@ -52,52 +52,39 @@
QFrame::Raised
- -
-
-
- Channel Post
-
-
-
- :/icons/png/comment.png:/icons/png/comment.png
-
-
-
- 24
- 24
-
-
-
-
- -
-
-
- Attachments
-
-
-
- :/icons/png/attachements.png:/icons/png/attachements.png
-
-
-
- 24
- 24
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 486
- 20
-
-
-
+
-
+
+
-
+
+
+ Generate mass data
+
+
+
+ -
+
+
+ 1
+
+
+ 999
+
+
+
+ -
+
+
+
+
+
+ Qt::Horizontal
+
+
+ QDialogButtonBox::Cancel|QDialogButtonBox::Ok
+
+
+
+
-
@@ -114,128 +101,8 @@
0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
- 0
-
-
-
-
-
-
-
-
-
- 156
- 107
-
-
-
-
- 0
- 0
-
-
-
- :/images/thumb-default-video.png
-
-
-
- -
-
-
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
-<html><head><meta name="qrichtext" content="1" /><style type="text/css">
-p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Attachments:</span></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Use Drag and Drop / Add Files button, to Hash new files.</span></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Copy/Paste RetroShare links from your shares</span></p></body></html>
-
-
-
- -
-
-
- Add Channel Thumbnail
-
-
-
- :/icons/png/add-image.png:/icons/png/add-image.png
-
-
-
- 24
- 24
-
-
-
-
- -
-
-
- Add File to Attach
-
-
-
- :/icons/png/add-file.png:/icons/png/add-file.png
-
-
-
- 24
- 24
-
-
-
-
- -
-
-
- Qt::Horizontal
-
-
- QSizePolicy::Expanding
-
-
-
- 40
- 20
-
-
-
-
-
-
- -
-
-
- Message
-
-
-
- 0
-
-
-
-
-
- Title
-
-
-
- -
-
-
-
-
-
- -
+
+
-
-
@@ -268,6 +135,119 @@ p, li { white-space: pre-wrap; }
+ -
+
+
-
+
+
+ -
+
+
-
+
+
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;">Attachments:</span></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Use Drag and Drop / Add Files button, to Hash new files.</span></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><img src=":/images/feedback_arrow.png" /><span style=" font-family:'MS Shell Dlg 2'; font-size:8pt;"> Copy/Paste RetroShare links from your shares</span></p></body></html>
+
+
+
+ -
+
+
-
+
+
+ Add Channel Thumbnail
+
+
+
+ :/icons/png/add-image.png:/icons/png/add-image.png
+
+
+
+ 24
+ 24
+
+
+
+
+ -
+
+
+ Add File to Attach
+
+
+
+ :/icons/png/add-file.png:/icons/png/add-file.png
+
+
+
+ 24
+ 24
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+ QSizePolicy::Expanding
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
+
+
+
+
+
+ -
+
+
+ Message
+
+
+
+ 0
+
+
-
+
+
+ Title
+
+
+
+ -
+
+
+
+
+
@@ -329,7 +309,7 @@ p, li { white-space: pre-wrap; }
0
0
- 632
+ 635
24
@@ -403,39 +383,65 @@ p, li { white-space: pre-wrap; }
- -
-
-
-
-
-
- Generate mass data
-
-
-
- -
-
-
- 1
-
-
- 999
-
-
-
- -
-
-
-
-
-
- Qt::Horizontal
-
-
- QDialogButtonBox::Cancel|QDialogButtonBox::Ok
-
-
-
-
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 486
+ 20
+
+
+
+
+ -
+
+
+ Attachments
+
+
+
+ :/icons/png/attachements.png:/icons/png/attachements.png
+
+
+
+ 24
+ 24
+
+
+
+
+ -
+
+
+ Channel Post
+
+
+
+ :/icons/png/comment.png:/icons/png/comment.png
+
+
+
+ 24
+ 24
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 40
+
+
+
@@ -455,10 +461,16 @@ p, li { white-space: pre-wrap; }
1
+
+ ChannelPostThumbnailView
+ QWidget
+ gui/gxschannels/GxsChannelPostThumbnail.h
+ 1
+
-
+
diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h
new file mode 100644
index 000000000..fd5c82d6b
--- /dev/null
+++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h *
+ * *
+ * 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 . *
+ * *
+ *******************************************************************************/
+
+#pragma once
+
+#include
+
+#include
+#include
+#include
+
+#include "retroshare/rsgxschannels.h"
+#include "retroshare/rsidentity.h"
+
+#include "gui/gxs/GxsIdDetails.h"
+#include "gui/common/FilesDefs.h"
+
+// Class to paint the thumbnails with title
+
+class ChannelPostThumbnailView: public QWidget
+{
+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;
+
+ // 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;
+ static const int THUMBNAIL_H = 6;
+
+ static constexpr char *CHAN_DEFAULT_IMAGE = ":images/thumb-default-video.png";
+
+ virtual ~ChannelPostThumbnailView()
+ {
+ delete lb;
+ delete lt;
+ }
+
+ ChannelPostThumbnailView(QWidget *parent=NULL): QWidget(parent)
+ {
+ init(FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE), QString("New post"),false);
+ }
+
+ ChannelPostThumbnailView(const RsGxsChannelPost& post,QWidget *parent=NULL)
+ : 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) );
+
+ }
+
+ 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);
+
+ lt->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) { lt->setText(s); }
+
+private:
+ QLabel *lb;
+ QLabel *lt;
+};
+
diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp
index 477c4f850..2d64bf8c8 100644
--- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp
+++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp
@@ -44,11 +44,10 @@
#include "GxsChannelPostsModel.h"
#include "GxsChannelPostFilesModel.h"
#include "GxsChannelFilesStatusWidget.h"
+#include "GxsChannelPostThumbnail.h"
#include
-#define CHAN_DEFAULT_IMAGE ":images/thumb-default-video.png"
-
#define ROLE_PUBLISH FEED_TREEWIDGET_SORTROLE
/****
@@ -64,11 +63,6 @@ static const int CHANNEL_TABS_POSTS = 1;
#define VIEW_MODE_FEEDS 1
#define VIEW_MODE_FILES 2
-// Size of thumbnails as a function of the height of the font. An aspect ratio of 3/4 is good.
-
-#define THUMBNAIL_W 4
-#define THUMBNAIL_H 6
-
// Determine the Shape and size of cells as a factor of the font height. An aspect ratio of 3/4 is what's needed
// for the image, so it's important that the height is a bit larger so as to leave some room for the text.
//
@@ -76,67 +70,10 @@ static const int CHANNEL_TABS_POSTS = 1;
#define COLUMN_SIZE_FONT_FACTOR_W 6
#define COLUMN_SIZE_FONT_FACTOR_H 10
-// This variable determines the zoom factor on the text below thumbnails. 2.0 is mostly correct for all screen.
-#define THUMBNAIL_OVERSAMPLE_FACTOR 2.0
#define STAR_OVERLAY_IMAGE ":icons/star_overlay_128.png"
Q_DECLARE_METATYPE(RsGxsFile)
-// Class to paint the thumbnails with title
-
-class ThumbnailView: public QWidget
-{
-public:
- ThumbnailView(const RsGxsChannelPost& post,QWidget *parent=NULL)
- : QWidget(parent)
- {
- QVBoxLayout *layout = new QVBoxLayout(this);
-
- QLabel *lb = new QLabel(this);
- lb->setScaledContents(true);
- layout->addWidget(lb);
-
- QLabel *lt = new QLabel(this);
- layout->addWidget(lt);
-
- setLayout(layout);
-
- setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
-
- // 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);
-
- 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);
-
- lt->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
-
- QFont font = lt->font();
-
- if(IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
- {
- font.setBold(true);
- lt->setFont(font);
- }
-
- lt->setMaximumWidth(W);
- lt->setWordWrap(true);
-
- adjustSize();
- update();
- }
-};
-
// Delegate used to paint into the table of thumbnails
void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const
@@ -151,7 +88,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
painter->fillRect( option.rect, option.backgroundBrush);
painter->restore();
- ThumbnailView w(post);
+ ChannelPostThumbnailView w(post);
QPixmap pixmap(w.size());
@@ -463,7 +400,7 @@ void GxsChannelPostsWidgetWithModel::showPostDetails()
if (post.mThumbnail.mData != NULL)
GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData, post.mThumbnail.mSize, postImage,GxsIdDetails::ORIGINAL);
else
- postImage = FilesDefs::getPixmapFromQtResourcePath(CHAN_DEFAULT_IMAGE);
+ postImage = FilesDefs::getPixmapFromQtResourcePath(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE);
int W = QFontMetricsF(font()).height() * 8;
@@ -689,7 +626,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
if (group.mImage.mData != NULL) {
GxsIdDetails::loadPixmapFromData(group.mImage.mData, group.mImage.mSize, chanImage,GxsIdDetails::ORIGINAL);
} else {
- chanImage = QPixmap(CHAN_DEFAULT_IMAGE);
+ chanImage = QPixmap(ChannelPostThumbnailView::CHAN_DEFAULT_IMAGE);
}
if(group.mMeta.mGroupName.empty())
ui->channelName_LB->setText(tr("[No name]"));
diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro
index 69dfc6b85..ce23a4f9c 100644
--- a/retroshare-gui/src/retroshare-gui.pro
+++ b/retroshare-gui/src/retroshare-gui.pro
@@ -1337,6 +1337,7 @@ gxschannels {
gui/gxschannels/GxsChannelPostsModel.h \
gui/gxschannels/GxsChannelPostFilesModel.h \
gui/gxschannels/GxsChannelFilesWidget.h \
+ gui/gxschannels/GxsChannelPostThumbnail.h \
gui/gxschannels/GxsChannelFilesStatusWidget.h \
gui/feeds/GxsChannelGroupItem.h \
gui/feeds/GxsChannelPostItem.h \