Skip to content

Commit

Permalink
In-code upload service selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ckaiser committed Jul 10, 2016
1 parent 0d9dfed commit 1d6579e
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dialogs/historydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 4 additions & 2 deletions lightscreenwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tools/screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions tools/screenshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Screenshot : public QObject
NamingOptions namingOptions;
QDir directory;
QString prefix;
QString uploadService;

int mode;
int quality;
Expand Down
6 changes: 3 additions & 3 deletions tools/uploader/uploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tools/uploader/uploader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1d6579e

Please sign in to comment.