Use optional instead of hardcoded cancelled string
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
bf04becc9e
commit
434f639b0c
@ -50,7 +50,7 @@
|
|||||||
#include <DesktopServices.h>
|
#include <DesktopServices.h>
|
||||||
#include <BuildConfig.h>
|
#include <BuildConfig.h>
|
||||||
|
|
||||||
QString GuiUtil::uploadPaste(const QString &name, const QString &text, QWidget *parentWidget)
|
std::optional<QString> GuiUtil::uploadPaste(const QString &name, const QString &text, QWidget *parentWidget)
|
||||||
{
|
{
|
||||||
ProgressDialog dialog(parentWidget);
|
ProgressDialog dialog(parentWidget);
|
||||||
auto pasteTypeSetting = static_cast<PasteUpload::PasteType>(APPLICATION->settings()->get("PastebinType").toInt());
|
auto pasteTypeSetting = static_cast<PasteUpload::PasteType>(APPLICATION->settings()->get("PastebinType").toInt());
|
||||||
@ -63,7 +63,8 @@ QString GuiUtil::uploadPaste(const QString &name, const QString &text, QWidget *
|
|||||||
else
|
else
|
||||||
baseUrl = pasteCustomAPIBaseSetting;
|
baseUrl = pasteCustomAPIBaseSetting;
|
||||||
|
|
||||||
if (baseUrl.isValid()) {
|
if (baseUrl.isValid())
|
||||||
|
{
|
||||||
auto response = CustomMessageBox::selectable(parentWidget, QObject::tr("Confirm Upload"),
|
auto response = CustomMessageBox::selectable(parentWidget, QObject::tr("Confirm Upload"),
|
||||||
QObject::tr("You are about to upload \"%1\" to %2.\n"
|
QObject::tr("You are about to upload \"%1\" to %2.\n"
|
||||||
"You should double-check for personal information.\n\n"
|
"You should double-check for personal information.\n\n"
|
||||||
@ -73,7 +74,7 @@ QString GuiUtil::uploadPaste(const QString &name, const QString &text, QWidget *
|
|||||||
->exec();
|
->exec();
|
||||||
|
|
||||||
if (response != QMessageBox::Yes)
|
if (response != QMessageBox::Yes)
|
||||||
return "canceled";
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace GuiUtil
|
namespace GuiUtil
|
||||||
{
|
{
|
||||||
QString uploadPaste(const QString &name, const QString &text, QWidget *parentWidget);
|
std::optional<QString> uploadPaste(const QString &name, 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);
|
||||||
QString BrowseForFile(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget);
|
QString BrowseForFile(QString context, QString caption, QString filter, QString defaultPath, QWidget *parentWidget);
|
||||||
|
@ -283,17 +283,18 @@ void LogPage::on_btnPaste_clicked()
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
auto url = GuiUtil::uploadPaste(tr("Minecraft Log"), m_model->toPlainText(), this);
|
auto url = GuiUtil::uploadPaste(tr("Minecraft Log"), m_model->toPlainText(), this);
|
||||||
if(url == "canceled")
|
if(!url.has_value())
|
||||||
{
|
{
|
||||||
m_model->append(MessageLevel::Error, QString("Log upload canceled"));
|
m_model->append(MessageLevel::Error, QString("Log upload canceled"));
|
||||||
}
|
}
|
||||||
else if(!url.isEmpty())
|
else if (url->isNull())
|
||||||
{
|
{
|
||||||
m_model->append(MessageLevel::Launcher, QString("Log uploaded to: %1").arg(url));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
m_model->append(MessageLevel::Error, QString("Log upload failed!"));
|
m_model->append(MessageLevel::Error, QString("Log upload failed!"));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_model->append(MessageLevel::Launcher, QString("Log uploaded to: %1").arg(url.value()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogPage::on_btnCopy_clicked()
|
void LogPage::on_btnCopy_clicked()
|
||||||
|
Loading…
Reference in New Issue
Block a user