changeset 2467:a0d0657aabfc

Merge from branch background-mode
author Chris Cannam
date Fri, 24 Jan 2020 15:13:43 +0000
parents 2508e661e544 (current diff) 2197ba438a3f (diff)
children f9e2a4434764
files repoint-lock.json repoint-project.json
diffstat 10 files changed, 129 insertions(+), 147 deletions(-) [+]
line wrap: on
line diff
Binary file icons/sv-splash.png has changed
--- a/icons/sv-splash.svg	Wed Jan 15 14:04:39 2020 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- Created with Inkscape (http://www.inkscape.org/) -->
-<svg
-   xmlns:dc="http://purl.org/dc/elements/1.1/"
-   xmlns:cc="http://web.resource.org/cc/"
-   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-   xmlns:svg="http://www.w3.org/2000/svg"
-   xmlns="http://www.w3.org/2000/svg"
-   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
-   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
-   width="640px"
-   height="480px"
-   id="svg1952"
-   sodipodi:version="0.32"
-   inkscape:version="0.44.1"
-   sodipodi:docbase="/home/studio/code/sonic-visualiser/sv/icons"
-   sodipodi:docname="sv-splash.svg"
-   inkscape:export-filename="/home/studio/code/sonic-visualiser/sv/icons/sv-splash.png"
-   inkscape:export-xdpi="90"
-   inkscape:export-ydpi="90">
-  <defs
-     id="defs1954" />
-  <sodipodi:namedview
-     id="base"
-     pagecolor="#ffffff"
-     bordercolor="#666666"
-     borderopacity="1.0"
-     inkscape:pageopacity="0.0"
-     inkscape:pageshadow="2"
-     inkscape:zoom="1"
-     inkscape:cx="320"
-     inkscape:cy="240"
-     inkscape:current-layer="layer1"
-     inkscape:document-units="px"
-     showgrid="true"
-     inkscape:window-width="1101"
-     inkscape:window-height="969"
-     inkscape:window-x="169"
-     inkscape:window-y="26" />
-  <metadata
-     id="metadata1957">
-    <rdf:RDF>
-      <cc:Work
-         rdf:about="">
-        <dc:format>image/svg+xml</dc:format>
-        <dc:type
-           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
-      </cc:Work>
-    </rdf:RDF>
-  </metadata>
-  <g
-     id="layer1"
-     inkscape:label="Layer 1"
-     inkscape:groupmode="layer">
-    <rect
-       style="fill:white;fill-opacity:1;stroke:black;stroke-width:5.70384979;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-       id="rect3849"
-       width="578.29614"
-       height="316.29614"
-       x="28.851925"
-       y="57.851925" />
-    <path
-       style="fill:none;fill-rule:evenodd;stroke:#d45500;stroke-width:7.58643961px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
-       d="M 226.71778,185.52035 C 407.22042,185.52035 407.22042,185.52035 407.22042,185.52035"
-       id="path4036" />
-    <path
-       style="fill:none;fill-rule:evenodd;stroke:black;stroke-width:10.28721237;stroke-linecap:butt;stroke-linejoin:miter;marker-start:none;marker-mid:none;marker-end:none;stroke-miterlimit:1.39999998;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
-       d="M 228.89103,185.52402 C 255.18599,185.52402 258.59857,185.60302 258.59857,185.60302 C 270.76871,133.56701 271.36497,127.54591 274.66485,178.25451 C 279.70514,266.89367 284.18048,220.02667 290.61951,183.64501 C 302.75722,68.043355 303.99332,111.5005 306.56423,135.80647 C 316.45027,256.01216 316.0237,282.95104 321.30811,243.02856 C 325.23523,213.36022 336.92287,88.29917 339.01862,122.7736 C 353.59512,259.79486 354.02613,251.94928 358.50413,216.49781 C 373.27326,77.656444 368.76189,188.69998 377.97144,186.27485 C 404.04172,186.27485 403.59893,185.60302 403.59893,185.60302 L 407.00661,185.60302"
-       id="path3783"
-       sodipodi:nodetypes="cccccsccccc" />
-    <rect
-       style="fill:none;stroke:#d45500;stroke-width:15.17287922;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
-       id="rect3775"
-       width="191.29092"
-       height="187.44695"
-       x="223.48573"
-       y="91.460907" />
-    <text
-       xml:space="preserve"
-       style="font-size:32px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Korataki"
-       x="59"
-       y="330"
-       id="text2049"
-       sodipodi:linespacing="125%"><tspan
-         sodipodi:role="line"
-         id="tspan2051"
-         x="59"
-         y="330">SONIC VISUALISER</tspan></text>
-    <text
-       xml:space="preserve"
-       style="font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:100%;writing-mode:lr-tb;text-anchor:start;fill:black;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;font-family:Korataki"
-       x="84.300003"
-       y="352"
-       id="text2053"
-       sodipodi:linespacing="100%"><tspan
-         sodipodi:role="line"
-         id="tspan2055"
-         x="84.300003"
-         y="352">QUEEN MARY, UNIVERSITY OF LONDON</tspan></text>
-  </g>
-</svg>
--- a/main/MainWindow.cpp	Wed Jan 15 14:04:39 2020 +0000
+++ b/main/MainWindow.cpp	Fri Jan 24 15:13:43 2020 +0000
@@ -196,7 +196,7 @@
     cdb->setUseDarkBackground(cdb->addColour(Qt::white, tr("White")), true);
     cdb->setUseDarkBackground(cdb->addColour(Qt::red, tr("Bright Red")), true);
     cdb->setUseDarkBackground(cdb->addColour(QColor(30, 150, 255), tr("Bright Blue")), true);
-    cdb->setUseDarkBackground(cdb->addColour(Qt::green, tr("Bright Green")), true);
+    cdb->setUseDarkBackground(cdb->addColour(QColor(20, 255, 90), tr("Bright Green")), true);
     cdb->setUseDarkBackground(cdb->addColour(QColor(225, 74, 255), tr("Bright Purple")), true);
     cdb->setUseDarkBackground(cdb->addColour(QColor(255, 188, 80), tr("Bright Orange")), true);
 
@@ -3913,17 +3913,27 @@
 {
     QSettings settings;
     settings.beginGroup("Preferences");
-    QString defaultColourName(tr("Green"));
-    if (m_viewManager && m_viewManager->getGlobalDarkBackground()) {
-        defaultColourName = tr("Bright Green");
-    }
+
+    bool haveDarkBackground = (m_viewManager &&
+                               m_viewManager->getGlobalDarkBackground());
+    QColor highlight = QApplication::palette().color(QPalette::Highlight);
     ColourDatabase *cdb = ColourDatabase::getInstance();
+    int nearestIndex = cdb->getNearbyColourIndex
+        (highlight,
+         haveDarkBackground ?
+         ColourDatabase::WithDarkBackground :
+         ColourDatabase::WithLightBackground);
+    QString defaultColourName = cdb->getColourName(nearestIndex);
+    
     QColor colour = QColor
         (settings.value("overview-colour",
                         cdb->getColour(defaultColourName).name()).toString());
     settings.endGroup();
 
     int index = cdb->getColourIndex(colour);
+
+    SVCERR << "MainWindow::coloursChanged: haveDarkBackground = " << haveDarkBackground << ", highlight = " << highlight.name() << ", nearestIndex = " << nearestIndex << ", defaultColourName = " << defaultColourName << ", colour = " << colour.name() << ", index = " << index << endl;
+
     if (index >= 0) {
         m_panLayer->setBaseColour(index);
     }
--- a/main/PreferencesDialog.cpp	Wed Jan 15 14:04:39 2020 +0000
+++ b/main/PreferencesDialog.cpp	Fri Jan 24 15:13:43 2020 +0000
@@ -149,12 +149,14 @@
                                            int(ColourMapper::Sunset)).toInt());
     m_colour3DColour = (settings.value("colour-3d-plot-colour",
                                        int(ColourMapper::Green)).toInt());
+    m_overviewColourIsSet = false;
     m_overviewColour = ColourDatabase::getInstance()->getColour(tr("Green"));
     if (settings.contains("overview-colour")) {
         QString qcolorName =
             settings.value("overview-colour", m_overviewColour.name())
             .toString();
         m_overviewColour.setNamedColor(qcolorName);
+        m_overviewColourIsSet = true;
         SVCERR << "loaded colour " << m_overviewColour.name() << " from settings" << endl;
     }
     settings.endGroup();
@@ -169,12 +171,16 @@
     colour3DColour->setCurrentIndex(m_colour3DColour);
 
     // can't have "add new colour", as it gets saved in the session not in prefs
-    ColourComboBox *overviewColour = new ColourComboBox(false);
-    int overviewColourIndex =
-        ColourDatabase::getInstance()->getColourIndex(m_overviewColour);
-    SVCERR << "index = " << overviewColourIndex << " for colour " << m_overviewColour.name() << endl;
-    if (overviewColourIndex >= 0) {
-        overviewColour->setCurrentIndex(overviewColourIndex);
+    m_overviewColourCombo = new ColourComboBox(false);
+    m_overviewColourCombo->includeUnsetEntry(tr("Follow desktop theme"));
+    if (m_overviewColourIsSet) {
+        int overviewColourIndex =
+            ColourDatabase::getInstance()->getColourIndex(m_overviewColour);
+        if (overviewColourIndex >= 0) {
+            m_overviewColourCombo->setCurrentIndex(overviewColourIndex + 1);
+        }
+    } else {
+        m_overviewColourCombo->setCurrentIndex(0);
     }
 
     connect(spectrogramGColour, SIGNAL(colourMapChanged(int)),
@@ -183,7 +189,7 @@
             this, SLOT(spectrogramMColourChanged(int)));
     connect(colour3DColour, SIGNAL(colourMapChanged(int)),
             this, SLOT(colour3DColourChanged(int)));
-    connect(overviewColour, SIGNAL(colourChanged(int)),
+    connect(m_overviewColourCombo, SIGNAL(colourChanged(int)),
             this, SLOT(overviewColourChanged(int)));
 
     m_tuningFrequency = prefs->getTuningFrequency();
@@ -285,7 +291,7 @@
     connect(showSplash, SIGNAL(stateChanged(int)),
             this, SLOT(showSplashChanged(int)));
 
-#ifdef NOT_DEFINED // This no longer works correctly on any platform AFAICS
+#ifndef Q_OS_MAC
     QComboBox *bgMode = new QComboBox;
     int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max,
                                              &deflt);
@@ -404,6 +410,13 @@
     }
 #endif
 
+#ifndef Q_OS_MAC
+    subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
+                                                ("Background Mode"))),
+                       row, 0);
+    subgrid->addWidget(bgMode, row++, 1, 1, 2);
+#endif
+
     subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
                                                 ("Property Box Layout"))),
                        row, 0);
@@ -423,14 +436,7 @@
 
     subgrid->addWidget(new QLabel(tr("Overview waveform colour:")),
                        row, 0);
-    subgrid->addWidget(overviewColour, row++, 1, 1, 2);
-
-#ifdef NOT_DEFINED // see earlier
-    subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
-                                                ("Background Mode"))),
-                       row, 0);
-    subgrid->addWidget(bgMode, row++, 1, 1, 2);
-#endif
+    subgrid->addWidget(m_overviewColourCombo, row++, 1, 1, 2);
 
     subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
                                                 ("View Font Size"))),
@@ -747,7 +753,10 @@
 void
 PreferencesDialog::overviewColourChanged(int colour)
 {
-    m_overviewColour = ColourDatabase::getInstance()->getColour(colour);
+    m_overviewColourIsSet = (colour >= 0);
+    if (m_overviewColourIsSet) {
+        m_overviewColour = ColourDatabase::getInstance()->getColour(colour);
+    }
     m_coloursChanged = true;
     m_applyButton->setEnabled(true);
 }
@@ -884,6 +893,28 @@
     m_backgroundMode = mode;
     m_applyButton->setEnabled(true);
     m_changesOnRestart = true;
+
+    // When switching to one of the explicit background choices
+    // (dark/light), also default the overview colour preference to
+    // something sensible
+    
+    int overviewColour = m_overviewColourCombo->getCurrentColourIndex();
+
+    if (overviewColour >= 0) {
+        int plainColours = 6; // we happen to know there are 6 light and 6 dark
+    
+        if (mode == Preferences::DarkBackground &&
+            overviewColour < plainColours) {
+            overviewColour += plainColours;
+        }
+        if (mode == Preferences::LightBackground &&
+            overviewColour >= plainColours) {
+            overviewColour -= plainColours;
+        }
+
+        m_overviewColourCombo->setCurrentIndex(overviewColour + 1);
+        overviewColourChanged(overviewColour);
+    }
 }
 
 void
@@ -999,7 +1030,11 @@
     settings.setValue("spectrogram-colour", m_spectrogramGColour);
     settings.setValue("spectrogram-melodic-colour", m_spectrogramMColour);
     settings.setValue("colour-3d-plot-colour", m_colour3DColour);
-    settings.setValue("overview-colour", m_overviewColour.name());
+    if (m_overviewColourIsSet) {
+        settings.setValue("overview-colour", m_overviewColour.name());
+    } else {
+        settings.remove("overview-colour");
+    }
     settings.endGroup();
 
     settings.beginGroup("MainWindow");
--- a/main/PreferencesDialog.h	Wed Jan 15 14:04:39 2020 +0000
+++ b/main/PreferencesDialog.h	Fri Jan 24 15:13:43 2020 +0000
@@ -28,6 +28,7 @@
 class QTabWidget;
 class QComboBox;
 class PluginPathConfigurator;
+class ColourComboBox;
 
 class PreferencesDialog : public QDialog
 {
@@ -98,6 +99,7 @@
 
     QLineEdit *m_tempDirRootEdit;
 
+    ColourComboBox *m_overviewColourCombo;
     QComboBox *m_audioPlaybackDeviceCombo;
     QComboBox *m_audioRecordDeviceCombo;
     void rebuildDeviceCombos();
@@ -116,6 +118,7 @@
     int m_spectrogramGColour;
     int m_spectrogramMColour;
     int m_colour3DColour;
+    bool m_overviewColourIsSet;
     QColor m_overviewColour;
     int m_propertyLayout;
     double m_tuningFrequency;
--- a/main/SVSplash.cpp	Wed Jan 15 14:04:39 2020 +0000
+++ b/main/SVSplash.cpp	Fri Jan 24 15:13:43 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(),
--- a/main/main.cpp	Wed Jan 15 14:04:39 2020 +0000
+++ b/main/main.cpp	Fri Jan 24 15:13:43 2020 +0000
@@ -44,6 +44,8 @@
 #include <QFileOpenEvent>
 #include <QCommandLineParser>
 #include <QSslSocket>
+#include <QFont>
+#include <QFontInfo>
 
 #include <iostream>
 #include <signal.h>
@@ -322,6 +324,30 @@
 
     QSettings settings;
 
+    QString language = QLocale::system().name();
+    SVDEBUG << "System language is: " << language << endl;
+
+    settings.beginGroup("Preferences");
+    QString prefLanguage = settings.value("locale", language).toString();
+    if (prefLanguage != QString()) language = prefLanguage;
+    settings.endGroup();
+
+    settings.beginGroup("Preferences");
+    if (!(settings.value("always-use-default-font", false).toBool())) {
+#ifdef Q_OS_WIN32
+        if (!language.startsWith("ru_")) { // + any future non-Latin i18ns
+            QFont font(QApplication::font());
+            QString preferredFamily = "Segoe UI";
+            font.setFamily(preferredFamily);
+            if (QFontInfo(font).family() == preferredFamily) {
+                font.setPointSize(9);
+                QApplication::setFont(font);
+            }
+        }
+#endif
+    }
+    settings.endGroup();
+
     settings.beginGroup("Preferences");
     // Default to using Piper server; can change in preferences
     if (!settings.contains("run-vamp-plugins-in-process")) {
@@ -355,14 +381,6 @@
     }
     QApplication::setWindowIcon(icon);
 
-    QString language = QLocale::system().name();
-    SVDEBUG << "System language is: " << language << endl;
-
-    settings.beginGroup("Preferences");
-    QString prefLanguage = settings.value("locale", language).toString();
-    if (prefLanguage != QString()) language = prefLanguage;
-    settings.endGroup();
-
     QTranslator qtTranslator;
     QString qtTrName = QString("qt_%1").arg(language);
     SVDEBUG << "Loading " << qtTrName << "... ";
--- a/noconfig.pri	Wed Jan 15 14:04:39 2020 +0000
+++ b/noconfig.pri	Fri Jan 24 15:13:43 2020 +0000
@@ -1,5 +1,11 @@
 
-CONFIG += c++14
+win32-msvc* {
+    # Necessary for WinRT header used to determine background colour
+    CONFIG += c++17
+}
+!win32-msvc* {
+    CONFIG += c++14
+}
 
 CONFIG += release
 #CONFIG += debug
@@ -97,7 +103,7 @@
             -L$$PWD/sv-dependency-builds/win64-msvc/lib
     }
 
-    DEFINES += NOMINMAX _USE_MATH_DEFINES CAPNP_LITE HAVE_MEDIAFOUNDATION
+    DEFINES += NOMINMAX _USE_MATH_DEFINES CAPNP_LITE HAVE_MEDIAFOUNDATION _HAS_STD_BYTE=0
 
     QMAKE_CXXFLAGS_RELEASE += -fp:fast -gl
     QMAKE_LFLAGS_RELEASE += -ltcg
@@ -111,8 +117,10 @@
     # Don't have liblo
     DEFINES -= HAVE_LIBLO
     LIBS -= -llo
+
+##!!! WindowsApp seems to be win10-specific! can I avoid this?
     
-    LIBS += -lmfplat -lmfreadwrite -lmfuuid -lpropsys -ladvapi32 -lwinmm -lws2_32
+    LIBS += -lWindowsApp -lmfplat -lmfreadwrite -lmfuuid -lpropsys -ladvapi32 -lwinmm -lws2_32
 }
 
 macx* {
--- a/repoint-lock.json	Wed Jan 15 14:04:39 2020 +0000
+++ b/repoint-lock.json	Fri Jan 24 15:13:43 2020 +0000
@@ -4,13 +4,13 @@
       "pin": "c42e50a5c297"
     },
     "svcore": {
-      "pin": "23d5cb3f9f38"
+      "pin": "0bc6caf87658"
     },
     "svgui": {
-      "pin": "5f6fdd525158"
+      "pin": "a2ff9c01889e"
     },
     "svapp": {
-      "pin": "16932dfaf64e"
+      "pin": "fda54e91ca05"
     },
     "checker": {
       "pin": "ef64b3f171d9"
@@ -22,7 +22,7 @@
       "pin": "f381235a4ba88eac2fa31fc1f7f613cca9707f63"
     },
     "dataquay": {
-      "pin": "c523464d1466"
+      "pin": "35098262cadd"
     },
     "bqvec": {
       "pin": "cd235ecbeb31"
@@ -46,7 +46,7 @@
       "pin": "d0c2a83c1364"
     },
     "icons/scalable": {
-      "pin": "be45984f7915"
+      "pin": "fd0ace21dce3"
     }
   }
 }
--- a/sonic-visualiser.qrc	Wed Jan 15 14:04:39 2020 +0000
+++ b/sonic-visualiser.qrc	Fri Jan 24 15:13:43 2020 +0000
@@ -73,6 +73,7 @@
     <file>icons/scalable/sv-splash.svg</file>
     <file>icons/scalable/sv-splash.png</file>
     <file>icons/scalable/sv-splash@2x.png</file>
+    <file>icons/scalable/sv-splash-dark.svg</file>
 
     <file>icons/image.png</file>
     <file>icons/draw-curve.png</file>
@@ -95,7 +96,6 @@
     <file>icons/sv-48x48.png</file>
     <file>icons/sv-64x64.png</file>
     <file>icons/sv-128x128.png</file>
-    <file>icons/sv-splash.png</file>
     <file>icons/qm-logo-larger.png</file>
     <file>icons/qm-logo-smaller.png</file>
     <file>samples/bass.wav</file>