summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-05 12:00:53 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-05 12:01:16 (GMT)
commita2ad080bef8bd0e4c7a00647739942c4f6269a89 (patch)
treea96b87c2359574f883b8adc3c0c344a32e0ed24e
parentd58cc3b33332694f53603f15e45a7dcba4caaf5e (diff)
Try to reduce number of KColorScheme usage
-rw-r--r--messagecore/src/messagecoreutil.cpp96
-rw-r--r--messagecore/src/messagecoreutil.h36
2 files changed, 132 insertions, 0 deletions
diff --git a/messagecore/src/messagecoreutil.cpp b/messagecore/src/messagecoreutil.cpp
index 606c3bf..236574b 100644
--- a/messagecore/src/messagecoreutil.cpp
+++ b/messagecore/src/messagecoreutil.cpp
@@ -21,6 +21,7 @@
#include <KColorScheme>
#include <QApplication>
+#include <QDebug>
using namespace MessageCore;
@@ -108,3 +109,98 @@ QColor Util::pgpSignedBadTextColor()
return KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::NegativeText).color();
}
+
+ColorUtil::ColorUtil()
+{
+ initializeColors();
+}
+
+void ColorUtil::updateColors()
+{
+ initializeColors();
+}
+
+void ColorUtil::initializeColors()
+{
+ KColorScheme scheme(QPalette::Active, KColorScheme::View);
+ mMisspelledDefaultTextColor = scheme.foreground(KColorScheme::NegativeText).color().lighter();
+ auto base = scheme.foreground(KColorScheme::PositiveText).color();
+ if (isLightTheme()) {
+ mQuoteLevel1DefaultTextColor = base.darker(120);
+ mQuoteLevel2DefaultTextColor = base.darker(150);
+ mQuoteLevel3DefaultTextColor = base.dark(200);
+ } else {
+ mQuoteLevel1DefaultTextColor = base.lighter(200);
+ mQuoteLevel2DefaultTextColor = base.lighter(170);
+ mQuoteLevel3DefaultTextColor = base.lighter(140);
+ }
+
+ mPgpEncryptedMessageColor = QColor(0x00, 0x80, 0xFF);
+ mPgpEncryptedTextColor = QColor(0xFF, 0xFF, 0xFF); // white
+ mPgpSignedTrustedMessageColor = scheme.background(KColorScheme::PositiveBackground).color();
+ mPgpSignedTrustedTextColor = scheme.foreground(KColorScheme::PositiveText).color();
+ mPgpSignedUntrustedMessageColor = scheme.background(KColorScheme::NeutralBackground).color();
+ mPgpSignedUntrustedTextColor = scheme.foreground(KColorScheme::NeutralText).color();
+ mPgpSignedBadMessageColor = scheme.background(KColorScheme::NegativeBackground).color();
+ mPgpSignedBadTextColor = scheme.foreground(KColorScheme::NegativeText).color();
+}
+
+QColor ColorUtil::misspelledDefaultTextColor() const
+{
+ return mMisspelledDefaultTextColor;
+}
+
+QColor ColorUtil::quoteLevel1DefaultTextColor() const
+{
+ return mQuoteLevel1DefaultTextColor;
+}
+
+QColor ColorUtil::quoteLevel2DefaultTextColor() const
+{
+ return mQuoteLevel2DefaultTextColor;
+}
+
+QColor ColorUtil::quoteLevel3DefaultTextColor() const
+{
+ return mQuoteLevel3DefaultTextColor;
+}
+
+QColor ColorUtil::pgpSignedTrustedMessageColor() const
+{
+ return mPgpSignedTrustedMessageColor;
+}
+
+QColor ColorUtil::pgpSignedTrustedTextColor() const
+{
+ return mPgpSignedTrustedTextColor;
+}
+
+QColor ColorUtil::pgpSignedUntrustedMessageColor() const
+{
+ return mPgpSignedUntrustedMessageColor;
+}
+
+QColor ColorUtil::pgpSignedUntrustedTextColor() const
+{
+ return mPgpSignedUntrustedTextColor;
+}
+
+QColor ColorUtil::pgpSignedBadMessageColor() const
+{
+ return mPgpSignedBadMessageColor;
+}
+
+QColor ColorUtil::pgpSignedBadTextColor() const
+{
+ return mPgpSignedBadTextColor;
+}
+
+QColor ColorUtil::pgpEncryptedMessageColor() const
+{
+ return mPgpEncryptedMessageColor;
+}
+
+QColor ColorUtil::pgpEncryptedTextColor() const
+{
+ return mPgpEncryptedTextColor;
+}
diff --git a/messagecore/src/messagecoreutil.h b/messagecore/src/messagecoreutil.h
index 21beec3..dd14206 100644
--- a/messagecore/src/messagecoreutil.h
+++ b/messagecore/src/messagecoreutil.h
@@ -26,6 +26,42 @@
namespace MessageCore
{
+class MESSAGECORE_EXPORT ColorUtil
+{
+public:
+ ColorUtil();
+
+ void updateColors();
+
+ QColor misspelledDefaultTextColor() const;
+ QColor quoteLevel1DefaultTextColor() const;
+ QColor quoteLevel2DefaultTextColor() const;
+ QColor quoteLevel3DefaultTextColor() const;
+ QColor pgpSignedTrustedMessageColor() const;
+ QColor pgpSignedTrustedTextColor() const;
+ QColor pgpSignedUntrustedMessageColor() const;
+ QColor pgpSignedUntrustedTextColor() const;
+ QColor pgpSignedBadMessageColor() const;
+ QColor pgpSignedBadTextColor() const;
+ QColor pgpEncryptedMessageColor() const;
+ QColor pgpEncryptedTextColor() const;
+
+private:
+ void initializeColors();
+ QColor mMisspelledDefaultTextColor;
+ QColor mQuoteLevel1DefaultTextColor;
+ QColor mQuoteLevel2DefaultTextColor;
+ QColor mQuoteLevel3DefaultTextColor;
+
+ QColor mPgpSignedTrustedMessageColor;
+ QColor mPgpSignedTrustedTextColor;
+ QColor mPgpSignedUntrustedMessageColor;
+ QColor mPgpSignedUntrustedTextColor;
+ QColor mPgpSignedBadMessageColor;
+ QColor mPgpSignedBadTextColor;
+ QColor mPgpEncryptedMessageColor;
+ QColor mPgpEncryptedTextColor;
+};
namespace Util
{