Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
System
Dolphin
Commits
65846125
Commit
65846125
authored
Jan 21, 2022
by
Jan Blackquill
🌈
Committed by
Jan Blackquill
Jan 25, 2022
Browse files
Make group headers mirror rtl
parent
d71b6172
Pipeline
#128805
passed with stage
in 3 minutes and 57 seconds
Changes
5
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
src/kitemviews/kitemlistgroupheader.cpp
View file @
65846125
...
...
@@ -161,6 +161,7 @@ void KItemListGroupHeader::resizeEvent(QGraphicsSceneResizeEvent* event)
if
(
event
->
oldSize
().
height
()
!=
event
->
newSize
().
height
())
{
m_dirtyCache
=
true
;
}
updateSize
();
}
void
KItemListGroupHeader
::
updateCache
()
...
...
@@ -174,6 +175,13 @@ void KItemListGroupHeader::updateCache()
m_separatorColor
=
mixedColor
(
c1
,
c2
,
10
);
m_roleColor
=
mixedColor
(
c1
,
c2
,
60
);
updateSize
();
m_dirtyCache
=
false
;
}
void
KItemListGroupHeader
::
updateSize
()
{
const
int
padding
=
qMax
(
1
,
m_styleOption
.
padding
);
const
int
horizontalMargin
=
qMax
(
2
,
m_styleOption
.
horizontalMargin
);
...
...
@@ -187,7 +195,7 @@ void KItemListGroupHeader::updateCache()
size
().
width
()
-
2
*
padding
-
horizontalMargin
,
roleHeight
);
m_dirtyCache
=
false
;
update
()
;
}
QColor
KItemListGroupHeader
::
mixedColor
(
const
QColor
&
c1
,
const
QColor
&
c2
,
int
c1Percent
)
...
...
src/kitemviews/kitemlistgroupheader.h
View file @
65846125
...
...
@@ -94,6 +94,7 @@ protected:
private:
void
updateCache
();
void
updateSize
();
static
QColor
mixedColor
(
const
QColor
&
c1
,
const
QColor
&
c2
,
int
c1Percent
=
50
);
...
...
src/kitemviews/kstandarditemlistgroupheader.cpp
View file @
65846125
...
...
@@ -17,8 +17,7 @@ KStandardItemListGroupHeader::KStandardItemListGroupHeader(QGraphicsWidget* pare
m_text
(),
m_pixmap
()
{
m_text
.
setTextFormat
(
Qt
::
PlainText
);
m_text
.
setPerformanceHint
(
QStaticText
::
AggressiveCaching
);
}
KStandardItemListGroupHeader
::~
KStandardItemListGroupHeader
()
...
...
@@ -37,7 +36,7 @@ void KStandardItemListGroupHeader::paintRole(QPainter* painter, const QRectF& ro
{
if
(
m_pixmap
.
isNull
())
{
painter
->
setPen
(
color
);
painter
->
draw
Static
Text
(
roleBounds
.
topLeft
()
,
m_text
);
painter
->
drawText
(
roleBounds
,
0
,
m_text
);
}
else
{
painter
->
drawPixmap
(
roleBounds
.
topLeft
(),
m_pixmap
);
}
...
...
@@ -55,7 +54,11 @@ void KStandardItemListGroupHeader::paintSeparator(QPainter* painter, const QColo
if
(
scrollOrientation
()
==
Qt
::
Horizontal
)
{
painter
->
drawLine
(
0
,
0
,
0
,
size
().
height
()
-
1
);
}
else
{
painter
->
drawLine
(
0
,
0
,
size
().
width
()
-
1
,
0
);
if
(
layoutDirection
()
==
Qt
::
LeftToRight
)
{
painter
->
drawLine
(
0
,
0
,
size
().
width
()
-
1
,
0
);
}
else
{
painter
->
drawLine
(
1
,
0
,
size
().
width
(),
0
);
}
}
}
...
...
@@ -75,7 +78,7 @@ void KStandardItemListGroupHeader::dataChanged(const QVariant& current, const QV
void
KStandardItemListGroupHeader
::
resizeEvent
(
QGraphicsSceneResizeEvent
*
event
)
{
QGraphicsWidget
::
resizeEvent
(
event
);
KItemListGroupHeader
::
resizeEvent
(
event
);
m_dirtyCache
=
true
;
}
...
...
@@ -87,7 +90,7 @@ void KStandardItemListGroupHeader::updateCache()
const
qreal
maxWidth
=
size
().
width
()
-
4
*
styleOption
().
padding
;
if
(
role
()
==
"rating"
)
{
m_text
.
setText
(
QString
()
)
;
m_text
=
QString
();
const
qreal
height
=
styleOption
().
fontMetrics
.
ascent
();
const
QSizeF
pixmapSize
(
qMin
(
height
*
5
,
maxWidth
),
height
);
...
...
@@ -104,7 +107,7 @@ void KStandardItemListGroupHeader::updateCache()
QFontMetricsF
fontMetrics
(
font
());
const
QString
text
=
fontMetrics
.
elidedText
(
data
().
toString
(),
Qt
::
ElideRight
,
maxWidth
);
m_text
.
setText
(
text
)
;
m_text
=
text
;
}
}
src/kitemviews/kstandarditemlistgroupheader.h
View file @
65846125
...
...
@@ -35,7 +35,7 @@ private:
private:
bool
m_dirtyCache
;
QSt
aticText
m_text
;
QSt
ring
m_text
;
QPixmap
m_pixmap
;
};
#endif
...
...
src/kitemviews/private/kitemlistheaderwidget.cpp
View file @
65846125
...
...
@@ -420,6 +420,12 @@ void KItemListHeaderWidget::paintRole(QPainter* painter,
// The following code is based on the code from QHeaderView::paintSection().
// SPDX-FileCopyrightText: 2011 Nokia Corporation and/or its subsidiary(-ies).
QStyleOptionHeader
option
;
option
.
direction
=
widget
->
layoutDirection
();
option
.
textAlignment
=
widget
->
layoutDirection
()
==
Qt
::
LeftToRight
?
Qt
::
AlignLeft
:
Qt
::
AlignRight
;
option
.
section
=
orderIndex
;
option
.
state
=
QStyle
::
State_None
|
QStyle
::
State_Raised
|
QStyle
::
State_Horizontal
;
if
(
isEnabled
())
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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