From 8b5a1036e06e794150aec8288846e113341680b3 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sat, 5 Oct 2019 19:23:59 +0200 Subject: [PATCH 01/11] Waiting cursor while loading --- retroshare-gui/src/gui/common/Emoticons.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 37e40e72f..bdb4a89cc 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -306,6 +306,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * QWidget *smWidget = new QWidget(parent, Qt::Popup) ; smWidget->setAttribute(Qt::WA_DeleteOnClose) ; smWidget->setWindowTitle("Stickers") ; + QApplication::setOverrideCursor(Qt::WaitCursor); if(StickerGroups.count() == 0) { QMessageBox::warning(parent, "Stickers", "No stickers installed"); @@ -444,10 +445,12 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * smWidget->move(x, y); smWidget->show(); + QApplication::restoreOverrideCursor(); } void Emoticons::loadToolTips(QWidget *container) { + QApplication::setOverrideCursor(Qt::WaitCursor); QList children = container->findChildren(); for(int i = 0; i < children.length(); ++i) { if(!children[i]->toolTip().contains('<')) { @@ -464,4 +467,5 @@ void Emoticons::loadToolTips(QWidget *container) } } + QApplication::restoreOverrideCursor(); } From 8ff71150c55102d0456750ff8402dfebebde4aee Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sat, 5 Oct 2019 19:53:24 +0200 Subject: [PATCH 02/11] Recheck for new stickers when opening the dialog --- retroshare-gui/src/gui/common/Emoticons.cpp | 30 +++++++++++++-------- retroshare-gui/src/gui/common/Emoticons.h | 5 +++- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index bdb4a89cc..8eba38628 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -41,17 +41,17 @@ static QHash, QHash > > Smileys; static QVector grpOrdered; -static QVector StickerGroups; static QStringList filters; +static QStringList stickerFolders; static QHash tooltipcache; void Emoticons::load() { loadSmiley(); filters << "*.png" << "*.jpg" << "*.gif"; - loadSticker(QString::fromStdString(RsAccounts::ConfigDirectory()) + "/stickers"); //under .retroshare, shared between users - loadSticker(QString::fromStdString(RsAccounts::AccountDirectory()) + "/stickers"); //under account, unique for user - loadSticker(QString::fromStdString(RsAccounts::systemDataDirectory()) + "/stickers"); //exe's folder, shipped with RS + stickerFolders << (QString::fromStdString(RsAccounts::ConfigDirectory()) + "/stickers"); //under .retroshare, shared between users + stickerFolders << (QString::fromStdString(RsAccounts::AccountDirectory()) + "/stickers"); //under account, unique for user + stickerFolders << (QString::fromStdString(RsAccounts::systemDataDirectory()) + "/stickers"); //exe's folder, shipped with RS } void Emoticons::loadSmiley() @@ -285,7 +285,13 @@ void Emoticons::showSmileyWidget(QWidget *parent, QWidget *button, const char *s smWidget->show() ; } -void Emoticons::loadSticker(QString foldername) +void Emoticons::refreshStickerTabs(QVector& stickerTabs) +{ + for(int i = 0; i < stickerFolders.count(); ++i) + refreshStickerTabs(stickerTabs, stickerFolders[i]); +} + +void Emoticons::refreshStickerTabs(QVector& stickerTabs, QString foldername) { QDir dir(foldername); if(!dir.exists()) return; @@ -293,26 +299,28 @@ void Emoticons::loadSticker(QString foldername) //If it contains at a least one png then add it as a group QStringList files = dir.entryList(filters, QDir::Files); if(files.count() > 0) - StickerGroups.append(foldername); + stickerTabs.append(foldername); //Check subfolders QFileInfoList subfolders = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot); for(int i = 0; i stickerTabs; + refreshStickerTabs(stickerTabs); QWidget *smWidget = new QWidget(parent, Qt::Popup) ; smWidget->setAttribute(Qt::WA_DeleteOnClose) ; smWidget->setWindowTitle("Stickers") ; - QApplication::setOverrideCursor(Qt::WaitCursor); - if(StickerGroups.count() == 0) { + if(stickerTabs.count() == 0) { QMessageBox::warning(parent, "Stickers", "No stickers installed"); return; } - bool bOnlyOneGroup = (StickerGroups.count() == 1); + bool bOnlyOneGroup = (stickerTabs.count() == 1); QTabWidget *smTab = nullptr; if (! bOnlyOneGroup) @@ -328,7 +336,7 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * int maxRowCount = 0; int maxCountPerLine = 0; - QVectorIterator grp(StickerGroups); + QVectorIterator grp(stickerTabs); while(grp.hasNext()) { QDir groupDir = QDir(grp.next()); diff --git a/retroshare-gui/src/gui/common/Emoticons.h b/retroshare-gui/src/gui/common/Emoticons.h index f4b42c0ff..11a1c78bd 100644 --- a/retroshare-gui/src/gui/common/Emoticons.h +++ b/retroshare-gui/src/gui/common/Emoticons.h @@ -21,6 +21,8 @@ #ifndef _EMOTICONS_H #define _EMOTICONS_H +#include + class QWidget; class QString; @@ -29,7 +31,8 @@ class Emoticons public: static void load(); static void loadSmiley(); - static void loadSticker(QString foldername); + static void refreshStickerTabs(QVector& stickerTabs, QString foldername); + static void refreshStickerTabs(QVector& stickerTabs); static void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above); static void showStickerWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above); From 5e0dcdc08099ff97e981d4e9d5e62812341b0904 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sat, 5 Oct 2019 20:11:38 +0200 Subject: [PATCH 03/11] Better message when there is no stickers Fix infinite waiting cursor --- retroshare-gui/src/gui/common/Emoticons.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 8eba38628..d4f556daa 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -309,17 +309,19 @@ void Emoticons::refreshStickerTabs(QVector& stickerTabs, QString folder void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above) { - QApplication::setOverrideCursor(Qt::WaitCursor); QVector stickerTabs; refreshStickerTabs(stickerTabs); + if(stickerTabs.count() == 0) { + QString message = "No stickers installed.\nYou can install them by putting images into one of these folders:\n" + stickerFolders.join('\n'); + QMessageBox::warning(parent, "Stickers", message); + return; + } + + QApplication::setOverrideCursor(Qt::WaitCursor); QWidget *smWidget = new QWidget(parent, Qt::Popup) ; smWidget->setAttribute(Qt::WA_DeleteOnClose) ; smWidget->setWindowTitle("Stickers") ; - if(stickerTabs.count() == 0) { - QMessageBox::warning(parent, "Stickers", "No stickers installed"); - return; - } bool bOnlyOneGroup = (stickerTabs.count() == 1); QTabWidget *smTab = nullptr; From 641964fff9e01531560e02d1ab1ef5c6630190d0 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sat, 5 Oct 2019 20:41:41 +0200 Subject: [PATCH 04/11] New sticker icon --- retroshare-gui/src/gui/chat/ChatWidget.ui | 2 +- retroshare-gui/src/gui/icons.qrc | 4 +- .../src/gui/icons/png/addstickers.png | Bin 0 -> 9551 bytes .../src/gui/icons/svg/addstickers.svg | 61 ++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 retroshare-gui/src/gui/icons/png/addstickers.png create mode 100644 retroshare-gui/src/gui/icons/svg/addstickers.svg diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index a937bf247..a0e6e3776 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -356,7 +356,7 @@ border-image: url(:/images/closepressed.png) - :/icons/png/new.png:/icons/png/new.png + :/icons/png/addstickers.png:/icons/png/addstickers.png diff --git a/retroshare-gui/src/gui/icons.qrc b/retroshare-gui/src/gui/icons.qrc index d510544a8..6743cdb7b 100644 --- a/retroshare-gui/src/gui/icons.qrc +++ b/retroshare-gui/src/gui/icons.qrc @@ -71,7 +71,7 @@ icons/png/add.png icons/png/attach-image.png icons/png/attach.png - icons/png/cert.png + icons/png/cert.png icons/png/channels-notify.png icons/png/channels.png icons/png/chat-bubble-notify.png @@ -261,5 +261,7 @@ icons/png/flame.png icons/png/new.png icons/png/top.png + icons/svg/addstickers.svg + icons/png/addstickers.png diff --git a/retroshare-gui/src/gui/icons/png/addstickers.png b/retroshare-gui/src/gui/icons/png/addstickers.png new file mode 100644 index 0000000000000000000000000000000000000000..91c4ee4c33ca5a0b4694045195016ed961b0db50 GIT binary patch literal 9551 zcmX|Hby!pH+aF`V=V-Em;pzps8Et!je7WE>vr@WD;uB)A=x0Smsz}wsV#XFbx9&fE+wl7@W z?K6*|GynhtKv_;k&nN51%-fR8cHyZ*u&(WgOKm3R-tW*aMA2{teP3-vUO`|FhYo0@ zv^dLN?4O3FWWPC)%xRwl(u)&3^_^KgEcBT48a(HJ6aYKSp++yal2Ze z8=2S0fIrin<(7=RDxDha>`M77(K-a@^`K5dH{b{tNmg^GJ10|<8FIKO_O3&)X>h`j zNygL|RKq?vaE|{~dd~*%4b3Q|1HJ1-jEHGY6MbAo;AlePk!P)^&Q*26a$n=?k_zL&QP9v!N|v z!3nS2?;}ls+{BDsk?GX^-R5ei*sBktN-M~xXGk@`>zY(jKCL;9h#lL~W1i9D9lRNV z5Jf-|N#KvkQa}K?^kQBm^AH0PTk9`el*?H+;g}xe?^(gct9sH?IE(=iX2yy^c3ZC! zy&$3z3-OKWIsRVau2MqG;n)u^zsOZhpvSpD5E%iDJdq5r{Ge~hjZ?w4coE!Pa@*G; znb@TU=&cG=ll_izA;yc&*#iCPoNRH1;;{Cq;ICd-ar)w?s>YwBqP_vi;#KOVq^@T1 zlfV!(?lG0^=PnrV?#HxOOUSi-VMZ!)*MZ$WzKbZ~e_Ml50`lAPSi)O|Z#}GdyeMY# zWePewu>0MAM78)ZbSyNH)`7ujr>X>h04lFAiMB>QGOI(2Jn;sXIfPB0kpf?Uu}mu2 z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w) zC)TrCHqoCXi-&uhPC2;Yr?JoNe_6MW1LRx*SQVmt?ZoR)I{~YY8eBR~OiLx+O8I!N zVwe5~F_@Fc>XeZ%Do2+*qxxS;83&Tmouy4uA)$`F`=!xnLz2s~A0_xJ2(a4$@Z=b? z$gb>(Y-lNa2%Tb%y*azR@_8%$CVsLPg&8Q$K#L#)TDUVCGx79dvoCQ(Ekz7a?HGUBpBI>0zP ziPQ_Wa4!TkBG8m%BdEl)d8(eUA^N5BGW&+~fP{S^{YAgcEA{DQJ3D`Q_@b8zRFHVj^WV;2LhWdizRuZBqsC{|(tYck`#hy%%GLeX94q01n>>62LDV zXP*`e+VB7og->z_@g^EJu4iRvkm2{P3rX>xF)F!r4M~Uo>lFXaa{W`D9w3=dn_@e7 z#$8)e%b+giy8&Nuq%NXSPQn;ZG8Hd3Ba_rHmVr(CG@D2z+!|lz^h3dbPKxc>LN#Z!8(w2h6!?e+e3oQfKP@! z|GvsnbX)nP=-je3FU&SjvF7BV@cXZ0Ki3b0t}I7@`3v@du{RMKszeuduLk;!C7;7i z(5WDY4Inz3&!8QMp-Nza0Z|1l7o)$AO}*MK7igCh^(G)wG^99NaOxVvkFhcwwZi9| zV~`EfLJm3yT;N~1`{UsxoPZN8DC{rh$PfEX6%Lr-3Pi8Op&`SY+5pnYsphcN0?a%v zmY=f?;f`1&l_`M0{&iVp2yqc(6|@5 + + +image/svg+xml \ No newline at end of file From e52f1282ec08f0a5cfe06d192ace29e3291e0e76 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Sat, 5 Oct 2019 23:18:41 +0200 Subject: [PATCH 05/11] Allow to import stickers from chat window --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 14 ++++++++++++++ retroshare-gui/src/gui/chat/ChatWidget.h | 1 + retroshare-gui/src/gui/chat/ChatWidget.ui | 9 +++++++++ retroshare-gui/src/gui/common/Emoticons.cpp | 12 +++++++++++- retroshare-gui/src/gui/common/Emoticons.h | 8 ++++---- retroshare-gui/src/util/imageutil.cpp | 12 ++++++------ retroshare-gui/src/util/imageutil.h | 2 +- 7 files changed, 46 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index bb7352ffd..6630f49a0 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "ChatWidget.h" #include "ui_ChatWidget.h" @@ -162,6 +163,7 @@ ChatWidget::ChatWidget(QWidget *parent) connect(ui->actionQuote, SIGNAL(triggered()), this, SLOT(quote())); connect(ui->actionDropPlacemark, SIGNAL(triggered()), this, SLOT(dropPlacemark())); connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage())); + connect(ui->actionImport_sticker, SIGNAL(triggered()), this, SLOT(saveSticker())); connect(ui->actionShow_Hidden_Images, SIGNAL(triggered()), ui->textBrowser, SLOT(showImages())); ui->actionShow_Hidden_Images->setIcon(ui->textBrowser->getBlockedImage()); @@ -1127,7 +1129,9 @@ void ChatWidget::contextMenuTextBrowser(QPoint point) contextMnu->addAction(ui->actionShow_Hidden_Images); ui->actionSave_image->setData(point); + ui->actionImport_sticker->setData(point); contextMnu->addAction(ui->actionSave_image); + contextMnu->addAction(ui->actionImport_sticker); } QString anchor = ui->textBrowser->anchorForPosition(point); @@ -1909,3 +1913,13 @@ void ChatWidget::saveImage() QTextCursor cursor = ui->textBrowser->cursorForPosition(point); ImageUtil::extractImage(window(), cursor); } + +void ChatWidget::saveSticker() +{ + QPoint point = ui->actionImport_sticker->data().toPoint(); + QTextCursor cursor = ui->textBrowser->cursorForPosition(point); + QString filename = QInputDialog::getText(window(), "Import sticker", "Sticker name"); + if(filename.isEmpty()) return; + filename = Emoticons::importedStickerPath() + "/" + filename + ".png"; + ImageUtil::extractImage(window(), cursor, filename); +} diff --git a/retroshare-gui/src/gui/chat/ChatWidget.h b/retroshare-gui/src/gui/chat/ChatWidget.h index b1b0a23db..535636ddd 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.h +++ b/retroshare-gui/src/gui/chat/ChatWidget.h @@ -194,6 +194,7 @@ private slots: void quote(); void dropPlacemark(); void saveImage(); + void saveSticker(); private: bool findText(const QString& qsStringToFind); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index a0e6e3776..17b9f5e34 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -918,6 +918,15 @@ border-image: url(:/images/closepressed.png) Save image + + + + :/icons/png/addstickers.png:/icons/png/addstickers.png + + + Import sticker + + true diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index d4f556daa..1bc58b871 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -49,9 +50,12 @@ void Emoticons::load() { loadSmiley(); filters << "*.png" << "*.jpg" << "*.gif"; - stickerFolders << (QString::fromStdString(RsAccounts::ConfigDirectory()) + "/stickers"); //under .retroshare, shared between users stickerFolders << (QString::fromStdString(RsAccounts::AccountDirectory()) + "/stickers"); //under account, unique for user + stickerFolders << (QString::fromStdString(RsAccounts::ConfigDirectory()) + "/stickers"); //under .retroshare, shared between users stickerFolders << (QString::fromStdString(RsAccounts::systemDataDirectory()) + "/stickers"); //exe's folder, shipped with RS + + QDir dir(QString::fromStdString(RsAccounts::AccountDirectory())); + dir.mkpath("stickers/imported"); } void Emoticons::loadSmiley() @@ -458,6 +462,12 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * QApplication::restoreOverrideCursor(); } +QString Emoticons::importedStickerPath() +{ + QDir dir(stickerFolders[0]); + return dir.absoluteFilePath("imported"); +} + void Emoticons::loadToolTips(QWidget *container) { QApplication::setOverrideCursor(Qt::WaitCursor); diff --git a/retroshare-gui/src/gui/common/Emoticons.h b/retroshare-gui/src/gui/common/Emoticons.h index 11a1c78bd..0d9a6bedd 100644 --- a/retroshare-gui/src/gui/common/Emoticons.h +++ b/retroshare-gui/src/gui/common/Emoticons.h @@ -30,15 +30,15 @@ class Emoticons { public: static void load(); - static void loadSmiley(); - static void refreshStickerTabs(QVector& stickerTabs, QString foldername); - static void refreshStickerTabs(QVector& stickerTabs); - static void showSmileyWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above); static void showStickerWidget(QWidget *parent, QWidget *button, const char *slotAddMethod, bool above); + static QString importedStickerPath(); private: static void loadToolTips(QWidget *container); + static void loadSmiley(); + static void refreshStickerTabs(QVector& stickerTabs, QString foldername); + static void refreshStickerTabs(QVector& stickerTabs); }; #endif diff --git a/retroshare-gui/src/util/imageutil.cpp b/retroshare-gui/src/util/imageutil.cpp index cefa22906..2c21be1bd 100644 --- a/retroshare-gui/src/util/imageutil.cpp +++ b/retroshare-gui/src/util/imageutil.cpp @@ -37,7 +37,7 @@ ImageUtil::ImageUtil() {} -void ImageUtil::extractImage(QWidget *window, QTextCursor cursor) +void ImageUtil::extractImage(QWidget *window, QTextCursor cursor, QString file) { cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1); cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 2); @@ -52,13 +52,13 @@ void ImageUtil::extractImage(QWidget *window, QTextCursor cursor) QImage image = QImage::fromData(ba); if(!image.isNull()) { - QString file; success = true; - if(misc::getSaveFileName(window, RshareSettings::LASTDIR_IMAGES, "Save Picture File", "Pictures (*.png *.xpm *.jpg)", file)) + if(!file.isEmpty() || misc::getSaveFileName(window, RshareSettings::LASTDIR_IMAGES, "Save Picture File", "Pictures (*.png *.xpm *.jpg)", file)) { - if(!image.save(file, 0, 100)) - if(!image.save(file + ".png", 0, 100)) - QMessageBox::warning(window, QApplication::translate("ImageUtil", "Save image"), QApplication::translate("ImageUtil", "Cannot save the image, invalid filename")); + if(!image.save(file, nullptr, 100)) + if(!image.save(file + ".png", nullptr, 100)) + QMessageBox::warning(window, QApplication::translate("ImageUtil", "Save image"), QApplication::translate("ImageUtil", "Cannot save the image, invalid filename") + + "\n" + file); } } } diff --git a/retroshare-gui/src/util/imageutil.h b/retroshare-gui/src/util/imageutil.h index dfea67282..a6ff19b88 100644 --- a/retroshare-gui/src/util/imageutil.h +++ b/retroshare-gui/src/util/imageutil.h @@ -30,7 +30,7 @@ class ImageUtil public: ImageUtil(); - static void extractImage(QWidget *window, QTextCursor cursor); + static void extractImage(QWidget *window, QTextCursor cursor, QString file = ""); static bool optimizeSize(QString &html, const QImage& original, QImage &optimized, int maxPixels = -1, int maxBytes = -1); private: From 9c877d3cdd837e73db77694f7d005310157aff4f Mon Sep 17 00:00:00 2001 From: hunbernd Date: Wed, 9 Oct 2019 17:27:14 +0200 Subject: [PATCH 06/11] Disable sticker button when sending is blocked --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 6630f49a0..d7cdf3dad 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -439,6 +439,7 @@ void ChatWidget::blockSending(QString msg) #ifndef RS_ASYNC_CHAT sendingBlocked = true; ui->sendButton->setEnabled(false); + ui->stickerButton->setEnabled(false); #endif ui->sendButton->setToolTip(msg); } @@ -446,6 +447,7 @@ void ChatWidget::blockSending(QString msg) void ChatWidget::unblockSending() { sendingBlocked = false; + ui->stickerButton->setEnabled(true); updateLenOfChatTextEdit(); } @@ -1559,6 +1561,7 @@ void ChatWidget::stickerWidget() void ChatWidget::sendSticker() { + if(sendingBlocked) return; QString sticker = qobject_cast(sender())->statusTip(); QString encodedImage; if (RsHtml::makeEmbeddedImage(sticker, encodedImage, 640*480, maxMessageSize() - 200)) { //-200 for the html stuff From dc3624945fc22551d9478f59aae26debb2f34ec1 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 23 Dec 2019 11:52:32 +0100 Subject: [PATCH 07/11] fixed uninitialized memory read and inconsistent initialization of mReputationScore in GxsReputation --- libretroshare/src/services/p3gxsreputation.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/services/p3gxsreputation.h b/libretroshare/src/services/p3gxsreputation.h index e9a14d4e7..2045e6f05 100644 --- a/libretroshare/src/services/p3gxsreputation.h +++ b/libretroshare/src/services/p3gxsreputation.h @@ -65,12 +65,14 @@ class Reputation { public: Reputation() : - mOwnOpinion(static_cast(RsOpinion::NEUTRAL)), mOwnOpinionTs(0), + mOwnOpinion(static_cast(RsOpinion::NEUTRAL)), + mOwnOpinionTs(0), mFriendAverage(1.0f), - /* G10h4ck: TODO shouln't this be initialized with - * RsReputation::NEUTRAL or UNKOWN? */ - mReputationScore(static_cast(RsOpinion::NEUTRAL)), - mIdentityFlags(0) {} + mFriendsPositive(0), + mFriendsNegative(0), + mReputationScore(1.0f), + mIdentityFlags(0), + mLastUsedTS(0) {} void updateReputation(); From e8bdce6e23f641e75b4330e856e300a70f3989db Mon Sep 17 00:00:00 2001 From: hunbernd Date: Tue, 24 Dec 2019 00:14:38 +0100 Subject: [PATCH 08/11] Fix sticker button disabled on distant chat --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 5c18d1cea..6249d5681 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -440,7 +440,7 @@ void ChatWidget::blockSending(QString msg) #ifndef RS_ASYNC_CHAT // sendingBlocked = true; // ui->sendButton->setEnabled(false); - ui->stickerButton->setEnabled(false); +// ui->stickerButton->setEnabled(false); #endif ui->sendButton->setToolTip(msg); } From f45a04b3d5b83a90cf3d2fb5e0eacef6bef6c062 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 24 Dec 2019 11:48:50 +0100 Subject: [PATCH 09/11] fixed key list not properly updating when importing new key in GenCertDialog, and improved tooltips --- retroshare-gui/src/gui/GenCertDialog.cpp | 15 ++++++++++++--- retroshare-gui/src/gui/connect/ConfCertDialog.cpp | 10 +++++++--- retroshare-gui/src/gui/settings/CryptoPage.ui | 12 +++++++++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/retroshare-gui/src/gui/GenCertDialog.cpp b/retroshare-gui/src/gui/GenCertDialog.cpp index e81c3794d..4fdb9f714 100644 --- a/retroshare-gui/src/gui/GenCertDialog.cpp +++ b/retroshare-gui/src/gui/GenCertDialog.cpp @@ -242,7 +242,7 @@ void GenCertDialog::initKeyList() RsAccounts::GetPGPLoginDetails(*it, name, email); std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl; QString gid = QString::fromStdString( (*it).toStdString()).right(8) ; - ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " <" + QString::fromUtf8(email.c_str()) + "> (" + gid + ")", userData); + ui.genPGPuser->addItem(QString::fromUtf8(name.c_str()) + " (" + gid + ")", userData); haveGPGKeys = true; } } @@ -294,7 +294,8 @@ void GenCertDialog::setupState() ui.reuse_existing_node_CB->setEnabled(adv_state) ; ui.importIdentity_PB->setVisible(adv_state && !generate_new) ; - ui.exportIdentity_PB->setVisible(adv_state && !generate_new) ; + //ui.exportIdentity_PB->setVisible(adv_state && !generate_new) ; + ui.exportIdentity_PB->setVisible(false); // not useful, and probably confusing ui.genPGPuser->setVisible(adv_state && haveGPGKeys && !generate_new) ; @@ -317,6 +318,11 @@ void GenCertDialog::setupState() ui.password_input->setVisible(true); ui.password_label->setVisible(true); + if(generate_new) + ui.password_input->setToolTip(tr("

Put a strong password here. This password will be required to start your Retroshare node and protects all your data.

")); + else + ui.password_input->setToolTip(tr("

Please supply the existing password for the selected profile above.

")); + ui.password2_check_LB->setVisible(generate_new); ui.password2_input->setVisible(generate_new); ui.password2_label->setVisible(generate_new); @@ -468,7 +474,10 @@ bool GenCertDialog::importIdentity() RsAccounts::GetPGPLoginDetails(gpg_id, name, email); std::cerr << "Adding PGPUser: " << name << " id: " << gpg_id << std::endl; - QMessageBox::information(this,tr("New profile imported"),tr("Your profile was imported successfully:")+" \n"+"\nName :"+QString::fromStdString(name)+"\nemail: " + QString::fromStdString(email)+"\nKey ID: "+QString::fromStdString(gpg_id.toStdString())+"\n\n"+tr("You can use it now to create a new node.")) ; + QMessageBox::information(this,tr("New profile imported"),tr("Your profile was imported successfully:")+" \n"+"\nName :"+QString::fromStdString(name)+"\nKey ID: "+QString::fromStdString(gpg_id.toStdString())+"\n\n"+tr("You can use it now to create a new node.")) ; + + initKeyList(); + setupState(); return true ; } diff --git a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp index c6be06b6e..fc56ebef5 100644 --- a/retroshare-gui/src/gui/connect/ConfCertDialog.cpp +++ b/retroshare-gui/src/gui/connect/ConfCertDialog.cpp @@ -306,11 +306,15 @@ QString ConfCertDialog::getCertificateDescription(const RsPeerDetails& detail,bo infotext += "
    " ; if(use_short_format) + { infotext += "
  • a Profile fingerprint"; + infotext += " (" + QString::fromUtf8(detail.name.c_str()) + "@" + detail.fpr.toStdString().c_str()+") " ; + } else - infotext += "
  • a Profile key"; - - infotext += " (" + QString::fromUtf8(detail.name.c_str()) + "@" + detail.gpg_id.toStdString().c_str()+") " ; + { + infotext += "
  • a Profile public key"; + infotext += " (" + QString::fromUtf8(detail.name.c_str()) + "@" + detail.gpg_id.toStdString().c_str()+") " ; + } if(signatures_included && !use_short_format) infotext += tr("with")+" "+QString::number(detail.gpgSigners.size()-1)+" "+tr("external signatures
  • ") ; diff --git a/retroshare-gui/src/gui/settings/CryptoPage.ui b/retroshare-gui/src/gui/settings/CryptoPage.ui index 50c0c84fb..bbda9302c 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.ui +++ b/retroshare-gui/src/gui/settings/CryptoPage.ui @@ -14,7 +14,7 @@ - 0 + 1 @@ -541,7 +541,7 @@ - + 0 0 @@ -569,6 +569,9 @@ + + <html><head/><body><p>This option includes all signatures of your profile key. Signatures are not mandatory, but only a way to express your trust in some particular profile.</p></body></html> + Include signatures @@ -576,6 +579,9 @@ + + <html><head/><body><p>The short format only contains the profile fingerprint, and authentication is based on the node ID (ID of the SSL key). If you choose the old (long) format, the certificate includes the full profile public key. There is no fundamental difference between making friends with either method, because the public profile keys will be exchanged and checked w.r.t. the fingerprint after connection.</p></body></html> + Short format @@ -601,7 +607,7 @@ - Save Key into a file + <html><head/><body><p>Saves your profile key pair into a file. This allows you to create a new node for the same profile, by importing this key pair on a different computer. Friends who already accept connections from you will automatically accept connections from that new node after you add them yourself. Your key is exported encrypted and you will need your login password to create a new profile.</p></body></html> Save certificate to file From 15ac7eecc85cf2d165bc3646e22e362068282dbf Mon Sep 17 00:00:00 2001 From: hunbernd Date: Thu, 26 Dec 2019 00:01:14 +0100 Subject: [PATCH 10/11] Cache sticker icons --- retroshare-gui/src/gui/common/Emoticons.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/common/Emoticons.cpp b/retroshare-gui/src/gui/common/Emoticons.cpp index 1bc58b871..347d88b6e 100644 --- a/retroshare-gui/src/gui/common/Emoticons.cpp +++ b/retroshare-gui/src/gui/common/Emoticons.cpp @@ -45,6 +45,7 @@ static QVector grpOrdered; static QStringList filters; static QStringList stickerFolders; static QHash tooltipcache; +static QHash iconcache; void Emoticons::load() { @@ -398,7 +399,11 @@ void Emoticons::showStickerWidget(QWidget *parent, QWidget *button, const char * QPushButton *button = new QPushButton("", tabGrpWidget); button->setIconSize(QSize(buttonWidth, buttonHeight)); button->setFixedSize(QSize(buttonWidth, buttonHeight)); - button->setIcon(QPixmap(fi.absoluteFilePath())); + if(!iconcache.contains(fi.absoluteFilePath())) + { + iconcache.insert(fi.absoluteFilePath(), QPixmap(fi.absoluteFilePath()).scaled(buttonWidth, buttonHeight, Qt::KeepAspectRatio)); + } + button->setIcon(iconcache[fi.absoluteFilePath()]); button->setToolTip(fi.fileName()); button->setStatusTip(fi.absoluteFilePath()); button->setStyleSheet("QPushButton:hover {border: 3px solid #0099cc; border-radius: 3px;}"); From cb68cb73d026d8823e154d70308077c837c26724 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Thu, 26 Dec 2019 00:04:19 +0100 Subject: [PATCH 11/11] Optimized image embedding algorithm --- retroshare-gui/src/util/imageutil.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/util/imageutil.cpp b/retroshare-gui/src/util/imageutil.cpp index f30f26cc9..c507bfa05 100644 --- a/retroshare-gui/src/util/imageutil.cpp +++ b/retroshare-gui/src/util/imageutil.cpp @@ -73,14 +73,12 @@ bool ImageUtil::optimizeSize(QString &html, const QImage& original, QImage &opti //nothing to do if it fits into the limits optimized = original; if ((maxPixels <= 0) || (optimized.width()*optimized.height() <= maxPixels)) { - if(checkSize(html, optimized, maxBytes) <= maxBytes) { + int s = checkSize(html, optimized, maxBytes); + if((maxBytes <= 0) || (s <= maxBytes)) { return true; } } - QVector ct; - quantization(original, ct); - //Downscale the image to fit into maxPixels double whratio = (qreal)original.width() / (qreal)original.height(); int maxwidth; @@ -98,6 +96,9 @@ bool ImageUtil::optimizeSize(QString &html, const QImage& original, QImage &opti return true; } + QVector ct; + quantization(original, ct); + //Use binary search to find a suitable image size + linear regression to guess the file size double maxsize = (double)checkSize(html, optimized = original.scaledToWidth(maxwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct, Qt::ThresholdDither), maxBytes); if(maxsize <= maxBytes) return true; //success