Commit a2ad080b authored by Laurent Montel's avatar Laurent Montel 😁

Try to reduce number of KColorScheme usage

parent d58cc3b3
......@@ -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;
}
......@@ -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
{
......
Markdown is supported
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