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
PIM
KAlarm
Commits
e3ca79e0
Commit
e3ca79e0
authored
Jul 21, 2021
by
David Jarvie
Browse files
Fix alarm time showing blank in alarm list in right-to-left mode
parent
32ea1d3f
Pipeline
#71344
failed with stage
in 4 minutes and 11 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Changelog
View file @
e3ca79e0
...
...
@@ -5,6 +5,7 @@ KAlarm Change Log
* Show hamburger menu when menu bar is hidden, to allow access to all options.
* Fix crash when context menu is requested after toolbar has been edited.
* Fix crash when alarm message is shown on a multiple screen system using Wayland [KDE Bug 439853]
* Fix alarm time showing blank in alarm list when using right-to-left languages.
* Fixes to dialogue layouts when using right-to-left languages.
=== Version 3.2.2 (KDE Applications 21.04.2) --- 26 May 2021 ===
...
...
src/resources/resourcedatamodelbase.cpp
View file @
e3ca79e0
...
...
@@ -660,7 +660,7 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
if
(
!
dateTime
.
isValid
())
return
i18nc
(
"@info Alarm never occurs"
,
"Never"
);
if
(
!
leadingZeroesChecked
&&
QApplication
::
isLeftToRight
())
// don't try to align right-to-left languages
if
(
!
leadingZeroesChecked
)
{
// Check whether the day number and/or hour have no leading zeroes, if
// they are at the start of the date/time. If no leading zeroes, they
...
...
@@ -668,75 +668,74 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
// can be aligned with each other.
// Note that if leading zeroes are not included in other components, no
// alignment will be attempted.
QLocale
locale
;
{
// Check the date format. 'dd' provides leading zeroes; single 'd'
// provides no leading zeroes.
dateFormat
=
locale
.
dateFormat
(
QLocale
::
ShortFormat
);
}
{
// Check the time format.
// Remove all but hours, minutes and AM/PM, since alarms are on minute
// boundaries. Preceding separators are also removed.
timeFormat
=
locale
.
timeFormat
(
QLocale
::
ShortFormat
);
for
(
int
del
=
0
,
predel
=
0
,
c
=
0
;
c
<
timeFormat
.
size
();
++
c
)
{
char
ch
=
timeFormat
.
at
(
c
).
toLatin1
();
switch
(
ch
)
{
case
'H'
:
case
'h'
:
case
'm'
:
case
'a'
:
case
'A'
:
if
(
predel
==
1
)
{
timeFormat
.
remove
(
del
,
c
-
del
);
c
=
del
;
}
del
=
c
+
1
;
// start deleting from the next character
if
((
ch
==
'A'
&&
del
<
timeFormat
.
size
()
&&
timeFormat
.
at
(
del
).
toLatin1
()
==
'P'
)
||
(
ch
==
'a'
&&
del
<
timeFormat
.
size
()
&&
timeFormat
.
at
(
del
).
toLatin1
()
==
'p'
))
++
c
,
++
del
;
predel
=
-
1
;
break
;
case
's'
:
case
'z'
:
case
't'
:
timeFormat
.
remove
(
del
,
c
+
1
-
del
);
c
=
del
-
1
;
if
(
!
predel
)
predel
=
1
;
break
;
default:
break
;
}
}
// Check the date format. 'dd' provides leading zeroes; single 'd'
// provides no leading zeroes.
QLocale
locale
;
dateFormat
=
locale
.
dateFormat
(
QLocale
::
ShortFormat
);
// 'HH' and 'hh' provide leading zeroes; single 'H' or 'h' provide no
// leading zeroes.
int
i
=
timeFormat
.
indexOf
(
QRegExp
(
QLatin1String
(
"[hH]"
)));
int
first
=
timeFormat
.
indexOf
(
QRegExp
(
QLatin1String
(
"[hHmaA]"
)));
if
(
i
>=
0
&&
i
==
first
&&
(
i
==
timeFormat
.
size
()
-
1
||
timeFormat
.
at
(
i
)
!=
timeFormat
.
at
(
i
+
1
)))
// Check the time format.
// Remove all but hours, minutes and AM/PM, since alarms are on minute
// boundaries. Preceding separators are also removed.
timeFormat
=
locale
.
timeFormat
(
QLocale
::
ShortFormat
);
for
(
int
del
=
0
,
predel
=
0
,
c
=
0
;
c
<
timeFormat
.
size
();
++
c
)
{
char
ch
=
timeFormat
.
at
(
c
).
toLatin1
();
switch
(
ch
)
{
timeFullFormat
=
timeFormat
;
timeFullFormat
.
insert
(
i
,
timeFormat
.
at
(
i
));
// Find index to hour in formatted times
const
QTime
t
(
1
,
30
,
30
);
const
QString
nozero
=
t
.
toString
(
timeFormat
);
const
QString
zero
=
t
.
toString
(
timeFullFormat
);
for
(
int
i
=
0
;
i
<
nozero
.
size
();
++
i
)
if
(
nozero
[
i
]
!=
zero
[
i
])
case
'H'
:
case
'h'
:
case
'm'
:
case
'a'
:
case
'A'
:
if
(
predel
==
1
)
{
hourOffset
=
i
;
break
;
timeFormat
.
remove
(
del
,
c
-
del
)
;
c
=
del
;
}
del
=
c
+
1
;
// start deleting from the next character
if
((
ch
==
'A'
&&
del
<
timeFormat
.
size
()
&&
timeFormat
.
at
(
del
).
toLatin1
()
==
'P'
)
||
(
ch
==
'a'
&&
del
<
timeFormat
.
size
()
&&
timeFormat
.
at
(
del
).
toLatin1
()
==
'p'
))
++
c
,
++
del
;
predel
=
-
1
;
break
;
case
's'
:
case
'z'
:
case
't'
:
timeFormat
.
remove
(
del
,
c
+
1
-
del
);
c
=
del
-
1
;
if
(
!
predel
)
predel
=
1
;
break
;
default:
break
;
}
}
// 'HH' and 'hh' provide leading zeroes; single 'H' or 'h' provide no
// leading zeroes.
int
i
=
timeFormat
.
indexOf
(
QRegExp
(
QLatin1String
(
"[hH]"
)));
int
first
=
timeFormat
.
indexOf
(
QRegExp
(
QLatin1String
(
"[hHmaA]"
)));
if
(
i
>=
0
&&
i
==
first
&&
(
i
==
timeFormat
.
size
()
-
1
||
timeFormat
.
at
(
i
)
!=
timeFormat
.
at
(
i
+
1
)))
{
timeFullFormat
=
timeFormat
;
timeFullFormat
.
insert
(
i
,
timeFormat
.
at
(
i
));
// Find index to hour in formatted times
const
QTime
t
(
1
,
30
,
30
);
const
QString
nozero
=
t
.
toString
(
timeFormat
);
const
QString
zero
=
t
.
toString
(
timeFullFormat
);
for
(
int
i
=
0
;
i
<
nozero
.
size
();
++
i
)
if
(
nozero
[
i
]
!=
zero
[
i
])
{
hourOffset
=
i
;
break
;
}
}
leadingZeroesChecked
=
true
;
}
leadingZeroesChecked
=
true
;
const
KADateTime
kdt
=
dateTime
.
effectiveKDateTime
().
toTimeSpec
(
Preferences
::
timeSpec
());
QString
dateTimeText
=
kdt
.
date
().
toString
(
dateFormat
);
...
...
@@ -746,7 +745,8 @@ QString ResourceDataModelBase::alarmTimeText(const DateTime& dateTime, char lead
// Display the time of day if it's a date/time value, or if it's
// a date-only value but it's in a different time zone
dateTimeText
+=
QLatin1Char
(
' '
);
bool
useFullFormat
=
leadingZero
&&
!
timeFullFormat
.
isEmpty
();
// Don't try to align right-to-left languages...
const
bool
useFullFormat
=
QApplication
::
isLeftToRight
()
&&
leadingZero
&&
!
timeFullFormat
.
isEmpty
();
QString
timeText
=
kdt
.
time
().
toString
(
useFullFormat
?
timeFullFormat
:
timeFormat
);
if
(
useFullFormat
&&
leadingZero
!=
'0'
&&
timeText
.
at
(
hourOffset
)
==
QLatin1Char
(
'0'
))
timeText
[
hourOffset
]
=
QChar
::
fromLatin1
(
leadingZero
);
...
...
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