Merge remote-tracking branch 'upstream/master' into v0.6-BugFixing_29

This commit is contained in:
csoler 2023-05-07 17:07:59 +02:00
commit 2f2495455f
40 changed files with 1775 additions and 375 deletions

View file

@ -37,6 +37,7 @@
#include "gui/advsearch/advancedsearchdialog.h"
#include "gui/common/RSTreeWidgetItem.h"
#include "util/QtVersion.h"
#include "util/qtthreadsutils.h"
#include <retroshare/rsfiles.h>
#include <retroshare/rsturtle.h>
@ -217,6 +218,15 @@ SearchDialog::SearchDialog(QWidget *parent)
checkText(ui.lineEdit->text());
// add an event handler to get search results (previously available through notifyQt)
mEventHandlerId = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event)
{
RsQThreadUtils::postToObject([=](){ handleEvent_main_thread(event); }, this );
}, mEventHandlerId, RsEventType::FILE_TRANSFER );
}
SearchDialog::~SearchDialog()
@ -235,6 +245,29 @@ SearchDialog::~SearchDialog()
ui.searchResultWidget->setItemDelegateForColumn(SR_SIZE_COL, nullptr);
ui.searchResultWidget->setItemDelegateForColumn(SR_AGE_COL, nullptr);
rsEvents->unregisterEventsHandler(mEventHandlerId);
}
void SearchDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{
if(event->mType != RsEventType::FILE_TRANSFER)
return;
auto fe = dynamic_cast<const RsFileTransferEvent*>(event.get());
if(!fe || fe->mFileTransferEventCode!=RsFileTransferEventCode::NEW_DISTANT_SEARCH_RESULTS)
return;
for(uint32_t i=0;i<fe->mResults.size();++i)
{
FileDetail f;
f.hash = fe->mResults[i].fHash;
f.name = fe->mResults[i].fName;
f.size = fe->mResults[i].fSize;
updateFiles(fe->mRequestId,f);
}
}
void SearchDialog::processSettings(bool bLoad)
@ -961,7 +994,7 @@ void SearchDialog::processResultQueue()
while(!searchResultsQueue.empty() && nb_treated_elements++ < 250)
{
qulonglong search_id = searchResultsQueue.back().first ;
FileDetail& file = searchResultsQueue.back().second ;
const FileDetail& file = searchResultsQueue.back().second ;
#ifdef DEBUG
std::cout << "Updating file detail:" << std::endl ;

View file

@ -22,6 +22,7 @@
#define _SEARCHDIALOG_H
#include "retroshare/rstypes.h"
#include "retroshare/rsevents.h"
#include "ui_SearchDialog.h"
#include "retroshare-gui/mainpage.h"
@ -125,6 +126,7 @@ private:
void setIconAndType(QTreeWidgetItem *item, const QString& filename);
void downloadDirectory(const QTreeWidgetItem *item, const QString &base);
void getSourceFriendsForHash(const RsFileHash &hash,std::list<RsPeerId> &srcIds);
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
/** the advanced search dialog instance */
AdvancedSearchDialog * advSearchDialog;
@ -176,6 +178,8 @@ private:
bool _queueIsAlreadyTakenCareOf ;
std::vector<std::pair<qulonglong,FileDetail> > searchResultsQueue ;
RsEventsHandlerId_t mEventHandlerId ;
};
#endif

View file

@ -301,8 +301,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>634</width>
<height>538</height>
<width>456</width>
<height>731</height>
</rect>
</property>
<layout class="QVBoxLayout" name="scrollAreaWidgetContentsVLayout">
@ -338,21 +338,14 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>518</width>
<height>17</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QFrame" name="info_Frame_Invite">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="palette">
<palette>
<active>
@ -490,6 +483,9 @@
<property name="text">
<string notr="true">Invite messages stay into your Outbox until an acknowledgement of receipt has been received.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
@ -895,9 +891,12 @@ border-image: url(:/images/closepressed.png)
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="autoBanIdentities_CB">
<property name="text">
<property name="toolTip">
<string>Auto-Ban all identities signed by the same node</string>
</property>
<property name="text">
<string>Auto-Ban profile</string>
</property>
</widget>
</item>
<item row="4" column="1">

View file

@ -50,6 +50,8 @@
#define IMG_ATTACH 0
#define IMG_PICTURE 1
const int MAXMESSAGESIZE = 199000;
PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGroupId& grpId, const RsGxsId& default_author, QWidget *parent):
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint),
mPosted(posted), mGrpId(grpId),
@ -226,7 +228,7 @@ void PostedCreatePostDialog::addPicture()
}
QImage opt;
if(ImageUtil::optimizeSizeBytes(imagebytes, image, opt,"JPG", 640*480, MAXMESSAGESIZE - 2000)) { //Leave space for other stuff
if (optimizeImage(image, imagebytes, opt)) {
ui->imageLabel->setPixmap(QPixmap::fromImage(opt));
ui->stackedWidgetPicture->setCurrentIndex(IMG_PICTURE);
ui->removeButton->show();
@ -274,7 +276,7 @@ void PostedCreatePostDialog::pastePicture()
image = (qvariant_cast<QImage>(mimeData->imageData()));
QImage opt;
if(ImageUtil::optimizeSizeBytes(imagebytes, image, opt,"JPG", 640*480, MAXMESSAGESIZE - 2000)) { //Leave space for other stuff
if (optimizeImage(image, imagebytes, opt)) {
ui->imageLabel->setPixmap(QPixmap::fromImage(opt));
ui->stackedWidgetPicture->setCurrentIndex(IMG_PICTURE);
ui->removeButton->show();
@ -287,6 +289,12 @@ void PostedCreatePostDialog::pastePicture()
}
}
bool PostedCreatePostDialog::optimizeImage(const QImage &image, QByteArray &imagebytes, QImage &imageOpt)
{
// Leave space for other stuff
return ImageUtil::optimizeSizeBytes(imagebytes, image, imageOpt, "JPG", 640*480, MAXMESSAGESIZE - 2000);
}
int PostedCreatePostDialog::viewMode()
{
if (ui->viewPostButton->isChecked()) {
@ -330,3 +338,18 @@ void PostedCreatePostDialog::reject()
QDialog::reject();
}
void PostedCreatePostDialog::setTitle(const QString& title)
{
ui->titleEdit->setText(title);
}
void PostedCreatePostDialog::setNotes(const QString& notes)
{
ui->RichTextEditWidget->setText(notes);
}
void PostedCreatePostDialog::setLink(const QString& link)
{
ui->linkEdit->setText(link);
}

View file

@ -41,10 +41,15 @@ public:
explicit PostedCreatePostDialog(RsPosted* posted, const RsGxsGroupId& grpId, const RsGxsId& default_author=RsGxsId(),QWidget *parent = 0);
~PostedCreatePostDialog();
void setTitle(const QString& title);
void setNotes(const QString& notes);
void setLink(const QString& link);
static bool optimizeImage(const QImage &image, QByteArray &imagebytes, QImage &imageOpt);
private:
QString imagefilename;
QByteArray imagebytes;
const int MAXMESSAGESIZE = 199000;
private slots:
void createPost();

View file

@ -454,22 +454,6 @@ p, li { white-space: pre-wrap; }
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Minimum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="LineEditClear" name="filter_LE">
<property name="placeholderText">

View file

@ -42,15 +42,26 @@ PulseAddDialog::PulseAddDialog(QWidget *parent)
connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelPulse( void ) ) );
connect(ui.textEdit_Pulse, SIGNAL( textChanged( void ) ), this, SLOT( pulseTextChanged( void ) ) );
connect(ui.pushButton_picture, SIGNAL(clicked()), this, SLOT( toggle()));
connect(ui.pushButton_remove, SIGNAL(clicked()), this, SLOT( removePictures()));
// this connection is from browse push button to the slot function onBrowseButtonClicked()
connect(ui.pushButton_Browse, SIGNAL(clicked()), this, SLOT( onBrowseButtonClicked()));
ui.pushButton_picture->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/photo.png")));
ui.pushButton_Browse->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/add-image.png")));
ui.pushButton_remove->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/mail/delete.png")));
ui.frame_picture->hide();
ui.pushButton_picture->hide();
// initially hiding the browse button as the attach image button is not pressed
ui.frame_PictureBrowse->hide();
//ui.frame_PictureBrowse->hide();
ui.label_image1->hide();
ui.label_image2->hide();
ui.label_image3->hide();
ui.label_image4->hide();
setAcceptDrops(true);
}
@ -160,11 +171,10 @@ void PulseAddDialog::cleanup()
ui.label_image4->clear();
ui.label_image4->setText(tr("Drag and Drop Image"));
ui.lineEdit_FilePath->clear();
// Hide Drag & Drop Frame and the browse frame
ui.frame_picture->hide();
ui.frame_PictureBrowse->hide();
//ui.frame_PictureBrowse->hide();
ui.pushButton_picture->hide();
ui.pushButton_picture->setChecked(false);
}
@ -489,24 +499,29 @@ void PulseAddDialog::addImage(const QString &path)
std::cerr << "PulseAddDialog::addImage() Installing in Image1";
std::cerr << std::endl;
ui.label_image1->setPixmap(icon);
ui.label_image1->show();
ui.frame_picture->show();
mImage1.copy((uint8_t *) ba.data(), ba.size());
std::cerr << "PulseAddDialog::addImage() Installing in Image1 Size: " << mImage1.mSize;
std::cerr << std::endl;
}
else if (mImage2.empty()) {
ui.label_image2->setPixmap(icon);
ui.label_image2->show();
mImage2.copy((uint8_t *) ba.data(), ba.size());
std::cerr << "PulseAddDialog::addImage() Installing in Image2 Size: " << mImage2.mSize;
std::cerr << std::endl;
}
else if (mImage3.empty()) {
ui.label_image3->setPixmap(icon);
ui.label_image3->show();
mImage3.copy((uint8_t *) ba.data(), ba.size());
std::cerr << "PulseAddDialog::addImage() Installing in Image3 Size: " << mImage3.mSize;
std::cerr << std::endl;
}
else if (mImage4.empty()) {
ui.label_image4->setPixmap(icon);
ui.label_image4->show();
mImage4.copy((uint8_t *) ba.data(), ba.size());
std::cerr << "PulseAddDialog::addImage() Installing in Image4 Size: " << mImage4.mSize;
std::cerr << std::endl;
@ -523,7 +538,6 @@ void PulseAddDialog::toggle()
{
// Show the input methods (drag and drop field and the browse button)
ui.frame_picture->show();
ui.frame_PictureBrowse->show();
ui.pushButton_picture->setToolTip(tr("Hide Pictures"));
}
@ -531,7 +545,6 @@ void PulseAddDialog::toggle()
{
// Hide the input methods (drag and drop field and the browse button)
ui.frame_picture->hide();
ui.frame_PictureBrowse->hide();
ui.pushButton_picture->setToolTip(tr("Add Pictures"));
}
@ -543,8 +556,27 @@ void PulseAddDialog::onBrowseButtonClicked()
QString filePath;
misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg *.gif *.webp )", filePath);
if (!filePath.isEmpty()) {
ui.lineEdit_FilePath->setText(filePath);
//ui.lineEdit_FilePath->setText(filePath);
addImage(filePath);
}
}
void PulseAddDialog::removePictures()
{
mImage1.clear();
ui.label_image1->clear();
mImage2.clear();
ui.label_image2->clear();
mImage3.clear();
ui.label_image3->clear();
mImage4.clear();
ui.label_image4->clear();
ui.label_image1->hide();
ui.label_image2->hide();
ui.label_image3->hide();
ui.label_image4->hide();
ui.frame_picture->hide();
}

View file

@ -53,7 +53,8 @@ private slots:
void clearDialog();
void pulseTextChanged();
void toggle();
void onBrowseButtonClicked();
void onBrowseButtonClicked();
void removePictures();
private:
// OLD VERSIONs, private now.

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>720</width>
<width>735</width>
<height>513</height>
</rect>
</property>
@ -52,6 +52,7 @@
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -249,6 +250,12 @@
</item>
<item>
<widget class="QFrame" name="frame_picture">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
@ -278,6 +285,22 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_image4">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>Drag and Drop Image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_image3">
<property name="minimumSize">
@ -310,63 +333,22 @@
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_image4">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
<item row="0" column="2" rowspan="2">
<widget class="QToolButton" name="pushButton_remove">
<property name="toolTip">
<string>Remove all images</string>
</property>
<property name="text">
<string>Drag and Drop Image</string>
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_PictureBrowse">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_FilePath">
<property name="minimumSize">
<property name="iconSize">
<size>
<width>541</width>
<height>25</height>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_Browse">
<property name="minimumSize">
<size>
<width>101</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -413,7 +395,6 @@
</layout>
<zorder>frame_URL</zorder>
<zorder>frame_picture</zorder>
<zorder>frame_PictureBrowse</zorder>
<zorder>textEdit_Pulse</zorder>
</widget>
</item>
@ -423,7 +404,7 @@
<number>6</number>
</property>
<item>
<widget class="QPushButton" name="pushButton_picture">
<widget class="QToolButton" name="pushButton_picture">
<property name="text">
<string/>
</property>
@ -438,6 +419,22 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="pushButton_Browse">
<property name="toolTip">
<string>Add Picture</string>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="buttonHSpacer">
<property name="orientation">
@ -456,6 +453,7 @@
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>

View file

@ -402,7 +402,7 @@
<string notr="true">&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;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; 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:8pt;&quot;&gt;Description&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
@ -534,7 +534,7 @@ p, li { white-space: pre-wrap; }
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QLabel" name="postName_LB">
<widget class="ElidedLabel" name="postName_LB">
<property name="font">
<font>
<weight>75</weight>

View file

@ -68,19 +68,19 @@ CreateGxsForumMsg::CreateGxsForumMsg(const RsGxsGroupId &fId, const RsGxsMessage
mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui->postButton);
mStateHelper->addWidget(CREATEGXSFORUMMSG_FORUMINFO, ui->innerFrame);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui->forumName);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui->forumSubject);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_FORUMINFO, ui->forumSubject, false);
mStateHelper->addClear(CREATEGXSFORUMMSG_FORUMINFO, ui->forumName);
mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui->postButton);
mStateHelper->addWidget(CREATEGXSFORUMMSG_PARENTMSG, ui->innerFrame);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui->forumName);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui->forumSubject);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_PARENTMSG, ui->forumSubject, false);
mStateHelper->addClear(CREATEGXSFORUMMSG_PARENTMSG, ui->forumName);
mStateHelper->addWidget(CREATEGXSFORUMMSG_ORIGMSG, ui->postButton);
mStateHelper->addWidget(CREATEGXSFORUMMSG_ORIGMSG, ui->innerFrame);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui->forumName);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui->forumSubject);
mStateHelper->addLoadPlaceholder(CREATEGXSFORUMMSG_ORIGMSG, ui->forumSubject, false);
mStateHelper->addClear(CREATEGXSFORUMMSG_ORIGMSG, ui->forumName);

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1215</width>
<height>825</height>
<width>800</width>
<height>650</height>
</rect>
</property>
<property name="windowTitle">

View file

@ -482,6 +482,8 @@ void NotifyQt::notifyTurtleSearchResult(uint32_t /*search_id*/,const std::list<T
std::cerr << "(EE) missing code to handle GXS turtle search result." << std::endl;
}
#ifdef TO_REMOVE
// Mai 2023: distant turtle search now uses RsEvents.
void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,const std::list<TurtleFileInfo>& files)
{
{
@ -507,6 +509,7 @@ void NotifyQt::notifyTurtleSearchResult(const RsPeerId& pid,uint32_t search_id,c
emit gotTurtleSearchResult(search_id,det) ;
}
}
#endif
void NotifyQt::notifyHistoryChanged(uint32_t msgId, int type)
{

View file

@ -67,7 +67,9 @@ class NotifyQt: public QObject, public NotifyClient
virtual void notifyChatStatus(const ChatId &chat_id,const std::string& status_string);
virtual void notifyChatCleared(const ChatId &chat_id);
virtual void notifyCustomState(const std::string& peer_id, const std::string& status_string);
#ifdef TO_REMOVE
virtual void notifyTurtleSearchResult(const RsPeerId &pid, uint32_t search_id, const std::list<TurtleFileInfo>& found_files);
#endif
virtual void notifyTurtleSearchResult(uint32_t search_id,const std::list<TurtleGxsInfo>& found_groups);
virtual void notifyPeerHasNewAvatar(std::string peer_id) ;
virtual void notifyOwnAvatarChanged() ;

View file

@ -540,7 +540,7 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
qRegisterMetaType<RsPeerId>("RsPeerId") ;
std::cerr << "connecting signals and slots" << std::endl ;
QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ;
// QObject::connect(notify,SIGNAL(gotTurtleSearchResult(qulonglong,FileDetail)),w->transfersDialog->searchDialog ,SLOT(updateFiles(qulonglong,FileDetail))) ;
QObject::connect(notify,SIGNAL(deferredSignatureHandlingRequested()),notify,SLOT(handleSignatureEvent()),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(chatLobbyTimeShift(int)),notify,SLOT(handleChatLobbyTimeShift(int)),Qt::QueuedConnection) ;
QObject::connect(notify,SIGNAL(diskFull(int,int)) ,w ,SLOT(displayDiskSpaceWarning(int,int))) ;