/*! * Return url for upload image */ QUrl Uploader_MediaCrush::apiUrl() { UploaderConfig config; // QUrl("https://mediacru.sh/api/upload/file") return config.loadSingleParam("mediacru.sh", KEY_MCSH_URL).toUrl(); }
void ModuleUploader::init() { Core *core = Core::instance(); if (core->checkCmdLineOption(_optUpload) == true && _ignoreCmdParam == false) { UploaderConfig config; QString selectedtHost = config.loadSingleParam(QByteArray("common"), QByteArray(KEY_DEFAULT_HOST)).toString(); Uploader *uploader = 0; switch(config.labelsList().indexOf(selectedtHost)) { case 0: uploader = new Uploader_ImgUr; break; default: uploader = new Uploader_ImgUr; } connect(uploader, &Uploader::uploadDoneStr, this, &ModuleUploader::shadowUploadDone); connect(uploader, &Uploader::uploadFail, this, &ModuleUploader::shadowUploadFail); uploader->startUploading(); _ignoreCmdParam = true; } else { DialogUploader *ui = new DialogUploader(); ui->exec(); } }
DialogUploader::DialogUploader(QWidget *parent) : QDialog(parent), _ui(new Ui::DialogUploader) { _ui->setupUi(this); _ui->stackedWidget->setCurrentIndex(0); _uploader = 0; _uploaderWidget = 0; slotSeletHost(0); _ui->cbxUploaderList->addItems(UploaderConfig::labelsList()); UploaderConfig config; QString defaultHost = config.loadSingleParam(QByteArray("common"), QByteArray(KEY_DEFAULT_HOST)).toString(); if (defaultHost.isEmpty()) _selectedHost = 0; else { _selectedHost = config.labelsList().indexOf(defaultHost); if (_selectedHost == -1) _selectedHost = 0; } // load ishot preview QSize imgSize = Core::instance()->getPixmap()->size(); QString pixmapSize = tr("Size: ") + QString::number(imgSize.width()) + "x" + QString::number(imgSize.height()) + tr(" pixel"); _ui->labImgSize->setText(pixmapSize); _ui->labImage->setFixedWidth(256); _ui->labImage->setFixedHeight(192); _ui->labImage->setPixmap(Core::instance()->getPixmap()->scaled(_ui->labImage->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); // progressbar _ui->progressBar->setVisible(false); _ui->progressBar->setFormat(tr("Uploaded ") + "%p%" + " (" + "%v" + " of " + "%m bytes"); // upload staus labelsList _ui->labUploadStatus->setText(tr("Ready to upload")); connect(_ui->butClose, &QPushButton::clicked, this, &DialogUploader::close); connect(_ui->butUpload, &QPushButton::clicked, this, &DialogUploader::slotUploadStart); void (QComboBox::*uploaderChnage)(int) = &QComboBox::currentIndexChanged; connect(_ui->cbxUploaderList, uploaderChnage, this, &DialogUploader::slotSeletHost); _ui->cbxUploaderList->setCurrentIndex(_selectedHost); }