From dd9e30b24ab20c6e559618f435b141383e0d0fcd Mon Sep 17 00:00:00 2001 From: flow Date: Mon, 29 Aug 2022 09:14:15 -0300 Subject: [PATCH] feat: add resource icon to InfoFrame Signed-off-by: flow --- launcher/ui/widgets/InfoFrame.cpp | 15 ++++++++++++++ launcher/ui/widgets/InfoFrame.h | 1 + launcher/ui/widgets/InfoFrame.ui | 34 +++++++++++++++++++++++++------ 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/launcher/ui/widgets/InfoFrame.cpp b/launcher/ui/widgets/InfoFrame.cpp index 69d77603..97d0ba37 100644 --- a/launcher/ui/widgets/InfoFrame.cpp +++ b/launcher/ui/widgets/InfoFrame.cpp @@ -87,11 +87,14 @@ void InfoFrame::updateWithMod(Mod const& m) { setDescription(m.description()); } + + setImage(); } void InfoFrame::updateWithResource(const Resource& resource) { setName(resource.name()); + setImage(); } // https://www.sportskeeda.com/minecraft-wiki/color-codes @@ -146,12 +149,14 @@ void InfoFrame::updateWithResourcePack(const ResourcePack& resource_pack) description_parsed.replace("\n", "
"); setDescription(description_parsed); + setImage(resource_pack.image({64, 64})); } void InfoFrame::clear() { setName(); setDescription(); + setImage(); } void InfoFrame::updateHiddenState() @@ -226,6 +231,16 @@ void InfoFrame::setDescription(QString text) ui->descriptionLabel->setText(labeltext); } +void InfoFrame::setImage(QPixmap img) +{ + if (img.isNull()) { + ui->iconLabel->setHidden(true); + } else { + ui->iconLabel->setHidden(false); + ui->iconLabel->setPixmap(img); + } +} + void InfoFrame::descriptionEllipsisHandler(QString link) { if(!m_current_box) diff --git a/launcher/ui/widgets/InfoFrame.h b/launcher/ui/widgets/InfoFrame.h index 4b6df023..d914aa0c 100644 --- a/launcher/ui/widgets/InfoFrame.h +++ b/launcher/ui/widgets/InfoFrame.h @@ -34,6 +34,7 @@ class InfoFrame : public QFrame { void setName(QString text = {}); void setDescription(QString text = {}); + void setImage(QPixmap img = {}); void clear(); diff --git a/launcher/ui/widgets/InfoFrame.ui b/launcher/ui/widgets/InfoFrame.ui index 0d3772d7..9e407ce9 100644 --- a/launcher/ui/widgets/InfoFrame.ui +++ b/launcher/ui/widgets/InfoFrame.ui @@ -22,10 +22,7 @@ 120 - - - 6 - + 0 @@ -38,7 +35,7 @@ 0 - + @@ -60,7 +57,7 @@ - + @@ -85,6 +82,31 @@ + + + + + 0 + 0 + + + + + 64 + 64 + + + + + + + false + + + 0 + + +