aboutsummaryrefslogtreecommitdiff
path: root/src/aoimage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/aoimage.cpp')
-rw-r--r--src/aoimage.cpp64
1 files changed, 30 insertions, 34 deletions
diff --git a/src/aoimage.cpp b/src/aoimage.cpp
index 3977c979..e1bd8b8c 100644
--- a/src/aoimage.cpp
+++ b/src/aoimage.cpp
@@ -8,49 +8,45 @@ AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
{
m_parent = parent;
ao_app = p_ao_app;
+ movie = new QMovie();
+ connect(movie, &QMovie::frameChanged, [=]{
+ QPixmap f_pixmap = movie->currentPixmap();
+ f_pixmap =
+ f_pixmap.scaled(this->size(), Qt::IgnoreAspectRatio);
+ this->setPixmap(f_pixmap);
+ this->setMask(f_pixmap.mask());
+ });
}
AOImage::~AOImage() {}
-bool AOImage::set_image(QString p_image)
+bool AOImage::set_image(QString p_path, QString p_misc)
{
- QString theme_image_path =
- ao_app->get_static_image_suffix(ao_app->get_theme_path(p_image));
- QString default_image_path =
- ao_app->get_static_image_suffix(ao_app->get_default_theme_path(p_image));
+ // Check if the user wants animated themes
+ if (ao_app->get_animated_theme())
+ // We want an animated image
+ p_path = ao_app->get_image(p_path, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_misc);
+ else
+ // Grab a static variant of the image
+ p_path = ao_app->get_image_path(ao_app->get_asset_paths(p_path, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_misc), true);
- QString final_image_path;
-
- if (file_exists(theme_image_path))
- final_image_path = theme_image_path;
- else if (file_exists(default_image_path))
- final_image_path = default_image_path;
- else {
- qDebug() << "Warning: Image" << p_image << "not found! Can't set!";
- return false;
- }
-
- QPixmap f_pixmap(final_image_path);
- f_pixmap =
- f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio);
- this->setPixmap(f_pixmap);
- this->setMask(f_pixmap.mask());
- return true;
-}
-
-bool AOImage::set_chatbox(QString p_path)
-{
- p_path = ao_app->get_static_image_suffix(p_path);
if (!file_exists(p_path)) {
- qDebug() << "Warning: Chatbox" << p_path << "not found! Can't set!";
+ qDebug() << "Warning: Image" << p_path << "not found! Can't set!";
return false;
}
+ path = p_path;
+ movie->stop();
+ movie->setFileName(path);
+ if (ao_app->get_animated_theme() && movie->frameCount() > 1) {
+ movie->start();
+ }
+ else {
+ QPixmap f_pixmap(path);
- QPixmap f_pixmap(p_path);
-
- f_pixmap =
- f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio);
- this->setPixmap(f_pixmap);
- this->setMask(f_pixmap.mask());
+ f_pixmap =
+ f_pixmap.scaled(this->size(), Qt::IgnoreAspectRatio);
+ this->setPixmap(f_pixmap);
+ this->setMask(f_pixmap.mask());
+ }
return true;
}