From a8811a27f78698f1ab2acad47e90f3b16274e221 Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 24 Feb 2014 10:34:51 +0100 Subject: Working screenshot upload --- gui/MainWindow.cpp | 4 +- gui/dialogs/ScreenshotDialog.cpp | 15 +++--- gui/dialogs/ScreenshotDialog.h | 2 +- gui/dialogs/ScreenshotDialog.ui | 114 ++++++++++++++++++++++----------------- 4 files changed, 75 insertions(+), 60 deletions(-) (limited to 'gui') diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index f79b981a..93608a0e 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -1522,8 +1522,8 @@ void MainWindow::on_actionScreenshots_triggered() QStringList urls; for (ScreenShot *shot : dialog.uploaded()) { - urls << QString("url + "\">Image %s") - .arg(QString::number(shot->imgurIndex)); + urls << QString("url + "\">Image %1") + .arg(shot->timestamp.toString()); } CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"), QMessageBox::Information)->exec(); diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index 02764fa3..33e93162 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -39,7 +39,7 @@ QList ScreenshotDialog::selected() const return list; } -void ScreenshotDialog::on_buttonBox_accepted() +void ScreenshotDialog::on_uploadBtn_clicked() { QList screenshots = selected(); if (screenshots.isEmpty()) @@ -50,17 +50,18 @@ void ScreenshotDialog::on_buttonBox_accepted() NetJob *job = new NetJob("Screenshot Upload"); for (ScreenShot *shot : screenshots) { - qDebug() << shot->file; job->addNetAction(ScreenShotUpload::make(shot)); } + m_uploaded = screenshots; ProgressDialog prog(this); - prog.exec(job); - connect(job, &NetJob::failed, [this] + if (prog.exec(job) == QDialog::Accepted) + { + accept(); + } + else { CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec(); reject(); - }); - m_uploaded = screenshots; - connect(job, &NetJob::succeeded, this, &ScreenshotDialog::accept); + } } diff --git a/gui/dialogs/ScreenshotDialog.h b/gui/dialogs/ScreenshotDialog.h index 1ca27bdd..104814f1 100644 --- a/gui/dialogs/ScreenshotDialog.h +++ b/gui/dialogs/ScreenshotDialog.h @@ -27,7 +27,7 @@ public: private slots: - void on_buttonBox_accepted(); + void on_uploadBtn_clicked(); private: Ui::ScreenshotDialog *ui; diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui index 7eeab859..9e4bd6f0 100644 --- a/gui/dialogs/ScreenshotDialog.ui +++ b/gui/dialogs/ScreenshotDialog.ui @@ -17,68 +17,82 @@ :/icons/multimc/scalable/apps/multimc.svg:/icons/multimc/scalable/apps/multimc.svg - - - - 10 - 260 - 441 - 31 - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - 10 - 10 - 439 - 241 - - - - QAbstractItemView::ExtendedSelection - - - QAbstractItemView::SelectItems - - - - 120 - 90 - - - - QListView::LeftToRight - - - true - - - QListView::IconMode - - + + + + + QAbstractItemView::ExtendedSelection + + + QAbstractItemView::SelectItems + + + + 120 + 90 + + + + QListView::LeftToRight + + + true + + + QListView::IconMode + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Close + + + + + + + Upload + + + + + + - buttonBox - rejected() + closeBtn + clicked() ScreenshotDialog reject() - 316 - 260 + 315 + 272 - 286 - 274 + 271 + 258 -- cgit v1.2.3