Commit 5491ec66 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Disable customs colors if high-contrast mode is active on Windows

Custom colors will very likely break the high-contrast promise of the
high-contrast mode. Therefore, we don't use custom colors for any UI
elements if the high-contrast mode is active.

GnuPG-bug-id: 6073
parent 02890d62
......@@ -34,7 +34,7 @@ set(KF5_MIN_VERSION "5.95.0")
set(KIDENTITYMANAGEMENT_VERSION "5.20.40")
set(KMAILTRANSPORT_VERSION "5.20.40")
set(KMIME_VERSION "5.20.40")
set(LIBKLEO_VERSION "5.20.46")
set(LIBKLEO_VERSION "5.20.47")
set(QT_REQUIRED_VERSION "5.15.2")
set(GPGME_REQUIRED_VERSION "1.16.0")
......
......@@ -24,6 +24,7 @@
#include <Libkleo/MessageBox>
#include <Libkleo/Classify>
#include <Libkleo/SystemInfo>
#include <gpgme++/key.h>
#include <gpgme++/decryptionresult.h>
......@@ -236,9 +237,18 @@ ResultItemWidget::ResultItemWidget(const std::shared_ptr<const Task::Result> &re
const QColor color = colorForVisualCode(d->m_result->code());
const QColor txtColor = txtColorForVisualCode(d->m_result->code());
const QColor linkColor = txtColor;
const QString styleSheet = QStringLiteral("QFrame,QLabel { background-color: %1; margin: 0px; }"
"QFrame#resultFrame{ border-color: %2; border-style: solid; border-radius: 3px; border-width: 1px }"
"QLabel { color: %3; padding: 5px; border-radius: 3px }").arg(color.name()).arg(color.darker(150).name()).arg(txtColor.name());
const QString styleSheet = SystemInfo::isHighContrastModeActive()
? QStringLiteral(
"QFrame,QLabel { margin: 0px; }"
"QFrame#resultFrame{ border-style: solid; border-radius: 3px; border-width: 1px }"
"QLabel { padding: 5px; border-radius: 3px }")
: QStringLiteral(
"QFrame,QLabel { background-color: %1; margin: 0px; }"
"QFrame#resultFrame{ border-color: %2; border-style: solid; border-radius: 3px; border-width: 1px }"
"QLabel { color: %3; padding: 5px; border-radius: 3px }")
.arg(color.name())
.arg(color.darker(150).name())
.arg(txtColor.name());
auto topLayout = new QVBoxLayout(this);
auto frame = new QFrame;
frame->setObjectName(QStringLiteral("resultFrame"));
......
......@@ -23,6 +23,7 @@
#include <Libkleo/Stl_Util>
#include <Libkleo/Formatting>
#include <Libkleo/SystemInfo>
#include <gpgme++/key.h>
......@@ -275,9 +276,11 @@ private:
btn->setIcon(QIcon::fromTheme(de_vs
? QStringLiteral("security-high")
: QStringLiteral("security-medium")));
btn->setStyleSheet(QStringLiteral("QPushButton { background-color: %1; }").arg(de_vs
? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::PositiveBackground).color().name()
: KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NegativeBackground).color().name()));
if (!SystemInfo::isHighContrastModeActive()) {
btn->setStyleSheet(QStringLiteral("QPushButton { background-color: %1; }").arg(de_vs
? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::PositiveBackground).color().name()
: KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NegativeBackground).color().name()));
}
ui.complianceLB.setText(de_vs
? 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())
......
......@@ -30,6 +30,7 @@
#include "kleopatra_debug.h"
#include <Libkleo/GnuPG>
#include <Libkleo/Formatting>
#include <Libkleo/SystemInfo>
#include <Libkleo/FileNameRequester>
#include <QWindow>
......@@ -448,9 +449,11 @@ private Q_SLOTS:
btn->setIcon(QIcon::fromTheme(de_vs
? QStringLiteral("security-high")
: QStringLiteral("security-medium")));
btn->setStyleSheet(QStringLiteral("QPushButton { background-color: %1; }").arg(de_vs
? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::PositiveBackground).color().name()
: KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NegativeBackground).color().name()));
if (!SystemInfo::isHighContrastModeActive()) {
btn->setStyleSheet(QStringLiteral("QPushButton { background-color: %1; }").arg(de_vs
? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::PositiveBackground).color().name()
: KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NegativeBackground).color().name()));
}
mParent->setLabelText(de_vs
? 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())
......
......@@ -13,6 +13,8 @@
#ifndef QT_NO_DIRMODEL
#include <Libkleo/SystemInfo>
#include <KLocalizedString>
#include <KMessageBox>
......@@ -58,7 +60,7 @@ public:
QVariant data(const QModelIndex &mi, int role = Qt::DisplayRole) const override
{
if (mi.isValid() && role == Qt::BackgroundRole) {
if (mi.isValid() && role == Qt::BackgroundRole && !SystemInfo::isHighContrastModeActive()) {
const QHash<QString, VerifyChecksumsDialog::Status>::const_iterator
it = statusMap.find(filePath(mi));
if (it != statusMap.end())
......
......@@ -15,6 +15,8 @@
#include <selftest/selftest.h>
#include <Libkleo/SystemInfo>
#include <KLocalizedString>
#include <KColorScheme>
......@@ -86,10 +88,12 @@ public:
}
break;
case Qt::BackgroundRole:
KColorScheme scheme(qApp->palette().currentColorGroup());
return (m_tests[row]->skipped() ? scheme.background(KColorScheme::NeutralBackground) :
m_tests[row]->passed() ? scheme.background(KColorScheme::PositiveBackground) :
scheme.background(KColorScheme::NegativeBackground)).color();
if (!SystemInfo::isHighContrastModeActive()) {
KColorScheme scheme(qApp->palette().currentColorGroup());
return (m_tests[row]->skipped() ? scheme.background(KColorScheme::NeutralBackground) :
m_tests[row]->passed() ? scheme.background(KColorScheme::PositiveBackground) :
scheme.background(KColorScheme::NegativeBackground)).color();
}
}
return QVariant();
}
......
......@@ -81,6 +81,7 @@
#include <Libkleo/Classify>
#include <Libkleo/KeyCache>
#include <Libkleo/DocAction>
#include <Libkleo/SystemInfo>
#include <vector>
#include <KSharedConfig>
......@@ -237,14 +238,16 @@ public:
if (Kleo::gnupgUsesDeVsCompliance()) {
auto statusBar = std::make_unique<QStatusBar>();
auto statusLbl = std::make_unique<QLabel>(Formatting::deVsString(Kleo::gnupgIsDeVsCompliant()));
const auto color = KColorScheme(QPalette::Active, KColorScheme::View).foreground(
Kleo::gnupgIsDeVsCompliant() ? KColorScheme::NormalText: KColorScheme::NegativeText
).color();
const auto background = KColorScheme(QPalette::Active, KColorScheme::View).background(
Kleo::gnupgIsDeVsCompliant() ? KColorScheme::PositiveBackground : KColorScheme::NegativeBackground
).color();
statusLbl->setStyleSheet(QStringLiteral("QLabel { color: %1; background-color: %2; }").
arg(color.name()).arg(background.name()));
if (!SystemInfo::isHighContrastModeActive()) {
const auto color = KColorScheme(QPalette::Active, KColorScheme::View).foreground(
Kleo::gnupgIsDeVsCompliant() ? KColorScheme::NormalText: KColorScheme::NegativeText
).color();
const auto background = KColorScheme(QPalette::Active, KColorScheme::View).background(
Kleo::gnupgIsDeVsCompliant() ? KColorScheme::PositiveBackground : KColorScheme::NegativeBackground
).color();
statusLbl->setStyleSheet(QStringLiteral("QLabel { color: %1; background-color: %2; }").
arg(color.name()).arg(background.name()));
}
statusBar->insertPermanentWidget(0, statusLbl.release());
q->setStatusBar(statusBar.release()); // QMainWindow takes ownership
} else {
......
......@@ -16,6 +16,7 @@
#include <Libkleo/Classify>
#include <Libkleo/KeyCache>
#include <Libkleo/Formatting>
#include <Libkleo/SystemInfo>
#include "crypto/gui/signencryptwidget.h"
#include "crypto/gui/resultitemwidget.h"
......@@ -494,9 +495,11 @@ public:
mCryptBtn->setIcon(QIcon::fromTheme(de_vs
? QStringLiteral("security-high")
: QStringLiteral("security-medium")));
mCryptBtn->setStyleSheet(QStringLiteral("QPushButton { background-color: %1; }").arg(de_vs
? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::PositiveBackground).color().name()
: KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NegativeBackground).color().name()));
if (!SystemInfo::isHighContrastModeActive()) {
mCryptBtn->setStyleSheet(QStringLiteral("QPushButton { background-color: %1; }").arg(de_vs
? KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::PositiveBackground).color().name()
: KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NegativeBackground).color().name()));
}
mAdditionalInfoLabel->setText(de_vs
? 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())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment