Add fade out effect to the loading screen

This commit is contained in:
James Rowe
2019-01-21 09:20:16 -07:00
parent 3740adb6f5
commit 3ca0af8bb3
4 changed files with 158 additions and 94 deletions

View File

@ -27,7 +27,9 @@ enum class LoadCallbackStage;
class QBuffer;
class QByteArray;
class QGraphicsOpacityEffect;
class QMovie;
class QPropertyAnimation;
class LoadingScreen : public QWidget {
Q_OBJECT
@ -45,14 +47,21 @@ public:
/// used resources such as the logo and banner.
void Clear();
/// Slot used to update the status of the progress bar
void OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total);
/// Hides the LoadingScreen with a fade out effect
void OnLoadComplete();
// 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;
signals:
void LoadProgress(VideoCore::LoadCallbackStage stage, std::size_t value, std::size_t total);
/// Signals that this widget is completely hidden now and should be replaced with the other
/// widget
void Hidden();
private:
#ifndef YUZU_QT_MOVIE_MISSING
@ -64,6 +73,9 @@ private:
std::size_t previous_total = 0;
VideoCore::LoadCallbackStage previous_stage;
QGraphicsOpacityEffect* opacity_effect = nullptr;
std::unique_ptr<QPropertyAnimation> fadeout_animation = nullptr;
// Definitions for the differences in text and styling for each stage
std::unordered_map<VideoCore::LoadCallbackStage, const char*> progressbar_style;
std::unordered_map<VideoCore::LoadCallbackStage, QString> stage_translations;