Use palette colors for stream stats
Using harcoded colors leads to unexpected results in dark mode.
This commit is contained in:
parent
2ce7f0c7a0
commit
22b8c405f7
@ -21,7 +21,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "protocol.pb.h"
|
#include "protocol.pb.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
|
#include <QFont>
|
||||||
|
#include <QPalette>
|
||||||
|
|
||||||
// XXX: Keep the enum in sync with it's string
|
// XXX: Keep the enum in sync with it's string
|
||||||
enum {
|
enum {
|
||||||
@ -103,20 +106,35 @@ QVariant StreamStatsModel::data(const QModelIndex &index, int role) const
|
|||||||
return Qt::AlignRight;
|
return Qt::AlignRight;
|
||||||
|
|
||||||
int portColumn = index.column() - kMaxAggrStreamStats;
|
int portColumn = index.column() - kMaxAggrStreamStats;
|
||||||
if (role == Qt::BackgroundRole) {
|
|
||||||
if (portColumn < 0)
|
// Stylesheets typically don't use or set palette colors, so if
|
||||||
return QBrush(QColor("lavender")); // Aggregate Column
|
// using one, don't use palette colors
|
||||||
if (index.row() == (guidList_.size() - 1))
|
if ((role == Qt::BackgroundRole) && qApp->styleSheet().isEmpty()) {
|
||||||
return QBrush(QColor("burlywood")); // Aggregate Row
|
QPalette palette = QApplication::palette();
|
||||||
else if ((portColumn/kMaxStreamStats) & 1)
|
if (index.row() == (guidList_.size() - 1)) // Aggregate Row
|
||||||
return QBrush(QColor("beige")); // Color alternate Ports
|
return palette.dark();
|
||||||
|
if (portColumn < 0) // Aggregate Column
|
||||||
|
return palette.alternateBase();
|
||||||
|
if ((portColumn/kMaxStreamStats) & 1) // Color alternate Ports
|
||||||
|
return palette.alternateBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
Guid guid = guidList_.at(index.row());
|
Guid guid = guidList_.at(index.row());
|
||||||
if (role == Qt::ForegroundRole) {
|
if ((role == Qt::ForegroundRole && qApp->styleSheet().isEmpty())) {
|
||||||
|
QPalette palette = QApplication::palette();
|
||||||
if ((index.column() == kAggrPktLoss)
|
if ((index.column() == kAggrPktLoss)
|
||||||
&& aggrGuidStats_.value(guid).pktLoss)
|
&& aggrGuidStats_.value(guid).pktLoss)
|
||||||
return QBrush(QColor("firebrick"));
|
return palette.link();
|
||||||
|
if (index.row() == (guidList_.size() - 1)) // Aggregate Row
|
||||||
|
return palette.brightText();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (role == Qt::FontRole ) {
|
||||||
|
if (index.row() == (guidList_.size() - 1)) { // Aggregate Row
|
||||||
|
QFont font;
|
||||||
|
font.setBold(true);
|
||||||
|
return font;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (role != Qt::DisplayRole)
|
if (role != Qt::DisplayRole)
|
||||||
|
Loading…
Reference in New Issue
Block a user