mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-08-03 11:27:33 -04:00
support gif catpacks
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
b90cda5eef
commit
2e428330f4
@ -22,12 +22,27 @@
|
||||
|
||||
CatPainter::CatPainter(const QString& path, QObject* parent) : QObject(parent)
|
||||
{
|
||||
m_image = QPixmap(path);
|
||||
// Attempt to load as a movie
|
||||
m_movie = new QMovie(path, QByteArray(), this);
|
||||
if (m_movie->isValid()) {
|
||||
// Start the animation if it's a valid movie file
|
||||
connect(m_movie, &QMovie::frameChanged, this, &CatPainter::updateFrame);
|
||||
m_movie->start();
|
||||
} else {
|
||||
// Otherwise, load it as a static image
|
||||
delete m_movie;
|
||||
m_movie = nullptr;
|
||||
|
||||
m_image = QPixmap(path);
|
||||
}
|
||||
}
|
||||
|
||||
void CatPainter::paint(QPainter* painter, const QRect& viewport)
|
||||
{
|
||||
QPixmap frame = m_image;
|
||||
if (m_movie && m_movie->isValid()) {
|
||||
frame = m_movie->currentPixmap();
|
||||
}
|
||||
|
||||
auto fit = APPLICATION->settings()->get("CatFit").toString();
|
||||
painter->setOpacity(APPLICATION->settings()->get("CatOpacity").toFloat() / 100);
|
||||
|
@ -34,5 +34,6 @@ class CatPainter : public QObject {
|
||||
void updateFrame();
|
||||
|
||||
private:
|
||||
QMovie* m_movie = nullptr;
|
||||
QPixmap m_image;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user