;
+ class Sink : public Net::Sink {
+ public:
+ Sink(ScreenShot::Ptr shot) : m_shot(shot){};
+ virtual ~Sink() = default;
- explicit ImgurUpload(ScreenShot::Ptr shot);
- static Ptr make(ScreenShot::Ptr shot) { return Ptr(new ImgurUpload(shot)); }
- void init() override{};
+ public:
+ auto init(QNetworkRequest& request) -> Task::State override;
+ auto write(QByteArray& data) -> Task::State override;
+ auto abort() -> Task::State override;
+ auto finalize(QNetworkReply& reply) -> Task::State override;
+ auto hasLocalData() -> bool override { return false; }
- protected slots:
- void downloadProgress(qint64 bytesReceived, qint64 bytesTotal) override;
- void downloadError(QNetworkReply::NetworkError error) override;
- void downloadFinished() override;
- void downloadReadyRead() override {}
+ private:
+ ScreenShot::Ptr m_shot;
+ QByteArray m_output;
+ };
+ ImgurUpload(QFileInfo info) : m_fileInfo(info) {}
+ virtual ~ImgurUpload() = default;
- public slots:
- void executeTask() override;
+ static NetRequest::Ptr make(ScreenShot::Ptr m_shot);
+
+ void init() override;
private:
- ScreenShot::Ptr m_shot;
- bool finished = true;
+ virtual QNetworkReply* getReply(QNetworkRequest&) override;
+ const QFileInfo m_fileInfo;
};
diff --git a/launcher/ui/dialogs/AboutDialog.cpp b/launcher/ui/dialogs/AboutDialog.cpp
index 3c6f6ef16..f5eaff7a1 100644
--- a/launcher/ui/dialogs/AboutDialog.cpp
+++ b/launcher/ui/dialogs/AboutDialog.cpp
@@ -85,6 +85,7 @@ QString getCreditsHtml()
stream << QString("TayouVR %1
\n").arg(getGitHub("TayouVR"));
stream << QString("TheKodeToad %1
\n").arg(getGitHub("TheKodeToad"));
stream << QString("getchoo %1
\n").arg(getGitHub("getchoo"));
+ stream << QString("Alexandru Tripon (Trial97) %1
\n").arg(getGitHub("Trial97"));
stream << "
\n";
// TODO: possibly retrieve from git history at build time?
diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp
index 690dc917b..7530fdfba 100644
--- a/launcher/ui/instanceview/InstanceView.cpp
+++ b/launcher/ui/instanceview/InstanceView.cpp
@@ -39,6 +39,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -478,6 +479,38 @@ void InstanceView::paintEvent([[maybe_unused]] QPaintEvent* event)
#endif
option.widget = this;
+ if (model()->rowCount() == 0) {
+ painter.save();
+ const QString line1 = tr("Welcome!");
+ const QString line2 = tr("Click \"Add Instance\" to get started.");
+ auto rect = this->viewport()->rect();
+ auto font = option.font;
+ font.setPointSize(37);
+ painter.setFont(font);
+ auto fm = painter.fontMetrics();
+
+ if (rect.height() <= (fm.height() * 5) || rect.width() <= fm.horizontalAdvance(line2)) {
+ auto s = rect.height() / (5. * fm.height());
+ auto sx = rect.width() * 1. / fm.horizontalAdvance(line2);
+ if (s >= sx)
+ s = sx;
+ auto ps = font.pointSize() * s;
+ if (ps <= 0)
+ ps = 1;
+ font.setPointSize(ps);
+ painter.setFont(font);
+ fm = painter.fontMetrics();
+ }
+
+ // text
+ rect.setTop(rect.top() + fm.height() * 1.5);
+ painter.drawText(rect, Qt::AlignHCenter, line1);
+ rect.setTop(rect.top() + fm.height());
+ painter.drawText(rect, Qt::AlignHCenter, line2);
+ painter.restore();
+ return;
+ }
+
int wpWidth = viewport()->width();
option.rect.setWidth(wpWidth);
for (int i = 0; i < m_groups.size(); ++i) {
diff --git a/launcher/ui/pages/instance/ScreenshotsPage.cpp b/launcher/ui/pages/instance/ScreenshotsPage.cpp
index 29c835fc1..25f978cea 100644
--- a/launcher/ui/pages/instance/ScreenshotsPage.cpp
+++ b/launcher/ui/pages/instance/ScreenshotsPage.cpp
@@ -383,20 +383,31 @@ void ScreenshotsPage::on_actionUpload_triggered()
QList uploaded;
auto job = NetJob::Ptr(new NetJob("Screenshot Upload", APPLICATION->network()));
+
+ ProgressDialog dialog(this);
+ dialog.setSkipButton(true, tr("Abort"));
+
if (selection.size() < 2) {
auto item = selection.at(0);
auto info = m_model->fileInfo(item);
auto screenshot = std::make_shared(info);
job->addNetAction(ImgurUpload::make(screenshot));
- m_uploadActive = true;
- ProgressDialog dialog(this);
+ connect(job.get(), &Task::failed, [this](QString reason) {
+ CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), reason, QMessageBox::Critical)->show();
+ });
+ connect(job.get(), &Task::aborted, [this] {
+ CustomMessageBox::selectable(this, tr("Screenshots upload aborted"), tr("The task has been aborted by the user."),
+ QMessageBox::Information)
+ ->show();
+ });
- if (dialog.execWithTask(job.get()) != QDialog::Accepted) {
- CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
- } else {
+ m_uploadActive = true;
+
+ if (dialog.execWithTask(job.get()) == QDialog::Accepted) {
auto link = screenshot->m_url;
QClipboard* clipboard = QApplication::clipboard();
+ qDebug() << "ImgurUpload link" << link;
clipboard->setText(link);
CustomMessageBox::selectable(
this, tr("Upload finished"),
@@ -417,22 +428,36 @@ void ScreenshotsPage::on_actionUpload_triggered()
}
SequentialTask task;
auto albumTask = NetJob::Ptr(new NetJob("Imgur Album Creation", APPLICATION->network()));
- auto imgurAlbum = ImgurAlbumCreation::make(uploaded);
+ auto imgurResult = std::make_shared();
+ auto imgurAlbum = ImgurAlbumCreation::make(imgurResult, uploaded);
albumTask->addNetAction(imgurAlbum);
task.addTask(job);
task.addTask(albumTask);
- m_uploadActive = true;
- ProgressDialog prog(this);
- if (prog.execWithTask(&task) != QDialog::Accepted) {
- CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
- } else {
- auto link = QString("https://imgur.com/a/%1").arg(imgurAlbum->id());
- QClipboard* clipboard = QApplication::clipboard();
- clipboard->setText(link);
- CustomMessageBox::selectable(this, tr("Upload finished"),
- tr("The link to the uploaded album has been placed in your clipboard.").arg(link),
+
+ connect(&task, &Task::failed, [this](QString reason) {
+ CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), reason, QMessageBox::Critical)->show();
+ });
+ connect(&task, &Task::aborted, [this] {
+ CustomMessageBox::selectable(this, tr("Screenshots upload aborted"), tr("The task has been aborted by the user."),
QMessageBox::Information)
- ->exec();
+ ->show();
+ });
+
+ m_uploadActive = true;
+ if (dialog.execWithTask(&task) == QDialog::Accepted) {
+ if (imgurResult->id.isEmpty()) {
+ CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
+ } else {
+ auto link = QString("https://imgur.com/a/%1").arg(imgurResult->id);
+ qDebug() << "ImgurUpload link" << link;
+ QClipboard* clipboard = QApplication::clipboard();
+ clipboard->setText(link);
+ CustomMessageBox::selectable(
+ this, tr("Upload finished"),
+ tr("The link to the uploaded album has been placed in your clipboard.").arg(link),
+ QMessageBox::Information)
+ ->exec();
+ }
}
m_uploadActive = false;
}
diff --git a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
index 43ff1c0fe..d46f16b4d 100644
--- a/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
+++ b/launcher/ui/pages/modplatform/import_ftb/ImportFTBPage.cpp
@@ -90,7 +90,7 @@ void ImportFTBPage::suggestCurrent()
}
dialog->setSuggestedPack(selected.name, new PackInstallTask(selected));
- QString editedLogoName = QString("ftb_%1_%2,jpg").arg(selected.name, selected.id);
+ QString editedLogoName = QString("ftb_%1_%2.jpg").arg(selected.name, QString::number(selected.id));
dialog->setSuggestedIconFromFile(FS::PathCombine(selected.path, "folder.jpg"), editedLogoName);
}
diff --git a/launcher/ui/themes/CustomTheme.cpp b/launcher/ui/themes/CustomTheme.cpp
index 29ecf6254..4859983c6 100644
--- a/launcher/ui/themes/CustomTheme.cpp
+++ b/launcher/ui/themes/CustomTheme.cpp
@@ -165,11 +165,15 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest
QString path = FS::PathCombine("themes", m_id);
QString pathResources = FS::PathCombine("themes", m_id, "resources");
- if (!FS::ensureFolderPathExists(path) || !FS::ensureFolderPathExists(pathResources)) {
- themeWarningLog() << "couldn't create folder for theme!";
+ if (!FS::ensureFolderPathExists(path)) {
+ themeWarningLog() << "Theme directory for" << m_id << "could not be created. This theme might be invalid";
return;
}
+ if (!FS::ensureFolderPathExists(pathResources)) {
+ themeWarningLog() << "Resources directory for" << m_id << "could not be created";
+ }
+
auto themeFilePath = FS::PathCombine(path, themeFile);
bool jsonDataIncomplete = false;
@@ -230,7 +234,11 @@ CustomTheme::CustomTheme(ITheme* baseTheme, QFileInfo& fileInfo, bool isManifest
QStringList CustomTheme::searchPaths()
{
- return { FS::PathCombine("themes", m_id, "resources") };
+ QString pathResources = FS::PathCombine("themes", m_id, "resources");
+ if (QFileInfo::exists(pathResources))
+ return { pathResources };
+
+ return {};
}
QString CustomTheme::id()