Made cat scalable
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
9b9d439fce
commit
d33de2e427
@ -901,21 +901,8 @@ void MainWindow::onCatToggled(bool state)
|
|||||||
|
|
||||||
void MainWindow::setCatBackground(bool enabled)
|
void MainWindow::setCatBackground(bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled) {
|
view->setCatVisible(enabled);
|
||||||
view->setStyleSheet(QString(R"(
|
view->viewport()->repaint();
|
||||||
InstanceView
|
|
||||||
{
|
|
||||||
background-image: url(:/backgrounds/%1);
|
|
||||||
background-attachment: fixed;
|
|
||||||
background-clip: padding;
|
|
||||||
background-position: bottom right;
|
|
||||||
background-repeat: none;
|
|
||||||
background-color:palette(base);
|
|
||||||
})")
|
|
||||||
.arg(ThemeManager::getCatImage()));
|
|
||||||
} else {
|
|
||||||
view->setStyleSheet(QString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::runModalTask(Task *task)
|
void MainWindow::runModalTask(Task *task)
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include <QAccessible>
|
#include <QAccessible>
|
||||||
|
|
||||||
#include "VisualGroup.h"
|
#include "VisualGroup.h"
|
||||||
|
#include "ui/themes/ThemeManager.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
@ -73,6 +74,7 @@ InstanceView::InstanceView(QWidget *parent)
|
|||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
setAutoScroll(true);
|
setAutoScroll(true);
|
||||||
|
setCatVisible(APPLICATION->settings()->get("TheCat").toBool());
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceView::~InstanceView()
|
InstanceView::~InstanceView()
|
||||||
@ -498,12 +500,31 @@ void InstanceView::mouseDoubleClickEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceView::setCatVisible(bool visible)
|
||||||
|
{
|
||||||
|
m_catVisible = visible;
|
||||||
|
m_catPixmap.load(QString(":/backgrounds/%1").arg(ThemeManager::getCatImage()));
|
||||||
|
}
|
||||||
|
|
||||||
void InstanceView::paintEvent(QPaintEvent* event)
|
void InstanceView::paintEvent(QPaintEvent* event)
|
||||||
{
|
{
|
||||||
executeDelayedItemsLayout();
|
executeDelayedItemsLayout();
|
||||||
|
|
||||||
QPainter painter(this->viewport());
|
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)
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
QStyleOptionViewItem option;
|
QStyleOptionViewItem option;
|
||||||
initViewItemOption(&option);
|
initViewItemOption(&option);
|
||||||
|
@ -85,10 +85,8 @@ public:
|
|||||||
|
|
||||||
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const override;
|
virtual QRegion visualRegionForSelection(const QItemSelection &selection) const override;
|
||||||
|
|
||||||
int spacing() const
|
int spacing() const { return m_spacing; };
|
||||||
{
|
void setCatVisible(bool visible);
|
||||||
return m_spacing;
|
|
||||||
};
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void updateGeometries() override;
|
virtual void updateGeometries() override;
|
||||||
@ -139,6 +137,8 @@ private:
|
|||||||
int m_currentItemsPerRow = -1;
|
int m_currentItemsPerRow = -1;
|
||||||
int m_currentCursorColumn= -1;
|
int m_currentCursorColumn= -1;
|
||||||
mutable QCache<int, QRect> geometryCache;
|
mutable QCache<int, QRect> geometryCache;
|
||||||
|
bool m_catVisible = false;
|
||||||
|
QPixmap m_catPixmap;
|
||||||
|
|
||||||
// point where the currently active mouse action started in geometry coordinates
|
// point where the currently active mouse action started in geometry coordinates
|
||||||
QPoint m_pressedPosition;
|
QPoint m_pressedPosition;
|
||||||
|
Loading…
Reference in New Issue
Block a user