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
libkleo
Commits
c0179b08
Commit
c0179b08
authored
Jul 13, 2022
by
Ingo Klöcker
Browse files
Add a helper for decorating a button according to compliance
GnuPG-bug-id: 6073
parent
24578a0c
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/ui/newkeyapprovaldialog.cpp
View file @
c0179b08
...
...
@@ -852,21 +852,12 @@ public:
}
}
DeVSCompliance
::
decorate
(
mOkButton
,
de_vs
);
if
(
de_vs
)
{
mOkButton
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"security-high"
)));
if
(
!
SystemInfo
::
isHighContrastModeActive
())
{
mOkButton
->
setStyleSheet
(
QStringLiteral
(
"background-color: "
)
+
KColorScheme
(
QPalette
::
Active
,
KColorScheme
::
View
).
background
(
KColorScheme
::
PositiveBackground
).
color
().
name
());
}
mComplianceLbl
->
setText
(
i18nc
(
"%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant"
,
"%1 communication possible."
,
Formatting
::
deVsString
()));
}
else
{
mOkButton
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"security-medium"
)));
if
(
!
SystemInfo
::
isHighContrastModeActive
())
{
mOkButton
->
setStyleSheet
(
QStringLiteral
(
"background-color: "
)
+
KColorScheme
(
QPalette
::
Active
,
KColorScheme
::
View
).
background
(
KColorScheme
::
NegativeBackground
).
color
().
name
());
}
mComplianceLbl
->
setText
(
i18nc
(
"%1 is a placeholder for the name of a compliance mode. E.g. NATO RESTRICTED compliant or VS-NfD compliant"
,
"%1 communication not possible."
,
Formatting
::
deVsString
()));
...
...
src/utils/compliance.cpp
View file @
c0179b08
...
...
@@ -14,6 +14,11 @@
#include
"cryptoconfig.h"
#include
"gnupg.h"
#include
"systeminfo.h"
#include
<KColorScheme>
#include
<QPushButton>
bool
Kleo
::
DeVSCompliance
::
isActive
()
{
...
...
@@ -36,3 +41,28 @@ bool Kleo::DeVSCompliance::isCompliant()
}
return
getCryptoConfigIntValue
(
"gpg"
,
"compliance_de_vs"
,
0
)
!=
0
;
}
void
Kleo
::
DeVSCompliance
::
decorate
(
QPushButton
*
button
)
{
decorate
(
button
,
isCompliant
());
}
void
Kleo
::
DeVSCompliance
::
decorate
(
QPushButton
*
button
,
bool
compliant
)
{
if
(
!
button
)
{
return
;
}
if
(
compliant
)
{
button
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"security-high"
)));
if
(
!
SystemInfo
::
isHighContrastModeActive
())
{
const
auto
bgColor
=
KColorScheme
(
QPalette
::
Active
,
KColorScheme
::
View
).
background
(
KColorScheme
::
PositiveBackground
).
color
().
name
();
button
->
setStyleSheet
(
QStringLiteral
(
"QPushButton { background-color: %1; };"
).
arg
(
bgColor
));
}
}
else
{
button
->
setIcon
(
QIcon
::
fromTheme
(
QStringLiteral
(
"security-medium"
)));
if
(
!
SystemInfo
::
isHighContrastModeActive
())
{
const
auto
bgColor
=
KColorScheme
(
QPalette
::
Active
,
KColorScheme
::
View
).
background
(
KColorScheme
::
NegativeBackground
).
color
().
name
();
button
->
setStyleSheet
(
QStringLiteral
(
"QPushButton { background-color: %1; };"
).
arg
(
bgColor
));
}
}
}
src/utils/compliance.h
View file @
c0179b08
...
...
@@ -12,6 +12,8 @@
#include
"kleo_export.h"
class
QPushButton
;
namespace
Kleo
::
DeVSCompliance
{
...
...
@@ -28,4 +30,20 @@ KLEO_EXPORT bool isActive();
*/
KLEO_EXPORT
bool
isCompliant
();
/**
* \overload
*
* Sets the appropriate icon and, unless high-contrast mode is active, the
* appropriate background color of \p button depending on the state of
* compliance.
*/
KLEO_EXPORT
void
decorate
(
QPushButton
*
button
);
/**
* Sets the appropriate icon and, unless high-contrast mode is active, the
* appropriate background color of \p button depending on the value of
* \p compliant.
*/
KLEO_EXPORT
void
decorate
(
QPushButton
*
button
,
bool
compliant
);
}
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