Skip to content

Commit

Permalink
Added 'Save to disk' button when uploading to imgur (flameshot-org#2237)
Browse files Browse the repository at this point in the history
(cherry picked from commit 00b1088)
  • Loading branch information
AndreaMarangoni authored and Yuriy Puchkov committed May 13, 2022
1 parent aa987fe commit bc17e6c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/tools/imgupload/storages/imguploaderbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "src/utils/confighandler.h"
#include "src/utils/globalvalues.h"
#include "src/utils/history.h"
#include "src/utils/screenshotsaver.h"
#include "src/widgets/imagelabel.h"
#include "src/widgets/loadspinner.h"
#include "src/widgets/notificationwidget.h"
Expand Down Expand Up @@ -130,10 +131,12 @@ void ImgUploaderBase::showPostUploadDialog()
m_openUrlButton = new QPushButton(tr("Open URL"));
m_openDeleteUrlButton = new QPushButton(tr("Delete image"));
m_toClipboardButton = new QPushButton(tr("Image to Clipboard."));
m_saveToFilesystemButton = new QPushButton(tr("Save image"));
m_hLayout->addWidget(m_copyUrlButton);
m_hLayout->addWidget(m_openUrlButton);
m_hLayout->addWidget(m_openDeleteUrlButton);
m_hLayout->addWidget(m_toClipboardButton);
m_hLayout->addWidget(m_saveToFilesystemButton);

connect(
m_copyUrlButton, &QPushButton::clicked, this, &ImgUploaderBase::copyURL);
Expand All @@ -147,6 +150,11 @@ void ImgUploaderBase::showPostUploadDialog()
&QPushButton::clicked,
this,
&ImgUploaderBase::copyImage);

QObject::connect(m_saveToFilesystemButton,
&QPushButton::clicked,
this,
&ImgUploaderBase::saveScreenshotToFilesystem);
}

void ImgUploaderBase::openURL()
Expand Down Expand Up @@ -176,3 +184,13 @@ void ImgUploaderBase::deleteCurrentImage()
history.unpackFileName(m_currentImageName);
deleteImage(unpackFileName.file, unpackFileName.token);
}

void ImgUploaderBase::saveScreenshotToFilesystem()
{
if (!ScreenshotSaver().saveToFilesystemGUI(m_pixmap)) {
m_notification->showMessage(
tr("Unable to save the screenshot to disk."));
return;
}
m_notification->showMessage(tr("Screenshot saved."));
}
2 changes: 2 additions & 0 deletions src/tools/imgupload/storages/imguploaderbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private slots:
void copyURL();
void copyImage();
void deleteCurrentImage();
void saveScreenshotToFilesystem();

private:
QPixmap m_pixmap;
Expand All @@ -62,6 +63,7 @@ private slots:
QPushButton* m_openDeleteUrlButton;
QPushButton* m_copyUrlButton;
QPushButton* m_toClipboardButton;
QPushButton* m_saveToFilesystemButton;
QUrl m_imageURL;
NotificationWidget* m_notification;

Expand Down

0 comments on commit bc17e6c

Please sign in to comment.