forked from ckaiser/Lightscreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully decoupled Uploader from imgur stuff, moved authorization to cal…
…lback static functions and added uploader-specific settings loaded from the main QSettings so uploaders themselves don't touch global settings.
- Loading branch information
Showing
7 changed files
with
228 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,63 @@ | ||
#include "imageuploader.h" | ||
#include "imguruploader.h" | ||
|
||
ImageUploader *ImageUploader::getNewUploader(const QString &name, const QVariantHash &options) | ||
#include <QSettings> | ||
#include "../screenshotmanager.h" | ||
|
||
ImageUploader *ImageUploader::factory(const QString &name) | ||
{ | ||
if (name == "imgur") { | ||
return new ImgurUploader(options); | ||
return new ImgurUploader(0); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
QVariantHash ImageUploader::loadSettings(const QString &uploaderType) | ||
{ | ||
auto globalSettings = ScreenshotManager::instance()->settings(); | ||
globalSettings->beginGroup("upload/" + uploaderType); | ||
auto keys = globalSettings->childKeys(); | ||
|
||
QVariantHash settings; | ||
|
||
for (auto key : qAsConst(keys)) { | ||
settings[key] = globalSettings->value(key); | ||
} | ||
|
||
globalSettings->endGroup(); | ||
return settings; | ||
} | ||
|
||
void ImageUploader::loadSettings() | ||
{ | ||
mSettings = loadSettings(mUploaderType); | ||
} | ||
|
||
void ImageUploader::saveSettings(const QString &uploaderType, const QVariantHash &settings) { | ||
auto globalSettings = ScreenshotManager::instance()->settings(); | ||
globalSettings->beginGroup("upload/" + uploaderType); | ||
|
||
for (auto key : settings.keys()) { | ||
globalSettings->setValue(key, settings[key]); | ||
} | ||
|
||
globalSettings->endGroup(); | ||
} | ||
|
||
void ImageUploader::saveSettings() | ||
{ | ||
saveSettings(mUploaderType, mSettings); | ||
} | ||
|
||
int ImageUploader::progress() const { | ||
return mProgress; | ||
} | ||
|
||
void ImageUploader::setProgress(int progress) | ||
{ | ||
if (mProgress != progress) { | ||
mProgress = progress; | ||
emit progressChanged(mProgress); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.