diff --git a/tools/uploader/imguruploader.cpp b/tools/uploader/imguruploader.cpp index 5c839ca..b19a431 100644 --- a/tools/uploader/imguruploader.cpp +++ b/tools/uploader/imguruploader.cpp @@ -191,7 +191,7 @@ void ImgurUploader::authorizationReply(QNetworkReply *reply, AuthorizationCallba newSettings["refresh_token"] = imgurResponse.value("refresh_token").toString(); newSettings["account_username"] = imgurResponse.value("account_username").toString(); newSettings["expires_in"] = imgurResponse.value("expires_in").toInt(); - saveSettings("imgur", newSettings); + ImgurUploader::saveSettings("imgur", newSettings); authorized = true; } diff --git a/widgets/pomfoptionswidget.cpp b/widgets/pomfoptionswidget.cpp index 83c58ab..a4d197a 100644 --- a/widgets/pomfoptionswidget.cpp +++ b/widgets/pomfoptionswidget.cpp @@ -16,16 +16,20 @@ PomfOptionsWidget::PomfOptionsWidget(QWidget *parent) : QWidget(parent) { ui.setupUi(this); + ui.progressIndicatorBar->setVisible(false); + connect(ui.verifyButton, &QPushButton::clicked, this, [&]() { ui.verifyButton->setEnabled(false); - ui.pomfUrlComboBox->setEnabled(false); + ui.downloadListButton->setEnabled(false); + ui.progressIndicatorBar->setVisible(true); QPointer guard(parentWidget()); PomfUploader::verify(ui.pomfUrlComboBox->currentText(), [&, guard](bool result) { if (guard.isNull()) return; ui.verifyButton->setEnabled(true); - ui.pomfUrlComboBox->setEnabled(true); + ui.downloadListButton->setEnabled(true); + ui.progressIndicatorBar->setVisible(false); if (result) { ui.verifyButton->setText(tr("Valid uploader!")); @@ -34,7 +38,7 @@ PomfOptionsWidget::PomfOptionsWidget(QWidget *parent) : QWidget(parent) } else { ui.verifyButton->setStyleSheet("color: red;"); ui.verifyButton->setIcon(os::icon("no")); - ui.verifyButton->setText(tr("Invalid :(")); + ui.verifyButton->setText(tr("Invalid uploader :(")); } }); }); @@ -45,7 +49,6 @@ PomfOptionsWidget::PomfOptionsWidget(QWidget *parent) : QWidget(parent) validUrl = true; } - ui.visitButton->setEnabled(validUrl); ui.verifyButton->setEnabled(validUrl); if (ui.verifyButton->styleSheet().count() > 0) { @@ -55,7 +58,41 @@ PomfOptionsWidget::PomfOptionsWidget(QWidget *parent) : QWidget(parent) } }); - connect(ui.visitButton, &QPushButton::clicked, this, [&]() { - QDesktopServices::openUrl(ui.pomfUrlComboBox->currentText()); + connect(ui.helpLabel, &QLabel::linkActivated, this, [&](const QString &url) { + QDesktopServices::openUrl(url); + }); + + connect(ui.downloadListButton, &QPushButton::clicked, this, [&]() { + ui.verifyButton->setEnabled(false); + ui.downloadListButton->setEnabled(false); + ui.progressIndicatorBar->setVisible(true); + + auto pomflistReply = Uploader::instance()->nam()->get(QNetworkRequest(QUrl("https://lightscreen.com.ar/pomf.json"))); + + QPointer guard(parentWidget()); + connect(pomflistReply, &QNetworkReply::finished, [&, guard, pomflistReply] { + if (guard.isNull()) return; + + ui.verifyButton->setEnabled(true); + ui.downloadListButton->setEnabled(true); + ui.progressIndicatorBar->setVisible(false); + + if (pomflistReply->error() != QNetworkReply::NoError) { + QMessageBox::warning(parentWidget(), tr("Connection error"), pomflistReply->errorString()); + return; + } + + auto pomfListData = QJsonDocument::fromJson(pomflistReply->readAll()).object(); + + if (pomfListData.contains("url")) { + auto urlList = pomfListData["url"].toArray(); + + for (auto url : qAsConst(urlList)) { + ui.pomfUrlComboBox->addItem(url.toString()); + } + + ui.pomfUrlComboBox->showPopup(); + } + }); }); } diff --git a/widgets/pomfoptionswidget.ui b/widgets/pomfoptionswidget.ui index 2956498..751b8f9 100644 --- a/widgets/pomfoptionswidget.ui +++ b/widgets/pomfoptionswidget.ui @@ -6,59 +6,92 @@ 0 0 - 305 - 75 + 297 + 84 Form - - - - - Pomf Clone URL: - - - - + + + + + 0 + 0 + + + + URL to a pomf.se clone + true - - - - - - Visit Site - - - - - - - Verify - - - - - - + Qt::Vertical - 198 - 97 + 0 + 0 + + + + Verify + + + + + + + + 0 + 0 + + + + <a href="https://lightscreen.com.ar/help#pomf">View Help</a> + + + Qt::AlignCenter + + + + + + + Download List + + + + + + + + 16777215 + 2 + + + + 0 + + + 0 + + + false + + +