Krita Source Code Documentation
Loading...
Searching...
No Matches
KisSplashPreview.cpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
#include "
KisSplashPreview.h
"
3
#include <QPainter>
4
5
KisSplashPreview::KisSplashPreview
(QWidget *parent)
6
: QWidget(parent)
7
{
8
}
9
10
void
KisSplashPreview::setPixmap
(
const
QPixmap &pixmap)
11
{
12
if
(pixmap.cacheKey() !=
m_originalPixmap
.cacheKey()) {
13
m_originalPixmap
= pixmap;
14
m_scaledPixmap
= QPixmap();
15
update();
16
}
17
}
18
19
void
KisSplashPreview::paintEvent
(QPaintEvent *event)
20
{
21
QWidget::paintEvent(event);
22
23
if
(!
m_originalPixmap
.isNull()) {
24
qreal dpr = qMax(1.0, devicePixelRatioF());
25
int
w = width();
26
int
h = height();
27
28
if
(
m_scaledPixmap
.isNull()) {
29
m_scaledPixmap
=
m_originalPixmap
.scaled(qRound(qreal(w) * dpr),
30
qRound(qreal(h) * dpr),
31
Qt::KeepAspectRatio,
32
Qt::SmoothTransformation);
33
}
34
35
int
pw = qRound(qreal(
m_scaledPixmap
.width()) / dpr);
36
int
ph = qRound(qreal(
m_scaledPixmap
.height()) / dpr);
37
int
x = (w - pw) / 2;
38
int
y = (h - ph) / 2;
39
40
QPainter painter(
this
);
41
painter.drawPixmap(QRect(x, y, pw, ph),
m_scaledPixmap
);
42
}
43
}
44
45
void
KisSplashPreview::resizeEvent
(QResizeEvent *event)
46
{
47
QWidget::resizeEvent(event);
48
m_scaledPixmap
= QPixmap();
49
}
KisSplashPreview.h
KisSplashPreview::setPixmap
void setPixmap(const QPixmap &pixmap)
Definition
KisSplashPreview.cpp:10
KisSplashPreview::m_originalPixmap
QPixmap m_originalPixmap
Definition
KisSplashPreview.h:20
KisSplashPreview::KisSplashPreview
KisSplashPreview(QWidget *parent=nullptr)
Definition
KisSplashPreview.cpp:5
KisSplashPreview::m_scaledPixmap
QPixmap m_scaledPixmap
Definition
KisSplashPreview.h:21
KisSplashPreview::paintEvent
void paintEvent(QPaintEvent *event) override
Definition
KisSplashPreview.cpp:19
KisSplashPreview::resizeEvent
void resizeEvent(QResizeEvent *event) override
Definition
KisSplashPreview.cpp:45
libs
ui
widgets
KisSplashPreview.cpp
Generated at
2026-12-01 02:30:03+01:00
from
Krita
branch
master
, commit
b26c9f3874ea47e043fb7787ab8ff9a3254784df