Fix toolbar vs sidebar color configuration

.. they got conflated, now are separate colors but when we
   apply a theme they are set to the same color, of course
   the user can override this.
This commit is contained in:
Mark Liversedge
2021-07-17 11:41:49 +01:00
parent 1b38e556c3
commit 663b6af8fb
5 changed files with 17 additions and 22 deletions

View File

@@ -152,7 +152,7 @@ ChartBar::configChanged(qint32)
scrollArea->setFixedHeight(height);
buttonBar->setFixedHeight(height);
QColor col=GColor(CCHROME);
QColor col=GColor(CTOOLBAR);
scrollArea->setStyleSheet(QString("QScrollArea { background: rgb(%1,%2,%3); }").arg(col.red()).arg(col.green()).arg(col.blue()));
foreach(ChartBarItem *b, buttons) {
@@ -386,7 +386,7 @@ ChartBar::paintBackground(QPaintEvent *)
painter.save();
QRect all(0,0,width(),height());
painter.fillRect(all, GColor(CCHROME));
painter.fillRect(all, GColor(CTOOLBAR));
painter.restore();
}
@@ -409,14 +409,10 @@ ButtonBar::paintBackground(QPaintEvent *)
painter.save();
QRect all(0,0,width(),height());
// linear gradients
QLinearGradient active = GCColor::linearGradient(23*dpiYFactor, true);
QLinearGradient inactive = GCColor::linearGradient(23*dpiYFactor, false);
// fill with a linear gradient
painter.setPen(Qt::NoPen);
painter.fillRect(all, QColor(Qt::white));
painter.fillRect(all, isActiveWindow() ? active : inactive);
painter.fillRect(all, GColor(CTOOLBAR));
if (!GCColor::isFlat()) {
QPen black(QColor(100,100,100,200));
@@ -457,7 +453,7 @@ ChartBarItem::paintEvent(QPaintEvent *)
painter.setPen(Qt::NoPen);
// background - chrome or slected colour
QBrush brush(GColor(CCHROME));
QBrush brush(GColor(CTOOLBAR));
if (underMouse() && !checked) brush = QBrush(Qt::darkGray);
if (checked) brush = color;
painter.fillRect(body, brush);

View File

@@ -226,7 +226,7 @@ void GCColor::setupColors()
#ifdef Q_OS_MAC
{ tr("Toolbar and Sidebar"), "CCHROME", QColor(213,213,213) },
#else
{ tr("Toolbar and Sidebar"), "CCHROME", QColor(0xec,0xec,0xec) },
{ tr("Sidebar background"), "CCHROME", QColor(0xec,0xec,0xec) },
#endif
#endif
{ tr("Overview Background"), "COVERVIEWBACKGROUND", QColor(0,0,0) },
@@ -928,6 +928,7 @@ GCColor::applyTheme(int index)
break;
case CCHROME:
case CTOOLBAR: // we always keep them the same, but user can make different
color = theme.colors[1];
break;

View File

@@ -57,11 +57,8 @@ GcToolBar::paintBackground(QPaintEvent *)
// get the widget area
QRect all(0,0,width(),height());
// fill with a linear gradient
QLinearGradient linearGradient = GCColor::linearGradient(23, isActiveWindow());
painter.setPen(Qt::NoPen);
painter.fillRect(all, linearGradient);
painter.fillRect(all, GColor(CTOOLBAR));
if (!GCColor::isFlat()) {
// paint the bottom lines

View File

@@ -469,7 +469,7 @@ MainWindow::MainWindow(const QDir &home)
* Application Menus
*--------------------------------------------------------------------*/
#ifdef WIN32
QString menuColorString = (GCColor::isFlat() ? GColor(CCHROME).name() : "rgba(225,225,225)");
QString menuColorString = (GCColor::isFlat() ? GColor(CTOOLBAR).name() : "rgba(225,225,225)");
menuBar()->setStyleSheet(QString("QMenuBar { color: black; background: %1; }"
"QMenuBar::item { color: black; background: %1; }").arg(menuColorString));
menuBar()->setContentsMargins(0,0,0,0);
@@ -2458,24 +2458,24 @@ MainWindow::configChanged(qint32)
#if defined (WIN32) || defined (Q_OS_LINUX)
// Windows and Linux menu bar should match chrome
QColor textCol(Qt::black);
if (GCColor::luminance(GColor(CCHROME)) < 127) textCol = QColor(Qt::white);
QString menuColorString = (GCColor::isFlat() ? GColor(CCHROME).name() : "rgba(225,225,225)");
if (GCColor::luminance(GColor(CTOOLBAR)) < 127) textCol = QColor(Qt::white);
QString menuColorString = (GCColor::isFlat() ? GColor(CTOOLBAR).name() : "rgba(225,225,225)");
menuBar()->setStyleSheet(QString("QMenuBar { color: %1; background: %2; }"
"QMenuBar::item { color: %1; background: %2; }")
.arg(textCol.name()).arg(menuColorString));
// search filter box match chrome color
searchBox->setStyleSheet(QString("QLineEdit { background: %1; color: %2; }").arg(GColor(CCHROME).name()).arg(GCColor::invertColor(GColor(CCHROME)).name()));
searchBox->setStyleSheet(QString("QLineEdit { background: %1; color: %2; }").arg(GColor(CTOOLBAR).name()).arg(GCColor::invertColor(GColor(CTOOLBAR)).name()));
// perspective selector mimics sidebar colors
QColor selected;
if (GCColor::invertColor(GColor(CCHROME)).name() == Qt::white) selected = QColor(Qt::lightGray);
if (GCColor::invertColor(GColor(CTOOLBAR)).name() == Qt::white) selected = QColor(Qt::lightGray);
else selected = QColor(Qt::darkGray);
perspectiveSelector->setStyleSheet(QString("QComboBox { background: %1; color: %2; }"
"QComboBox::item { background: %1; color: %2; }"
"QComboBox::item::selected { background: %3; color: %1; }").arg(GColor(CCHROME).name()).arg(GCColor::invertColor(GColor(CCHROME)).name()).arg(selected.name()));
"QComboBox::item::selected { background: %3; color: %1; }").arg(GColor(CTOOLBAR).name()).arg(GCColor::invertColor(GColor(CTOOLBAR)).name()).arg(selected.name()));
#endif
QString buttonstyle = QString("QPushButton { border: none; background-color: %1; }").arg(CCHROME);
QString buttonstyle = QString("QPushButton { border: none; background-color: %1; }").arg(CTOOLBAR);
back->setStyleSheet(buttonstyle);
forward->setStyleSheet(buttonstyle);
@@ -2485,8 +2485,8 @@ MainWindow::configChanged(qint32)
tabbar->setShape(QTabBar::RoundedSouth);
tabbar->setDrawBase(false);
tabbarPalette.setBrush(backgroundRole(), GColor(CCHROME));
tabbarPalette.setBrush(foregroundRole(), GCColor::invertColor(GColor(CCHROME)));
tabbarPalette.setBrush(backgroundRole(), GColor(CTOOLBAR));
tabbarPalette.setBrush(foregroundRole(), GCColor::invertColor(GColor(CTOOLBAR)));
tabbar->setPalette(tabbarPalette);
athleteView->setPalette(tabbarPalette);

View File

@@ -1438,6 +1438,7 @@ ColorsPage::applyThemeClicked()
break;
case CCHROME:
case CTOOLBAR: // we always keep them the same, but user can make different
// set to black for dark themese and grey for light themes
color = theme.colors[1];
break;