diff options
| author | Salanto <62221668+Salanto@users.noreply.github.com> | 2024-05-18 03:33:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-18 03:33:43 +0200 |
| commit | 51338e30e046f1a62c84049b34577f0f3b5db6e3 (patch) | |
| tree | 283c95f8f776ed852d03a816388695afd65c0f73 /src/aoimage.cpp | |
| parent | 469e293a1885e49f1d5994d41ac7cfc9f4666952 (diff) | |
| parent | f9c7205210fb9f768f583065971ece09e6b5eb03 (diff) | |
Merge pull request #957 from AttorneyOnline/kaleidoscope
The Kaleidoscope - Hell, it's about time.
Diffstat (limited to 'src/aoimage.cpp')
| -rw-r--r-- | src/aoimage.cpp | 65 |
1 files changed, 22 insertions, 43 deletions
diff --git a/src/aoimage.cpp b/src/aoimage.cpp index e737ffb3..062efbae 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -5,56 +5,35 @@ #include <QBitmap> -AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app, bool make_static) : QLabel(parent) +AOImage::AOImage(AOApplication *ao_app, QWidget *parent) + : QLabel(parent) + , ao_app(ao_app) +{} + +QString AOImage::image() { - m_parent = parent; - ao_app = p_ao_app; - is_static = make_static; - if (!is_static) // Only create the QMovie if we're non-static - { - movie = new QMovie(this); - connect(movie, &QMovie::frameChanged, [this]{ - QPixmap f_pixmap = movie->currentPixmap(); - f_pixmap = - f_pixmap.scaled(this->size(), Qt::IgnoreAspectRatio); - this->setPixmap(f_pixmap); - if (masked) { - this->setMask(f_pixmap.mask()); - } - }); - } + return m_file_name; } -AOImage::~AOImage() {} - -bool AOImage::set_image(QString p_image, QString p_misc) +bool AOImage::setImage(QString fileName, QString miscellaneous) { - QString p_image_resolved = ao_app->get_image(p_image, Options::getInstance().theme(), Options::getInstance().subTheme(), - ao_app->default_theme, p_misc, "", "", - is_static || !Options::getInstance().animatedThemeEnabled()); + QString p_image_resolved = ao_app->get_image(fileName, Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, miscellaneous, "", "", false); - if (!file_exists(p_image_resolved)) { - qWarning() << "could not find image" << p_image; + if (!file_exists(p_image_resolved)) + { + qWarning() << "could not find image" << fileName; return false; } - path = p_image_resolved; - if (!is_static) { - movie->stop(); - movie->setFileName(path); - if (Options::getInstance().animatedThemeEnabled() && movie->frameCount() > 1) { - movie->start(); - } - } - if (is_static || !Options::getInstance().animatedThemeEnabled() || movie->frameCount() <= 1) { - QPixmap f_pixmap(path); - - f_pixmap = - f_pixmap.scaled(this->size(), Qt::IgnoreAspectRatio); - this->setPixmap(f_pixmap); - if (masked) { - this->setMask(f_pixmap.mask()); - } - } + m_file_name = p_image_resolved; + QPixmap f_pixmap(m_file_name); + f_pixmap = f_pixmap.scaled(size(), Qt::IgnoreAspectRatio); + setPixmap(f_pixmap); + return true; } + +bool AOImage::setImage(QString fileName) +{ + return setImage(fileName, QString()); +} |
