From 7ee008e150bc5bcf76082d726f719ee0fdfda982 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Wed, 11 Feb 2026 02:37:39 -0600 Subject: Fluorine Manager: full Linux port of Mod Organizer 2 Complete native Linux port with FUSE-based virtual filesystem, Proton/umu-run integration, and Flatpak packaging. Key features: - FUSE VFS replacing Windows USVFS (in-process + standalone helper for Flatpak) - Proton/GE-Proton/umu-run launcher with env var forwarding - Flatpak support (sandbox-aware VFS, NXM handler, umu-run) - Wine prefix management UI - Case-insensitive path resolution for Linux filesystems - QSettings-safe INI handling (avoids Bethesda INI corruption) - Portable instance support with auto-generated launcher scripts Co-Authored-By: Claude Opus 4.6 --- libs/installer_fomod/src/scalelabel.cpp | 107 ++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 libs/installer_fomod/src/scalelabel.cpp (limited to 'libs/installer_fomod/src/scalelabel.cpp') diff --git a/libs/installer_fomod/src/scalelabel.cpp b/libs/installer_fomod/src/scalelabel.cpp new file mode 100644 index 0000000..e654bf5 --- /dev/null +++ b/libs/installer_fomod/src/scalelabel.cpp @@ -0,0 +1,107 @@ +#include "scalelabel.h" + +#include + +static bool isResourceMovie(const QString& path) +{ + for (QByteArray format : QMovie::supportedFormats()) { + QString fileExtension = "." + QString::fromUtf8(format); + if (path.endsWith(fileExtension)) { + return true; + } + } + + return false; +} + +ScaleLabel::ScaleLabel(QWidget* parent) : QLabel(parent) {} + +void ScaleLabel::setScalableResource(const QString& path) +{ + if (auto m = movie()) { + setMovie(nullptr); + delete m; + m_OriginalMovieSize = QSize(); + } + if (!pixmap().isNull()) { + setPixmap(QPixmap()); + m_UnscaledImage = QImage(); + } + + if (path.isEmpty()) { + return; + } + + if (isResourceMovie(path)) { + setScalableMovie(path); + } else { + setScalableImage(path); + } +} + +void ScaleLabel::setStatic(bool isStatic) +{ + m_isStatic = isStatic; + + if (auto m = movie()) { + if (isStatic) { + m->stop(); + } else { + m->start(); + } + } +} + +void ScaleLabel::setScalableMovie(const QString& path) +{ + QMovie* m = new QMovie(path); + if (!m->isValid()) { + qWarning(">%s< is an invalid movie. Reason: %s", qUtf8Printable(path), + m->lastErrorString().toStdString().c_str()); + delete m; + return; + } + + m->setParent(this); + setMovie(m); + m->start(); + m->stop(); + m_OriginalMovieSize = m->currentImage().size(); + + m->setScaledSize(m_OriginalMovieSize.scaled(size(), Qt::KeepAspectRatio)); + if (!m_isStatic) { + m->start(); + } +} + +void ScaleLabel::setScalableImage(const QString& path) +{ + QImage image(path); + if (image.isNull()) { + qWarning(">%s< is a null image", qUtf8Printable(path)); + } else { + m_UnscaledImage = image; + setPixmap(QPixmap::fromImage(image).scaled(size(), Qt::KeepAspectRatio)); + } +} + +void ScaleLabel::resizeEvent(QResizeEvent* event) +{ + if (auto m = movie()) { + m->stop(); + m->setScaledSize(m_OriginalMovieSize.scaled(event->size(), Qt::KeepAspectRatio)); + m->start(); + + // We can't just skip the start() above since that is what triggers the label to + // resize the movie The only way to resize the movie but keep it paused is to start + // and then re-stop it + if (m_isStatic) { + m->stop(); + } + } + auto p = pixmap(); + if (!p.isNull()) { + setPixmap( + QPixmap::fromImage(m_UnscaledImage).scaled(event->size(), Qt::KeepAspectRatio)); + } +} -- cgit v1.3.1