diff --git a/src/GoldenCheetah.cpp b/src/GoldenCheetah.cpp index 3e099ae8c..275231f0b 100644 --- a/src/GoldenCheetah.cpp +++ b/src/GoldenCheetah.cpp @@ -257,19 +257,19 @@ GcWindow::paintEvent(QPaintEvent * /*event*/) // fill in the title bar QRect bar(0,0,width(),contentsMargins().top()); - if (contentsMargins().top() < 25) { - QColor bg; - if (property("active").toBool() == true) { - bg = GColor(CTILEBARSELECT); - painter.drawPixmap(bar, aluBar); - } else { - bg = GColor(CTILEBAR); - painter.drawPixmap(bar, aluBarDark); - } - } else { + //if (contentsMargins().top() < 25) { + //QColor bg; + //if (property("active").toBool() == true) { + //bg = GColor(CTILEBARSELECT); + //painter.drawPixmap(bar, aluBar); + //} else { + //bg = GColor(CTILEBAR); + //painter.drawPixmap(bar, aluBarDark); + //} + //} else { painter.setPen(Qt::darkGray); painter.drawRect(QRect(0,0,width()-1,height()-1)); - } + //} // heading QFont font; @@ -281,13 +281,29 @@ GcWindow::paintEvent(QPaintEvent * /*event*/) QString heading = subtitle != "" ? subtitle : title; // embossed... - QRect shad = bar; - shad.setY(bar.y()+2); + //QRect shad = bar; + //shad.setY(bar.y()+2); //shad.setX(bar.x()+2); - painter.setPen(QColor(255,255,255,180)); - painter.drawText(shad, heading, Qt::AlignVCenter | Qt::AlignCenter); + //painter.setPen(QColor(255,255,255,180)); + //painter.drawText(shad, heading, Qt::AlignVCenter | Qt::AlignCenter); - painter.setPen(QColor(0,0,0,200)); + // pen color needs to contrast to background color + QColor bgColor = property("color").value(); + QColor fgColor; + + if (bgColor == Qt::black) fgColor = Qt::white; + else if (bgColor == Qt::white) fgColor = Qt::black; + else { + + QColor cRGB = bgColor.convertTo(QColor::Rgb); + // lets work it out.. + int r = cRGB.red() < 128 ? 255 : 0; + int g = cRGB.green() < 128 ? 255 : 0; + int b = cRGB.blue() < 128 ? 255 : 0; + fgColor = QColor(r,g,b); + } + + painter.setPen(fgColor); painter.drawText(bar, heading, Qt::AlignVCenter | Qt::AlignCenter); // border diff --git a/src/HomeWindow.cpp b/src/HomeWindow.cpp index 45d8b6d3e..532d97bf7 100644 --- a/src/HomeWindow.cpp +++ b/src/HomeWindow.cpp @@ -24,6 +24,9 @@ #include +static const int tileMargin = 20; +static const int tileSpacing = 10; + HomeWindow::HomeWindow(MainWindow *mainWindow, QString name, QString /* windowtitle */) : GcWindow(mainWindow), mainWindow(mainWindow), name(name), active(false), clicked(NULL), dropPending(false), chartCursor(-2), loaded(false) @@ -173,8 +176,8 @@ HomeWindow::HomeWindow(MainWindow *mainWindow, QString name, QString /* windowti winWidget->setContentsMargins(0,0,0,0); winWidget->setPalette(palette); - winFlow = new GcWindowLayout(winWidget, 0, 20, 20); - winFlow->setContentsMargins(20,20,20,20); + winFlow = new GcWindowLayout(winWidget, 0, tileSpacing, tileSpacing); + winFlow->setContentsMargins(tileMargin,tileMargin,tileMargin,tileMargin); winArea = new QScrollArea(this); winArea->setAutoFillBackground(false); @@ -666,13 +669,13 @@ HomeWindow::addChart(GcWindow* newone) // divided by the number of items double newwidth = (winArea->width() - 20 /* scrollbar */ - - 40 /* left and right marings */ - - ((widthFactor-1) * 20) /* internal spacing */ + - (tileMargin*2) /* left and right marings */ + - ((widthFactor-1) * tileSpacing) /* internal spacing */ ) / widthFactor; double newheight = (winArea->height() - - 40 /* top and bottom marings */ - - ((heightFactor-1) * 20) /* internal spacing */ + - (tileMargin*2) /* top and bottom marings */ + - ((heightFactor-1) * tileSpacing) /* internal spacing */ ) / heightFactor; int minWidth = 10; @@ -815,13 +818,13 @@ HomeWindow::resizeEvent(QResizeEvent * /* e */) double newwidth = (winArea->width() - 20 /* scrollbar */ - - 40 /* left and right marings */ - - ((widthFactor-1) * 20) /* internal spacing */ + - (tileMargin*2) /* left and right marings */ + - ((widthFactor-1) * tileSpacing) /* internal spacing */ ) / widthFactor; double newheight = (winArea->height() - - 40 /* top and bottom marings */ - - ((heightFactor-1) * 20) /* internal spacing */ + - (tileMargin*2) /* top and bottom marings */ + - ((heightFactor-1) * tileSpacing) /* internal spacing */ ) / heightFactor; int minWidth = 10;