changeset 2463:7e70382e6ece background-mode

Render dark splash in dark mode (on platforms where OSReportsDarkThemeActive() works, i.e. only Windows at present - can't base this on actual UI colours as we haven't created the UI yet)
author Chris Cannam
date Fri, 24 Jan 2020 12:43:13 +0000
parents 91154a387599
children c2a1213812b7
files main/SVSplash.cpp
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/main/SVSplash.cpp	Fri Jan 24 12:42:20 2020 +0000
+++ b/main/SVSplash.cpp	Fri Jan 24 12:43:13 2020 +0000
@@ -21,6 +21,8 @@
 #include <QScreen>
 #include <QSvgRenderer>
 
+#include "system/System.h"
+
 #include <cmath>
 
 #include <iostream>
@@ -29,8 +31,10 @@
 SVSplash::SVSplash()
 {
     setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
+
+    bool darkTheme = OSReportsDarkThemeActive();
     
-    QPixmap *p1 = new QPixmap(":icons/scalable/sv-splash.png");
+    QPixmap *p1 = new QPixmap(QString(":icons/scalable/sv-splash.png"));
 
     int w = p1->width(), h = p1->height();
     QScreen *screen = QApplication::primaryScreen();
@@ -41,10 +45,11 @@
 
     int sw = w, sh = h;
 
-    if (widthMultiple > 2.5 || dpratio > 1.0) {
+    if (widthMultiple > 2.5 || dpratio > 1.0 || darkTheme) {
 
         // Hi-dpi either via pixel doubling or simply via lots of
-        // pixels
+        // pixels - or dark theme splash, for which we only have an
+        // svg version
 
         double factor = widthMultiple / 2.5;
         if (factor < 1.0) factor = 1.0;
@@ -58,8 +63,12 @@
 //        cerr << "pixmap size = " << m_pixmap->width() << " * "
 //             << m_pixmap->height() << endl;
         
-        m_pixmap->fill(Qt::red);
-        QSvgRenderer renderer(QString(":icons/scalable/sv-splash.svg"));
+        m_pixmap->fill(Qt::white);
+        QString filename = "sv-splash";
+        if (darkTheme) {
+            filename = "sv-splash-dark";
+        }
+        QSvgRenderer renderer(QString(":icons/scalable/%1.svg").arg(filename));
         QPainter painter(m_pixmap);
         renderer.render(&painter);
         painter.end();
@@ -97,7 +106,7 @@
 
     painter->drawPixmap(rect(), *m_pixmap, m_pixmap->rect());
     QString text = QString("v%1").arg(SV_VERSION);
-    painter->setPen(Qt::black);
+    painter->setPen(OSReportsDarkThemeActive() ? Qt::white : Qt::black);
     painter->drawText
         (width() - painter->fontMetrics().width(text) - (width()/50),
          (width()/70) + painter->fontMetrics().ascent(),