aboutsummaryrefslogtreecommitdiff
path: root/src/aoscene.cpp
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-09-10 23:26:03 +0300
committerCrystalwarrior <varsash@gmail.com>2019-09-10 23:26:03 +0300
commit7e2ec58c7eb62077733f354764d0b729fe0e0a93 (patch)
tree36b27b664bc2d7535ad2b3df101ea161212ad30d /src/aoscene.cpp
parent73782055237ee8948b26935348e8ca2b8a71a95a (diff)
Prevent the animated background/foreground from restarting itself if the image is the exact same as the currently playing one
Diffstat (limited to 'src/aoscene.cpp')
-rw-r--r--src/aoscene.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/aoscene.cpp b/src/aoscene.cpp
index 6d2dc890..0f4e7458 100644
--- a/src/aoscene.cpp
+++ b/src/aoscene.cpp
@@ -7,6 +7,7 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
m_parent = parent;
ao_app = p_ao_app;
m_movie = new QMovie(this);
+ last_image = "";
}
void AOScene::set_image(QString p_image)
@@ -15,6 +16,9 @@ void AOScene::set_image(QString p_image)
QString default_path = ao_app->get_default_background_path(p_image + ".png");
QString animated_background_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image));
+ if (file_exists(animated_background_path) && animated_background_path == last_image)
+ return;
+
QPixmap background(background_path);
QPixmap default_bg(default_path);
@@ -32,11 +36,16 @@ void AOScene::set_image(QString p_image)
{
this->setMovie(m_movie);
m_movie->start();
+ last_image = animated_background_path;
}
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)
@@ -48,6 +57,9 @@ void AOScene::set_legacy_desk(QString p_image)
QString animated_desk_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image));
QString default_path = ao_app->get_image_suffix(ao_app->get_default_background_path(p_image));
+ if (file_exists(animated_desk_path) && animated_desk_path == last_image)
+ return;
+
QPixmap f_desk;
int vp_width = m_parent->width();
@@ -73,6 +85,7 @@ void AOScene::set_legacy_desk(QString p_image)
{
this->setMovie(m_movie);
m_movie->start();
+ last_image = animated_desk_path;
}
else
{