diff options
author | James Rowe <jroweboy@gmail.com> | 2019-01-18 18:02:27 +0100 |
---|---|---|
committer | James Rowe <jroweboy@gmail.com> | 2019-01-20 07:34:03 +0100 |
commit | 69da26754003cb4695380738f5a837c9a93b5eaa (patch) | |
tree | f34b3c75e0c36cf64d13a0c91366de0b1cb60085 | |
parent | QT Frontend: Add a Loading screen with progressbar (diff) | |
download | yuzu-69da26754003cb4695380738f5a837c9a93b5eaa.tar yuzu-69da26754003cb4695380738f5a837c9a93b5eaa.tar.gz yuzu-69da26754003cb4695380738f5a837c9a93b5eaa.tar.bz2 yuzu-69da26754003cb4695380738f5a837c9a93b5eaa.tar.lz yuzu-69da26754003cb4695380738f5a837c9a93b5eaa.tar.xz yuzu-69da26754003cb4695380738f5a837c9a93b5eaa.tar.zst yuzu-69da26754003cb4695380738f5a837c9a93b5eaa.zip |
-rw-r--r-- | src/yuzu/loading_screen.cpp | 15 | ||||
-rw-r--r-- | src/yuzu/loading_screen.h | 6 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/yuzu/loading_screen.cpp b/src/yuzu/loading_screen.cpp index f2d3214f6..0f3c4bb6c 100644 --- a/src/yuzu/loading_screen.cpp +++ b/src/yuzu/loading_screen.cpp @@ -8,7 +8,6 @@ #include <QIODevice> #include <QImage> #include <QLabel> -#include <QMovie> #include <QPainter> #include <QPalette> #include <QPixmap> @@ -20,6 +19,12 @@ #include "ui_loading_screen.h" #include "yuzu/loading_screen.h" +// Mingw seems to not have QMovie at all. If QMovie is missing then use a single frame instead of an +// showing the full animation +#if !YUZU_QT_MOVIE_MISSING +#include <QMovie> +#endif + LoadingScreen::LoadingScreen(QWidget* parent) : QWidget(parent), ui(std::make_unique<Ui::LoadingScreen>()) { ui->setupUi(this); @@ -32,6 +37,11 @@ LoadingScreen::~LoadingScreen() = default; void LoadingScreen::Prepare(Loader::AppLoader& loader) { std::vector<u8> buffer; if (loader.ReadBanner(buffer) == Loader::ResultStatus::Success) { +#ifdef YUZU_QT_MOVIE_MISSING + QPixmap map; + map.loadFromData(buffer.data(), buffer.size()); + ui->banner->setPixmap(map); +#else backing_mem = std::make_unique<QByteArray>(reinterpret_cast<char*>(buffer.data()), buffer.size()); backing_buf = std::make_unique<QBuffer>(backing_mem.get()); @@ -39,6 +49,7 @@ void LoadingScreen::Prepare(Loader::AppLoader& loader) { animation = std::make_unique<QMovie>(backing_buf.get(), QByteArray("GIF")); animation->start(); ui->banner->setMovie(animation.get()); +#endif buffer.clear(); } if (loader.ReadLogo(buffer) == Loader::ResultStatus::Success) { @@ -65,7 +76,9 @@ void LoadingScreen::paintEvent(QPaintEvent* event) { } void LoadingScreen::Clear() { +#ifndef YUZU_QT_MOVIE_MISSING animation.reset(); backing_buf.reset(); backing_mem.reset(); +#endif } diff --git a/src/yuzu/loading_screen.h b/src/yuzu/loading_screen.h index ffcaa260d..2a6cf1142 100644 --- a/src/yuzu/loading_screen.h +++ b/src/yuzu/loading_screen.h @@ -7,6 +7,10 @@ #include <memory> #include <QWidget> +#if !QT_CONFIG(movie) +#define YUZU_QT_MOVIE_MISSING 1 +#endif + namespace Loader { class AppLoader; } @@ -42,9 +46,11 @@ public: void OnLoadProgress(std::size_t value, std::size_t total); private: +#ifndef YUZU_QT_MOVIE_MISSING std::unique_ptr<QMovie> animation; std::unique_ptr<QBuffer> backing_buf; std::unique_ptr<QByteArray> backing_mem; +#endif std::unique_ptr<Ui::LoadingScreen> ui; std::size_t previous_total = 0; }; |