From c2fc2e998d90006b00fbb945168a96e05c10bea7 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Tue, 4 Aug 2020 19:08:16 +0300 Subject: [PATCH 01/11] Remove screenshot feature --- graphics.qrc | 1 + img/material/black/delete.png | Bin 0 -> 6803 bytes img/material/black/delete.svg | 7 ++ src/utils/history.h | 2 +- src/widgets/historywidget.cpp | 194 +++++++++++++++++++++------------- src/widgets/historywidget.h | 5 + 6 files changed, 134 insertions(+), 75 deletions(-) create mode 100644 img/material/black/delete.png create mode 100644 img/material/black/delete.svg diff --git a/graphics.qrc b/graphics.qrc index 87a2a790..43919bdc 100644 --- a/graphics.qrc +++ b/graphics.qrc @@ -2,6 +2,7 @@ img/app/flameshot.svg img/app/flameshot.png + img/material/black/delete.svg img/material/black/undo-variant.svg img/material/black/text.svg img/material/black/square.svg diff --git a/img/material/black/delete.png b/img/material/black/delete.png new file mode 100644 index 0000000000000000000000000000000000000000..024a1100afb102c888a6f2625b00d938fe8f122d GIT binary patch literal 6803 zcmV;E8f@i>P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3;eb|X8CZT~rn8Up)fIBeH?GkC+V4KgH$+@*b8 zskEgGF&HG8g98w$=KueHOZ^Xjk_lP)ka8?BYX11*i>-Xf`ur*Tx6yw8KL2=pXI`(X z=NFbsj(2zdnd&vZay`7=@SLZ;URU}0#^!4x^PG79aq?vOJnoC+x;@v8za}d4e268d z`%>FAQNIT6rCdL@U!$(E@^5v&;1g0Bfd@Hjr!!9P-}$V-ouA52-oHKL%>Ha#QM?5g zugMU|%l01cTHgiqBIL&>^vi3|lV!YQ#D`D6FyY;G_k4`KKiEB2WM98% z%hV6sxqj9fd98VNSA9gH@vU^@K6KZOS2x92 zw6c`(W|(T0nftw)&Jw+yHt}w4w{Bm{F4mx}C~7F5Bl?%zkd! z&+AzI(8Dm)8YVN`^5si?_vLS1YOO9JGCDtH#k#E6HOmmq$!|uX5VJ15g)QL6>r%hI z*$<|Q2E!I}W`h+a?kQR@Z?@&Oo*m-?@5hCVO5>UU5%KK6VvIurIvN*DG&)(Ej6seW z1yxpV@r{NCObB+cNb8-8RwbLQJezxx*<)?6(aL482}R&QE}@&^D$4RcU_Z%cY^Vko zdJI(qjrEa1umkXv}(p#*=6O zgSMhGosIWaG$%UK#o`pfvdAF1QNxJFP@$j3hGm|*d(+&H^rk}ok>2dTG^a#${}-B5 zsP3cQKGE6`xa(VE#|uTK+TneSsWvNqwC2}$@2;n{VxEiJicO^^`80BfjwcvAC3V$J zSi!7042oIPfTr4&eT%L=4Yy`1Y;yrxn4TMUg;d{i{WNhFwvD7b>(@IlEhIttsWP&;aL4@!>KRo!$clD!zX8N`oYg;{M zZ~}=L&!TxKRweuPiuGB!@cpnLb3R00{Xzs8L0Mu(Y`{@Ts)oKIV82XgEp)7Yu<2TY z?zLspLdY{=AT8CAl4zl0EyN!Yfi4)Rd`e5rC?6)Ko+d-qvOzEYuBLNmNE>WAws&X)Kx*4cYCzBxPf zoFO=@+{`gm!F~q@)eX{2Y4zgW*iV_581kCff80hnMMM~Q8(|^*i8y2&5eHp^N0?x+ ze%mT{hSYicIPk+bF^}<6^_zty2iuz59;#ad*Tlglz!U4%tD8$4C8@r*fzG(GOgBcb zA&x%cimCJnc%Y4G@e9{RwXN^lCme0;)y@y8P*y6KF<1{TheWn*LXPXqhYTjbT^Bq%;~T(U_oJ1Fm*Q~-hu!iL#<4g2 z&DKQ|H7FcP$ z6tFGx58@J(lY0qSb8X_rWY)E^l=%5p&1^L+i7h>4!H;k(*P1Ysa8*L^8a=mVk&6r5 zw?tbwh$dcICEBV*v?VLv+SUtnHOVm>EhhF*uzGtGHL4Q?24STR0$n?#0L#n_;V*aWf+JNn6*h8a6*R~@Is>@=+sa|eYcq)eAaumz~HctcB} zLMsblh^(dKTq^>W5x@a8Jd`>5i86qxRwl7uo;Pkp2=Xyyc~D5>jwwQP_e#=?;V=c@ zuGO68z+h}|z6=ElE)VhZ(3G-DH6@9;4(CO9H6XkN+0ZtzT6UgtS)rBMSs*h2G0wLb zi}E07sn!Iv~fS(@dq#+!r^%SBGL?e^dL{%w4w0o1NH2cl^$k&nxL*ImP zM1dd@YK5jVH>+{o88KE;7G4-YF>W;5tM8&J z5%oM4V#zd!r<><5KP>!=rKr>}eRuYrUiU6iGI!qr4J=kg#FjK|;Uj!xstM+i9iEF6>XT|pmkVv!1fEnz7i z7Q}$fsolaA9T0~{7ZLzGR}x=@v36ory9XpjRSgV0$z1?Is^mDBj}s1%S=@HgNCX2> z$Z&StL+r;}F&R`^2k4L#6udKa9;DdSB@OL>Z4e~06xvWa898xt$5(7li))NTR0Szg z4AaI|iuFQk{3y+?E_8f{cbu@FaGZCPK6{quXUSTYi6UireB2HWFvU%e2gy1gV5`%+a85?1jST_W!A{6Lt~NM4LH4HS+cdA*^BtgappAn&hI zR9}RQ$EFU$FxDJK#GUQ}S|>RjqMDZY?*&tlbu5weMIn?v0`b9gfM_Ryq;akD7bPtV zAr|WxWee7m6oJ`hxXF{ol#v?|qyW}{~np=uLUQ&FFM*kp%*J2uOsa?$}mPHFKM{q~g2J{dZIkUk&HhE_< zztKl#6m~>R5%HU~i5A;{GCWEfQY;d~K4cxkF77IBgk9YDVw}1U6pTQK4~)>}@zE2_ z;z&h_IjrnU9+5G3P1jFzKzD`j|4M$CM}6y?puUpvkL;hY|rEmU!7A z0-1;JiY-38^UaoDOj+!xKV6f@jrTQGV#e3O@?gpyr@kL}udGU3l2Yb@!EN8RUiu|D z4sSTPQT5a$3GfK`g*YGdnX$a>-G28(cE&l|G70xNK-o_P7Hi<<;) znEHvn9)PMoLDb6{x7Nnd+8d^#wNF7+{To$9RvT9zsQM|Wstqh(VCt^=3#wj|l|9*e zNW~-gMvZkHO^By{jj1;)l=5M-$EDstRef#C?{QT^))QIh$wk%^GGDfK$JP6w*D?N6 zP*o39-AK3<`w>+|Rxh~v39PEGa*Jeu1cheQ$930ZdgESU6bv{(R<+qz69_knR(T_du$iNP6MudrovA=_f$?8q(Fe z;DC$U441%^vlC3b;r;P^WIQYF!ViyenCvt2L%0(#8j;>@$+}YRDCt@x5QN4 zndx7Msk$@MzYtS(XQqE4rs~UR{!3!2)_eT?kHl2nndx7Msrmhm}$+Nv18P2Cift z?zJn%`sf-Ll8rp?l+Oa*%|`^P&Ti9nn36XZ`SDgnbaS7#RYGQ7@U+E-8$9WEM-LLirF%CJBx>*!JlUdnYdA{wk3 z^~ODcwF4bD-&(QJ=OJhIK}T@&I$`PtWWa*PKHJ0>c)Aixld!w(te+s|({~*IbBeEi z&+$K}`0AG&U#NkpJ%(16R7G8N7FqkIA* zl8Mfa=5eD@G&wC|2R%c@a>MqXyh1n?^|UaNytuI$(O7z`xq1P%xz7-YN6R*4v@gT& zlRoxnWglrV(llwJ5#Lx+MUKWkNLW872ye0IoQrfTmG*OJna=sScqGp{9Z5^`43ACt z0T?u#j{z2?_?Cin>(#Ii9#xEv0KZQjEv|AjWPpUdJ)KkcW@;qsLZ6ss2}oR8b?qof z3yBQdb04bZR`-c3P+@X#16N@8-EEqg*bh9aJ`OFZ(zVP+e|`Zhk4(+x3# zbO&^hQisSwq;;^Wfu|)PXvO0Eva&OliZwK6F?0YeyHe zXSt;A2m^j3`GW+TfXIwiTf;my*--pSxCQ21=g#}(tS`tBksMUQL)vaHkwc)DCIbvZ znk)C&11LnitzNLv*6?LUICll};0!qi*~|sWAA-4SGqSogGKP^+V4B8g=4pJ0BpfWNFksE0}Ch zmRR0!Bv099t%L1XK*!e>0v=;U-T?7X&h#zlAuv}iDk_-qfv%?jOF*M_m^tLw7+WnE zoa@p>q-ti$-8nCj1DnCy>(W=}jKj#!L6pq1uKWzgJESb^p0psxV+xO*gFRHxd3V>L zU+l$cv-|3{fX25VdoUKBJ@wTwg$02~m?6{@O~e31v>1;SUcDVWgdH?3XF785E?j!! zgwm%!LfkLyXm>g&PLl^Rl{j&{&!=>}&$Q!x`SLx;*iLFb>jF7VAbYCyv#Hcq4JE&w zN)7XWGnG0!{QFeuA*{bnrQYQJx2e=!g@2h!y;{Q$ruw3Ir=HcjI`)I?+FgIyKuCpw zNoUf^^U*`H8x{FLl*=i|VYg{PT2)jX(#Ze@m(vjuW9()0E@&@DzI7+~LT}{C7Xka;qGEcjhe60oQmSw)kS+c4T9tvLfy)D&F<=FZSy7yy($=7uvR(-Q-_(tro9E` z!9u5GJu}uki1(+)Xs-7l1lw+oEKP-FXlde0&qlpn13++NdW3SERyYC90A@$Y8Fi8y z5VSej2cg~henj0KqRv6UUSchw)_LVmOPbHtOJod^EXe;KAx?nqQyMHRe3D(=i2znA zT?hXQu{d964UAz=0004mX+uL$Nkc;*aB^>EX>4Tx0C=2zkv&MmKpe$iKg1%H4(*`g zkfAzR5EXIMDionYs1;guFuC*#nlvOSE{=k0!NHHks)LKOt`4q(Aou~|}?mh0_0sdx{sb+8-P&LcQq>@4|zbf>;B7`6!h+x%k-{RDAVPqQ zIx48bLV{L}6cZWRPkQ)=9KT2|nOqexax9<*6_Voz|AXJ%n#IWpHz}M1dR}b%V+82k z1zHW;{yw(t)(H@J2ClS@zt#k1K1pwMwD=Ja*#<7IJDR))TteAw97&(F_YU0nhK0z^ba#l^+T z%gaGQLCDC+@9*z!Zf*ku0|5a6>gwvQuC5ms7Zel}sHmv=`ucZwclGu4;o;#lG&CFM3w-ObI-%*@OwDJfA=QGkGeSy@>!GBQ|LSbu+i zwzjs}+1WcgJJ;9OmX?+|IXRP)lkDv55)u*(4Gjwm3wU^Vv$L}yAt9lmp;lH_?(Xg+ zBqWH4h;MIi{r&xOb8~}(gQTRSpP!#4B_(HPXJcby{QUedFfc4EERvFvk&%)3`1qKZ zn6IpoOiWBmOG{HzQ?RhGH#avB5D;W! zWYyKx($dmxZEfi2=!uDmM@L6WN=i*lO^%L^)6>&yYiku173=Hkii(PMc6K~GJhHN~ zH8nM{v9UrzLdVC)R8&+yKR>3Xrb$UjS65dmDk`k3tYBbZNJvPBhlg}@bmQaW)YQ~2 zE-t*hytufyw6wI0jEtkBqpz>8oSd9bPfxz>%0d!JM zQvg8b*k%9#00Cl4M??UK1szBL000SaNLh0L04^f{04^f|c%?sf00007bV*G`2jmC@ z4-+}drJ)4?004VQL_t(2&tqVK0d6p0zyP};61%ZTfVE*tuyYqNFcfjKqZy3}aLF*> z1Hxbv;YNdqGZ3a31H)zz-_{ny+swdV22lobBG}NTCI$#=_wbXD12J1AKs-4V32c$Z zz`X=rVhKb-?H0O(wj3-HIg#V&EFzkwp~fCK-U0NQEB(o^NrM0Y002ovPDHLkV1jHP B&@2D| literal 0 HcmV?d00001 diff --git a/img/material/black/delete.svg b/img/material/black/delete.svg new file mode 100644 index 00000000..0fcbb634 --- /dev/null +++ b/img/material/black/delete.svg @@ -0,0 +1,7 @@ + + + + + Svg Vector Icons : http://www.onlinewebfonts.com/icon + + \ No newline at end of file diff --git a/src/utils/history.h b/src/utils/history.h index 6a2fc686..4f720336 100644 --- a/src/utils/history.h +++ b/src/utils/history.h @@ -1,7 +1,7 @@ #ifndef HISTORY_H #define HISTORY_H -#define HISTORY_MAX_SIZE 10 +#define HISTORY_MAX_SIZE 20 #define HISTORY_THUNB_SCALE 1.5 #define HISTORY_THUNB_WIDTH 160*HISTORY_THUNB_SCALE #define HISTORY_THUNB_HEIGH 90*HISTORY_THUNB_SCALE diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index 20b8140f..d13c68f3 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -18,6 +18,7 @@ #include #include #include +#include HistoryWidget::HistoryWidget(QWidget *parent) : QDialog(parent) @@ -43,88 +44,133 @@ HistoryWidget::HistoryWidget(QWidget *parent) : QDialog(parent) } void HistoryWidget::loadHistory() { - History history = History(); - QList historyFiles = history.history(); - + // get settings ConfigEnterprise configEnterprise; QSettings *settings = configEnterprise.settings(); settings->beginGroup("S3"); QString s3BaseUrl = settings->value("S3_URL").toString(); settings->endGroup(); + // read history files + History history = History(); + QList historyFiles = history.history(); + if(historyFiles.isEmpty()) { - QPushButton *buttonEmpty = new QPushButton; - buttonEmpty->setText(tr("Screenshots history is empty")); - buttonEmpty->setMinimumSize(1, HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - connect(buttonEmpty, &QPushButton::clicked, this, [=](){ - this->close(); - }); - m_pVBox->addWidget(buttonEmpty); - return; + setEmptyMessage(); } - foreach(QString fileName, historyFiles) { - // generate url - QString fullFileName = history.path() + fileName; - QString url = s3BaseUrl + fileName; - - // load pixmap - QPixmap pixmap; - pixmap.load( fullFileName, "png" ); - - if (pixmap.height() / HISTORYPIXMAP_MAX_PREVIEW_HEIGHT >= pixmap.width() / HISTORYPIXMAP_MAX_PREVIEW_WIDTH) { - pixmap = pixmap.scaledToHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - } else { - pixmap = pixmap.scaledToWidth(HISTORYPIXMAP_MAX_PREVIEW_WIDTH); + else { + // generate history list + foreach(QString fileName, historyFiles) { + addLine(s3BaseUrl + fileName, history.path() + fileName); } - - // get file info - QFileInfo *pFileInfo = new QFileInfo(fullFileName); - QString lastModified = pFileInfo->lastModified().toString(" yyyy-MM-dd hh:mm:ss"); - - // screenshot preview - QLabel *pScreenshot = new QLabel(); - pScreenshot->setStyleSheet("padding: 5px;"); - pScreenshot->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - pScreenshot->setPixmap(pixmap); - - // screenshot datetime - QLabel *pScreenshotText = new QLabel(); - pScreenshotText->setStyleSheet("padding: 5px;"); - pScreenshotText->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - pScreenshotText->setText(lastModified); - - // copy url - QPushButton *buttonCopyUrl = new QPushButton; - buttonCopyUrl->setText(tr("Copy URL")); - buttonCopyUrl->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - connect(buttonCopyUrl, &QPushButton::clicked, this, [=](){ - QApplication::clipboard()->setText(url); - m_notification->showMessage(tr("URL copied to clipboard.")); - this->close(); - }); - - // open in browser - QPushButton *buttonOpen = new QPushButton; - buttonOpen->setText(tr("Open in browser")); - buttonOpen->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - connect(buttonOpen, &QPushButton::clicked, this, [=](){ - QDesktopServices::openUrl(QUrl(url)); - this->close(); - }); - - // layout - QHBoxLayout *phbl = new QHBoxLayout(); - phbl->addWidget(pScreenshot); - phbl->addWidget(pScreenshotText); - phbl->addWidget(buttonCopyUrl); - phbl->addWidget(buttonOpen); - - phbl->setStretchFactor(pScreenshot, 3); - phbl->setStretchFactor(pScreenshotText, 2); - phbl->setStretchFactor(buttonCopyUrl, 2); - phbl->setStretchFactor(buttonOpen, 2); - - // add to scroll - m_pVBox->addLayout(phbl); + } +} + +void HistoryWidget::setEmptyMessage() { + QPushButton *buttonEmpty = new QPushButton; + buttonEmpty->setText(tr("Screenshots history is empty")); + buttonEmpty->setMinimumSize(1, HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + connect(buttonEmpty, &QPushButton::clicked, this, [=](){ + this->close(); + }); + m_pVBox->addWidget(buttonEmpty); +} + +void HistoryWidget::addLine(const QString &url, const QString &fullFileName) { + QHBoxLayout *phbl = new QHBoxLayout(); + + // load pixmap + QPixmap pixmap; + pixmap.load( fullFileName, "png" ); + + if (pixmap.height() / HISTORYPIXMAP_MAX_PREVIEW_HEIGHT >= pixmap.width() / HISTORYPIXMAP_MAX_PREVIEW_WIDTH) { + pixmap = pixmap.scaledToHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + } else { + pixmap = pixmap.scaledToWidth(HISTORYPIXMAP_MAX_PREVIEW_WIDTH); + } + + // get file info + QFileInfo *pFileInfo = new QFileInfo(fullFileName); + QString lastModified = pFileInfo->lastModified().toString(" yyyy-MM-dd\nhh:mm:ss"); + + // screenshot preview + QLabel *pScreenshot = new QLabel(); + pScreenshot->setStyleSheet("padding: 5px;"); + pScreenshot->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + pScreenshot->setPixmap(pixmap); + + // screenshot datetime + QLabel *pScreenshotText = new QLabel(); + pScreenshotText->setStyleSheet("padding: 5px;"); + pScreenshotText->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + pScreenshotText->setAlignment(Qt::AlignCenter); + pScreenshotText->setText(lastModified); + + // copy url + QPushButton *buttonCopyUrl = new QPushButton; + buttonCopyUrl->setText(tr("Copy URL")); + buttonCopyUrl->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + connect(buttonCopyUrl, &QPushButton::clicked, this, [=](){ + QApplication::clipboard()->setText(url); + m_notification->showMessage(tr("URL copied to clipboard.")); + this->close(); + }); + + // open in browser + QPushButton *buttonOpen = new QPushButton; + buttonOpen->setText(tr("Open in browser")); + buttonOpen->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + connect(buttonOpen, &QPushButton::clicked, this, [=](){ + QDesktopServices::openUrl(QUrl(url)); + this->close(); + }); + + // delete + QPushButton *buttonDelete = new QPushButton; + buttonDelete->setIcon(QIcon(":/img/material/black/delete.svg")); + buttonDelete->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + connect(buttonDelete, &QPushButton::clicked, this, [=](){ + removeItem(phbl, fullFileName); + }); + + // layout + phbl->addWidget(pScreenshot); + phbl->addWidget(pScreenshotText); + phbl->addWidget(buttonCopyUrl); + phbl->addWidget(buttonOpen); + phbl->addWidget(buttonDelete); + + phbl->setStretchFactor(pScreenshot, 6); + phbl->setStretchFactor(pScreenshotText, 4); + phbl->setStretchFactor(buttonCopyUrl, 4); + phbl->setStretchFactor(buttonOpen, 4); + phbl->setStretchFactor(buttonDelete, 1); + + + // add to scroll + m_pVBox->addLayout(phbl); +} + +void HistoryWidget::removeItem(QLayout *pl, const QString &fullFileName) { + // TODO - send delete request + qDebug() << "Delete image on S3"; + + // delete cached image on local dist + QFile file(fullFileName); + file.remove(); + + // remove current row or refresh list + while(pl->count() > 0) + { + QLayoutItem *item = pl->takeAt(0); + delete item->widget(); + delete item; + } + m_pVBox->removeItem(pl); + delete pl; + + // set "empty" message if no items left + if(m_pVBox->count() == 0) { + setEmptyMessage(); } } diff --git a/src/widgets/historywidget.h b/src/widgets/historywidget.h index e0f1bac1..c685a501 100644 --- a/src/widgets/historywidget.h +++ b/src/widgets/historywidget.h @@ -7,7 +7,9 @@ #include #include #include +#include +class QLayout; class QVBoxLayout; class NotificationWidget; @@ -21,6 +23,9 @@ signals: private: void loadHistory(); + void addLine(const QString &, const QString &); + void removeItem(QLayout *, const QString &); + void setEmptyMessage(); private: QVBoxLayout *m_pVBox; From 4fda2cd4f6f4747c7bf4f60cf798252f9d5af234 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Wed, 5 Aug 2020 17:30:40 +0300 Subject: [PATCH 02/11] Code refactoring - remove hardcode for fields list --- src/tools/imgs3/imgs3uploader.cpp | 83 ++++++------------------------- 1 file changed, 14 insertions(+), 69 deletions(-) diff --git a/src/tools/imgs3/imgs3uploader.cpp b/src/tools/imgs3/imgs3uploader.cpp index 6357a7b5..ca3441e9 100644 --- a/src/tools/imgs3/imgs3uploader.cpp +++ b/src/tools/imgs3/imgs3uploader.cpp @@ -226,78 +226,23 @@ void ImgS3Uploader::handleCredsReply(QNetworkReply *reply){ } void ImgS3Uploader::uploadToS3(QJsonDocument &response) { - QJsonObject json = response.object(); - QJsonObject formData = json["formData"].toObject(); - QJsonObject fields = formData["fields"].toObject(); - - QString resultURL = json["resultURL"].toString(); - - QString url = formData["url"].toString(); - - QString acl = fields["acl"].toString(); - QString contentType = fields["Content-Type"].toString(); - QString key = fields["Key"].toString(); - QString bucket = fields["bucket"].toString(); - QString xAmzAlgorithm = fields["X-Amz-Algorithm"].toString(); - QString xAmzCredential = fields["X-Amz-Credential"].toString(); - QString xAmzDate = fields["X-Amz-Date"].toString(); - QString xAmzSecurityToken = fields["X-Amz-Security-Token"].toString(); - QString policy = fields["Policy"].toString(); - QString xAmzSignature = fields["X-Amz-Signature"].toString(); - - // + // set paramets from "fields" QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); - QHttpPart aclPart; - aclPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"acl\"")); - aclPart.setBody(acl.toLatin1()); - multiPart->append(aclPart); - - QHttpPart contentTypePart; - contentTypePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"Content-Type\"")); - contentTypePart.setBody(contentType.toLatin1()); - multiPart->append(contentTypePart); - - QHttpPart keyPart; - keyPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"Key\"")); - keyPart.setBody(key.toLatin1()); - multiPart->append(keyPart); - - QHttpPart bucketPart; - bucketPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"bucket\"")); - bucketPart.setBody(bucket.toLatin1()); - multiPart->append(bucketPart); - - QHttpPart xAmzAlgorithmPart; - xAmzAlgorithmPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"X-Amz-Algorithm\"")); - xAmzAlgorithmPart.setBody(xAmzAlgorithm.toLatin1()); - multiPart->append(xAmzAlgorithmPart); - - QHttpPart xAmzCredentialPart; - xAmzCredentialPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"X-Amz-Credential\"")); - xAmzCredentialPart.setBody(xAmzCredential.toLatin1()); - multiPart->append(xAmzCredentialPart); - - QHttpPart xAmzDatePart; - xAmzDatePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"X-Amz-Date\"")); - xAmzDatePart.setBody(xAmzDate.toLatin1()); - multiPart->append(xAmzDatePart); - - QHttpPart xAmzSecurityTokenPart; - xAmzSecurityTokenPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"X-Amz-Security-Token\"")); - xAmzSecurityTokenPart.setBody(xAmzSecurityToken.toLatin1()); - multiPart->append(xAmzSecurityTokenPart); - - QHttpPart policyPart; - policyPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"Policy\"")); - policyPart.setBody(policy.toLatin1()); - multiPart->append(policyPart); - - QHttpPart xAmzSignaturePart; - xAmzSignaturePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"X-Amz-Signature\"")); - xAmzSignaturePart.setBody(xAmzSignature.toLatin1()); - multiPart->append(xAmzSignaturePart); + // read JSON response + QJsonObject json = response.object(); + QString resultURL = json["resultURL"].toString(); + QJsonObject formData = json["formData"].toObject(); + QString url = formData["url"].toString(); + QJsonObject fields = formData["fields"].toObject(); + foreach (auto key, fields.keys()) { + QString field = fields[key].toString(); + QHttpPart part; + part.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"" + key + "\"")); + part.setBody(field.toLatin1()); + multiPart->append(part); + } QHttpPart imagePart; imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png")); From 0175d7fd02fe14212e833ac595849f2ab4c79dd1 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Thu, 6 Aug 2020 15:17:13 +0300 Subject: [PATCH 03/11] Remove screenshot from s3 bucket --- flameshot.pro | 2 + src/tools/imgs3/imgs3settings.cpp | 35 +++++++++++ src/tools/imgs3/imgs3settings.h | 27 +++++++++ src/tools/imgs3/imgs3uploader.cpp | 83 ++++++++++++++++++--------- src/tools/imgs3/imgs3uploader.h | 26 ++++++--- src/tools/imgs3/imgs3uploadertool.cpp | 4 +- src/widgets/historywidget.cpp | 75 ++++++++++++++---------- src/widgets/historywidget.h | 4 +- 8 files changed, 190 insertions(+), 66 deletions(-) create mode 100644 src/tools/imgs3/imgs3settings.cpp create mode 100644 src/tools/imgs3/imgs3settings.h diff --git a/flameshot.pro b/flameshot.pro index 93a4e828..86ba63b3 100644 --- a/flameshot.pro +++ b/flameshot.pro @@ -85,6 +85,7 @@ DEFINES += QAPPLICATION_CLASS=QApplication SOURCES += src/main.cpp \ src/config/filepathconfiguration.cpp \ + src/tools/imgs3/imgs3settings.cpp \ src/widgets/historywidget.cpp \ src/utils/configenterprise.cpp \ src/utils/history.cpp \ @@ -164,6 +165,7 @@ SOURCES += src/main.cpp \ HEADERS += src/widgets/capture/buttonhandler.h \ src/config/filepathconfiguration.h \ + src/tools/imgs3/imgs3settings.h \ src/widgets/historywidget.h \ src/utils/configenterprise.h \ src/utils/history.h \ diff --git a/src/tools/imgs3/imgs3settings.cpp b/src/tools/imgs3/imgs3settings.cpp new file mode 100644 index 00000000..9fef1c02 --- /dev/null +++ b/src/tools/imgs3/imgs3settings.cpp @@ -0,0 +1,35 @@ +#include "imgs3settings.h" +#include "src/utils/configenterprise.h" +#include + +ImgS3Settings::ImgS3Settings() +{ + m_configEnterprise = new ConfigEnterprise(); + + // get s3 credentials + QSettings *settings = m_configEnterprise->settings(); + settings->beginGroup("S3"); + + m_credsUrl = settings->value("S3_CREDS_URL").toString(); + m_credsUrl = m_credsUrl + (m_credsUrl.length() > 0 && m_credsUrl.at(m_credsUrl.length() - 1) == "/" ? "" : "/") + S3_API_IMG_PATH; + + m_xApiKey = settings->value("S3_X_API_KEY").toString(); + + m_url = settings->value("S3_URL").toString(); + m_url = m_url + (m_url.length() > 0 && m_url.at(m_url.length() - 1) == "/" ? "" : "/"); + + settings->endGroup(); + +} + +const QString &ImgS3Settings::credsUrl() { + return m_credsUrl; +} + +const QString &ImgS3Settings::xApiKey() { + return m_xApiKey; +} + +const QString &ImgS3Settings::url() { + return m_url; +} diff --git a/src/tools/imgs3/imgs3settings.h b/src/tools/imgs3/imgs3settings.h new file mode 100644 index 00000000..d44b79e2 --- /dev/null +++ b/src/tools/imgs3/imgs3settings.h @@ -0,0 +1,27 @@ +#ifndef IMGS3SETTINGS_H +#define IMGS3SETTINGS_H + +#define S3_API_IMG_PATH "v2/image/" + + +#include + +class ConfigEnterprise; + +class ImgS3Settings +{ +public: + ImgS3Settings(); + + const QString &credsUrl(); + const QString &xApiKey(); + const QString &url(); + +private: + ConfigEnterprise *m_configEnterprise; + QString m_credsUrl; + QString m_xApiKey; + QString m_url; +}; + +#endif // IMGS3SETTINGS_H diff --git a/src/tools/imgs3/imgs3uploader.cpp b/src/tools/imgs3/imgs3uploader.cpp index ca3441e9..a8932e41 100644 --- a/src/tools/imgs3/imgs3uploader.cpp +++ b/src/tools/imgs3/imgs3uploader.cpp @@ -50,15 +50,25 @@ ImgS3Uploader::ImgS3Uploader(const QPixmap &capture, QWidget *parent) : QWidget(parent), m_pixmap(capture) { + init(tr("Upload image to S3"), tr("Uploading Image")); +} + +ImgS3Uploader::ImgS3Uploader(QWidget *parent) : + QWidget(parent) +{ + init(tr("Delete image from S3"), tr("Deleting Image")); +} + +void ImgS3Uploader::init(const QString &title, const QString &label) { m_proxy = nullptr; - setWindowTitle(tr("Upload to ImgS3")); + setWindowTitle(title); setWindowIcon(QIcon(":img/app/flameshot.svg")); m_spinner = new LoadSpinner(this); m_spinner->setColor(ConfigHandler().uiMainColorValue()); m_spinner->start(); - m_infoLabel = new QLabel(tr("Uploading Image")); + m_infoLabel = new QLabel(label); m_vLayout = new QVBoxLayout(); setLayout(m_vLayout); @@ -71,23 +81,19 @@ ImgS3Uploader::ImgS3Uploader(const QPixmap &capture, QWidget *parent) : m_configEnterprise = new ConfigEnterprise(); // get s3 credentials - QSettings *settings = m_configEnterprise->settings(); - settings->beginGroup("S3"); - m_s3CredsUrl = settings->value("S3_CREDS_URL").toString(); - m_s3XApiKey = settings->value("S3_X_API_KEY").toString(); - settings->endGroup(); - initNetwork(); - upload(); } void ImgS3Uploader::initNetwork() { // Init network - m_NetworkAM = new QNetworkAccessManager(this); - connect(m_NetworkAM, &QNetworkAccessManager::finished, this, &ImgS3Uploader::handleReply); + m_NetworkAMUpload = new QNetworkAccessManager(this); + connect(m_NetworkAMUpload, &QNetworkAccessManager::finished, this, &ImgS3Uploader::handleReplyUpload); - m_NetworkAMCreds = new QNetworkAccessManager(this); - connect(m_NetworkAMCreds, &QNetworkAccessManager::finished, this, &ImgS3Uploader::handleCredsReply); + m_NetworkAMGetCreds = new QNetworkAccessManager(this); + connect(m_NetworkAMGetCreds, &QNetworkAccessManager::finished, this, &ImgS3Uploader::handleReplyGetCreds); + + m_NetworkAMRemove = new QNetworkAccessManager(this); + connect(m_NetworkAMRemove, &QNetworkAccessManager::finished, this, &ImgS3Uploader::handleReplyDeleteResource); // get proxy settings from "config.ini" file QSettings *settings = m_configEnterprise->settings(); @@ -137,7 +143,7 @@ void ImgS3Uploader::initNetwork() { } else { // Get proxy settings from OS settings - QNetworkProxyQuery q(QUrl(m_s3CredsUrl.toUtf8())); + QNetworkProxyQuery q(QUrl(m_s3Settings.credsUrl().toUtf8())); q.setQueryType(QNetworkProxyQuery::UrlRequest); q.setProtocolTag("http"); @@ -160,10 +166,10 @@ void ImgS3Uploader::initNetwork() { qDebug() << "proxy user:" << (m_proxy->user().length() > 0 ? m_proxy->user() : "no user"); qDebug() << "proxy password:" << (m_proxy->password().length() > 0 ? "***" : "no password"); - QNetworkProxy::setApplicationProxy(*m_proxy); - m_NetworkAM->setProxy(*m_proxy); - m_NetworkAMCreds->setProxy(*m_proxy); + m_NetworkAMUpload->setProxy(*m_proxy); + m_NetworkAMGetCreds->setProxy(*m_proxy); + m_NetworkAMRemove->setProxy(*m_proxy); } else { qDebug() << "No proxy"; @@ -171,15 +177,16 @@ void ImgS3Uploader::initNetwork() { } -void ImgS3Uploader::handleReply(QNetworkReply *reply) { +void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { m_spinner->deleteLater(); if (reply->error() == QNetworkReply::NoError) { // save history QString imageName = m_imageURL.toString(); int lastSlash = imageName.lastIndexOf("/"); if (lastSlash >= 0) { - imageName = imageName.mid(lastSlash); + imageName = imageName.mid(lastSlash + 1); } + imageName = m_deleteToken + "-" + imageName; History history; history.save(m_pixmap, imageName); @@ -198,6 +205,20 @@ void ImgS3Uploader::handleReply(QNetworkReply *reply) { new QShortcut(Qt::Key_Escape, this, SLOT(close())); } +void ImgS3Uploader::handleReplyDeleteResource(QNetworkReply *reply) { + m_spinner->deleteLater(); + if (reply->error() == QNetworkReply::NoError) { + if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { + SystemNotification().sendMessage(QObject::tr("File is deleted from S3")); + close(); + } + } else { + QString reason = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString(); + m_infoLabel->setText(reply->errorString()); + } + new QShortcut(Qt::Key_Escape, this, SLOT(close())); +} + void ImgS3Uploader::startDrag() { QMimeData *mimeData = new QMimeData; mimeData->setUrls(QList { m_imageURL }); @@ -210,12 +231,12 @@ void ImgS3Uploader::startDrag() { dragHandler->exec(); } -void ImgS3Uploader::handleCredsReply(QNetworkReply *reply){ +void ImgS3Uploader::handleReplyGetCreds(QNetworkReply *reply){ if (reply->error() == QNetworkReply::NoError) { QJsonDocument response = QJsonDocument::fromJson(reply->readAll()); uploadToS3(response); } else { - if(m_s3CredsUrl.length() == 0){ + if(m_s3Settings.credsUrl().length() == 0){ m_infoLabel->setText("S3 Creds URL is not found in your configuration file"); } else { @@ -234,6 +255,7 @@ void ImgS3Uploader::uploadToS3(QJsonDocument &response) { QString resultURL = json["resultURL"].toString(); QJsonObject formData = json["formData"].toObject(); QString url = formData["url"].toString(); + m_deleteToken = json["deleteToken"].toString(); QJsonObject fields = formData["fields"].toObject(); foreach (auto key, fields.keys()) { @@ -261,17 +283,26 @@ void ImgS3Uploader::uploadToS3(QJsonDocument &response) { QUrl qUrl(url); QNetworkRequest request(qUrl); - m_NetworkAM->post(request, multiPart); + m_NetworkAMUpload->post(request, multiPart); +} + +void ImgS3Uploader::deleteResource(const QString &fileName, const QString &deleteToken) { + QNetworkRequest request; + request.setUrl(m_s3Settings.credsUrl().toUtf8() + fileName); + request.setRawHeader("X-API-Key", m_s3Settings.xApiKey().toLatin1()); + request.setRawHeader("Authorization", "Bearer " + deleteToken.toLatin1()); + m_NetworkAMRemove->deleteResource(request); } void ImgS3Uploader::upload() { // get creads - QUrl creds(m_s3CredsUrl); + QUrl creds(m_s3Settings.credsUrl()); QNetworkRequest requestCreds(creds); - if(m_s3XApiKey.length() > 0) { - requestCreds.setRawHeader(QByteArray("X-API-Key"), QByteArray(m_s3XApiKey.toLocal8Bit())); + if(m_s3Settings.xApiKey().length() > 0) { + requestCreds.setRawHeader(QByteArray("X-API-Key"), QByteArray(m_s3Settings.xApiKey().toLocal8Bit())); } - m_NetworkAMCreds->get(requestCreds); + m_deleteToken.clear(); + m_NetworkAMGetCreds->get(requestCreds); } void ImgS3Uploader::onUploadOk() { diff --git a/src/tools/imgs3/imgs3uploader.h b/src/tools/imgs3/imgs3uploader.h index 3df0a224..c7454258 100644 --- a/src/tools/imgs3/imgs3uploader.h +++ b/src/tools/imgs3/imgs3uploader.h @@ -17,6 +17,9 @@ #pragma once +#define S3_API_IMG_PATH "v2/image/" + +#include "imgs3settings.h" #include #include @@ -36,10 +39,14 @@ class ImgS3Uploader : public QWidget { Q_OBJECT public: explicit ImgS3Uploader(const QPixmap &capture, QWidget *parent = nullptr); + explicit ImgS3Uploader(QWidget *parent = nullptr); + void upload(); + void deleteResource(const QString &, const QString &); private slots: - void handleReply(QNetworkReply *reply); - void handleCredsReply(QNetworkReply *reply); + void handleReplyUpload(QNetworkReply *reply); + void handleReplyGetCreds(QNetworkReply *reply); + void handleReplyDeleteResource(QNetworkReply *reply); void startDrag(); void openURL(); @@ -47,19 +54,24 @@ private slots: void copyImage(); private: + void init(const QString &title, const QString &label); void uploadToS3(QJsonDocument &response); void initNetwork(); + void onUploadOk(); + +// class members private: ConfigEnterprise *m_configEnterprise; - QString m_s3CredsUrl; - QString m_s3XApiKey; + ImgS3Settings m_s3Settings; + QString m_deleteToken; QString m_hostName; QPixmap m_pixmap; QNetworkProxy *m_proxy; - QNetworkAccessManager *m_NetworkAM; - QNetworkAccessManager *m_NetworkAMCreds; + QNetworkAccessManager *m_NetworkAMUpload; + QNetworkAccessManager *m_NetworkAMGetCreds; + QNetworkAccessManager *m_NetworkAMRemove; QVBoxLayout *m_vLayout; QHBoxLayout *m_hLayout; @@ -73,6 +85,4 @@ private: QUrl m_imageURL; NotificationWidget *m_notification; - void upload(); - void onUploadOk(); }; diff --git a/src/tools/imgs3/imgs3uploadertool.cpp b/src/tools/imgs3/imgs3uploadertool.cpp index 99bf1856..45f04aaf 100644 --- a/src/tools/imgs3/imgs3uploadertool.cpp +++ b/src/tools/imgs3/imgs3uploadertool.cpp @@ -47,7 +47,9 @@ QString ImgS3UploaderTool::description() const { } QWidget *ImgS3UploaderTool::widget() { - return new ImgS3Uploader(capture); + ImgS3Uploader *p = new ImgS3Uploader(capture); + p->upload(); + return p; } void ImgS3UploaderTool::setCapture(const QPixmap &pixmap) { diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index d13c68f3..a7131891 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -1,7 +1,7 @@ #include "historywidget.h" #include "src/utils/history.h" -#include "src/utils/configenterprise.h" #include "src/widgets/notificationwidget.h" +#include "src/tools/imgs3/imgs3uploader.h" #include #include #include @@ -45,11 +45,6 @@ HistoryWidget::HistoryWidget(QWidget *parent) : QDialog(parent) void HistoryWidget::loadHistory() { // get settings - ConfigEnterprise configEnterprise; - QSettings *settings = configEnterprise.settings(); - settings->beginGroup("S3"); - QString s3BaseUrl = settings->value("S3_URL").toString(); - settings->endGroup(); // read history files History history = History(); @@ -61,7 +56,7 @@ void HistoryWidget::loadHistory() { else { // generate history list foreach(QString fileName, historyFiles) { - addLine(s3BaseUrl + fileName, history.path() + fileName); + addLine(history.path(), fileName); } } } @@ -76,8 +71,20 @@ void HistoryWidget::setEmptyMessage() { m_pVBox->addWidget(buttonEmpty); } -void HistoryWidget::addLine(const QString &url, const QString &fullFileName) { +void HistoryWidget::addLine(const QString &path, const QString& fileName) { QHBoxLayout *phbl = new QHBoxLayout(); + QString fullFileName = path + fileName; + QString s3FileName = fileName; + + // + QString deleteToken; + int nSeparatorIndex = s3FileName.indexOf("-"); + if(nSeparatorIndex >= 0) { + deleteToken = s3FileName.mid(0, nSeparatorIndex); + s3FileName = s3FileName.mid(nSeparatorIndex + 1, s3FileName.size()); + } + QString url = m_s3Settings.url() + s3FileName; + // load pixmap QPixmap pixmap; @@ -129,9 +136,14 @@ void HistoryWidget::addLine(const QString &url, const QString &fullFileName) { QPushButton *buttonDelete = new QPushButton; buttonDelete->setIcon(QIcon(":/img/material/black/delete.svg")); buttonDelete->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - connect(buttonDelete, &QPushButton::clicked, this, [=](){ - removeItem(phbl, fullFileName); - }); + if(deleteToken.size() > 0) { + connect(buttonDelete, &QPushButton::clicked, this, [=](){ + removeItem(phbl, fullFileName, s3FileName, deleteToken); + }); + } + else { + buttonDelete->setDisabled(true); + } // layout phbl->addWidget(pScreenshot); @@ -151,26 +163,29 @@ void HistoryWidget::addLine(const QString &url, const QString &fullFileName) { m_pVBox->addLayout(phbl); } -void HistoryWidget::removeItem(QLayout *pl, const QString &fullFileName) { - // TODO - send delete request - qDebug() << "Delete image on S3"; +void HistoryWidget::removeItem(QLayout *pl, const QString &fullFileName, const QString& s3FileName, const QString& deleteToken) { + ImgS3Uploader *uploader = new ImgS3Uploader(); + uploader->show(); + uploader->deleteResource(s3FileName, deleteToken); - // delete cached image on local dist - QFile file(fullFileName); - file.remove(); + connect(uploader, &QWidget::destroyed, this, [=](){ + // delete cached image on local dist + QFile file(fullFileName); + file.remove(); - // remove current row or refresh list - while(pl->count() > 0) - { - QLayoutItem *item = pl->takeAt(0); - delete item->widget(); - delete item; - } - m_pVBox->removeItem(pl); - delete pl; + // remove current row or refresh list + while(pl->count() > 0) + { + QLayoutItem *item = pl->takeAt(0); + delete item->widget(); + delete item; + } + m_pVBox->removeItem(pl); + delete pl; - // set "empty" message if no items left - if(m_pVBox->count() == 0) { - setEmptyMessage(); - } + // set "empty" message if no items left + if(m_pVBox->count() == 0) { + setEmptyMessage(); + } + }); } diff --git a/src/widgets/historywidget.h b/src/widgets/historywidget.h index c685a501..c80e9092 100644 --- a/src/widgets/historywidget.h +++ b/src/widgets/historywidget.h @@ -8,6 +8,7 @@ #include #include #include +#include "src/tools/imgs3/imgs3settings.h" class QLayout; class QVBoxLayout; @@ -24,10 +25,11 @@ signals: private: void loadHistory(); void addLine(const QString &, const QString &); - void removeItem(QLayout *, const QString &); + void removeItem(QLayout *, const QString &, const QString &, const QString &); void setEmptyMessage(); private: + ImgS3Settings m_s3Settings; QVBoxLayout *m_pVBox; NotificationWidget *m_notification; }; From fe1c37d28a81cde2b3c8992e7106ffa7c4493bb4 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Thu, 6 Aug 2020 16:29:48 +0300 Subject: [PATCH 04/11] Remove screenshot from s3 bucket and old format cache only --- src/widgets/historywidget.cpp | 67 ++++++++++++++++++----------------- src/widgets/historywidget.h | 1 + 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index a7131891..296a40c1 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -136,14 +136,9 @@ void HistoryWidget::addLine(const QString &path, const QString& fileName) { QPushButton *buttonDelete = new QPushButton; buttonDelete->setIcon(QIcon(":/img/material/black/delete.svg")); buttonDelete->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); - if(deleteToken.size() > 0) { - connect(buttonDelete, &QPushButton::clicked, this, [=](){ - removeItem(phbl, fullFileName, s3FileName, deleteToken); - }); - } - else { - buttonDelete->setDisabled(true); - } + connect(buttonDelete, &QPushButton::clicked, this, [=](){ + removeItem(phbl, fullFileName, s3FileName, deleteToken); + }); // layout phbl->addWidget(pScreenshot); @@ -158,34 +153,40 @@ void HistoryWidget::addLine(const QString &path, const QString& fileName) { phbl->setStretchFactor(buttonOpen, 4); phbl->setStretchFactor(buttonDelete, 1); - // add to scroll m_pVBox->addLayout(phbl); } void HistoryWidget::removeItem(QLayout *pl, const QString &fullFileName, const QString& s3FileName, const QString& deleteToken) { - ImgS3Uploader *uploader = new ImgS3Uploader(); - uploader->show(); - uploader->deleteResource(s3FileName, deleteToken); - - connect(uploader, &QWidget::destroyed, this, [=](){ - // delete cached image on local dist - QFile file(fullFileName); - file.remove(); - - // remove current row or refresh list - while(pl->count() > 0) - { - QLayoutItem *item = pl->takeAt(0); - delete item->widget(); - delete item; - } - m_pVBox->removeItem(pl); - delete pl; - - // set "empty" message if no items left - if(m_pVBox->count() == 0) { - setEmptyMessage(); - } - }); + if (deleteToken.length() > 0) { + ImgS3Uploader *uploader = new ImgS3Uploader(); + uploader->show(); + uploader->deleteResource(s3FileName, deleteToken); + connect(uploader, &QWidget::destroyed, this, [=](){ + removeLocalItem(pl, fullFileName); + }); + } + else { + removeLocalItem(pl, fullFileName); + } +} + +void HistoryWidget::removeLocalItem(QLayout *pl, const QString &fullFileName) { + QFile file(fullFileName); + file.remove(); + + // remove current row or refresh list + while(pl->count() > 0) + { + QLayoutItem *item = pl->takeAt(0); + delete item->widget(); + delete item; + } + m_pVBox->removeItem(pl); + delete pl; + + // set "empty" message if no items left + if(m_pVBox->count() == 0) { + setEmptyMessage(); + } } diff --git a/src/widgets/historywidget.h b/src/widgets/historywidget.h index c80e9092..064a2db4 100644 --- a/src/widgets/historywidget.h +++ b/src/widgets/historywidget.h @@ -26,6 +26,7 @@ private: void loadHistory(); void addLine(const QString &, const QString &); void removeItem(QLayout *, const QString &, const QString &, const QString &); + void removeLocalItem(QLayout *, const QString &); void setEmptyMessage(); private: From 3053541827da25a37139284a4abedd8cb0d1e670 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Thu, 6 Aug 2020 16:35:29 +0300 Subject: [PATCH 05/11] Save cached images on local dist in original size to be able to copy to clipboard later --- src/utils/history.cpp | 6 +----- src/utils/history.h | 5 +---- src/widgets/historywidget.cpp | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/utils/history.cpp b/src/utils/history.cpp index 4cade7a8..ed4a46e7 100644 --- a/src/utils/history.cpp +++ b/src/utils/history.cpp @@ -28,11 +28,7 @@ const QString &History::path() { void History::save(const QPixmap &pixmap, const QString &fileName) { QFile file(path() + fileName); file.open(QIODevice::WriteOnly); - pixmap.scaled(HISTORY_THUNB_WIDTH, - HISTORY_THUNB_HEIGH, - Qt::KeepAspectRatio, - Qt::SmoothTransformation - ).save(&file, "PNG"); + pixmap.save(&file, "PNG"); history(); } diff --git a/src/utils/history.h b/src/utils/history.h index 4f720336..c1888639 100644 --- a/src/utils/history.h +++ b/src/utils/history.h @@ -1,10 +1,7 @@ #ifndef HISTORY_H #define HISTORY_H -#define HISTORY_MAX_SIZE 20 -#define HISTORY_THUNB_SCALE 1.5 -#define HISTORY_THUNB_WIDTH 160*HISTORY_THUNB_SCALE -#define HISTORY_THUNB_HEIGH 90*HISTORY_THUNB_SCALE +#define HISTORY_MAX_SIZE 25 #include #include diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index 296a40c1..7a66cfe9 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -85,7 +85,6 @@ void HistoryWidget::addLine(const QString &path, const QString& fileName) { } QString url = m_s3Settings.url() + s3FileName; - // load pixmap QPixmap pixmap; pixmap.load( fullFileName, "png" ); From aba85cbf5207d14eaf1c6349bbd7be7f790ef7d4 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Thu, 6 Aug 2020 18:57:14 +0300 Subject: [PATCH 06/11] Hide history window during waiting for delete screenshot from S3 --- src/tools/imgs3/imgs3uploader.cpp | 7 +++++++ src/tools/imgs3/imgs3uploader.h | 2 ++ src/widgets/historywidget.cpp | 15 +++++++++------ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/tools/imgs3/imgs3uploader.cpp b/src/tools/imgs3/imgs3uploader.cpp index a8932e41..ea5beb88 100644 --- a/src/tools/imgs3/imgs3uploader.cpp +++ b/src/tools/imgs3/imgs3uploader.cpp @@ -61,6 +61,7 @@ ImgS3Uploader::ImgS3Uploader(QWidget *parent) : void ImgS3Uploader::init(const QString &title, const QString &label) { m_proxy = nullptr; + m_success = false; setWindowTitle(title); setWindowIcon(QIcon(":img/app/flameshot.svg")); @@ -194,6 +195,7 @@ void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { QApplication::clipboard()->setText(m_imageURL.toString()); SystemNotification().sendMessage(QObject::tr("URL copied to clipboard.")); + m_success = true; close(); } else { onUploadOk(); @@ -209,6 +211,7 @@ void ImgS3Uploader::handleReplyDeleteResource(QNetworkReply *reply) { m_spinner->deleteLater(); if (reply->error() == QNetworkReply::NoError) { if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { + m_success = true; SystemNotification().sendMessage(QObject::tr("File is deleted from S3")); close(); } @@ -351,3 +354,7 @@ void ImgS3Uploader::copyImage() { QApplication::clipboard()->setPixmap(m_pixmap); m_notification->showMessage(tr("Screenshot copied to clipboard.")); } + +bool ImgS3Uploader::success() { + return m_success; +} diff --git a/src/tools/imgs3/imgs3uploader.h b/src/tools/imgs3/imgs3uploader.h index c7454258..0298c4b7 100644 --- a/src/tools/imgs3/imgs3uploader.h +++ b/src/tools/imgs3/imgs3uploader.h @@ -42,6 +42,7 @@ public: explicit ImgS3Uploader(QWidget *parent = nullptr); void upload(); void deleteResource(const QString &, const QString &); + bool success(); private slots: void handleReplyUpload(QNetworkReply *reply); @@ -62,6 +63,7 @@ private: // class members private: + bool m_success; ConfigEnterprise *m_configEnterprise; ImgS3Settings m_s3Settings; QString m_deleteToken; diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index 7a66cfe9..6e15bd6e 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -159,10 +159,14 @@ void HistoryWidget::addLine(const QString &path, const QString& fileName) { void HistoryWidget::removeItem(QLayout *pl, const QString &fullFileName, const QString& s3FileName, const QString& deleteToken) { if (deleteToken.length() > 0) { ImgS3Uploader *uploader = new ImgS3Uploader(); + hide(); uploader->show(); uploader->deleteResource(s3FileName, deleteToken); connect(uploader, &QWidget::destroyed, this, [=](){ - removeLocalItem(pl, fullFileName); + if(uploader->success()) { + removeLocalItem(pl, fullFileName); + } + show(); }); } else { @@ -175,11 +179,10 @@ void HistoryWidget::removeLocalItem(QLayout *pl, const QString &fullFileName) { file.remove(); // remove current row or refresh list - while(pl->count() > 0) - { - QLayoutItem *item = pl->takeAt(0); - delete item->widget(); - delete item; + while(pl->count() > 0) { + QLayoutItem *item = pl->takeAt(0); + delete item->widget(); + delete item; } m_pVBox->removeItem(pl); delete pl; From cd9661bfa93296ba848272070b1bf18f8a9691d4 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Thu, 6 Aug 2020 19:02:04 +0300 Subject: [PATCH 07/11] Update translations --- translations/Internationalization_ca.ts | 49 ++++++++++++++-------- translations/Internationalization_de_DE.ts | 49 ++++++++++++++-------- translations/Internationalization_es.ts | 49 ++++++++++++++-------- translations/Internationalization_fr.ts | 49 ++++++++++++++-------- translations/Internationalization_hu.ts | 20 +++++++-- translations/Internationalization_ja.ts | 49 ++++++++++++++-------- translations/Internationalization_ka.ts | 49 ++++++++++++++-------- translations/Internationalization_nl.ts | 49 ++++++++++++++-------- translations/Internationalization_pl.ts | 49 ++++++++++++++-------- translations/Internationalization_pt_br.ts | 49 ++++++++++++++-------- translations/Internationalization_ru.ts | 49 +++++++++++++++------- translations/Internationalization_sk.ts | 49 ++++++++++++++-------- translations/Internationalization_sr.ts | 49 ++++++++++++++-------- translations/Internationalization_tr.ts | 49 ++++++++++++++-------- translations/Internationalization_uk.ts | 49 +++++++++++++++------- translations/Internationalization_zh_CN.ts | 49 ++++++++++++++-------- translations/Internationalization_zh_TW.ts | 49 ++++++++++++++-------- 17 files changed, 532 insertions(+), 272 deletions(-) diff --git a/translations/Internationalization_ca.ts b/translations/Internationalization_ca.ts index f5dc2206..88e1cf9b 100644 --- a/translations/Internationalization_ca.ts +++ b/translations/Internationalization_ca.ts @@ -440,27 +440,27 @@ Press Space to open the side panel. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL Copia l'URL - + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. - + Open in browser @@ -469,41 +469,51 @@ Press Space to open the side panel. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image S'està pujant la imatge - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL Copia l'URL - + Open URL Obri l'URL - + Image to Clipboard. Imatge al porta-retalls. - + Unable to open the URL. No es pot obrir l'URL. - + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. - + Screenshot copied to clipboard. La captura s'ha copiat al porta-retalls. @@ -800,11 +810,16 @@ Press Space to open the side panel. - + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_de_DE.ts b/translations/Internationalization_de_DE.ts index 18254720..923e695b 100644 --- a/translations/Internationalization_de_DE.ts +++ b/translations/Internationalization_de_DE.ts @@ -443,27 +443,27 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL URL kopieren - + URL copied to clipboard. URL kopiert. - + Open in browser @@ -472,41 +472,51 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Bild hochladen - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL URL kopieren - + Open URL URL öffnen - + Image to Clipboard. Bild in Zwischenablage. - + Unable to open the URL. Kann URL nicht öffnen. - + URL copied to clipboard. URL kopiert. - + Screenshot copied to clipboard. Bildschirmaufnahme in Zwischenablage kopiert. @@ -803,11 +813,16 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. Kein Schreibzugriff auf - + URL copied to clipboard. URL kopiert. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_es.ts b/translations/Internationalization_es.ts index 51ad0a58..d69311ff 100644 --- a/translations/Internationalization_es.ts +++ b/translations/Internationalization_es.ts @@ -443,27 +443,27 @@ Presiona Espacio para abrir el panel lateral. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL Copiar URL - + URL copied to clipboard. URL copiada al portapapeles. - + Open in browser @@ -472,41 +472,51 @@ Presiona Espacio para abrir el panel lateral. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Subiendo Imagen - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL Copiar URL - + Open URL Abrir URL - + Image to Clipboard. Imagen al Portapapeles. - + Unable to open the URL. No puede abrir la URL. - + URL copied to clipboard. URL copiada al portapapeles. - + Screenshot copied to clipboard. Captura copiada al portapapeles. @@ -803,11 +813,16 @@ Presiona Espacio para abrir el panel lateral. Imposible escribir en - + URL copied to clipboard. URL copiada al portapapeles. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_fr.ts b/translations/Internationalization_fr.ts index 24644a32..53b4810b 100644 --- a/translations/Internationalization_fr.ts +++ b/translations/Internationalization_fr.ts @@ -443,27 +443,27 @@ Appuyer sur Espace pour ouvrir le panneau latéral. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL Copier l'URL - + URL copied to clipboard. URL copiée dans le Presse-papier. - + Open in browser @@ -472,41 +472,51 @@ Appuyer sur Espace pour ouvrir le panneau latéral. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Mise en ligne de l'image - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL Copier l'URL - + Open URL Ouvrir l'URL - + Image to Clipboard. Image dans le Presse-papier. - + Unable to open the URL. Impossible d'ouvrir l'URL. - + URL copied to clipboard. URL copiée dans le Presse-papier. - + Screenshot copied to clipboard. Capture d'écran copiée dans le Presse-papier. @@ -803,11 +813,16 @@ Appuyer sur Espace pour ouvrir le panneau latéral. Imposible d'écrire par dessus - + URL copied to clipboard. URL copiée dans le Presse-papier. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_hu.ts b/translations/Internationalization_hu.ts index 2bc58ac8..ac4b15da 100644 --- a/translations/Internationalization_hu.ts +++ b/translations/Internationalization_hu.ts @@ -407,10 +407,6 @@ Press Space to open the side panel. ImgS3Uploader - - Upload to ImgS3 - - Uploading Image Kép felötlése @@ -439,6 +435,18 @@ Press Space to open the side panel. Screenshot copied to clipboard. Képernyőmentés másolva a vágólapra. + + Upload image to S3 + + + + Delete image from S3 + + + + Deleting Image + + ImgS3UploaderTool @@ -678,6 +686,10 @@ Press Space to open the side panel. URL copied to clipboard. URL másolva a vágólapra. + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_ja.ts b/translations/Internationalization_ja.ts index dd4e4e17..b66c93c7 100644 --- a/translations/Internationalization_ja.ts +++ b/translations/Internationalization_ja.ts @@ -443,27 +443,27 @@ Enter を押すと画面をキャプチャー。 HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL URL をコピー - + URL copied to clipboard. URL をクリップボードにコピーしました。 - + Open in browser @@ -472,41 +472,51 @@ Enter を押すと画面をキャプチャー。 ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image 画像をアップロード中 - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL URL をコピー - + Open URL URL を開く - + Image to Clipboard. 画像をクリップボードへ。 - + Unable to open the URL. URL を開けません。 - + URL copied to clipboard. URL をクリップボードにコピーしました。 - + Screenshot copied to clipboard. スクリーンショットをクリップボードにコピーしました。 @@ -803,11 +813,16 @@ Enter を押すと画面をキャプチャー。 書き込めません: - + URL copied to clipboard. URL をクリップボードにコピーしました。 + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_ka.ts b/translations/Internationalization_ka.ts index c9a573fe..32e628ec 100644 --- a/translations/Internationalization_ka.ts +++ b/translations/Internationalization_ka.ts @@ -439,27 +439,27 @@ Press Space to open the side panel. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL URL-ის კოპირება - + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. - + Open in browser @@ -468,41 +468,51 @@ Press Space to open the side panel. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image სურათის ატვირთვა - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL URL-ის კოპირება - + Open URL URL-ის გახსნა - + Image to Clipboard. სურათის გაცვლის ბუფერში გაგზავნა - + Unable to open the URL. URL-ის გახსნა ვერ მოხერხდა. - + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. - + Screenshot copied to clipboard. სურათი დაკოპირდა გაცვლის ბუფერში. @@ -799,11 +809,16 @@ Press Space to open the side panel. შემდეგ მისამართზე ჩაწერა ვერ მოხერხდა: - + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_nl.ts b/translations/Internationalization_nl.ts index 1cbbfd2d..4eb591d6 100644 --- a/translations/Internationalization_nl.ts +++ b/translations/Internationalization_nl.ts @@ -443,27 +443,27 @@ Druk op spatie om het zijpaneel te openen. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL URL kopiëren - + URL copied to clipboard. URL gekopieerd naar klembord. - + Open in browser @@ -472,41 +472,51 @@ Druk op spatie om het zijpaneel te openen. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Bezig met uploaden van afbeelding... - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL URL kopiëren - + Open URL URL openen - + Image to Clipboard. Afbeelding naar klembord. - + Unable to open the URL. Kan URL niet openen. - + URL copied to clipboard. URL gekopieerd naar klembord. - + Screenshot copied to clipboard. Schermafdruk gekopieerd naar klembord. @@ -803,11 +813,16 @@ Druk op spatie om het zijpaneel te openen. Kan niet wegschrijven naar - + URL copied to clipboard. URL gekopieerd naar klembord. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_pl.ts b/translations/Internationalization_pl.ts index e2c0ad36..8b9b1a16 100644 --- a/translations/Internationalization_pl.ts +++ b/translations/Internationalization_pl.ts @@ -442,27 +442,27 @@ Spacja, aby pokazać panel boczny. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL Kopiuj URL - + URL copied to clipboard. URL skopiowany do schowka. - + Open in browser @@ -471,41 +471,51 @@ Spacja, aby pokazać panel boczny. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Wysyłanie obrazka - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL Kopiuj URL - + Open URL Otwórz URL - + Image to Clipboard. Obrazek do schowka. - + Unable to open the URL. Nie można otworzyć adresu URL. - + URL copied to clipboard. URL skopiowany do schowka. - + Screenshot copied to clipboard. Zrzut ekranu skopiowany do schowka. @@ -802,11 +812,16 @@ Spacja, aby pokazać panel boczny. Nie można zapisać w - + URL copied to clipboard. URL skopiowany do schowka. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_pt_br.ts b/translations/Internationalization_pt_br.ts index 0699934e..a482f1ee 100644 --- a/translations/Internationalization_pt_br.ts +++ b/translations/Internationalization_pt_br.ts @@ -443,27 +443,27 @@ Pressione espaço abrir o painel lateral. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL Copiar URL - + URL copied to clipboard. URL copiada para o clipboard. - + Open in browser @@ -472,41 +472,51 @@ Pressione espaço abrir o painel lateral. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Upando Imagem - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL Copiar URL - + Open URL Abrir URL - + Image to Clipboard. Imagem no Clipboard. - + Unable to open the URL. Não foi possível abrir a URL. - + URL copied to clipboard. URL copiada para o clipboard. - + Screenshot copied to clipboard. Screenshot copiada para o clipboard. @@ -803,11 +813,16 @@ Pressione espaço abrir o painel lateral. Não foi possível escrever em - + URL copied to clipboard. URL copiada para o clipboard. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_ru.ts b/translations/Internationalization_ru.ts index 55b45049..16abfa0c 100644 --- a/translations/Internationalization_ru.ts +++ b/translations/Internationalization_ru.ts @@ -451,7 +451,7 @@ Press Space to open the side panel. HistoryWidget - + Screenshots history История скриншотов @@ -460,22 +460,22 @@ Press Space to open the side panel. История скриншотов пустая - + Screenshots history is empty История скриншотов пуста - + Copy URL Скопировать URL - + URL copied to clipboard. URL скопирован в буфер обмена. - + Open in browser Открыть в браузере @@ -483,22 +483,36 @@ Press Space to open the side panel. ImgS3Uploader - Upload to ImgS3 - Загрузить на S3 + Загрузить на S3 - + Uploading Image Загрузка изображения - + + Upload image to S3 + Загрузить на S3 + + + + Delete image from S3 + Удалить скриншот с S3 + + + + Deleting Image + Удалить скриншот + + + Copy URL Скопировать URL - + Open URL Открыть URL @@ -507,22 +521,22 @@ Press Space to open the side panel. Удалить изображение - + Image to Clipboard. Изображение в буфер обмена. - + Unable to open the URL. Не удалось открыть URL. - + URL copied to clipboard. URL скопирован в буфер обмена. - + Screenshot copied to clipboard. Снимок скопирован в буфер обмена. @@ -823,11 +837,16 @@ Press Space to open the side panel. Не удалось сохранить - + URL copied to clipboard. URL скопирован в буфер обмена. + + + File is deleted from S3 + Файл удален с S3 + RectangleTool diff --git a/translations/Internationalization_sk.ts b/translations/Internationalization_sk.ts index ca1c13ab..ad1b3cb6 100644 --- a/translations/Internationalization_sk.ts +++ b/translations/Internationalization_sk.ts @@ -443,27 +443,27 @@ Stlačte medzerník pre otvorenie postranného panelu. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL Kopírovať URL - + URL copied to clipboard. URL skopírovaná do schránky. - + Open in browser @@ -472,41 +472,51 @@ Stlačte medzerník pre otvorenie postranného panelu. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Nahrávam obrázok - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL Kopírovať URL - + Open URL Otvoriť URL - + Image to Clipboard. Obrázok do schránky. - + Unable to open the URL. Nepodarilo sa otvoriť URL. - + URL copied to clipboard. URL skopírovaná do schránky. - + Screenshot copied to clipboard. Snímka obrazovky bola skopírovaná do schránky. @@ -803,11 +813,16 @@ Stlačte medzerník pre otvorenie postranného panelu. Chyba pri ukladaní - + URL copied to clipboard. URL skopírovaná do schránky. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_sr.ts b/translations/Internationalization_sr.ts index 0017f9ed..e855495a 100644 --- a/translations/Internationalization_sr.ts +++ b/translations/Internationalization_sr.ts @@ -443,27 +443,27 @@ Press Space to open the side panel. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL Запамти интернет адресу - + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. - + Open in browser @@ -472,41 +472,51 @@ Press Space to open the side panel. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Објављујем слику - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL Запамти интернет адресу - + Open URL Посети интернет адресу - + Image to Clipboard. Сачувај у привремену меморију. - + Unable to open the URL. Нисам успео да посетим интернет адресу. - + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. - + Screenshot copied to clipboard. Слика је сачувана у привременој меморији. @@ -803,11 +813,16 @@ Press Space to open the side panel. Нисам успео са сачувам - + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_tr.ts b/translations/Internationalization_tr.ts index 4a710cf6..c3aecdf1 100644 --- a/translations/Internationalization_tr.ts +++ b/translations/Internationalization_tr.ts @@ -443,27 +443,27 @@ Yan paneli açmak için Boşluk tuşuna basın. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL URL Kopyala - + URL copied to clipboard. URL panoya kopyalandı. - + Open in browser @@ -472,41 +472,51 @@ Yan paneli açmak için Boşluk tuşuna basın. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image Resim Yükleniyor - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL URL Kopyala - + Open URL URL Aç - + Image to Clipboard. Resim Pano'ya. - + Unable to open the URL. URL açılamıyor. - + URL copied to clipboard. URL panoya kopyalandı. - + Screenshot copied to clipboard. Ekran görüntüsü panoya kopyalandı. @@ -803,11 +813,16 @@ Yan paneli açmak için Boşluk tuşuna basın. Yazma mümkün değil - + URL copied to clipboard. URL panoya kopyalandı. + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_uk.ts b/translations/Internationalization_uk.ts index 86721e74..64f5a140 100644 --- a/translations/Internationalization_uk.ts +++ b/translations/Internationalization_uk.ts @@ -451,7 +451,7 @@ Press Space to open the side panel. HistoryWidget - + Screenshots history Історія скріншотів @@ -460,22 +460,22 @@ Press Space to open the side panel. Історія скріншотів пуста - + Screenshots history is empty Історія скріншотів пуста - + Copy URL Скопіювати URL - + URL copied to clipboard. URL скопійовано до буферу обміну. - + Open in browser Відкрити у браузері @@ -483,22 +483,36 @@ Press Space to open the side panel. ImgS3Uploader - Upload to ImgS3 - Вивантажити на S3 + Вивантажити на S3 - + Uploading Image Вивантаження зображення - + + Upload image to S3 + Завантажити на S3 + + + + Delete image from S3 + Видалити скріншот з S3 + + + + Deleting Image + Видалити скіншот + + + Copy URL Скопіювати URL - + Open URL Відкрити URL @@ -507,22 +521,22 @@ Press Space to open the side panel. Видалити зображення - + Image to Clipboard. Зображення до буферу обміну. - + Unable to open the URL. Не вдалось відкрити URL. - + URL copied to clipboard. URL скопійовано до буферу обміну. - + Screenshot copied to clipboard. Знімок скопійовано до буферу обміну. @@ -823,11 +837,16 @@ Press Space to open the side panel. Не вдалось зберегти - + URL copied to clipboard. URL скопійовано до буферу обміну. + + + File is deleted from S3 + Файл видален з S3 + RectangleTool diff --git a/translations/Internationalization_zh_CN.ts b/translations/Internationalization_zh_CN.ts index c72fad5c..c92a0a6d 100644 --- a/translations/Internationalization_zh_CN.ts +++ b/translations/Internationalization_zh_CN.ts @@ -444,27 +444,27 @@ Press Space to open the side panel. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL 复制链接 - + URL copied to clipboard. 复制链接到剪贴板。 - + Open in browser @@ -473,41 +473,51 @@ Press Space to open the side panel. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image 正在上传 - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL 复制链接 - + Open URL 打开链接 - + Image to Clipboard. 保存文件到剪贴板。 - + Unable to open the URL. 无法打开此链接。 - + URL copied to clipboard. 复制链接到剪贴板。 - + Screenshot copied to clipboard. 截图复制到剪贴板。 @@ -804,11 +814,16 @@ Press Space to open the side panel. 无法写入 - + URL copied to clipboard. 复制链接到剪贴板。 + + + File is deleted from S3 + + RectangleTool diff --git a/translations/Internationalization_zh_TW.ts b/translations/Internationalization_zh_TW.ts index 51b53056..f1068344 100644 --- a/translations/Internationalization_zh_TW.ts +++ b/translations/Internationalization_zh_TW.ts @@ -439,27 +439,27 @@ Press Space to open the side panel. HistoryWidget - + Screenshots history - + Screenshots history is empty - + Copy URL 複製連結 - + URL copied to clipboard. 連結已複製到剪貼簿 - + Open in browser @@ -468,41 +468,51 @@ Press Space to open the side panel. ImgS3Uploader - Upload to ImgS3 - - - - Uploading Image 正在上傳 - + + Upload image to S3 + + + + + Delete image from S3 + + + + + Deleting Image + + + + Copy URL 複製連結 - + Open URL 打開連結 - + Image to Clipboard. 將檔案複製到剪貼簿 - + Unable to open the URL. 無法打開此連結 - + URL copied to clipboard. 連結已複製到剪貼簿 - + Screenshot copied to clipboard. 截圖已複製到剪貼簿 @@ -799,11 +809,16 @@ Press Space to open the side panel. 無法寫入 - + URL copied to clipboard. 連結已複製到剪貼簿 + + + File is deleted from S3 + + RectangleTool From 1f40697656def84eaa131d61d85c14d46df05a72 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Thu, 6 Aug 2020 20:42:58 +0300 Subject: [PATCH 08/11] Include storage type into history file name --- src/tools/imgs3/imgs3settings.cpp | 1 - src/tools/imgs3/imgs3uploader.cpp | 6 +-- src/utils/history.cpp | 43 ++++++++++++++++++++++ src/utils/history.h | 17 +++++++++ src/widgets/historywidget.cpp | 17 +++------ translations/Internationalization_ca.ts | 6 +-- translations/Internationalization_de_DE.ts | 6 +-- translations/Internationalization_es.ts | 6 +-- translations/Internationalization_fr.ts | 6 +-- translations/Internationalization_ja.ts | 6 +-- translations/Internationalization_ka.ts | 6 +-- translations/Internationalization_nl.ts | 6 +-- translations/Internationalization_pl.ts | 6 +-- translations/Internationalization_pt_br.ts | 6 +-- translations/Internationalization_ru.ts | 6 +-- translations/Internationalization_sk.ts | 6 +-- translations/Internationalization_sr.ts | 6 +-- translations/Internationalization_tr.ts | 6 +-- translations/Internationalization_uk.ts | 6 +-- translations/Internationalization_zh_CN.ts | 6 +-- translations/Internationalization_zh_TW.ts | 6 +-- 21 files changed, 116 insertions(+), 64 deletions(-) diff --git a/src/tools/imgs3/imgs3settings.cpp b/src/tools/imgs3/imgs3settings.cpp index 9fef1c02..76ac96ad 100644 --- a/src/tools/imgs3/imgs3settings.cpp +++ b/src/tools/imgs3/imgs3settings.cpp @@ -19,7 +19,6 @@ ImgS3Settings::ImgS3Settings() m_url = m_url + (m_url.length() > 0 && m_url.at(m_url.length() - 1) == "/" ? "" : "/"); settings->endGroup(); - } const QString &ImgS3Settings::credsUrl() { diff --git a/src/tools/imgs3/imgs3uploader.cpp b/src/tools/imgs3/imgs3uploader.cpp index ea5beb88..55a22e76 100644 --- a/src/tools/imgs3/imgs3uploader.cpp +++ b/src/tools/imgs3/imgs3uploader.cpp @@ -187,14 +187,14 @@ void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { if (lastSlash >= 0) { imageName = imageName.mid(lastSlash + 1); } - imageName = m_deleteToken + "-" + imageName; History history; + imageName = history.packFileName(SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, imageName); history.save(m_pixmap, imageName); // Copy url to clipboard if required if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { QApplication::clipboard()->setText(m_imageURL.toString()); - SystemNotification().sendMessage(QObject::tr("URL copied to clipboard.")); + SystemNotification().sendMessage(tr("URL copied to clipboard.")); m_success = true; close(); } else { @@ -212,7 +212,7 @@ void ImgS3Uploader::handleReplyDeleteResource(QNetworkReply *reply) { if (reply->error() == QNetworkReply::NoError) { if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { m_success = true; - SystemNotification().sendMessage(QObject::tr("File is deleted from S3")); + SystemNotification().sendMessage(tr("File is deleted from S3")); close(); } } else { diff --git a/src/utils/history.cpp b/src/utils/history.cpp index ed4a46e7..c58c6d60 100644 --- a/src/utils/history.cpp +++ b/src/utils/history.cpp @@ -3,6 +3,7 @@ #include #include #include +#include History::History() @@ -48,3 +49,45 @@ const QList &History::history() { } return m_thumbs; } + +const HISTORY_FILE_NAME &History::unpackFileName(const QString &fileNamePacked) { + int nPathIndex = fileNamePacked.lastIndexOf("/"); + QStringList unpackedFileName; + if(nPathIndex == -1) { + unpackedFileName = fileNamePacked.split("-"); + } else { + unpackedFileName = fileNamePacked.mid(nPathIndex + 1).split("-"); + } + + switch (unpackedFileName.length()) { + case 3: + m_unpackedFileName.file = unpackedFileName[2]; + m_unpackedFileName.token = unpackedFileName[1]; + m_unpackedFileName.type = unpackedFileName[0]; + break; + case 2: + m_unpackedFileName.file = unpackedFileName[1]; + m_unpackedFileName.token = ""; + m_unpackedFileName.type = unpackedFileName[0]; + break; + default: + m_unpackedFileName.file = unpackedFileName[0]; + m_unpackedFileName.token = ""; + m_unpackedFileName.type = SCREENSHOT_STORAGE_TYPE_LOCAL; + break; + } + return m_unpackedFileName; +} + +const QString &History::packFileName(const QString &storageType, const QString &deleteToken, const QString &fileName) { + m_packedFileName = fileName; + if(storageType.length() > 0) { + if(deleteToken.length() > 0) { + m_packedFileName = storageType + "-" + deleteToken + "-" + m_packedFileName; + } + else { + m_packedFileName = storageType + "-" + m_packedFileName; + } + } + return m_packedFileName; +} diff --git a/src/utils/history.h b/src/utils/history.h index c1888639..fc111615 100644 --- a/src/utils/history.h +++ b/src/utils/history.h @@ -8,6 +8,16 @@ #include +#define SCREENSHOT_STORAGE_TYPE_LOCAL "" +#define SCREENSHOT_STORAGE_TYPE_S3 "s3" +#define SCREENSHOT_STORAGE_TYPE_IMGUR "imgur" + +struct HISTORY_FILE_NAME { + QString file; + QString token; + QString type; +}; + class History { public: @@ -17,9 +27,16 @@ public: const QList &history(); const QString &path(); + const HISTORY_FILE_NAME &unpackFileName(const QString &); + const QString &packFileName(const QString &, const QString &, const QString &); + private: QString m_historyPath; QList m_thumbs; + + // temporary variables + QString m_packedFileName; + HISTORY_FILE_NAME m_unpackedFileName; }; #endif // HISTORY_H diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index 6e15bd6e..52127e31 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -44,8 +44,6 @@ HistoryWidget::HistoryWidget(QWidget *parent) : QDialog(parent) } void HistoryWidget::loadHistory() { - // get settings - // read history files History history = History(); QList historyFiles = history.history(); @@ -74,16 +72,11 @@ void HistoryWidget::setEmptyMessage() { void HistoryWidget::addLine(const QString &path, const QString& fileName) { QHBoxLayout *phbl = new QHBoxLayout(); QString fullFileName = path + fileName; - QString s3FileName = fileName; - // - QString deleteToken; - int nSeparatorIndex = s3FileName.indexOf("-"); - if(nSeparatorIndex >= 0) { - deleteToken = s3FileName.mid(0, nSeparatorIndex); - s3FileName = s3FileName.mid(nSeparatorIndex + 1, s3FileName.size()); - } - QString url = m_s3Settings.url() + s3FileName; + History history; + HISTORY_FILE_NAME unpackFileName = history.unpackFileName(fileName); + + QString url = m_s3Settings.url() + unpackFileName.file; // load pixmap QPixmap pixmap; @@ -136,7 +129,7 @@ void HistoryWidget::addLine(const QString &path, const QString& fileName) { buttonDelete->setIcon(QIcon(":/img/material/black/delete.svg")); buttonDelete->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); connect(buttonDelete, &QPushButton::clicked, this, [=](){ - removeItem(phbl, fullFileName, s3FileName, deleteToken); + removeItem(phbl, fullFileName, unpackFileName.file, unpackFileName.token); }); // layout diff --git a/translations/Internationalization_ca.ts b/translations/Internationalization_ca.ts index 88e1cf9b..1d1d58fc 100644 --- a/translations/Internationalization_ca.ts +++ b/translations/Internationalization_ca.ts @@ -450,17 +450,17 @@ Press Space to open the side panel. - + Copy URL Copia l'URL - + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. - + Open in browser diff --git a/translations/Internationalization_de_DE.ts b/translations/Internationalization_de_DE.ts index 923e695b..65e831a8 100644 --- a/translations/Internationalization_de_DE.ts +++ b/translations/Internationalization_de_DE.ts @@ -453,17 +453,17 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. - + Copy URL URL kopieren - + URL copied to clipboard. URL kopiert. - + Open in browser diff --git a/translations/Internationalization_es.ts b/translations/Internationalization_es.ts index d69311ff..e1765ccc 100644 --- a/translations/Internationalization_es.ts +++ b/translations/Internationalization_es.ts @@ -453,17 +453,17 @@ Presiona Espacio para abrir el panel lateral. - + Copy URL Copiar URL - + URL copied to clipboard. URL copiada al portapapeles. - + Open in browser diff --git a/translations/Internationalization_fr.ts b/translations/Internationalization_fr.ts index 53b4810b..4e01c58e 100644 --- a/translations/Internationalization_fr.ts +++ b/translations/Internationalization_fr.ts @@ -453,17 +453,17 @@ Appuyer sur Espace pour ouvrir le panneau latéral. - + Copy URL Copier l'URL - + URL copied to clipboard. URL copiée dans le Presse-papier. - + Open in browser diff --git a/translations/Internationalization_ja.ts b/translations/Internationalization_ja.ts index b66c93c7..24c09fd6 100644 --- a/translations/Internationalization_ja.ts +++ b/translations/Internationalization_ja.ts @@ -453,17 +453,17 @@ Enter を押すと画面をキャプチャー。 - + Copy URL URL をコピー - + URL copied to clipboard. URL をクリップボードにコピーしました。 - + Open in browser diff --git a/translations/Internationalization_ka.ts b/translations/Internationalization_ka.ts index 32e628ec..575840fe 100644 --- a/translations/Internationalization_ka.ts +++ b/translations/Internationalization_ka.ts @@ -449,17 +449,17 @@ Press Space to open the side panel. - + Copy URL URL-ის კოპირება - + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. - + Open in browser diff --git a/translations/Internationalization_nl.ts b/translations/Internationalization_nl.ts index 4eb591d6..6a372b5a 100644 --- a/translations/Internationalization_nl.ts +++ b/translations/Internationalization_nl.ts @@ -453,17 +453,17 @@ Druk op spatie om het zijpaneel te openen. - + Copy URL URL kopiëren - + URL copied to clipboard. URL gekopieerd naar klembord. - + Open in browser diff --git a/translations/Internationalization_pl.ts b/translations/Internationalization_pl.ts index 8b9b1a16..ebf2fab8 100644 --- a/translations/Internationalization_pl.ts +++ b/translations/Internationalization_pl.ts @@ -452,17 +452,17 @@ Spacja, aby pokazać panel boczny. - + Copy URL Kopiuj URL - + URL copied to clipboard. URL skopiowany do schowka. - + Open in browser diff --git a/translations/Internationalization_pt_br.ts b/translations/Internationalization_pt_br.ts index a482f1ee..67558d79 100644 --- a/translations/Internationalization_pt_br.ts +++ b/translations/Internationalization_pt_br.ts @@ -453,17 +453,17 @@ Pressione espaço abrir o painel lateral. - + Copy URL Copiar URL - + URL copied to clipboard. URL copiada para o clipboard. - + Open in browser diff --git a/translations/Internationalization_ru.ts b/translations/Internationalization_ru.ts index 16abfa0c..6bb1f6cc 100644 --- a/translations/Internationalization_ru.ts +++ b/translations/Internationalization_ru.ts @@ -465,17 +465,17 @@ Press Space to open the side panel. История скриншотов пуста - + Copy URL Скопировать URL - + URL copied to clipboard. URL скопирован в буфер обмена. - + Open in browser Открыть в браузере diff --git a/translations/Internationalization_sk.ts b/translations/Internationalization_sk.ts index ad1b3cb6..4e0e83d2 100644 --- a/translations/Internationalization_sk.ts +++ b/translations/Internationalization_sk.ts @@ -453,17 +453,17 @@ Stlačte medzerník pre otvorenie postranného panelu. - + Copy URL Kopírovať URL - + URL copied to clipboard. URL skopírovaná do schránky. - + Open in browser diff --git a/translations/Internationalization_sr.ts b/translations/Internationalization_sr.ts index e855495a..2d66a513 100644 --- a/translations/Internationalization_sr.ts +++ b/translations/Internationalization_sr.ts @@ -453,17 +453,17 @@ Press Space to open the side panel. - + Copy URL Запамти интернет адресу - + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. - + Open in browser diff --git a/translations/Internationalization_tr.ts b/translations/Internationalization_tr.ts index c3aecdf1..a77e882a 100644 --- a/translations/Internationalization_tr.ts +++ b/translations/Internationalization_tr.ts @@ -453,17 +453,17 @@ Yan paneli açmak için Boşluk tuşuna basın. - + Copy URL URL Kopyala - + URL copied to clipboard. URL panoya kopyalandı. - + Open in browser diff --git a/translations/Internationalization_uk.ts b/translations/Internationalization_uk.ts index 64f5a140..85ee98a7 100644 --- a/translations/Internationalization_uk.ts +++ b/translations/Internationalization_uk.ts @@ -465,17 +465,17 @@ Press Space to open the side panel. Історія скріншотів пуста - + Copy URL Скопіювати URL - + URL copied to clipboard. URL скопійовано до буферу обміну. - + Open in browser Відкрити у браузері diff --git a/translations/Internationalization_zh_CN.ts b/translations/Internationalization_zh_CN.ts index c92a0a6d..fc3d2850 100644 --- a/translations/Internationalization_zh_CN.ts +++ b/translations/Internationalization_zh_CN.ts @@ -454,17 +454,17 @@ Press Space to open the side panel. - + Copy URL 复制链接 - + URL copied to clipboard. 复制链接到剪贴板。 - + Open in browser diff --git a/translations/Internationalization_zh_TW.ts b/translations/Internationalization_zh_TW.ts index f1068344..dd72c6cc 100644 --- a/translations/Internationalization_zh_TW.ts +++ b/translations/Internationalization_zh_TW.ts @@ -449,17 +449,17 @@ Press Space to open the side panel. - + Copy URL 複製連結 - + URL copied to clipboard. 連結已複製到剪貼簿 - + Open in browser From 30a07f26bdb2db4e11c3fa11cf541441cc4bb48b Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Fri, 7 Aug 2020 12:20:53 +0300 Subject: [PATCH 09/11] Fix - delete screendhot issue in 'Copy url after upload' option disabled --- src/tools/imgs3/imgs3uploader.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/tools/imgs3/imgs3uploader.cpp b/src/tools/imgs3/imgs3uploader.cpp index 55a22e76..4cd5bd70 100644 --- a/src/tools/imgs3/imgs3uploader.cpp +++ b/src/tools/imgs3/imgs3uploader.cpp @@ -190,12 +190,12 @@ void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { History history; imageName = history.packFileName(SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, imageName); history.save(m_pixmap, imageName); + m_success = true; // Copy url to clipboard if required if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { QApplication::clipboard()->setText(m_imageURL.toString()); SystemNotification().sendMessage(tr("URL copied to clipboard.")); - m_success = true; close(); } else { onUploadOk(); @@ -210,11 +210,8 @@ void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { void ImgS3Uploader::handleReplyDeleteResource(QNetworkReply *reply) { m_spinner->deleteLater(); if (reply->error() == QNetworkReply::NoError) { - if (ConfigHandler().copyAndCloseAfterUploadEnabled()) { - m_success = true; - SystemNotification().sendMessage(tr("File is deleted from S3")); - close(); - } + m_success = true; + close(); } else { QString reason = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString(); m_infoLabel->setText(reply->errorString()); From 3da7e28acbb73faaa7dc346b9507a016dca29c07 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Fri, 7 Aug 2020 15:34:31 +0300 Subject: [PATCH 10/11] Include storage type into history file name --- src/tools/imgs3/imgs3uploader.cpp | 79 ++++++++++++++++++---- src/tools/imgs3/imgs3uploader.h | 13 +++- src/widgets/historywidget.cpp | 46 +++++++------ src/widgets/historywidget.h | 4 +- translations/Internationalization_ca.ts | 44 ++++++------ translations/Internationalization_de_DE.ts | 44 ++++++------ translations/Internationalization_es.ts | 44 ++++++------ translations/Internationalization_fr.ts | 44 ++++++------ translations/Internationalization_hu.ts | 22 +++--- translations/Internationalization_ja.ts | 44 ++++++------ translations/Internationalization_ka.ts | 44 ++++++------ translations/Internationalization_nl.ts | 44 ++++++------ translations/Internationalization_pl.ts | 44 ++++++------ translations/Internationalization_pt_br.ts | 44 ++++++------ translations/Internationalization_ru.ts | 50 +++++++++----- translations/Internationalization_sk.ts | 44 ++++++------ translations/Internationalization_sr.ts | 44 ++++++------ translations/Internationalization_tr.ts | 44 ++++++------ translations/Internationalization_uk.ts | 50 +++++++++----- translations/Internationalization_zh_CN.ts | 44 ++++++------ translations/Internationalization_zh_TW.ts | 44 ++++++------ 21 files changed, 530 insertions(+), 350 deletions(-) diff --git a/src/tools/imgs3/imgs3uploader.cpp b/src/tools/imgs3/imgs3uploader.cpp index 4cd5bd70..4231d6e9 100644 --- a/src/tools/imgs3/imgs3uploader.cpp +++ b/src/tools/imgs3/imgs3uploader.cpp @@ -56,11 +56,15 @@ ImgS3Uploader::ImgS3Uploader(const QPixmap &capture, QWidget *parent) : ImgS3Uploader::ImgS3Uploader(QWidget *parent) : QWidget(parent) { - init(tr("Delete image from S3"), tr("Deleting Image")); + init(tr("Delete image from S3"), tr("Deleting image...")); } void ImgS3Uploader::init(const QString &title, const QString &label) { m_proxy = nullptr; + + m_imageLabel = nullptr; + m_spinner = nullptr; + m_success = false; setWindowTitle(title); setWindowIcon(QIcon(":img/app/flameshot.svg")); @@ -70,6 +74,7 @@ void ImgS3Uploader::init(const QString &title, const QString &label) { m_spinner->start(); m_infoLabel = new QLabel(label); + m_infoLabel->setAlignment(Qt::AlignCenter); m_vLayout = new QVBoxLayout(); setLayout(m_vLayout); @@ -179,7 +184,8 @@ void ImgS3Uploader::initNetwork() { void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { - m_spinner->deleteLater(); + hideSpinner(); + m_s3ImageName.clear(); if (reply->error() == QNetworkReply::NoError) { // save history QString imageName = m_imageURL.toString(); @@ -187,6 +193,7 @@ void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { if (lastSlash >= 0) { imageName = imageName.mid(lastSlash + 1); } + m_s3ImageName = imageName; History history; imageName = history.packFileName(SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, imageName); history.save(m_pixmap, imageName); @@ -202,19 +209,30 @@ void ImgS3Uploader::handleReplyUpload(QNetworkReply *reply) { } } else { QString reason = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString(); - m_infoLabel->setText(reply->errorString()); + setInfoLabelText(reply->errorString()); } new QShortcut(Qt::Key_Escape, this, SLOT(close())); } void ImgS3Uploader::handleReplyDeleteResource(QNetworkReply *reply) { - m_spinner->deleteLater(); if (reply->error() == QNetworkReply::NoError) { m_success = true; + + // remove local file + History history; + QString packedFileName = history.packFileName(SCREENSHOT_STORAGE_TYPE_S3, m_deleteToken, m_s3ImageName); + QString fullFileName = history.path() + packedFileName; + + QFile file(fullFileName); + if (file.exists()) { + file.remove(); + } + m_deleteToken.clear(); + m_s3ImageName.clear(); close(); } else { QString reason = reply->attribute( QNetworkRequest::HttpReasonPhraseAttribute ).toString(); - m_infoLabel->setText(reply->errorString()); + setInfoLabelText(reply->errorString()); } new QShortcut(Qt::Key_Escape, this, SLOT(close())); } @@ -237,10 +255,10 @@ void ImgS3Uploader::handleReplyGetCreds(QNetworkReply *reply){ uploadToS3(response); } else { if(m_s3Settings.credsUrl().length() == 0){ - m_infoLabel->setText("S3 Creds URL is not found in your configuration file"); + setInfoLabelText(tr("S3 Creds URL is not found in your configuration file")); } else { - m_infoLabel->setText(reply->errorString()); + setInfoLabelText(reply->errorString()); } } new QShortcut(Qt::Key_Escape, this, SLOT(close())); @@ -288,6 +306,8 @@ void ImgS3Uploader::uploadToS3(QJsonDocument &response) { void ImgS3Uploader::deleteResource(const QString &fileName, const QString &deleteToken) { QNetworkRequest request; + m_s3ImageName = fileName; + m_deleteToken = deleteToken; request.setUrl(m_s3Settings.credsUrl().toUtf8() + fileName); request.setRawHeader("X-API-Key", m_s3Settings.xApiKey().toLatin1()); request.setRawHeader("Authorization", "Bearer " + deleteToken.toLatin1()); @@ -295,42 +315,50 @@ void ImgS3Uploader::deleteResource(const QString &fileName, const QString &delet } void ImgS3Uploader::upload() { + m_deleteToken.clear(); + m_s3ImageName.clear(); + // get creads QUrl creds(m_s3Settings.credsUrl()); QNetworkRequest requestCreds(creds); if(m_s3Settings.xApiKey().length() > 0) { requestCreds.setRawHeader(QByteArray("X-API-Key"), QByteArray(m_s3Settings.xApiKey().toLocal8Bit())); } - m_deleteToken.clear(); m_NetworkAMGetCreds->get(requestCreds); } void ImgS3Uploader::onUploadOk() { - m_infoLabel->deleteLater(); + hideSpinner(); m_notification = new NotificationWidget(); m_vLayout->addWidget(m_notification); - ImageLabel *imageLabel = new ImageLabel(); - imageLabel->setScreenshot(m_pixmap); - imageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - connect(imageLabel, &ImageLabel::dragInitiated, this, &ImgS3Uploader::startDrag); - m_vLayout->addWidget(imageLabel); + if(nullptr == m_imageLabel) { + m_imageLabel = new ImageLabel(); + m_imageLabel->setScreenshot(m_pixmap); + m_imageLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + connect(m_imageLabel, &ImageLabel::dragInitiated, this, &ImgS3Uploader::startDrag); + m_vLayout->addWidget(m_imageLabel); + } m_hLayout = new QHBoxLayout(); m_vLayout->addLayout(m_hLayout); m_copyUrlButton = new QPushButton(tr("Copy URL")); m_openUrlButton = new QPushButton(tr("Open URL")); + m_deleteImageOnS3 = new QPushButton(tr("Delete image")); m_toClipboardButton = new QPushButton(tr("Image to Clipboard.")); m_hLayout->addWidget(m_copyUrlButton); m_hLayout->addWidget(m_openUrlButton); + m_hLayout->addWidget(m_deleteImageOnS3); m_hLayout->addWidget(m_toClipboardButton); connect(m_copyUrlButton, &QPushButton::clicked, this, &ImgS3Uploader::copyURL); connect(m_openUrlButton, &QPushButton::clicked, this, &ImgS3Uploader::openURL); + connect(m_deleteImageOnS3, &QPushButton::clicked, + this, &ImgS3Uploader::deleteImageOnS3); connect(m_toClipboardButton, &QPushButton::clicked, this, &ImgS3Uploader::copyImage); } @@ -352,6 +380,29 @@ void ImgS3Uploader::copyImage() { m_notification->showMessage(tr("Screenshot copied to clipboard.")); } +void ImgS3Uploader::deleteImageOnS3() { + if(nullptr != m_imageLabel) { + m_imageLabel->hide(); + } + m_spinner->show(); + setInfoLabelText(tr("Deleting image...")); + deleteResource(m_s3ImageName, m_deleteToken); +} + bool ImgS3Uploader::success() { return m_success; } + +void ImgS3Uploader::hideSpinner() { + if(nullptr != m_spinner) { + m_spinner->hide(); + } + if(nullptr != m_imageLabel) { + m_imageLabel->hide(); + } +} + +void ImgS3Uploader::setInfoLabelText(const QString &infoText) { + m_infoLabel->setText(infoText); + m_infoLabel->show(); +} diff --git a/src/tools/imgs3/imgs3uploader.h b/src/tools/imgs3/imgs3uploader.h index 0298c4b7..9c90e207 100644 --- a/src/tools/imgs3/imgs3uploader.h +++ b/src/tools/imgs3/imgs3uploader.h @@ -34,6 +34,7 @@ class QPushButton; class QUrl; class NotificationWidget; class ConfigEnterprise; +class ImageLabel; class ImgS3Uploader : public QWidget { Q_OBJECT @@ -53,6 +54,7 @@ private slots: void openURL(); void copyURL(); void copyImage(); + void deleteImageOnS3(); private: void init(const QString &title, const QString &label); @@ -61,12 +63,17 @@ private: void onUploadOk(); + void hideSpinner(); + void setInfoLabelText(const QString &); + + // class members private: bool m_success; ConfigEnterprise *m_configEnterprise; ImgS3Settings m_s3Settings; - QString m_deleteToken; + + ImageLabel *m_imageLabel; QString m_hostName; QPixmap m_pixmap; @@ -84,7 +91,11 @@ private: QPushButton *m_openUrlButton; QPushButton *m_copyUrlButton; QPushButton *m_toClipboardButton; + QPushButton *m_deleteImageOnS3; QUrl m_imageURL; NotificationWidget *m_notification; + // Temporary variables + QString m_deleteToken; + QString m_s3ImageName; }; diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index 52127e31..138069a9 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -24,7 +24,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : QDialog(parent) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - setWindowTitle(tr("Screenshots history")); + setWindowTitle(tr("Latest Uploads")); setFixedSize(800, this->height()); m_notification = new NotificationWidget(); @@ -129,7 +129,17 @@ void HistoryWidget::addLine(const QString &path, const QString& fileName) { buttonDelete->setIcon(QIcon(":/img/material/black/delete.svg")); buttonDelete->setMinimumHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); connect(buttonDelete, &QPushButton::clicked, this, [=](){ - removeItem(phbl, fullFileName, unpackFileName.file, unpackFileName.token); + if (unpackFileName.token.length() > 0) { + removeItem(phbl, unpackFileName.file, unpackFileName.token); + } + else { + // for compatibility with previous versions and to be able to remove previous screenshots + QFile file(fullFileName); + if (file.exists()) { + file.remove(); + } + removeLocalItem(phbl); + } }); // layout @@ -149,28 +159,20 @@ void HistoryWidget::addLine(const QString &path, const QString& fileName) { m_pVBox->addLayout(phbl); } -void HistoryWidget::removeItem(QLayout *pl, const QString &fullFileName, const QString& s3FileName, const QString& deleteToken) { - if (deleteToken.length() > 0) { - ImgS3Uploader *uploader = new ImgS3Uploader(); - hide(); - uploader->show(); - uploader->deleteResource(s3FileName, deleteToken); - connect(uploader, &QWidget::destroyed, this, [=](){ - if(uploader->success()) { - removeLocalItem(pl, fullFileName); - } - show(); - }); - } - else { - removeLocalItem(pl, fullFileName); - } +void HistoryWidget::removeItem(QLayout *pl, const QString& s3FileName, const QString& deleteToken) { + ImgS3Uploader *uploader = new ImgS3Uploader(); + hide(); + uploader->show(); + uploader->deleteResource(s3FileName, deleteToken); + connect(uploader, &QWidget::destroyed, this, [=](){ + if(uploader->success()) { + removeLocalItem(pl); + } + show(); + }); } -void HistoryWidget::removeLocalItem(QLayout *pl, const QString &fullFileName) { - QFile file(fullFileName); - file.remove(); - +void HistoryWidget::removeLocalItem(QLayout *pl) { // remove current row or refresh list while(pl->count() > 0) { QLayoutItem *item = pl->takeAt(0); diff --git a/src/widgets/historywidget.h b/src/widgets/historywidget.h index 064a2db4..b29cb000 100644 --- a/src/widgets/historywidget.h +++ b/src/widgets/historywidget.h @@ -25,8 +25,8 @@ signals: private: void loadHistory(); void addLine(const QString &, const QString &); - void removeItem(QLayout *, const QString &, const QString &, const QString &); - void removeLocalItem(QLayout *, const QString &); + void removeItem(QLayout *pl, const QString& s3FileName, const QString& deleteToken); + void removeLocalItem(QLayout *pl); void setEmptyMessage(); private: diff --git a/translations/Internationalization_ca.ts b/translations/Internationalization_ca.ts index 1d1d58fc..531de07d 100644 --- a/translations/Internationalization_ca.ts +++ b/translations/Internationalization_ca.ts @@ -441,26 +441,26 @@ Press Space to open the side panel. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL Copia l'URL - + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. - + Open in browser @@ -483,37 +483,49 @@ Press Space to open the side panel. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL Copia l'URL - + Open URL Obri l'URL - + + Delete image + + + + Image to Clipboard. Imatge al porta-retalls. - + Unable to open the URL. No es pot obrir l'URL. - + + URL copied to clipboard. L'URL s'ha copiat al porta-retalls. - + + + Deleting image... + + + + Screenshot copied to clipboard. La captura s'ha copiat al porta-retalls. @@ -810,16 +822,10 @@ Press Space to open the side panel. - URL copied to clipboard. L'URL s'ha copiat al porta-retalls. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_de_DE.ts b/translations/Internationalization_de_DE.ts index 65e831a8..362f135d 100644 --- a/translations/Internationalization_de_DE.ts +++ b/translations/Internationalization_de_DE.ts @@ -444,26 +444,26 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL URL kopieren - + URL copied to clipboard. URL kopiert. - + Open in browser @@ -486,37 +486,49 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL URL kopieren - + Open URL URL öffnen - + + Delete image + Bild löschen + + + Image to Clipboard. Bild in Zwischenablage. - + Unable to open the URL. Kann URL nicht öffnen. - + + URL copied to clipboard. URL kopiert. - + + + Deleting image... + + + + Screenshot copied to clipboard. Bildschirmaufnahme in Zwischenablage kopiert. @@ -813,16 +825,10 @@ Drücke die Leertaste um das Seitenmenü zu öffnen. Kein Schreibzugriff auf - URL copied to clipboard. URL kopiert. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_es.ts b/translations/Internationalization_es.ts index e1765ccc..a1c72751 100644 --- a/translations/Internationalization_es.ts +++ b/translations/Internationalization_es.ts @@ -444,26 +444,26 @@ Presiona Espacio para abrir el panel lateral. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL Copiar URL - + URL copied to clipboard. URL copiada al portapapeles. - + Open in browser @@ -486,37 +486,49 @@ Presiona Espacio para abrir el panel lateral. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL Copiar URL - + Open URL Abrir URL - + + Delete image + Borrar imagen + + + Image to Clipboard. Imagen al Portapapeles. - + Unable to open the URL. No puede abrir la URL. - + + URL copied to clipboard. URL copiada al portapapeles. - + + + Deleting image... + + + + Screenshot copied to clipboard. Captura copiada al portapapeles. @@ -813,16 +825,10 @@ Presiona Espacio para abrir el panel lateral. Imposible escribir en - URL copied to clipboard. URL copiada al portapapeles. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_fr.ts b/translations/Internationalization_fr.ts index 4e01c58e..5ef43c67 100644 --- a/translations/Internationalization_fr.ts +++ b/translations/Internationalization_fr.ts @@ -444,26 +444,26 @@ Appuyer sur Espace pour ouvrir le panneau latéral. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL Copier l'URL - + URL copied to clipboard. URL copiée dans le Presse-papier. - + Open in browser @@ -486,37 +486,49 @@ Appuyer sur Espace pour ouvrir le panneau latéral. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL Copier l'URL - + Open URL Ouvrir l'URL - + + Delete image + + + + Image to Clipboard. Image dans le Presse-papier. - + Unable to open the URL. Impossible d'ouvrir l'URL. - + + URL copied to clipboard. URL copiée dans le Presse-papier. - + + + Deleting image... + + + + Screenshot copied to clipboard. Capture d'écran copiée dans le Presse-papier. @@ -813,16 +825,10 @@ Appuyer sur Espace pour ouvrir le panneau latéral. Imposible d'écrire par dessus - URL copied to clipboard. URL copiée dans le Presse-papier. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_hu.ts b/translations/Internationalization_hu.ts index ac4b15da..3fce8960 100644 --- a/translations/Internationalization_hu.ts +++ b/translations/Internationalization_hu.ts @@ -384,10 +384,6 @@ Press Space to open the side panel. HistoryWidget - - Screenshots history - - URL copied to clipboard. URL másolva a vágólapra. @@ -404,6 +400,10 @@ Press Space to open the side panel. Copy URL URL másolása + + Latest Uploads + + ImgS3Uploader @@ -444,7 +444,15 @@ Press Space to open the side panel. - Deleting Image + Delete image + + + + S3 Creds URL is not found in your configuration file + + + + Deleting image... @@ -686,10 +694,6 @@ Press Space to open the side panel. URL copied to clipboard. URL másolva a vágólapra. - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_ja.ts b/translations/Internationalization_ja.ts index 24c09fd6..a0891358 100644 --- a/translations/Internationalization_ja.ts +++ b/translations/Internationalization_ja.ts @@ -444,26 +444,26 @@ Enter を押すと画面をキャプチャー。 HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL URL をコピー - + URL copied to clipboard. URL をクリップボードにコピーしました。 - + Open in browser @@ -486,37 +486,49 @@ Enter を押すと画面をキャプチャー。 - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL URL をコピー - + Open URL URL を開く - + + Delete image + 画像を削除 + + + Image to Clipboard. 画像をクリップボードへ。 - + Unable to open the URL. URL を開けません。 - + + URL copied to clipboard. URL をクリップボードにコピーしました。 - + + + Deleting image... + + + + Screenshot copied to clipboard. スクリーンショットをクリップボードにコピーしました。 @@ -813,16 +825,10 @@ Enter を押すと画面をキャプチャー。 書き込めません: - URL copied to clipboard. URL をクリップボードにコピーしました。 - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_ka.ts b/translations/Internationalization_ka.ts index 575840fe..7134590f 100644 --- a/translations/Internationalization_ka.ts +++ b/translations/Internationalization_ka.ts @@ -440,26 +440,26 @@ Press Space to open the side panel. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL URL-ის კოპირება - + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. - + Open in browser @@ -482,37 +482,49 @@ Press Space to open the side panel. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL URL-ის კოპირება - + Open URL URL-ის გახსნა - + + Delete image + + + + Image to Clipboard. სურათის გაცვლის ბუფერში გაგზავნა - + Unable to open the URL. URL-ის გახსნა ვერ მოხერხდა. - + + URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. - + + + Deleting image... + + + + Screenshot copied to clipboard. სურათი დაკოპირდა გაცვლის ბუფერში. @@ -809,16 +821,10 @@ Press Space to open the side panel. შემდეგ მისამართზე ჩაწერა ვერ მოხერხდა: - URL copied to clipboard. URL დაკოპირდა გაცვლის ბუფერში. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_nl.ts b/translations/Internationalization_nl.ts index 6a372b5a..87f7751d 100644 --- a/translations/Internationalization_nl.ts +++ b/translations/Internationalization_nl.ts @@ -444,26 +444,26 @@ Druk op spatie om het zijpaneel te openen. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL URL kopiëren - + URL copied to clipboard. URL gekopieerd naar klembord. - + Open in browser @@ -486,37 +486,49 @@ Druk op spatie om het zijpaneel te openen. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL URL kopiëren - + Open URL URL openen - + + Delete image + Afbeelding verwijderen + + + Image to Clipboard. Afbeelding naar klembord. - + Unable to open the URL. Kan URL niet openen. - + + URL copied to clipboard. URL gekopieerd naar klembord. - + + + Deleting image... + + + + Screenshot copied to clipboard. Schermafdruk gekopieerd naar klembord. @@ -813,16 +825,10 @@ Druk op spatie om het zijpaneel te openen. Kan niet wegschrijven naar - URL copied to clipboard. URL gekopieerd naar klembord. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_pl.ts b/translations/Internationalization_pl.ts index ebf2fab8..9a8fe7aa 100644 --- a/translations/Internationalization_pl.ts +++ b/translations/Internationalization_pl.ts @@ -443,26 +443,26 @@ Spacja, aby pokazać panel boczny. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL Kopiuj URL - + URL copied to clipboard. URL skopiowany do schowka. - + Open in browser @@ -485,37 +485,49 @@ Spacja, aby pokazać panel boczny. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL Kopiuj URL - + Open URL Otwórz URL - + + Delete image + Usuń obrazek + + + Image to Clipboard. Obrazek do schowka. - + Unable to open the URL. Nie można otworzyć adresu URL. - + + URL copied to clipboard. URL skopiowany do schowka. - + + + Deleting image... + + + + Screenshot copied to clipboard. Zrzut ekranu skopiowany do schowka. @@ -812,16 +824,10 @@ Spacja, aby pokazać panel boczny. Nie można zapisać w - URL copied to clipboard. URL skopiowany do schowka. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_pt_br.ts b/translations/Internationalization_pt_br.ts index 67558d79..2e409a6e 100644 --- a/translations/Internationalization_pt_br.ts +++ b/translations/Internationalization_pt_br.ts @@ -444,26 +444,26 @@ Pressione espaço abrir o painel lateral. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL Copiar URL - + URL copied to clipboard. URL copiada para o clipboard. - + Open in browser @@ -486,37 +486,49 @@ Pressione espaço abrir o painel lateral. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL Copiar URL - + Open URL Abrir URL - + + Delete image + Deletar imagem + + + Image to Clipboard. Imagem no Clipboard. - + Unable to open the URL. Não foi possível abrir a URL. - + + URL copied to clipboard. URL copiada para o clipboard. - + + + Deleting image... + + + + Screenshot copied to clipboard. Screenshot copiada para o clipboard. @@ -813,16 +825,10 @@ Pressione espaço abrir o painel lateral. Não foi possível escrever em - URL copied to clipboard. URL copiada para o clipboard. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_ru.ts b/translations/Internationalization_ru.ts index 6bb1f6cc..fd13d4c0 100644 --- a/translations/Internationalization_ru.ts +++ b/translations/Internationalization_ru.ts @@ -451,31 +451,35 @@ Press Space to open the side panel. HistoryWidget - Screenshots history - История скриншотов + История скриншотов Screenshots history is epmty История скриншотов пустая - + + Latest Uploads + Последние загрузки + + + Screenshots history is empty История скриншотов пуста - + Copy URL Скопировать URL - + URL copied to clipboard. URL скопирован в буфер обмена. - + Open in browser Открыть в браузере @@ -502,41 +506,53 @@ Press Space to open the side panel. Удалить скриншот с S3 - Deleting Image - Удалить скриншот + Удалить скриншот - + + S3 Creds URL is not found in your configuration file + Параметры доступов к S3 не найдены в конфигурационном файле + + + Copy URL Скопировать URL - + Open URL Открыть URL + Delete image - Удалить изображение + Удалить изображение - + Image to Clipboard. Изображение в буфер обмена. - + Unable to open the URL. Не удалось открыть URL. - + + URL copied to clipboard. URL скопирован в буфер обмена. - + + + Deleting image... + Удаление скриншота... + + + Screenshot copied to clipboard. Снимок скопирован в буфер обмена. @@ -837,15 +853,13 @@ Press Space to open the side panel. Не удалось сохранить - URL copied to clipboard. URL скопирован в буфер обмена. - File is deleted from S3 - Файл удален с S3 + Файл удален с S3 diff --git a/translations/Internationalization_sk.ts b/translations/Internationalization_sk.ts index 4e0e83d2..292a2eb5 100644 --- a/translations/Internationalization_sk.ts +++ b/translations/Internationalization_sk.ts @@ -444,26 +444,26 @@ Stlačte medzerník pre otvorenie postranného panelu. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL Kopírovať URL - + URL copied to clipboard. URL skopírovaná do schránky. - + Open in browser @@ -486,37 +486,49 @@ Stlačte medzerník pre otvorenie postranného panelu. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL Kopírovať URL - + Open URL Otvoriť URL - + + Delete image + Vymazať obrázok + + + Image to Clipboard. Obrázok do schránky. - + Unable to open the URL. Nepodarilo sa otvoriť URL. - + + URL copied to clipboard. URL skopírovaná do schránky. - + + + Deleting image... + + + + Screenshot copied to clipboard. Snímka obrazovky bola skopírovaná do schránky. @@ -813,16 +825,10 @@ Stlačte medzerník pre otvorenie postranného panelu. Chyba pri ukladaní - URL copied to clipboard. URL skopírovaná do schránky. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_sr.ts b/translations/Internationalization_sr.ts index 2d66a513..fa8a97b9 100644 --- a/translations/Internationalization_sr.ts +++ b/translations/Internationalization_sr.ts @@ -444,26 +444,26 @@ Press Space to open the side panel. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL Запамти интернет адресу - + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. - + Open in browser @@ -486,37 +486,49 @@ Press Space to open the side panel. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL Запамти интернет адресу - + Open URL Посети интернет адресу - + + Delete image + Избриши слику + + + Image to Clipboard. Сачувај у привремену меморију. - + Unable to open the URL. Нисам успео да посетим интернет адресу. - + + URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. - + + + Deleting image... + + + + Screenshot copied to clipboard. Слика је сачувана у привременој меморији. @@ -813,16 +825,10 @@ Press Space to open the side panel. Нисам успео са сачувам - URL copied to clipboard. Интернет адреса је сачувана у привременој меморији. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_tr.ts b/translations/Internationalization_tr.ts index a77e882a..d64c51e4 100644 --- a/translations/Internationalization_tr.ts +++ b/translations/Internationalization_tr.ts @@ -444,26 +444,26 @@ Yan paneli açmak için Boşluk tuşuna basın. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL URL Kopyala - + URL copied to clipboard. URL panoya kopyalandı. - + Open in browser @@ -486,37 +486,49 @@ Yan paneli açmak için Boşluk tuşuna basın. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL URL Kopyala - + Open URL URL Aç - + + Delete image + Resmi sil + + + Image to Clipboard. Resim Pano'ya. - + Unable to open the URL. URL açılamıyor. - + + URL copied to clipboard. URL panoya kopyalandı. - + + + Deleting image... + + + + Screenshot copied to clipboard. Ekran görüntüsü panoya kopyalandı. @@ -813,16 +825,10 @@ Yan paneli açmak için Boşluk tuşuna basın. Yazma mümkün değil - URL copied to clipboard. URL panoya kopyalandı. - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_uk.ts b/translations/Internationalization_uk.ts index 85ee98a7..02617ecb 100644 --- a/translations/Internationalization_uk.ts +++ b/translations/Internationalization_uk.ts @@ -451,31 +451,35 @@ Press Space to open the side panel. HistoryWidget - Screenshots history - Історія скріншотів + Історія скріншотів Screenshots history is epmty Історія скріншотів пуста - + + Latest Uploads + Останні завантаження + + + Screenshots history is empty Історія скріншотів пуста - + Copy URL Скопіювати URL - + URL copied to clipboard. URL скопійовано до буферу обміну. - + Open in browser Відкрити у браузері @@ -502,41 +506,53 @@ Press Space to open the side panel. Видалити скріншот з S3 - Deleting Image - Видалити скіншот + Видалити скіншот - + + S3 Creds URL is not found in your configuration file + Параметри доступів до S3 не знайдені у конфігураціонному файлі + + + Copy URL Скопіювати URL - + Open URL Відкрити URL + Delete image - Видалити зображення + Видалити зображення - + Image to Clipboard. Зображення до буферу обміну. - + Unable to open the URL. Не вдалось відкрити URL. - + + URL copied to clipboard. URL скопійовано до буферу обміну. - + + + Deleting image... + Видалення скріншоту... + + + Screenshot copied to clipboard. Знімок скопійовано до буферу обміну. @@ -837,15 +853,13 @@ Press Space to open the side panel. Не вдалось зберегти - URL copied to clipboard. URL скопійовано до буферу обміну. - File is deleted from S3 - Файл видален з S3 + Файл видален з S3 diff --git a/translations/Internationalization_zh_CN.ts b/translations/Internationalization_zh_CN.ts index fc3d2850..dcb772de 100644 --- a/translations/Internationalization_zh_CN.ts +++ b/translations/Internationalization_zh_CN.ts @@ -445,26 +445,26 @@ Press Space to open the side panel. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL 复制链接 - + URL copied to clipboard. 复制链接到剪贴板。 - + Open in browser @@ -487,37 +487,49 @@ Press Space to open the side panel. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL 复制链接 - + Open URL 打开链接 - + + Delete image + 删除图像 + + + Image to Clipboard. 保存文件到剪贴板。 - + Unable to open the URL. 无法打开此链接。 - + + URL copied to clipboard. 复制链接到剪贴板。 - + + + Deleting image... + + + + Screenshot copied to clipboard. 截图复制到剪贴板。 @@ -814,16 +826,10 @@ Press Space to open the side panel. 无法写入 - URL copied to clipboard. 复制链接到剪贴板。 - - - File is deleted from S3 - - RectangleTool diff --git a/translations/Internationalization_zh_TW.ts b/translations/Internationalization_zh_TW.ts index dd72c6cc..2d0330fd 100644 --- a/translations/Internationalization_zh_TW.ts +++ b/translations/Internationalization_zh_TW.ts @@ -440,26 +440,26 @@ Press Space to open the side panel. HistoryWidget - Screenshots history + Latest Uploads - + Screenshots history is empty - + Copy URL 複製連結 - + URL copied to clipboard. 連結已複製到剪貼簿 - + Open in browser @@ -482,37 +482,49 @@ Press Space to open the side panel. - - Deleting Image + + S3 Creds URL is not found in your configuration file - + Copy URL 複製連結 - + Open URL 打開連結 - + + Delete image + + + + Image to Clipboard. 將檔案複製到剪貼簿 - + Unable to open the URL. 無法打開此連結 - + + URL copied to clipboard. 連結已複製到剪貼簿 - + + + Deleting image... + + + + Screenshot copied to clipboard. 截圖已複製到剪貼簿 @@ -809,16 +821,10 @@ Press Space to open the side panel. 無法寫入 - URL copied to clipboard. 連結已複製到剪貼簿 - - - File is deleted from S3 - - RectangleTool From 09ebd0c2e5c1d7823988621d590b8eb41f4b9e39 Mon Sep 17 00:00:00 2001 From: Yuriy Puchkov Date: Mon, 10 Aug 2020 12:58:43 +0300 Subject: [PATCH 11/11] Fix - build fails on some Ubuntu distributions --- src/tools/imgs3/imgs3settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/imgs3/imgs3settings.cpp b/src/tools/imgs3/imgs3settings.cpp index 76ac96ad..41695aee 100644 --- a/src/tools/imgs3/imgs3settings.cpp +++ b/src/tools/imgs3/imgs3settings.cpp @@ -11,12 +11,12 @@ ImgS3Settings::ImgS3Settings() settings->beginGroup("S3"); m_credsUrl = settings->value("S3_CREDS_URL").toString(); - m_credsUrl = m_credsUrl + (m_credsUrl.length() > 0 && m_credsUrl.at(m_credsUrl.length() - 1) == "/" ? "" : "/") + S3_API_IMG_PATH; + m_credsUrl = m_credsUrl + ((m_credsUrl.length() > 0 && m_credsUrl[m_credsUrl.length() - 1] == '/') ? "" : "/") + S3_API_IMG_PATH; m_xApiKey = settings->value("S3_X_API_KEY").toString(); m_url = settings->value("S3_URL").toString(); - m_url = m_url + (m_url.length() > 0 && m_url.at(m_url.length() - 1) == "/" ? "" : "/"); + m_url = m_url + ((m_url.length() > 0 && m_url[m_url.length() - 1] == '/') ? "" : "/"); settings->endGroup(); }