fixed merge with master

This commit is contained in:
csoler 2020-01-11 00:08:36 +01:00
commit 2bd5bb5a3e
No known key found for this signature in database
GPG key ID: 7BCA522266C0804C
176 changed files with 6345 additions and 3927 deletions

View file

@ -33,6 +33,7 @@
#include "util/HandleRichText.h"
#include "util/misc.h"
#include "util/rsdir.h"
#include "util/RichTextEdit.h"
#include <retroshare/rsfiles.h>
@ -55,7 +56,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
Settings->loadWidgetInformation(this);
mChannelQueue = new TokenQueue(rsGxsChannels->getTokenService(), this);
headerFrame->setHeaderImage(QPixmap(":/images/channels.png"));
headerFrame->setHeaderImage(QPixmap(":/icons/png/channel.png"));
if(!existing_post.isNull())
headerFrame->setHeaderText(tr("Edit Channel Post"));
@ -64,17 +65,19 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
setAttribute ( Qt::WA_DeleteOnClose, true );
buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Post"));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(sendMsg()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(cancelMsg()));
connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
connect(thumbNailCb, SIGNAL(toggled(bool)), this, SLOT(allowAutoMediaThumbNail(bool)));
connect(tabWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
connect(stackedWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool)));
connect(addPictureButton, SIGNAL(clicked()), this, SLOT(addPicture()));
connect(msgEdit, SIGNAL(textChanged()), this, SLOT(checkLength()));
generateSpinBox->setEnabled(false);
thumbNailCb->setVisible(false);
@ -84,7 +87,6 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
thumbNailCb->setVisible(true);
thumbNailCb->setEnabled(true);
#endif
//buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
setAcceptDrops(true);
@ -95,27 +97,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
generateSpinBox->hide();
#endif
}
static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000;
void CreateGxsChannelMsg::checkLength()
{
QString text;
RsHtml::optimizeHtml(msgEdit, text);
std::wstring msg = text.toStdWString();
int charRemains = MAX_ALLOWED_GXS_MESSAGE_SIZE - msg.length();
if(charRemains >= 0) {
text = tr("It remains %1 characters after HTML conversion.").arg(charRemains);
infoLabel->setStyleSheet("QLabel#infoLabel { }");
}else{
text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains));
infoLabel->setStyleSheet("QLabel#infoLabel {color: red; font: bold; }");
}
buttonBox->button(QDialogButtonBox::Ok)->setToolTip(text);
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(charRemains>=0);
infoLabel->setText(text);
}
CreateGxsChannelMsg::~CreateGxsChannelMsg()
{
Settings->saveWidgetInformation(this);
@ -442,7 +424,7 @@ void CreateGxsChannelMsg::addSubject(const QString& text)
void CreateGxsChannelMsg::addHtmlText(const QString& text)
{
msgEdit->setHtml(text) ;
RichTextEditWidget->setText(text) ;
}
void CreateGxsChannelMsg::addAttachment(const std::string &path)
@ -650,8 +632,9 @@ void CreateGxsChannelMsg::sendMsg()
/* construct message bits */
std::string subject = std::string(misc::removeNewLine(subjectEdit->text()).toUtf8());
QString text;
RsHtml::optimizeHtml(msgEdit, text);
text = RichTextEditWidget->toHtml();
std::string msg = std::string(text.toUtf8());
std::list<RsGxsFile> files;
@ -763,18 +746,6 @@ void CreateGxsChannelMsg::addThumbnail()
thumbnail_label->setPixmap(picture);
}
void CreateGxsChannelMsg::addPicture()
{
QString file;
if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg)", file)) {
QString encodedImage;
if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480, MAX_ALLOWED_GXS_MESSAGE_SIZE - 200)) {
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
msgEdit->textCursor().insertFragment(fragment);
}
}
}
void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token)
{
#ifdef DEBUG_CREATE_GXS_MSG
@ -801,13 +772,16 @@ void CreateGxsChannelMsg::loadChannelPostInfo(const uint32_t &token)
}
subjectEdit->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str())) ;
msgEdit->setText(QString::fromUtf8(post.mMsg.c_str())) ;
RichTextEditWidget->setText(QString::fromUtf8(post.mMsg.c_str()));
for(std::list<RsGxsFile>::const_iterator it(post.mFiles.begin());it!=post.mFiles.end();++it)
addAttachment(it->mHash,it->mName,it->mSize,true,RsPeerId(),true);
GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData,post.mThumbnail.mSize,picture,GxsIdDetails::ORIGINAL);
thumbnail_label->setPixmap(picture);
if(post.mThumbnail.mData != NULL)
{
GxsIdDetails::loadPixmapFromData(post.mThumbnail.mData,post.mThumbnail.mSize,picture,GxsIdDetails::ORIGINAL);
thumbnail_label->setPixmap(picture);
}
}
void CreateGxsChannelMsg::loadChannelInfo(const uint32_t &token)
@ -856,3 +830,13 @@ void CreateGxsChannelMsg::loadRequest(const TokenQueue *queue, const TokenReques
}
}
}
void CreateGxsChannelMsg::on_channelpostButton_clicked()
{
stackedWidget->setCurrentIndex(0);
}
void CreateGxsChannelMsg::on_attachmentsButton_clicked()
{
stackedWidget->setCurrentIndex(1);
}

View file

@ -69,10 +69,10 @@ private slots:
void contextMenu(QPoint) ;
void addThumbnail();
void addPicture();
void checkLength();
void allowAutoMediaThumbNail(bool);
void on_channelpostButton_clicked();
void on_attachmentsButton_clicked();
private:
void loadChannelInfo(const uint32_t &token);
void loadChannelPostInfo(const uint32_t &token);

View file

@ -37,7 +37,11 @@
<number>0</number>
</property>
<item row="0" column="0">
<widget class="HeaderFrame" name="headerFrame"/>
<widget class="HeaderFrame" name="headerFrame">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QFrame" name="mainFrame">
@ -47,9 +51,56 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="mainFrameGLayout">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<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="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>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>486</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3">
<widget class="QStackedWidget" name="stackedWidget">
<property name="mouseTracking">
<bool>true</bool>
</property>
@ -62,15 +113,138 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="channelPostTab">
<attribute name="title">
<string>Channel Post</string>
</attribute>
<layout class="QGridLayout" name="channelPostTabGLayout">
<item row="0" column="0" colspan="3">
<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>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;&quot;&gt;Attachments:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/feedback_arrow.png&quot; /&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt; Use Drag and Drop / Add Files button, to Hash new files.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/feedback_arrow.png&quot; /&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt; Copy/Paste RetroShare links from your shares&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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="QHBoxLayout" name="channelNameHLayout">
<item>
<widget class="QLabel" name="channelNameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>75</weight>
@ -94,138 +268,22 @@
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QGridLayout" name="channelAttachGLayout">
<item row="1" column="0">
<widget class="QPushButton" name="addfilepushButton">
<property name="text">
<string>Add File to Attach</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</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="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="addPictureButton">
<property name="text">
<string>Add Picture</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="channelAttachLabel">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:600;&quot;&gt;Attachments:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/feedback_arrow.png&quot; /&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt; Use Drag and Drop / Add Files button, to Hash new files.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;img src=&quot;:/images/feedback_arrow.png&quot; /&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt; Copy/Paste RetroShare links from your shares&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<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="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>12</width>
<height>98</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" colspan="3">
<widget class="QGroupBox" name="messageGBox">
<property name="title">
<string>Message</string>
</property>
<layout class="QVBoxLayout" name="messageGBoxVLayout">
<item>
<layout class="QHBoxLayout" name="subjectHLayout">
<item>
<widget class="QLabel" name="subjectLabel">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Subject :</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="subjectEdit"/>
</item>
</layout>
</item>
<item>
<widget class="MimeTextEdit" name="msgEdit"/>
</item>
<item>
<widget class="QLabel" name="infoLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="attachmentsTab">
<attribute name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/attachment.png</normaloff>:/images/attachment.png</iconset>
</attribute>
<attribute name="title">
<string>Attachments</string>
</attribute>
<widget class="QWidget" name="stackedWidgetPage2">
<layout class="QGridLayout" name="attachmentsTabGLayout">
<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="0" column="0">
<widget class="QLabel" name="attachmentsPixLabel">
<property name="text">
@ -286,8 +344,8 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/add-file.png</normaloff>:/icons/png/add-file.png</iconset>
</property>
<property name="iconSize">
<size>
@ -320,7 +378,7 @@ p, li { white-space: pre-wrap; }
<rect>
<x>0</x>
<y>0</y>
<width>812</width>
<width>81</width>
<height>24</height>
</rect>
</property>
@ -371,7 +429,7 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0" colspan="3">
<layout class="QHBoxLayout" name="buttonHLayout">
<item>
<widget class="QCheckBox" name="generateCheckBox">
@ -392,6 +450,9 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -408,19 +469,21 @@ p, li { white-space: pre-wrap; }
</layout>
</widget>
<customwidgets>
<customwidget>
<class>MimeTextEdit</class>
<extends>QTextEdit</extends>
<header location="global">gui/common/MimeTextEdit.h</header>
</customwidget>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>RichTextEdit</class>
<extends>QWidget</extends>
<header>util/RichTextEdit.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../icons.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/>

View file

@ -62,13 +62,13 @@ void GxsChannelDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> ev
if(!e)
return;
switch(e->mChannelEventCode)
{
case RsGxsChannelEvent::ChannelEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
break;
default:
break;
}
switch(e->mChannelEventCode)
{
case RsChannelEventCode::SUBSCRIBE_STATUS_CHANGED: updateDisplay(true);
break;
default:
break;
}
}
GxsChannelDialog::~GxsChannelDialog()

View file

@ -142,18 +142,18 @@ void GxsChannelPostsWidget::handleEvent_main_thread(std::shared_ptr<const RsEven
if(!e)
return;
switch(e->mChannelEventCode)
{
case RsGxsChannelEvent::ChannelEventCode::UPDATED_CHANNEL:
case RsGxsChannelEvent::ChannelEventCode::NEW_CHANNEL:
case RsGxsChannelEvent::ChannelEventCode::UPDATED_MESSAGE:
case RsGxsChannelEvent::ChannelEventCode::NEW_MESSAGE:
if(e->mChannelGroupId == mChannelGroupId)
updateDisplay(true);
break;
default:
break;
}
switch(e->mChannelEventCode)
{
case RsChannelEventCode::UPDATED_CHANNEL:
case RsChannelEventCode::NEW_CHANNEL:
case RsChannelEventCode::UPDATED_MESSAGE:
case RsChannelEventCode::NEW_MESSAGE:
if(e->mChannelGroupId == mChannelGroupId)
updateDisplay(true);
break;
default:
break;
}
}
GxsChannelPostsWidget::~GxsChannelPostsWidget()