Skip to content

Commit

Permalink
Added 'Save to disk' button when uploading to imgur (#2237)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaMarangoni authored Jan 22, 2022
1 parent 31690b8 commit 00b1088
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

3 comments on commit 00b1088

@zensubz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

I have cherry-picked this commit and applied it to v11.0.0, but unfortunately, there is no 'Save to disk' button in my case - all it does is ask for confirmation if the image has to be uploaded to Imgur, and then a notification appears that the URL has been copied to the clipboard. The corresponding image-entry is available in the 'Latest Uploads', but here also, I don't see any provision for saving the image to disk.

Am I missing something? Just in case, I use Qt v5.9.7.

@borgmanJeremy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the dialog that displays the new feature does not display if you enable "Copy URL after Upload". This was once a feature but is now a bug in my opinion. Try disabling that option and seeing if it works then. Also feel free to open an issue for this and we will get it fixed.

@zensubz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@borgmanJeremy Thanks. Will open an issue for this.

Please sign in to comment.