Skip to content

Commit 008f54e

Browse files
authored
fix(catpacks): restore cover scaling option (#153)
2 parents 3bdc758 + fc55187 commit 008f54e

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

launcher/ui/themes/CatPainter.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ void CatPainter::paint(QPainter* painter, const QRect& viewport)
5757
widWidth = frame.width();
5858
if (frame.height() < widHeight)
5959
widHeight = frame.height();
60+
} else if (fit == "cover") {
61+
aspectMode = Qt::KeepAspectRatioByExpanding;
6062
}
6163
auto pixmap = frame.scaled(widWidth, widHeight, aspectMode, Qt::SmoothTransformation);
6264
QRect rectOfPixmap = pixmap.rect();
63-
rectOfPixmap.moveBottomRight(viewport.bottomRight());
65+
if (fit == "cover") {
66+
rectOfPixmap.moveCenter(viewport.center());
67+
} else {
68+
rectOfPixmap.moveBottomRight(viewport.bottomRight());
69+
}
6470
painter->drawPixmap(rectOfPixmap.topLeft(), pixmap);
6571
painter->setOpacity(1.0);
6672
};

launcher/ui/widgets/AppearanceWidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ void AppearanceWidget::applySettings()
9898
settings->set("ConsoleFontSize", m_ui->fontSizeBox->value());
9999
settings->set("CatOpacity", m_ui->catOpacitySlider->value());
100100
auto catFit = m_ui->catFitComboBox->currentIndex();
101-
settings->set("CatFit", catFit == 0 ? "fit" : catFit == 1 ? "fill" : "strech");
101+
settings->set("CatFit", catFit == 0 ? "fit" : catFit == 1 ? "fill" : catFit == 2 ? "cover" : "strech");
102102
applySnow(m_ui->snowCheckBox->isChecked());
103103
}
104104

@@ -121,7 +121,7 @@ void AppearanceWidget::loadSettings()
121121
m_ui->catOpacitySlider->setValue(settings->get("CatOpacity").toInt());
122122

123123
auto catFit = settings->get("CatFit").toString();
124-
m_ui->catFitComboBox->setCurrentIndex(catFit == "fit" ? 0 : catFit == "fill" ? 1 : 2);
124+
m_ui->catFitComboBox->setCurrentIndex(catFit == "fit" ? 0 : catFit == "fill" ? 1 : catFit == "cover" ? 2 : 3);
125125
}
126126

127127
void AppearanceWidget::retranslateUi()

launcher/ui/widgets/AppearanceWidget.ui

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@
372372
</item>
373373
<item>
374374
<property name="text">
375+
<string>Cover</string>
376+
</property>
377+
</item>
378+
<item>
379+
<property name="text">
375380
<string>Stretch</string>
376381
</property>
377382
</item>

0 commit comments

Comments
 (0)