diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-03 17:00:56 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-03 17:00:56 +0300 |
commit | 6d758795af8a414d13db4951e3e9ed60af7091fd (patch) | |
tree | 8ca9785feb702b0342b05f7930b645fcc4204fed /launcher/ui/instanceview | |
parent | 5d5f1b86fdaa865bf8627acd86163469389ebb83 (diff) | |
parent | dedc9e4edc2769c62f33b6564f3009414245d9f3 (diff) | |
download | PrismLauncher-6d758795af8a414d13db4951e3e9ed60af7091fd.tar.gz PrismLauncher-6d758795af8a414d13db4951e3e9ed60af7091fd.tar.bz2 PrismLauncher-6d758795af8a414d13db4951e3e9ed60af7091fd.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into catpacks
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui/instanceview')
-rw-r--r-- | launcher/ui/instanceview/InstanceView.cpp | 25 | ||||
-rw-r--r-- | launcher/ui/instanceview/InstanceView.h | 8 |
2 files changed, 28 insertions, 5 deletions
diff --git a/launcher/ui/instanceview/InstanceView.cpp b/launcher/ui/instanceview/InstanceView.cpp index fbeffe35..05f0004d 100644 --- a/launcher/ui/instanceview/InstanceView.cpp +++ b/launcher/ui/instanceview/InstanceView.cpp @@ -73,6 +73,7 @@ InstanceView::InstanceView(QWidget *parent) setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); setAcceptDrops(true); setAutoScroll(true); + setPaintCat(APPLICATION->settings()->get("TheCat").toBool()); } InstanceView::~InstanceView() @@ -498,12 +499,34 @@ void InstanceView::mouseDoubleClickEvent(QMouseEvent *event) } } -void InstanceView::paintEvent(QPaintEvent *event) +void InstanceView::setPaintCat(bool visible) +{ + m_catVisible = visible; + if (visible) + m_catPixmap.load(APPLICATION->getCatPack()); + 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); diff --git a/launcher/ui/instanceview/InstanceView.h b/launcher/ui/instanceview/InstanceView.h index ac338274..36405675 100644 --- a/launcher/ui/instanceview/InstanceView.h +++ b/launcher/ui/instanceview/InstanceView.h @@ -85,10 +85,8 @@ public: virtual QRegion visualRegionForSelection(const QItemSelection &selection) const override; - int spacing() const - { - return m_spacing; - }; + int spacing() const { return m_spacing; }; + void setPaintCat(bool visible); public slots: virtual void updateGeometries() override; @@ -139,6 +137,8 @@ private: int m_currentItemsPerRow = -1; int m_currentCursorColumn= -1; mutable QCache<int, QRect> geometryCache; + bool m_catVisible = false; + QPixmap m_catPixmap; // point where the currently active mouse action started in geometry coordinates QPoint m_pressedPosition; |