summaryrefslogtreecommitdiffstats
path: root/qt-ui/tagwidget.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-12-19 17:16:57 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-20 09:53:04 -0800
commitbdd1b3b5469a045b71343fbf721a512f9cd2b0e8 (patch)
tree1537a0eeb9e50851f7393486f01ca286fad76854 /qt-ui/tagwidget.cpp
parent9e57dd48260ecc52a1333e9c6298036d7c42f73d (diff)
downloadsubsurface-bdd1b3b5469a045b71343fbf721a512f9cd2b0e8.tar.gz
Make it possible to use the Tag System in dark themes
The color used on the bright theme was cyan, and it's too bright when the font is also white. This patch uses the HSL information of the color to determine if the text color is light or dark, and adjusting the background color for that. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/tagwidget.cpp')
-rw-r--r--qt-ui/tagwidget.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/qt-ui/tagwidget.cpp b/qt-ui/tagwidget.cpp
index 27c191440..494a473d0 100644
--- a/qt-ui/tagwidget.cpp
+++ b/qt-ui/tagwidget.cpp
@@ -2,14 +2,33 @@
#include <QPair>
#include <QDebug>
#include <QAbstractItemView>
+#include <QSettings>
+#include <QFont>
TagWidget::TagWidget(QWidget *parent) : GroupedLineEdit(parent), m_completer(NULL)
{
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(reparse()));
connect(this, SIGNAL(textChanged()), this, SLOT(reparse()));
- addColor(QColor(0x00, 0xAE, 0xFF));
- addColor(QColor(0x00, 0x78, 0xB0));
+ QColor textColor = palette().color(QPalette::Text);
+ qreal h, s, l, a;
+ textColor.getHslF(&h, &s, &l, &a);
+ // I use dark themes
+ if (l <= 0.3 ){ // very dark text. get a brigth background
+ addColor( QColor(Qt::red).lighter(120) );
+ addColor( QColor(Qt::green).lighter(120) );
+ addColor( QColor(Qt::blue).lighter(120) );
+ }
+ else if ( l <= 0.6 ){ // moderated dark text. get a somewhat brigth background
+ addColor( QColor(Qt::red).lighter(60) );
+ addColor( QColor(Qt::green).lighter(60) );
+ addColor( QColor(Qt::blue).lighter(60) );
+ }
+ else{
+ addColor( QColor(Qt::red).darker(120) );
+ addColor( QColor(Qt::green).darker(120) );
+ addColor( QColor(Qt::blue).darker(120) );
+ } // light text. get a dark background.
}
void TagWidget::setCompleter(QCompleter *completer)