aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-08-26 21:04:05 +0200
committerCerapter <cerap@protonmail.com>2018-08-26 21:04:05 +0200
commitc01857063b72f4b5bff21b78ce4a28d463a6d5d2 (patch)
tree4e3ccc99ce2894709767c04b6b5bfd068a76d227
parentce73d268011fe3d0f410c1fe99b3dbb97bdbff91 (diff)
Support for animated backgrounds.
-rw-r--r--aoscene.cpp20
-rw-r--r--aoscene.h2
2 files changed, 19 insertions, 3 deletions
diff --git a/aoscene.cpp b/aoscene.cpp
index a2e2ceae..fef6b8fd 100644
--- a/aoscene.cpp
+++ b/aoscene.cpp
@@ -8,6 +8,7 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
{
m_parent = parent;
ao_app = p_ao_app;
+ m_movie = new QMovie(this);
}
void AOScene::set_image(QString p_image)
@@ -17,18 +18,31 @@ void AOScene::set_image(QString p_image)
QString default_path = ao_app->get_default_background_path() + p_image;
QPixmap background(background_path);
- QPixmap animated_background(animated_background_path);
QPixmap default_bg(default_path);
int w = this->width();
int h = this->height();
- if (file_exists(animated_background_path))
- this->setPixmap(animated_background.scaled(w, h));
+ this->clear();
+ this->setMovie(nullptr);
+
+ m_movie->stop();
+ m_movie->setFileName(animated_background_path);
+ m_movie->setScaledSize(QSize(w, h));
+
+ if (m_movie->isValid())
+ {
+ this->setMovie(m_movie);
+ m_movie->start();
+ }
else if (file_exists(background_path))
+ {
this->setPixmap(background.scaled(w, h));
+ }
else
+ {
this->setPixmap(default_bg.scaled(w, h));
+ }
}
void AOScene::set_legacy_desk(QString p_image)
diff --git a/aoscene.h b/aoscene.h
index 08c286e1..b58c0fd0 100644
--- a/aoscene.h
+++ b/aoscene.h
@@ -3,6 +3,7 @@
#include <QLabel>
#include <QDebug>
+#include <QMovie>
class Courtroom;
class AOApplication;
@@ -18,6 +19,7 @@ public:
private:
QWidget *m_parent;
+ QMovie *m_movie;
AOApplication *ao_app;
};