Additional updates to make coloring better for dark themes

This commit is contained in:
Collin Kidder
2019-02-26 22:20:45 -05:00
parent 5d427e8db4
commit 75c2693a97
4 changed files with 33 additions and 8 deletions
+14 -2
View File
@@ -7,14 +7,26 @@
SnifferDelegate::SnifferDelegate(QWidget *parent) : QItemDelegate(parent) SnifferDelegate::SnifferDelegate(QWidget *parent) : QItemDelegate(parent)
{ {
blackBrush = QBrush(Qt::black); QColor TextColor = QApplication::palette().color(QPalette::Text);
whiteBrush = QBrush(Qt::white); if (TextColor.red() + TextColor.green() + TextColor.blue() < 200)
{
mDarkMode = false;
redBrush = QBrush(Qt::red); redBrush = QBrush(Qt::red);
greenBrush = QBrush(Qt::green); greenBrush = QBrush(Qt::green);
}
else
{
mDarkMode = true;
redBrush = QBrush(QColor(128,0,0));
greenBrush = QBrush(QColor(0,128,0));
}
blackBrush = QBrush(Qt::black);
whiteBrush = QBrush(Qt::white);
grayBrush = QBrush(QColor(230,230,230)); grayBrush = QBrush(QColor(230,230,230));
mainFont.setPointSize(10); mainFont.setPointSize(10);
mainFontInfo = new QFontInfo(mainFont); mainFontInfo = new QFontInfo(mainFont);
mFadeInactive = false; mFadeInactive = false;
} }
bool SnifferDelegate::getFadeInactive() bool SnifferDelegate::getFadeInactive()
+1
View File
@@ -22,6 +22,7 @@ private:
QFont mainFont; QFont mainFont;
QFontInfo* mainFontInfo; QFontInfo* mainFontInfo;
bool mFadeInactive; bool mFadeInactive;
bool mDarkMode;
}; };
#endif #endif
+16 -5
View File
@@ -13,6 +13,12 @@ SnifferModel::SnifferModel(QObject *parent)
mMuteNotched(false), mMuteNotched(false),
mTimeSequence(0) mTimeSequence(0)
{ {
QColor TextColor = QApplication::palette().color(QPalette::Text);
if (TextColor.red() + TextColor.green() + TextColor.blue() < 200)
{
mDarkMode = false;
}
else mDarkMode = true;
} }
SnifferModel::~SnifferModel() SnifferModel::~SnifferModel()
@@ -76,8 +82,8 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
//qDebug() << "mTS: " << mTimeSequence << " gDT(" << (col - 2) << ") " << item->getDataTimestamp(col - 2); //qDebug() << "mTS: " << mTimeSequence << " gDT(" << (col - 2) << ") " << item->getDataTimestamp(col - 2);
if (v > 225) v = 225; if (v > 225) v = 225;
if (v < 0) v = 0; if (v < 0) v = 0;
QColor TextColor = QApplication::palette().color(QPalette::Text);
if (TextColor.red() + TextColor.green() + TextColor.blue() < 200) //text defaults to being dark if (!mDarkMode) //text defaults to being dark
{ {
return QBrush(QColor(v,v,v,255)); return QBrush(QColor(v,v,v,255));
} }
@@ -92,7 +98,10 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
if(tc::ID==col) if(tc::ID==col)
{ {
if(item->elapsed() > 4000) if(item->elapsed() > 4000)
return QBrush(Qt::red); {
if (!mDarkMode) return QBrush(Qt::red);
return QBrush(QColor(128,0,0));
}
} }
else if(tc::DATA_0<=col && col<=tc::DATA_7) else if(tc::DATA_0<=col && col<=tc::DATA_7)
{ {
@@ -100,9 +109,11 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
switch(change) switch(change)
{ {
case dc::INC: case dc::INC:
return QBrush(Qt::green); if (!mDarkMode) return QBrush(Qt::green);
return QBrush(QColor(0,128,0));
case dc::DEINC: case dc::DEINC:
return QBrush(Qt::red); if (!mDarkMode) return QBrush(Qt::red);
return QBrush(QColor(128,0,0));
default: default:
return QApplication::palette().brush(QPalette::Base); return QApplication::palette().brush(QPalette::Base);
} }
+1
View File
@@ -63,6 +63,7 @@ private:
bool mNeverExpire; bool mNeverExpire;
bool mFadeInactive; bool mFadeInactive;
bool mMuteNotched; bool mMuteNotched;
bool mDarkMode;
quint32 mTimeSequence; quint32 mTimeSequence;
}; };