Additional updates to make coloring better for dark themes
This commit is contained in:
@@ -7,14 +7,26 @@
|
||||
|
||||
SnifferDelegate::SnifferDelegate(QWidget *parent) : QItemDelegate(parent)
|
||||
{
|
||||
QColor TextColor = QApplication::palette().color(QPalette::Text);
|
||||
if (TextColor.red() + TextColor.green() + TextColor.blue() < 200)
|
||||
{
|
||||
mDarkMode = false;
|
||||
redBrush = QBrush(Qt::red);
|
||||
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);
|
||||
redBrush = QBrush(Qt::red);
|
||||
greenBrush = QBrush(Qt::green);
|
||||
grayBrush = QBrush(QColor(230,230,230));
|
||||
mainFont.setPointSize(10);
|
||||
mainFontInfo = new QFontInfo(mainFont);
|
||||
mFadeInactive = false;
|
||||
|
||||
}
|
||||
|
||||
bool SnifferDelegate::getFadeInactive()
|
||||
|
||||
@@ -21,7 +21,8 @@ private:
|
||||
QBrush blackBrush, whiteBrush, redBrush, greenBrush, grayBrush;
|
||||
QFont mainFont;
|
||||
QFontInfo* mainFontInfo;
|
||||
bool mFadeInactive;
|
||||
bool mFadeInactive;
|
||||
bool mDarkMode;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,6 +13,12 @@ SnifferModel::SnifferModel(QObject *parent)
|
||||
mMuteNotched(false),
|
||||
mTimeSequence(0)
|
||||
{
|
||||
QColor TextColor = QApplication::palette().color(QPalette::Text);
|
||||
if (TextColor.red() + TextColor.green() + TextColor.blue() < 200)
|
||||
{
|
||||
mDarkMode = false;
|
||||
}
|
||||
else mDarkMode = true;
|
||||
}
|
||||
|
||||
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);
|
||||
if (v > 225) v = 225;
|
||||
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));
|
||||
}
|
||||
@@ -92,7 +98,10 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
|
||||
if(tc::ID==col)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -100,9 +109,11 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
|
||||
switch(change)
|
||||
{
|
||||
case dc::INC:
|
||||
return QBrush(Qt::green);
|
||||
if (!mDarkMode) return QBrush(Qt::green);
|
||||
return QBrush(QColor(0,128,0));
|
||||
case dc::DEINC:
|
||||
return QBrush(Qt::red);
|
||||
if (!mDarkMode) return QBrush(Qt::red);
|
||||
return QBrush(QColor(128,0,0));
|
||||
default:
|
||||
return QApplication::palette().brush(QPalette::Base);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ private:
|
||||
bool mNeverExpire;
|
||||
bool mFadeInactive;
|
||||
bool mMuteNotched;
|
||||
bool mDarkMode;
|
||||
quint32 mTimeSequence;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user