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
Network
KTorrent
Commits
084362d1
Commit
084362d1
authored
Dec 27, 2021
by
Alexander Lohnau
💬
Browse files
Port away from deprecated QFontMetrics::width
parent
797fc5fd
Changes
2
Hide whitespace changes
Inline
Side-by-side
plugins/bwscheduler/guidanceline.cpp
View file @
084362d1
...
...
@@ -27,7 +27,7 @@ GuidanceLine::GuidanceLine(qreal x, qreal y, qreal text_offset)
text
->
setPos
(
text_offset
,
y
);
QFontMetricsF
fm
(
text
->
font
());
qreal
xe
=
text_offset
+
fm
.
width
(
ZERO
);
qreal
xe
=
text_offset
+
fm
.
horizontalAdvance
(
ZERO
);
setLine
(
x
,
y
,
xe
,
y
);
}
...
...
@@ -42,7 +42,7 @@ void GuidanceLine::update(qreal nx, qreal ny, const QString &txt)
text
->
setPlainText
(
txt
);
text
->
setPos
(
text_offset
,
y
);
QFontMetricsF
fm
(
text
->
font
());
qreal
xe
=
text_offset
+
fm
.
width
(
txt
);
qreal
xe
=
text_offset
+
fm
.
horizontalAdvance
(
txt
);
setLine
(
x
,
y
,
xe
,
y
);
}
...
...
plugins/bwscheduler/weekscene.cpp
View file @
084362d1
...
...
@@ -44,7 +44,7 @@ qreal LongestDayWidth(const QFontMetricsF &fm)
{
qreal
wd
=
0
;
for
(
int
i
=
1
;
i
<=
7
;
i
++
)
{
qreal
w
=
fm
.
width
(
QLocale
::
system
().
dayName
(
i
));
qreal
w
=
fm
.
horizontalAdvance
(
QLocale
::
system
().
dayName
(
i
));
if
(
w
>
wd
)
wd
=
w
;
}
...
...
@@ -80,7 +80,7 @@ void WeekScene::addCalendar()
delete
tmp
;
// first add 7 rectangles for each day of the week
xoff
=
fm
.
width
(
QStringLiteral
(
"00:00"
))
+
10
;
xoff
=
fm
.
horizontalAdvance
(
QStringLiteral
(
"00:00"
))
+
10
;
yoff
=
2
*
fm
.
height
()
+
10
;
day_width
=
LongestDayWidth
(
fm
)
*
1.5
;
hour_height
=
fm
.
height
()
*
1.5
;
...
...
@@ -99,7 +99,7 @@ void WeekScene::addCalendar()
QString
day
=
QLocale
::
system
().
dayName
(
i
+
1
);
// make sure day is centered in the middle of the column
qreal
dlen
=
fm
.
width
(
day
);
qreal
dlen
=
fm
.
horizontalAdvance
(
day
);
qreal
mid
=
xoff
+
day_width
*
(
i
+
0.5
);
qreal
start
=
mid
-
dlen
*
0.5
;
...
...
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