Fixes to the sniffer visuals to allow them to adapt to dark themes in
the OS.
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
#include "SnifferDelegate.h"
|
#include "SnifferDelegate.h"
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
#include "re/sniffer/snifferitem.h"
|
#include "re/sniffer/snifferitem.h"
|
||||||
@@ -101,7 +102,7 @@ void SnifferDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
|
|||||||
|
|
||||||
//painter->setPen(QPen(QColor(v,v,v,255)));
|
//painter->setPen(QPen(QColor(v,v,v,255)));
|
||||||
painter->setOpacity(1.0);
|
painter->setOpacity(1.0);
|
||||||
painter->setPen(Qt::black);
|
painter->setPen(QApplication::palette().color(QPalette::Text));
|
||||||
painter->setFont(mainFont);
|
painter->setFont(mainFont);
|
||||||
painter->drawText(QRect(viewport.left(), viewport.top() + xSector + yOffset, xSpan, mainFontInfo->pixelSize()), Qt::AlignCenter, Utility::formatNumber(val));
|
painter->drawText(QRect(viewport.left(), viewport.top() + xSector + yOffset, xSpan, mainFontInfo->pixelSize()), Qt::AlignCenter, Utility::formatNumber(val));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <Qt>
|
||||||
|
#include <QApplication>
|
||||||
#include "sniffermodel.h"
|
#include "sniffermodel.h"
|
||||||
#include "snifferwindow.h"
|
#include "snifferwindow.h"
|
||||||
#include "SnifferDelegate.h"
|
#include "SnifferDelegate.h"
|
||||||
@@ -69,13 +71,20 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
case Qt::ForegroundRole:
|
case Qt::ForegroundRole:
|
||||||
{
|
{
|
||||||
if (!mFadeInactive || col < 2) return QBrush(Qt::black);
|
if (!mFadeInactive || col < 2) return QApplication::palette().brush(QPalette::Text);
|
||||||
int v = item->getSeqInterval(col - 2) * 10;
|
int v = item->getSeqInterval(col - 2) * 10;
|
||||||
//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
|
||||||
|
{
|
||||||
return QBrush(QColor(v,v,v,255));
|
return QBrush(QColor(v,v,v,255));
|
||||||
break;
|
}
|
||||||
|
else //text defaults to being light
|
||||||
|
{
|
||||||
|
return QBrush(QColor(255-v,255-v,255-v,255));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case Qt::BackgroundRole:
|
case Qt::BackgroundRole:
|
||||||
@@ -95,7 +104,7 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
|
|||||||
case dc::DEINC:
|
case dc::DEINC:
|
||||||
return QBrush(Qt::red);
|
return QBrush(Qt::red);
|
||||||
default:
|
default:
|
||||||
break;
|
return QApplication::palette().brush(QPalette::Base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user