diff options
author | Jan Dalheimer <jan@dalheimer.de> | 2014-02-24 09:34:21 +0100 |
---|---|---|
committer | Jan Dalheimer <jan@dalheimer.de> | 2014-02-24 09:34:21 +0100 |
commit | 226c1bdae5ec615381965b6731f6496dffa3299e (patch) | |
tree | 6d437bf3aea4b3954d705f3fa11b78b3e3b42f99 /gui | |
parent | 5e33da258c3b5159dba854eb4792d0852a1ca363 (diff) | |
download | MultiMC-226c1bdae5ec615381965b6731f6496dffa3299e.tar MultiMC-226c1bdae5ec615381965b6731f6496dffa3299e.tar.gz MultiMC-226c1bdae5ec615381965b6731f6496dffa3299e.tar.lz MultiMC-226c1bdae5ec615381965b6731f6496dffa3299e.tar.xz MultiMC-226c1bdae5ec615381965b6731f6496dffa3299e.zip |
Screenshot fixes, move some code around, fix some stuff
Diffstat (limited to 'gui')
-rw-r--r-- | gui/ConsoleWindow.cpp | 3 | ||||
-rw-r--r-- | gui/ConsoleWindow.h | 1 | ||||
-rw-r--r-- | gui/ConsoleWindow.ui | 7 | ||||
-rw-r--r-- | gui/MainWindow.cpp | 36 | ||||
-rw-r--r-- | gui/MainWindow.h | 2 | ||||
-rw-r--r-- | gui/dialogs/ScreenshotDialog.cpp | 42 | ||||
-rw-r--r-- | gui/dialogs/ScreenshotDialog.h | 11 | ||||
-rw-r--r-- | gui/dialogs/ScreenshotDialog.ui | 16 |
8 files changed, 70 insertions, 48 deletions
diff --git a/gui/ConsoleWindow.cpp b/gui/ConsoleWindow.cpp index ccc037f2..d11e8aff 100644 --- a/gui/ConsoleWindow.cpp +++ b/gui/ConsoleWindow.cpp @@ -42,6 +42,8 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) connect(mcproc, SIGNAL(launch_failed(BaseInstance *)), this, SLOT(onLaunchFailed(BaseInstance *))); + connect(ui->btnScreenshots, &QPushButton::clicked, this, &ConsoleWindow::uploadScreenshots); + restoreState( QByteArray::fromBase64(MMC->settings()->get("ConsoleWindowState").toByteArray())); restoreGeometry( @@ -52,6 +54,7 @@ ConsoleWindow::ConsoleWindow(MinecraftProcess *mcproc, QWidget *parent) auto icon = MMC->icons()->getIcon(iconKey); setWindowIcon(icon); m_trayIcon = new QSystemTrayIcon(icon, this); + // TODO add screenshot upload as a menu item in the tray icon QString consoleTitle = tr("Console window for ") + name; m_trayIcon->setToolTip(consoleTitle); setWindowTitle(consoleTitle); diff --git a/gui/ConsoleWindow.h b/gui/ConsoleWindow.h index 7fe90c52..e21da33c 100644 --- a/gui/ConsoleWindow.h +++ b/gui/ConsoleWindow.h @@ -51,6 +51,7 @@ private: signals: void isClosing(); + void uploadScreenshots(); public slots: diff --git a/gui/ConsoleWindow.ui b/gui/ConsoleWindow.ui index c2307ecc..e50fb520 100644 --- a/gui/ConsoleWindow.ui +++ b/gui/ConsoleWindow.ui @@ -50,6 +50,13 @@ </widget> </item> <item> + <widget class="QPushButton" name="btnScreenshots"> + <property name="text"> + <string>Upload Screenshots</string> + </property> + </widget> + </item> + <item> <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 87c65601..f79b981a 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -1235,6 +1235,7 @@ void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session) console = new ConsoleWindow(proc); connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded())); + connect(console, &ConsoleWindow::uploadScreenshots, this, &MainWindow::on_actionScreenshots_triggered); proc->setLogin(session); proc->launch(); @@ -1516,34 +1517,15 @@ void MainWindow::on_actionScreenshots_triggered() return; } ScreenshotDialog dialog(list, this); - if (dialog.exec() == QDialog::Accepted) + if (dialog.exec() == ScreenshotDialog::Accepted) { - QList<ScreenShot *> screenshots = dialog.selected(); - if (screenshots.size() == 0) - return; - NetJob *job = new NetJob("Screenshot Upload"); - for (ScreenShot *shot : screenshots) - job->addNetAction(ScreenShotUpload::make(shot)); - ProgressDialog prog2(this); - prog2.exec(job); - connect(job, &NetJob::failed, [this] + QStringList urls; + for (ScreenShot *shot : dialog.uploaded()) { - CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), - tr("Unknown error"), QMessageBox::Warning)->exec(); - }); - connect(job, &NetJob::succeeded, [this, screenshots] - { screenshotsUploaded(screenshots); }); - } -} - -void MainWindow::screenshotsUploaded(QList<ScreenShot *> screenshots) -{ - QStringList urls; - for (ScreenShot *shot : screenshots) - { - urls << QString("<a href=\"" + shot->url + "\">Image %s</a>") - .arg(QString::number(shot->imgurIndex)); + urls << QString("<a href=\"" + shot->url + "\">Image %s</a>") + .arg(QString::number(shot->imgurIndex)); + } + CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"), + QMessageBox::Information)->exec(); } - CustomMessageBox::selectable(this, tr("Done uploading!"), urls.join("\n"), - QMessageBox::Information)->exec(); } diff --git a/gui/MainWindow.h b/gui/MainWindow.h index 0a474ef1..5911d175 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -170,8 +170,6 @@ slots: void reloadStatus(); - void screenshotsUploaded(QList<class ScreenShot*> screenshots); - /*! * Runs the DownloadUpdateTask and installs updates. */ diff --git a/gui/dialogs/ScreenshotDialog.cpp b/gui/dialogs/ScreenshotDialog.cpp index 8900f15b..02764fa3 100644 --- a/gui/dialogs/ScreenshotDialog.cpp +++ b/gui/dialogs/ScreenshotDialog.cpp @@ -1,6 +1,13 @@ #include "ScreenshotDialog.h" #include "ui_ScreenshotDialog.h" -#include "QModelIndex" + +#include <QModelIndex> +#include <QDebug> + +#include "ProgressDialog.h" +#include "CustomMessageBox.h" +#include "logic/net/NetJob.h" +#include "logic/net/ScreenshotUploader.h" ScreenshotDialog::ScreenshotDialog(ScreenshotList *list, QWidget *parent) : QDialog(parent), @@ -16,7 +23,12 @@ ScreenshotDialog::~ScreenshotDialog() delete ui; } -QList<ScreenShot*> ScreenshotDialog::selected() +QList<ScreenShot *> ScreenshotDialog::uploaded() const +{ + return m_uploaded; +} + +QList<ScreenShot*> ScreenshotDialog::selected() const { QList<ScreenShot*> list; QList<ScreenShot*> first = m_list->screenshots(); @@ -26,3 +38,29 @@ QList<ScreenShot*> ScreenshotDialog::selected() } return list; } + +void ScreenshotDialog::on_buttonBox_accepted() +{ + QList<ScreenShot *> screenshots = selected(); + if (screenshots.isEmpty()) + { + done(NothingDone); + return; + } + NetJob *job = new NetJob("Screenshot Upload"); + for (ScreenShot *shot : screenshots) + { + qDebug() << shot->file; + job->addNetAction(ScreenShotUpload::make(shot)); + } + ProgressDialog prog(this); + prog.exec(job); + connect(job, &NetJob::failed, [this] + { + 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 d3f629e7..1ca27bdd 100644 --- a/gui/dialogs/ScreenshotDialog.h +++ b/gui/dialogs/ScreenshotDialog.h @@ -18,12 +18,21 @@ public: explicit ScreenshotDialog(ScreenshotList *list, QWidget *parent = 0); ~ScreenshotDialog(); - QList<ScreenShot *> selected(); + enum + { + NothingDone = 0x42 + }; + + QList<ScreenShot *> uploaded() const; private slots: + void on_buttonBox_accepted(); private: Ui::ScreenshotDialog *ui; ScreenshotList *m_list; + QList<ScreenShot *> m_uploaded; + + QList<ScreenShot *> selected() const; }; diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui index af73e5ec..7eeab859 100644 --- a/gui/dialogs/ScreenshotDialog.ui +++ b/gui/dialogs/ScreenshotDialog.ui @@ -68,22 +68,6 @@ <connections> <connection> <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>ScreenshotDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> <signal>rejected()</signal> <receiver>ScreenshotDialog</receiver> <slot>reject()</slot> |