Set alternate colors for port stats row headers

All 'sent' rows including the row header have the alt color, and
the 'recv' rows including the row header has the base color. This
change should make it easier to quickly distinguish sent/recv rows
This commit is contained in:
Srivats P 2023-03-03 17:37:43 +05:30
parent 8dbd01622c
commit 4f6749f16d

View File

@ -20,7 +20,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
#include "portstatsmodel.h"
#include "portgrouplist.h"
#include <QApplication>
#include <QPainter>
#include <QPalette>
#include <QPixmapCache>
#include <QTimer>
@ -272,6 +274,14 @@ QVariant PortStatsModel::headerData(int section, Qt::Orientation orientation, in
return QVariant();
}
if ((role == Qt::BackgroundRole) && (orientation == Qt::Vertical)
&& qApp->styleSheet().isEmpty())
{
QPalette palette = QApplication::palette();
return section & 0x1 ?
palette.base() : palette.alternateBase();
}
if (role != Qt::DisplayRole)
return QVariant();