# HG changeset patch
# User Chris Cannam
# Date 1579878823 0
# Node ID a0d0657aabfc242bbac56cc86768522371dd862e
# Parent 2508e661e544717d46b81fdf1be5bd425cb7fccc# Parent 2197ba438a3f2c07dc2fd26359db06b4a1f73dbd
Merge from branch background-mode
diff -r 2508e661e544 -r a0d0657aabfc icons/sv-splash.png
Binary file icons/sv-splash.png has changed
diff -r 2508e661e544 -r a0d0657aabfc icons/sv-splash.svg
--- 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 @@
-
-
-
diff -r 2508e661e544 -r a0d0657aabfc main/MainWindow.cpp
--- 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);
}
diff -r 2508e661e544 -r a0d0657aabfc main/PreferencesDialog.cpp
--- 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");
diff -r 2508e661e544 -r a0d0657aabfc main/PreferencesDialog.h
--- 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;
diff -r 2508e661e544 -r a0d0657aabfc main/SVSplash.cpp
--- 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
#include
+#include "system/System.h"
+
#include
#include
@@ -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(),
diff -r 2508e661e544 -r a0d0657aabfc main/main.cpp
--- 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
#include
#include
+#include
+#include
#include
#include
@@ -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 << "... ";
diff -r 2508e661e544 -r a0d0657aabfc noconfig.pri
--- 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* {
diff -r 2508e661e544 -r a0d0657aabfc repoint-lock.json
--- 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"
}
}
}
diff -r 2508e661e544 -r a0d0657aabfc sonic-visualiser.qrc
--- 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 @@
icons/scalable/sv-splash.svg
icons/scalable/sv-splash.png
icons/scalable/sv-splash@2x.png
+ icons/scalable/sv-splash-dark.svg
icons/image.png
icons/draw-curve.png
@@ -95,7 +96,6 @@
icons/sv-48x48.png
icons/sv-64x64.png
icons/sv-128x128.png
- icons/sv-splash.png
icons/qm-logo-larger.png
icons/qm-logo-smaller.png
samples/bass.wav