feat: add resource icon to InfoFrame

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-08-29 09:14:15 -03:00
parent 6a93688b2e
commit dd9e30b24a
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
3 changed files with 44 additions and 6 deletions

View File

@ -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", "<br>");
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)

View File

@ -34,6 +34,7 @@ class InfoFrame : public QFrame {
void setName(QString text = {});
void setDescription(QString text = {});
void setImage(QPixmap img = {});
void clear();

View File

@ -22,10 +22,7 @@
<height>120</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>6</number>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
@ -38,7 +35,7 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<item row="0" column="1">
<widget class="QLabel" name="nameLabel">
<property name="text">
<string notr="true"/>
@ -60,7 +57,7 @@
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="QLabel" name="descriptionLabel">
<property name="toolTip">
<string notr="true"/>
@ -85,6 +82,31 @@
</property>
</widget>
</item>
<item row="0" column="0" rowspan="2">
<widget class="QLabel" name="iconLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>64</width>
<height>64</height>
</size>
</property>
<property name="text">
<string notr="true"/>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>