From 1d6579ed4a0f23d42459f1fd9b1d1bddc7967d84 Mon Sep 17 00:00:00 2001 From: Christian Kaiser Date: Sun, 10 Jul 2016 20:27:15 -0300 Subject: [PATCH] In-code upload service selection --- dialogs/historydialog.cpp | 2 +- lightscreenwindow.cpp | 6 ++++-- tools/screenshot.cpp | 4 ++-- tools/screenshot.h | 1 + tools/uploader/uploader.cpp | 6 +++--- tools/uploader/uploader.h | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/dialogs/historydialog.cpp b/dialogs/historydialog.cpp index 6a64461..6dbcb62 100644 --- a/dialogs/historydialog.cpp +++ b/dialogs/historydialog.cpp @@ -168,7 +168,7 @@ void HistoryDialog::selectionChanged(const QItemSelection &selected, const QItem void HistoryDialog::upload() { - Uploader::instance()->upload(mSelectedScreenshot); + Uploader::instance()->upload(mSelectedScreenshot, ScreenshotManager::instance()->settings()->value("options/upload/service", "imgur").toString()); ui->uploadProgressWidget->setVisible(true); } diff --git a/lightscreenwindow.cpp b/lightscreenwindow.cpp index 488bd21..73ad0b0 100644 --- a/lightscreenwindow.cpp +++ b/lightscreenwindow.cpp @@ -538,7 +538,7 @@ void LightscreenWindow::screenshotAction(int mode) options.quality = settings()->value("options/quality", 100).toInt(); options.currentMonitor = settings()->value("options/currentMonitor", false).toBool(); options.clipboard = settings()->value("options/clipboard", true).toBool(); - options.urlClipboard = settings()->value("options/urlClipboard", false).toBool(); + options.urlClipboard = settings()->value("options/urlClipboard", false).toBool(); options.preview = settings()->value("options/preview", false).toBool(); options.magnify = settings()->value("options/magnify", false).toBool(); options.cursor = settings()->value("options/cursor", true).toBool(); @@ -548,6 +548,8 @@ void LightscreenWindow::screenshotAction(int mode) options.upload = settings()->value("options/uploadAuto", false).toBool(); options.optimize = settings()->value("options/optipng", false).toBool(); + options.uploadService = settings()->value("options/upload/service", "imgur").toString(); + Screenshot::NamingOptions namingOptions; namingOptions.naming = (Screenshot::Naming) settings()->value("file/naming").toInt(); namingOptions.leadingZeros = settings()->value("options/naming/leadingZeros", 0).toInt(); @@ -778,7 +780,7 @@ void LightscreenWindow::updaterDone(bool result) void LightscreenWindow::upload(const QString &fileName) { - Uploader::instance()->upload(fileName); + Uploader::instance()->upload(fileName, settings()->value("options/upload/service", "imgur").toString()); } void LightscreenWindow::uploadCancel() diff --git a/tools/screenshot.cpp b/tools/screenshot.cpp index 580bbd7..7ce53f5 100644 --- a/tools/screenshot.cpp +++ b/tools/screenshot.cpp @@ -331,9 +331,9 @@ void Screenshot::take() void Screenshot::upload() { if (mOptions.file) { - Uploader::instance()->upload(mOptions.fileName); + Uploader::instance()->upload(mOptions.fileName, mOptions.uploadService); } else if (unloadPixmap()) { - Uploader::instance()->upload(mUnloadFilename); + Uploader::instance()->upload(mUnloadFilename, mOptions.uploadService); } else { emit finished(); } diff --git a/tools/screenshot.h b/tools/screenshot.h index ef5db3b..c8d3b34 100644 --- a/tools/screenshot.h +++ b/tools/screenshot.h @@ -74,6 +74,7 @@ class Screenshot : public QObject NamingOptions namingOptions; QDir directory; QString prefix; + QString uploadService; int mode; int quality; diff --git a/tools/uploader/uploader.cpp b/tools/uploader/uploader.cpp index ac64fa4..506d1be 100644 --- a/tools/uploader/uploader.cpp +++ b/tools/uploader/uploader.cpp @@ -61,13 +61,13 @@ void Uploader::cancel() emit cancelAll(); } -void Uploader::upload(const QString &fileName) +void Uploader::upload(const QString &fileName, const QString &uploadService) { if (fileName.isEmpty()) { return; } - ImageUploader *uploader = ImageUploader::factory("imgur"); + ImageUploader *uploader = ImageUploader::factory(uploadService); connect(uploader, &ImageUploader::progressChanged, this , &Uploader::progressChanged); connect(this , &Uploader::cancelAll , uploader, &ImageUploader::cancel); @@ -101,8 +101,8 @@ void Uploader::upload(const QString &fileName) emit done(file, url, deleteHash); }); - uploader->upload(fileName); mUploaders.append(uploader); + uploader->upload(fileName); } int Uploader::uploading() diff --git a/tools/uploader/uploader.h b/tools/uploader/uploader.h index 3a26864..3c001f2 100644 --- a/tools/uploader/uploader.h +++ b/tools/uploader/uploader.h @@ -36,7 +36,7 @@ class Uploader : public QObject public slots: void cancel(); - void upload(const QString &fileName); + void upload(const QString &fileName, const QString &uploadService); int uploading(); void progressChanged(int p); //TODO: Rename