summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-05 20:57:59 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-05 20:57:59 (GMT)
commitf1978e83ea45316d96c874e74791f7ebe0d4b662 (patch)
treebd036f1f75102eef4b136d1a5c1da42c0df3b4bc
parent843e1e8bdbae71e0ed450646c75610a0a93204f8 (diff)
Optimization
-rw-r--r--CMakeLists.txt2
-rw-r--r--messagecore/src/messagecoreutil.cpp79
-rw-r--r--messagecore/src/messagecoreutil.h21
-rw-r--r--messagecore/src/settings/messagecore.kcfg6
-rw-r--r--messageviewer/src/viewer/csshelper.cpp27
5 files changed, 23 insertions, 112 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cff037b..55dc55d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
-set(PIM_VERSION "5.3.69")
+set(PIM_VERSION "5.3.70")
set(MESSAGELIB_LIB_VERSION ${PIM_VERSION})
set(AKONADIMIME_LIB_VERSION "5.3.40")
diff --git a/messagecore/src/messagecoreutil.cpp b/messagecore/src/messagecoreutil.cpp
index 236574b..60086d6 100644
--- a/messagecore/src/messagecoreutil.cpp
+++ b/messagecore/src/messagecoreutil.cpp
@@ -30,86 +30,13 @@ static bool isLightTheme()
return qApp->palette().color(QPalette::Background).value() >= 128;
}
-QColor Util::misspelledDefaultTextColor()
-{
- return KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::NegativeText).color().lighter();
-}
-
-QColor Util::quoteLevel1DefaultTextColor()
-{
- auto base = KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::PositiveText).color();
- if (isLightTheme()) {
- return base.darker(120);
- } else {
- return base.lighter(200);
- }
-}
-
-QColor Util::quoteLevel2DefaultTextColor()
-{
- auto base = KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::PositiveText).color();
- if (isLightTheme()) {
- return base.darker(150);
- } else {
- return base.lighter(170);
- }
-}
-
-QColor Util::quoteLevel3DefaultTextColor()
-{
- auto base = KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::PositiveText).color();
- if (isLightTheme()) {
- return base.dark(200);
- } else {
- return base.lighter(140);
- }
-}
-
-// The reason the encrypted message colors are hard-coded while the others not
-// is that we simply don't have a KColorScheme role for that that would have a
-// good analogy. The blue color however works nicely with both dark and light
-// themes and has a good contrast
-QColor Util::pgpEncryptedMessageColor()
-{
- return QColor(0x00, 0x80, 0xFF); // light blue
-}
-
-QColor Util::pgpEncryptedTextColor()
-{
- return QColor(0xFF, 0xFF, 0xFF); // white
-}
-
-QColor Util::pgpSignedTrustedMessageColor()
-{
- return KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::PositiveBackground).color();
-}
-
-QColor Util::pgpSignedTrustedTextColor()
-{
- return KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::PositiveText).color();
-}
+Q_GLOBAL_STATIC(ColorUtil, s_self)
-QColor Util::pgpSignedUntrustedMessageColor()
+ColorUtil *ColorUtil::self()
{
- return KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NeutralBackground).color();
+ return s_self;
}
-QColor Util::pgpSignedUntrustedTextColor()
-{
- return KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::NeutralText).color();
-}
-
-QColor Util::pgpSignedBadMessageColor()
-{
- return KColorScheme(QPalette::Active, KColorScheme::View).background(KColorScheme::NegativeBackground).color();
-}
-
-QColor Util::pgpSignedBadTextColor()
-{
- return KColorScheme(QPalette::Active, KColorScheme::View).foreground(KColorScheme::NegativeText).color();
-}
-
-
ColorUtil::ColorUtil()
{
initializeColors();
diff --git a/messagecore/src/messagecoreutil.h b/messagecore/src/messagecoreutil.h
index dd14206..55be400 100644
--- a/messagecore/src/messagecoreutil.h
+++ b/messagecore/src/messagecoreutil.h
@@ -29,6 +29,8 @@ namespace MessageCore
class MESSAGECORE_EXPORT ColorUtil
{
public:
+ static ColorUtil *self();
+
ColorUtil();
void updateColors();
@@ -62,25 +64,6 @@ private:
QColor mPgpEncryptedMessageColor;
QColor mPgpEncryptedTextColor;
};
-
-namespace Util
-{
-
-MESSAGECORE_EXPORT QColor misspelledDefaultTextColor();
-MESSAGECORE_EXPORT QColor quoteLevel1DefaultTextColor();
-MESSAGECORE_EXPORT QColor quoteLevel2DefaultTextColor();
-MESSAGECORE_EXPORT QColor quoteLevel3DefaultTextColor();
-
-MESSAGECORE_EXPORT QColor pgpSignedTrustedMessageColor();
-MESSAGECORE_EXPORT QColor pgpSignedTrustedTextColor();
-MESSAGECORE_EXPORT QColor pgpSignedUntrustedMessageColor();
-MESSAGECORE_EXPORT QColor pgpSignedUntrustedTextColor();
-MESSAGECORE_EXPORT QColor pgpSignedBadMessageColor();
-MESSAGECORE_EXPORT QColor pgpSignedBadTextColor();
-MESSAGECORE_EXPORT QColor pgpEncryptedMessageColor();
-MESSAGECORE_EXPORT QColor pgpEncryptedTextColor();
-
-}
}
#endif // MESSAGECORE_UTIL_H
diff --git a/messagecore/src/settings/messagecore.kcfg b/messagecore/src/settings/messagecore.kcfg
index 746060b..160dbc0 100644
--- a/messagecore/src/settings/messagecore.kcfg
+++ b/messagecore/src/settings/messagecore.kcfg
@@ -32,15 +32,15 @@
</entry>
<entry name="QuotedText3" type="Color">
<label>This is the color used in the 3rd level of quoted text</label>
- <default code="true">MessageCore::Util::quoteLevel3DefaultTextColor()</default>
+ <default code="true">MessageCore::ColorUtil::self()->quoteLevel3DefaultTextColor()</default>
</entry>
<entry name="QuotedText2" type="Color">
<label>This is the color used in the 2nd level of quoted text</label>
- <default code="true">MessageCore::Util::quoteLevel2DefaultTextColor()</default>
+ <default code="true">MessageCore::ColorUtil::self()->quoteLevel2DefaultTextColor()</default>
</entry>
<entry name="QuotedText1" type="Color">
<label>This is the color used in the 1st level of quoted text</label>
- <default code="true">MessageCore::Util::quoteLevel1DefaultTextColor()</default>
+ <default code="true">MessageCore::ColorUtil::self()->quoteLevel1DefaultTextColor()</default>
</entry>
</group>
diff --git a/messageviewer/src/viewer/csshelper.cpp b/messageviewer/src/viewer/csshelper.cpp
index 1bc65e4..71db368 100644
--- a/messageviewer/src/viewer/csshelper.cpp
+++ b/messageviewer/src/viewer/csshelper.cpp
@@ -33,6 +33,7 @@
#include "settings/messageviewersettings.h"
#include "MessageCore/MessageCoreSettings"
+#include <MessageCore/MessageCoreUtil>
#include <kconfig.h>
#include <kconfiggroup.h>
@@ -55,21 +56,21 @@ CSSHelper::CSSHelper(const QPaintDevice *pd)
mBackgroundColor = QApplication::palette().color(QPalette::Base);
cHtmlWarning = QColor(0xFF, 0x40, 0x40); // warning frame color: light red
- cPgpEncrH = MessageCore::Util::pgpEncryptedMessageColor();
- cPgpEncrHT = MessageCore::Util::pgpEncryptedTextColor();
- cPgpOk1H = MessageCore::Util::pgpSignedTrustedMessageColor();
- cPgpOk1HT = MessageCore::Util::pgpSignedTrustedTextColor();
- cPgpOk0H = MessageCore::Util::pgpSignedUntrustedMessageColor();
- cPgpOk0HT = MessageCore::Util::pgpSignedUntrustedTextColor();
- cPgpWarnH = MessageCore::Util::pgpSignedUntrustedMessageColor();
- cPgpWarnHT = MessageCore::Util::pgpSignedUntrustedTextColor();
- cPgpErrH = MessageCore::Util::pgpSignedBadMessageColor();
- cPgpErrHT = MessageCore::Util::pgpSignedBadTextColor();
+ cPgpEncrH = MessageCore::ColorUtil::self()->pgpEncryptedMessageColor();
+ cPgpEncrHT = MessageCore::ColorUtil::self()->pgpEncryptedTextColor();
+ cPgpOk1H = MessageCore::ColorUtil::self()->pgpSignedTrustedMessageColor();
+ cPgpOk1HT = MessageCore::ColorUtil::self()->pgpSignedTrustedTextColor();
+ cPgpOk0H = MessageCore::ColorUtil::self()->pgpSignedUntrustedMessageColor();
+ cPgpOk0HT = MessageCore::ColorUtil::self()->pgpSignedUntrustedTextColor();
+ cPgpWarnH = MessageCore::ColorUtil::self()->pgpSignedUntrustedMessageColor();
+ cPgpWarnHT = MessageCore::ColorUtil::self()->pgpSignedUntrustedTextColor();
+ cPgpErrH = MessageCore::ColorUtil::self()->pgpSignedBadMessageColor();
+ cPgpErrHT = MessageCore::ColorUtil::self()->pgpSignedBadTextColor();
if (MessageCore::MessageCoreSettings::self()->useDefaultColors()) {
- mQuoteColor[0] = MessageCore::Util::quoteLevel1DefaultTextColor();
- mQuoteColor[1] = MessageCore::Util::quoteLevel2DefaultTextColor();
- mQuoteColor[2] = MessageCore::Util::quoteLevel3DefaultTextColor();
+ mQuoteColor[0] = MessageCore::ColorUtil::self()->quoteLevel1DefaultTextColor();
+ mQuoteColor[1] = MessageCore::ColorUtil::self()->quoteLevel2DefaultTextColor();
+ mQuoteColor[2] = MessageCore::ColorUtil::self()->quoteLevel3DefaultTextColor();
} else {
mQuoteColor[0] = MessageCore::MessageCoreSettings::self()->quotedText1();
mQuoteColor[1] = MessageCore::MessageCoreSettings::self()->quotedText2();