mirror of
https://github.com/fergalmoran/flameshot.git
synced 2026-02-04 09:37:32 +00:00
Hide history window during waiting for delete screenshot from S3
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user