GH-1362 Put timestamps into the log when it is copied or uploaded

This commit is contained in:
Petr Mrázek 2016-01-20 03:10:02 +01:00
parent 47ea2a71c0
commit 9fd66b3bb1
3 changed files with 17 additions and 4 deletions

View File

@ -13,7 +13,7 @@
#include <DesktopServices.h> #include <DesktopServices.h>
#include <BuildConfig.h> #include <BuildConfig.h>
void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget) QString GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
{ {
ProgressDialog dialog(parentWidget); ProgressDialog dialog(parentWidget);
auto APIKeySetting = MMC->settings()->get("PasteEEAPIKey").toString(); auto APIKeySetting = MMC->settings()->get("PasteEEAPIKey").toString();
@ -29,7 +29,7 @@ void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
parentWidget, QObject::tr("Upload failed"), parentWidget, QObject::tr("Upload failed"),
QObject::tr("The log file is too big. You'll have to upload it manually."), QObject::tr("The log file is too big. You'll have to upload it manually."),
QMessageBox::Warning)->exec(); QMessageBox::Warning)->exec();
return; return QString();
} }
dialog.execWithTask(paste.get()); dialog.execWithTask(paste.get());
@ -37,6 +37,7 @@ void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
{ {
CustomMessageBox::selectable(parentWidget, QObject::tr("Upload failed"), CustomMessageBox::selectable(parentWidget, QObject::tr("Upload failed"),
paste->failReason(), QMessageBox::Critical)->exec(); paste->failReason(), QMessageBox::Critical)->exec();
return QString();
} }
else else
{ {
@ -49,6 +50,7 @@ void GuiUtil::uploadPaste(const QString &text, QWidget *parentWidget)
"the default " "the default "
"browser and placed in your clipboard.").arg(link), "browser and placed in your clipboard.").arg(link),
QMessageBox::Information)->exec(); QMessageBox::Information)->exec();
return link;
} }
} }

View File

@ -4,7 +4,7 @@
namespace GuiUtil namespace GuiUtil
{ {
void uploadPaste(const QString &text, QWidget *parentWidget); QString uploadPaste(const QString &text, QWidget *parentWidget);
void setClipboardText(const QString &text); void setClipboardText(const QString &text);
QStringList BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget); QStringList BrowseForFiles(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget);
} }

View File

@ -74,11 +74,22 @@ bool LogPage::shouldDisplay() const
void LogPage::on_btnPaste_clicked() void LogPage::on_btnPaste_clicked()
{ {
GuiUtil::uploadPaste(ui->text->toPlainText(), this); //FIXME: turn this into a proper task and move the upload logic out of GuiUtil!
write(tr("MultiMC: Log upload triggered at: %1").arg(QDateTime::currentDateTime().toString(Qt::RFC2822Date)), MessageLevel::MultiMC);
auto url = GuiUtil::uploadPaste(ui->text->toPlainText(), this);
if(!url.isEmpty())
{
write(tr("MultiMC: Log uploaded to: %1").arg(url), MessageLevel::MultiMC);
}
else
{
write(tr("MultiMC: Log upload failed!"), MessageLevel::Error);
}
} }
void LogPage::on_btnCopy_clicked() void LogPage::on_btnCopy_clicked()
{ {
write(QString("Clipboard copy at: %1").arg(QDateTime::currentDateTime().toString(Qt::RFC2822Date)), MessageLevel::MultiMC);
GuiUtil::setClipboardText(ui->text->toPlainText()); GuiUtil::setClipboardText(ui->text->toPlainText());
} }