Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
System
Dolphin
Commits
891ebf57
Commit
891ebf57
authored
Sep 25, 2020
by
Martin Tobias Holmedahl Sandsmark
Committed by
Elvis Angelaccio
Nov 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings about scaling pixmaps
parent
adfca907
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
13 deletions
+35
-13
src/kitemviews/kfileitemlistview.cpp
src/kitemviews/kfileitemlistview.cpp
+6
-1
src/kitemviews/kfileitemmodelrolesupdater.cpp
src/kitemviews/kfileitemmodelrolesupdater.cpp
+10
-8
src/kitemviews/kstandarditemlistwidget.cpp
src/kitemviews/kstandarditemlistwidget.cpp
+11
-2
src/kitemviews/private/kpixmapmodifier.cpp
src/kitemviews/private/kpixmapmodifier.cpp
+7
-1
src/panels/information/pixmapviewer.cpp
src/panels/information/pixmapviewer.cpp
+1
-1
No files found.
src/kitemviews/kfileitemlistview.cpp
View file @
891ebf57
...
...
@@ -168,7 +168,12 @@ QPixmap KFileItemListView::createDragPixmap(const KItemSet& indexes) const
QPixmap
pixmap
=
model
()
->
data
(
index
).
value
(
"iconPixmap"
).
value
<
QPixmap
>
();
if
(
pixmap
.
isNull
())
{
QIcon
icon
=
QIcon
::
fromTheme
(
model
()
->
data
(
index
).
value
(
"iconName"
).
toString
());
pixmap
=
icon
.
pixmap
(
size
,
size
);
if
(
!
icon
.
isNull
())
{
pixmap
=
icon
.
pixmap
(
size
,
size
);
}
else
{
pixmap
=
QPixmap
(
size
,
size
);
pixmap
.
fill
(
Qt
::
transparent
);
}
}
else
{
KPixmapModifier
::
scale
(
pixmap
,
QSize
(
size
,
size
)
*
dpr
);
}
...
...
src/kitemviews/kfileitemmodelrolesupdater.cpp
View file @
891ebf57
...
...
@@ -494,7 +494,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
QPixmap
scaledPixmap
=
pixmap
;
if
(
!
pixmap
.
hasAlpha
()
if
(
!
pixmap
.
hasAlpha
()
&&
!
pixmap
.
isNull
()
&&
m_iconSize
.
width
()
>
KIconLoader
::
SizeSmallMedium
&&
m_iconSize
.
height
()
>
KIconLoader
::
SizeSmallMedium
)
{
if
(
m_enlargeSmallPreviews
)
{
...
...
@@ -525,7 +525,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
KPixmapModifier
::
applyFrame
(
scaledPixmap
,
m_iconSize
);
}
}
}
else
{
}
else
if
(
!
pixmap
.
isNull
())
{
KPixmapModifier
::
scale
(
scaledPixmap
,
m_iconSize
*
qApp
->
devicePixelRatio
());
scaledPixmap
.
setDevicePixelRatio
(
qApp
->
devicePixelRatio
());
}
...
...
@@ -538,12 +538,14 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
// It is more efficient to do it here, as KIconLoader::drawOverlays()
// assumes that an overlay will be drawn and has some additional
// setup time.
for
(
const
QString
&
overlay
:
overlays
)
{
if
(
!
overlay
.
isEmpty
())
{
// There is at least one overlay, draw all overlays above m_pixmap
// and cancel the check
KIconLoader
::
global
()
->
drawOverlays
(
overlays
,
scaledPixmap
,
KIconLoader
::
Desktop
);
break
;
if
(
!
scaledPixmap
.
isNull
())
{
for
(
const
QString
&
overlay
:
overlays
)
{
if
(
!
overlay
.
isEmpty
())
{
// There is at least one overlay, draw all overlays above m_pixmap
// and cancel the check
KIconLoader
::
global
()
->
drawOverlays
(
overlays
,
scaledPixmap
,
KIconLoader
::
Desktop
);
break
;
}
}
}
...
...
src/kitemviews/kstandarditemlistwidget.cpp
View file @
891ebf57
...
...
@@ -314,7 +314,7 @@ void KStandardItemListWidget::paint(QPainter* painter, const QStyleOptionGraphic
}
const
KItemListStyleOption
&
itemListStyleOption
=
styleOption
();
if
(
isHovered
())
{
if
(
isHovered
()
&&
!
m_pixmap
.
isNull
()
)
{
if
(
hoverOpacity
()
<
1.0
)
{
/*
* Linear interpolation between m_pixmap and m_hoverPixmap.
...
...
@@ -357,7 +357,7 @@ void KStandardItemListWidget::paint(QPainter* painter, const QStyleOptionGraphic
}
else
{
drawPixmap
(
painter
,
m_hoverPixmap
);
}
}
else
{
}
else
if
(
!
m_pixmap
.
isNull
())
{
drawPixmap
(
painter
,
m_pixmap
);
}
...
...
@@ -962,6 +962,11 @@ void KStandardItemListWidget::updatePixmapCache()
KPixmapModifier
::
scale
(
m_pixmap
,
QSize
(
maxIconWidth
,
maxIconHeight
)
*
qApp
->
devicePixelRatio
());
}
if
(
m_pixmap
.
isNull
())
{
m_hoverPixmap
=
QPixmap
();
return
;
}
if
(
m_isCut
)
{
KIconEffect
*
effect
=
KIconLoader
::
global
()
->
iconEffect
();
m_pixmap
=
effect
->
apply
(
m_pixmap
,
KIconLoader
::
Desktop
,
KIconLoader
::
DisabledState
);
...
...
@@ -974,6 +979,10 @@ void KStandardItemListWidget::updatePixmapCache()
if
(
m_layout
==
IconsLayout
&&
isSelected
())
{
const
QColor
color
=
palette
().
brush
(
QPalette
::
Normal
,
QPalette
::
Highlight
).
color
();
QImage
image
=
m_pixmap
.
toImage
();
if
(
image
.
isNull
())
{
m_hoverPixmap
=
QPixmap
();
return
;
}
KIconEffect
::
colorize
(
image
,
color
,
0.8
f
);
m_pixmap
=
QPixmap
::
fromImage
(
image
);
}
...
...
src/kitemviews/private/kpixmapmodifier.cpp
View file @
891ebf57
...
...
@@ -298,7 +298,7 @@ namespace {
void
KPixmapModifier
::
scale
(
QPixmap
&
pixmap
,
const
QSize
&
scaledSize
)
{
if
(
scaledSize
.
isEmpty
())
{
if
(
scaledSize
.
isEmpty
()
||
pixmap
.
isNull
()
)
{
pixmap
=
QPixmap
();
return
;
}
...
...
@@ -309,6 +309,12 @@ void KPixmapModifier::scale(QPixmap& pixmap, const QSize& scaledSize)
void
KPixmapModifier
::
applyFrame
(
QPixmap
&
icon
,
const
QSize
&
scaledSize
)
{
if
(
icon
.
isNull
())
{
icon
=
QPixmap
(
scaledSize
);
icon
.
fill
(
Qt
::
transparent
);
return
;
}
static
TileSet
tileSet
;
qreal
dpr
=
qApp
->
devicePixelRatio
();
...
...
src/panels/information/pixmapviewer.cpp
View file @
891ebf57
...
...
@@ -136,7 +136,7 @@ void PixmapViewer::paintEvent(QPaintEvent* event)
style
()
->
drawItemPixmap
(
&
painter
,
rect
(),
Qt
::
AlignCenter
,
scaledPixmap
);
}
}
else
{
}
else
if
(
!
m_pixmap
.
isNull
())
{
style
()
->
drawItemPixmap
(
&
painter
,
rect
(),
Qt
::
AlignCenter
,
m_pixmap
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment