Athlete tab colour fix (#4257)

* Corrects Athlete QTabBar tab colours to match NewSideBar,
  abstract on select background color selection from NewSideBar
  to Colors for reuse in MainWindow
* Fixes dropMenu visibility within the Filter/Search Box on Dark Themes
---------
Co-authored-by: Alejandro Martinez <amtriathlon@gmail.com>
This commit is contained in:
Paul Johnson
2023-03-23 23:01:46 +00:00
committed by GitHub
parent e32eabc102
commit fdb35bf74e
5 changed files with 35 additions and 16 deletions

View File

@@ -444,6 +444,22 @@ QColor GCColor::alternateColor(QColor bgColor)
return QColor(Qt::lightGray);
}
QColor GCColor::selectedColor(QColor bgColor)
{
// if foreground is white then we're "dark" if it's
// black the we're "light" so this controls palette
bool dark = invertColor(bgColor) == QColor(Qt::white);
bool isblack = bgColor == QColor(Qt::black); // e.g. mustang theme
// on select background color
QColor bg_select = bgColor;
if (dark) bg_select = bg_select.lighter(200);
else bg_select = bg_select.darker(200);
if (isblack) bg_select = QColor(30, 30, 30);
return bg_select;
}
const Colors * GCColor::colorSet()
{
return ColorList;

View File

@@ -130,6 +130,7 @@ class GCColor : public QObject
static double luminance(QColor color); // return the relative luminance
static QColor invertColor(QColor); // return the contrasting color
static QColor alternateColor(QColor); // return the alternate background
static QColor selectedColor(QColor); // return the on select background color
static QColor htmlCode(QColor x) { return x.name(); } // return the alternate background
static Themes &themes();
static void applyTheme(int index);

View File

@@ -2535,15 +2535,21 @@ MainWindow::configChanged(qint32)
whatsthis->setStyleSheet(buttonstyle);
// All platforms
QPalette tabbarPalette;
tabbar->setAutoFillBackground(true);
tabbar->setShape(QTabBar::RoundedSouth);
tabbar->setDrawBase(false);
tabbarPalette.setBrush(backgroundRole(), GColor(CTOOLBAR));
tabbarPalette.setBrush(foregroundRole(), GCColor::invertColor(GColor(CTOOLBAR)));
tabbar->setPalette(tabbarPalette);
athleteView->setPalette(tabbarPalette);
// on select
QColor bg_select = GCColor::selectedColor(GColor(CTOOLBAR));
QColor fg_select = GCColor::invertColor(bg_select);
tabbar->setStyleSheet(QString("QTabBar::tab { background-color: %1; color: %2;}"
"QTabBar::tab::selected { background-color: %3; color: %4; }").arg(GColor(CTOOLBAR).name())
.arg(GCColor::invertColor(GColor(CTOOLBAR)).name())
.arg(bg_select.name())
.arg(fg_select.name()));
tabbar->setDocumentMode(true);
athleteView->setPalette(tabbar->palette());
head->updateGeometry();
repaint();

View File

@@ -218,8 +218,9 @@ static QImage imageRGB(QImage &source, QColor target)
void
NewSideBarItem::configChanged(qint32)
{
QColor col = GColor(CCHROME);
QString style=QString("QWidget { background: rgb(%1,%2,%3); }").arg(col.red()).arg(col.green()).arg(col.blue());
// set background colors
bg_normal = GColor(CCHROME);
QString style = QString("QWidget { background: rgb(%1,%2,%3); }").arg(bg_normal.red()).arg(bg_normal.green()).arg(bg_normal.blue());
setStyleSheet(style);
// set foreground colors
@@ -232,16 +233,8 @@ NewSideBarItem::configChanged(qint32)
if (dark) fg_disabled = QColor(80,80,80);
else fg_disabled = QColor(180,180,180);
// set background colors
col=GColor(CCHROME);
bool isblack = (col == QColor(Qt::black)); // e.g. mustang theme
bg_normal = col;
// on select
bg_select =GColor(CCHROME);
if (dark) bg_select = bg_select.lighter(200);
else bg_select = bg_select.darker(200);
if (isblack) bg_select = QColor(30,30,30);
bg_select = GCColor::selectedColor(bg_normal);
fg_select = GCColor::invertColor(bg_select);
// on hover

View File

@@ -148,6 +148,9 @@ SearchBox::configChanged(qint32)
.arg(clearButton->sizeHint().width() + frameWidth + 12));
}
toolButton->setStyleSheet(QString("QToolButton { background: transparent; color: %1;}")
.arg(GCColor::invertColor(GColor(CTOOLBAR)).name()));
// get suitably formated list
QList<QString> list;