Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
9e74f90f
Commit
9e74f90f
authored
Jan 20, 2021
by
Waqar Ahmed
Committed by
Christoph Cullmann
Jan 20, 2021
Browse files
Fix layout for RTL
parent
361d01d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
kate/katecommandbar.cpp
View file @
9e74f90f
...
...
@@ -80,6 +80,8 @@ public:
QTextDocument
doc
;
const
auto
original
=
index
.
data
().
toString
();
const
auto
strs
=
index
.
data
().
toString
().
split
(
QLatin1Char
(
':'
));
QString
str
=
strs
.
at
(
1
);
const
QString
nameColor
=
option
.
palette
.
color
(
QPalette
::
Link
).
name
();
...
...
@@ -102,10 +104,27 @@ public:
options
.
text
=
QString
();
// clear old text
options
.
widget
->
style
()
->
drawControl
(
QStyle
::
CE_ItemViewItem
,
&
options
,
painter
,
options
.
widget
);
// fix stuff for rtl
// QTextDocument doesn't work with RTL text out of the box so we give it a hand here by increasing
// the text width to our rect size. Icon displacement is also calculated here because 'translate()'
// later will not work.
const
bool
rtl
=
original
.
isRightToLeft
();
if
(
rtl
)
{
auto
r
=
options
.
widget
->
style
()
->
subElementRect
(
QStyle
::
SE_ItemViewItemText
,
&
options
,
options
.
widget
);
auto
hasIcon
=
index
.
data
(
Qt
::
DecorationRole
).
value
<
QIcon
>
().
isNull
();
if
(
hasIcon
)
doc
.
setTextWidth
(
r
.
width
()
-
25
);
else
doc
.
setTextWidth
(
r
.
width
());
}
// draw text
painter
->
translate
(
option
.
rect
.
x
(),
option
.
rect
.
y
());
// leave space for icon
painter
->
translate
(
25
,
0
);
if
(
!
rtl
)
painter
->
translate
(
25
,
0
);
doc
.
drawContents
(
painter
);
painter
->
restore
();
...
...
Write
Preview
Supports
Markdown
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