diff options
| author | bunnei <bunneidev@gmail.com> | 2019-01-20 15:45:07 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-01-20 15:45:07 -0500 |
| commit | 1c733bf175253bbe3f2f7747fe5344e654eff6e0 (patch) | |
| tree | 5caf78c0e37fd6e158211301c10514f09eac7a77 /src/yuzu/loading_screen.h | |
| parent | 197d0d9d2408e608909b32dfa057791215d42c77 (diff) | |
| parent | 69da26754003cb4695380738f5a837c9a93b5eaa (diff) | |
Merge pull request #2034 from jroweboy/loading-widget
QT Frontend: Add a Loading screen with progressbar
Diffstat (limited to 'src/yuzu/loading_screen.h')
| -rw-r--r-- | src/yuzu/loading_screen.h | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/yuzu/loading_screen.h b/src/yuzu/loading_screen.h new file mode 100644 index 000000000..2a6cf1142 --- /dev/null +++ b/src/yuzu/loading_screen.h @@ -0,0 +1,56 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <memory> +#include <QWidget> + +#if !QT_CONFIG(movie) +#define YUZU_QT_MOVIE_MISSING 1 +#endif + +namespace Loader { +class AppLoader; +} + +namespace Ui { +class LoadingScreen; +} + +class QBuffer; +class QByteArray; +class QMovie; + +class LoadingScreen : public QWidget { + Q_OBJECT + +public: + explicit LoadingScreen(QWidget* parent = nullptr); + + ~LoadingScreen(); + + /// Call before showing the loading screen to load the widgets with the logo and banner for the + /// currently loaded application. + void Prepare(Loader::AppLoader& loader); + + /// After the loading screen is hidden, the owner of this class can call this to clean up any + /// used resources such as the logo and banner. + void Clear(); + + // In order to use a custom widget with a stylesheet, you need to override the paintEvent + // See https://wiki.qt.io/How_to_Change_the_Background_Color_of_QWidget + void paintEvent(QPaintEvent* event) override; + + 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; +}; |
