mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
added preview widget when creating pochannel posts
This commit is contained in:
parent
f1092b4a29
commit
fd85965e7d
@ -72,6 +72,7 @@ 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)));
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,6 +58,7 @@ private slots:
|
||||
void addExtraFile();
|
||||
void checkAttachmentReady();
|
||||
void deleteAttachment();
|
||||
void updatePreviewText(const QString &);
|
||||
|
||||
void cancelMsg();
|
||||
void sendMsg();
|
||||
|
@ -52,52 +52,39 @@
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="channelpostButton">
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="buttonHLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="generateCheckBox">
|
||||
<property name="text">
|
||||
<string>Channel Post</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/comment.png</normaloff>:/icons/png/comment.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
<string>Generate mass data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="attachmentsButton">
|
||||
<property name="text">
|
||||
<string>Attachments</string>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="generateSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/attachements.png</normaloff>:/icons/png/attachements.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>486</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
@ -114,128 +101,8 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="stackedWidgetPage1">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="QLabel" name="thumbnail_label">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>156</width>
|
||||
<height>107</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../images.qrc">:/images/thumb-default-video.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="4">
|
||||
<widget class="QLabel" name="channelAttachLabel">
|
||||
<property name="text">
|
||||
<string><!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></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="addThumbnailButton">
|
||||
<property name="text">
|
||||
<string>Add Channel Thumbnail</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/add-image.png</normaloff>:/icons/png/add-image.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QPushButton" name="addfilepushButton">
|
||||
<property name="text">
|
||||
<string>Add File to Attach</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/add-file.png</normaloff>:/icons/png/add-file.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" colspan="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="messageGBox">
|
||||
<property name="title">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="subjectEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="RichTextEdit" name="RichTextEditWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="channelNameHLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="channelNameLabel">
|
||||
@ -268,6 +135,119 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="ChannelPostThumbnailView" name="preview_W" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="channelAttachLabel">
|
||||
<property name="text">
|
||||
<string><!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></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="addThumbnailButton">
|
||||
<property name="text">
|
||||
<string>Add Channel Thumbnail</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/add-image.png</normaloff>:/icons/png/add-image.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="addfilepushButton">
|
||||
<property name="text">
|
||||
<string>Add File to Attach</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/add-file.png</normaloff>:/icons/png/add-file.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="messageGBox">
|
||||
<property name="title">
|
||||
<string>Message</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="subjectEdit">
|
||||
<property name="placeholderText">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="RichTextEdit" name="RichTextEditWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="stackedWidgetPage2">
|
||||
@ -329,7 +309,7 @@ p, li { white-space: pre-wrap; }
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>632</width>
|
||||
<width>635</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -403,39 +383,65 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<layout class="QHBoxLayout" name="buttonHLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="generateCheckBox">
|
||||
<property name="text">
|
||||
<string>Generate mass data</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="generateSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>486</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="attachmentsButton">
|
||||
<property name="text">
|
||||
<string>Attachments</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/attachements.png</normaloff>:/icons/png/attachements.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="channelpostButton">
|
||||
<property name="text">
|
||||
<string>Channel Post</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../icons.qrc">
|
||||
<normaloff>:/icons/png/comment.png</normaloff>:/icons/png/comment.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -455,10 +461,16 @@ p, li { white-space: pre-wrap; }
|
||||
<header>util/RichTextEdit.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ChannelPostThumbnailView</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/gxschannels/GxsChannelPostThumbnail.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../icons.qrc"/>
|
||||
<include location="../images.qrc"/>
|
||||
<include location="../icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
123
retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h
Normal file
123
retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h
Normal file
@ -0,0 +1,123 @@
|
||||
/*******************************************************************************
|
||||
* retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h *
|
||||
* *
|
||||
* Copyright 2020 by Retroshare Team <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* 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 <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QLayout>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
@ -44,11 +44,10 @@
|
||||
#include "GxsChannelPostsModel.h"
|
||||
#include "GxsChannelPostFilesModel.h"
|
||||
#include "GxsChannelFilesStatusWidget.h"
|
||||
#include "GxsChannelPostThumbnail.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#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]"));
|
||||
|
@ -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 \
|
||||
|
Loading…
Reference in New Issue
Block a user