diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-09 19:38:17 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-09 19:38:17 +0300 |
commit | d7f4e40f85d1e253fe62e1c9e1cfb1842ffb0c86 (patch) | |
tree | 9348d96110913ec2916e0854d5e495e33e1c9352 /launcher/ui/instanceview/InstanceView.cpp | |
parent | 908ac813e0f96126a643851e99379956faa08cda (diff) | |
parent | 67d473aab773e7f94c394ebdde05581dc8f805de (diff) | |
download | PrismLauncher-d7f4e40f85d1e253fe62e1c9e1cfb1842ffb0c86.tar.gz PrismLauncher-d7f4e40f85d1e253fe62e1c9e1cfb1842ffb0c86.tar.bz2 PrismLauncher-d7f4e40f85d1e253fe62e1c9e1cfb1842ffb0c86.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into curse
Diffstat (limited to 'launcher/ui/instanceview/InstanceView.cpp')
-rw-r--r-- | launcher/ui/instanceview/InstanceView.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index fbeffe35..1911dd59 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -48,6 +48,7 @@ #include <QAccessible> #include "VisualGroup.h" +#include "ui/themes/ThemeManager.h" #include <QDebug> #include <Application.h> @@ -73,6 +74,7 @@ InstanceView::InstanceView(QWidget *parent) setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setAcceptDrops(true); setAutoScroll(true); + setPaintCat(APPLICATION->settings()->get("TheCat").toBool()); } InstanceView::~InstanceView() @@ -498,12 +500,34 @@ void InstanceView::mouseDoubleClickEvent(QMouseEvent *event) } } -void InstanceView::paintEvent(QPaintEvent *event) +void InstanceView::setPaintCat(bool visible) +{ + m_catVisible = visible; + if (visible) + m_catPixmap.load(QString(":/backgrounds/%1").arg(ThemeManager::getCatImage())); + else + m_catPixmap = QPixmap(); +} + +void InstanceView::paintEvent(QPaintEvent* event) { executeDelayedItemsLayout(); QPainter painter(this->viewport()); + if (m_catVisible) { + int widWidth = this->viewport()->width(); + int widHeight = this->viewport()->height(); + if (m_catPixmap.width() < widWidth) + widWidth = m_catPixmap.width(); + if (m_catPixmap.height() < widHeight) + widHeight = m_catPixmap.height(); + auto pixmap = m_catPixmap.scaled(widWidth, widHeight, Qt::KeepAspectRatio); + QRect rectOfPixmap = pixmap.rect(); + rectOfPixmap.moveBottomRight(this->viewport()->rect().bottomRight()); + painter.drawPixmap(rectOfPixmap.topLeft(), pixmap); + } + #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) QStyleOptionViewItem option; initViewItemOption(&option); |