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
PIM
KPkPass
Commits
659931f7
Commit
659931f7
authored
Mar 10, 2018
by
Volker Krause
Browse files
Add field text alignment property
parent
c0d9a2ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
autotests/pkpasstest.cpp
View file @
659931f7
...
...
@@ -63,6 +63,7 @@ private slots:
field
=
pass
->
field
(
QLatin1String
(
"boarding"
));
QCOMPARE
(
field
.
key
(),
QLatin1String
(
"boarding"
));
QCOMPARE
(
field
.
value
(),
QLatin1String
(
"20:25"
));
QCOMPARE
(
field
.
textAlignment
(),
Qt
::
AlignLeft
);
auto
boardingPass
=
dynamic_cast
<
KPkPass
::
BoardingPass
*>
(
pass
.
get
());
QVERIFY
(
boardingPass
);
...
...
src/pkpass/field.cpp
View file @
659931f7
...
...
@@ -21,6 +21,7 @@
#include
"pass.h"
#include
"pass_p.h"
#include
<QGuiApplication>
#include
<QJsonObject>
using
namespace
KPkPass
;
...
...
@@ -91,3 +92,16 @@ QString Field::changeMessage() const
msg
=
msg
.
replace
(
QLatin1String
(
"%@"
),
valueDisplayString
());
return
msg
;
}
Qt
::
Alignment
Field
::
textAlignment
()
const
{
const
auto
alignStr
=
d
->
obj
.
value
(
QLatin1String
(
"textAlignment"
)).
toString
();
if
(
alignStr
==
QLatin1String
(
"PKTextAlignmentLeft"
))
{
return
Qt
::
AlignLeft
;
}
else
if
(
alignStr
==
QLatin1String
(
"PKTextAlignmentCenter"
))
{
return
Qt
::
AlignHCenter
;
}
else
if
(
alignStr
==
QLatin1String
(
"PKTextAlignmentRight"
))
{
return
Qt
::
AlignRight
;
}
return
QGuiApplication
::
layoutDirection
()
==
Qt
::
LeftToRight
?
Qt
::
AlignLeft
:
Qt
::
AlignRight
;
}
src/pkpass/field.h
View file @
659931f7
...
...
@@ -46,6 +46,7 @@ class KPKPASS_EXPORT Field
Q_PROPERTY
(
QVariant
value
READ
value
CONSTANT
)
Q_PROPERTY
(
QString
valueDisplayString
READ
valueDisplayString
CONSTANT
)
Q_PROPERTY
(
QString
changeMessage
READ
changeMessage
CONSTANT
)
Q_PROPERTY
(
Qt
::
Alignment
textAlignment
READ
textAlignment
CONSTANT
)
public:
Field
();
...
...
@@ -72,7 +73,9 @@ public:
/** The localized change message for this value. */
QString
changeMessage
()
const
;
// TODO add textAlignment property
/** Text alignment. */
Qt
::
Alignment
textAlignment
()
const
;
private:
friend
class
PassPrivate
;
explicit
Field
(
const
QJsonObject
&
obj
,
const
Pass
*
pass
);
...
...
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