changeset 1038:0f46daf55706 3.0-integration

Merge from default branch
author Chris Cannam
date Fri, 24 Jul 2015 16:31:54 +0100
parents afe496c595e1 (diff) 2d524c9eee33 (current diff)
children e517197049bc
files .hgsubstate main/MainWindow.cpp
diffstat 12 files changed, 237 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/.hgsub	Mon Jul 13 14:39:41 2015 +0100
+++ b/.hgsub	Fri Jul 24 16:31:54 2015 +0100
@@ -3,3 +3,4 @@
 svapp = https://code.soundsoftware.ac.uk/hg/svapp
 dataquay = https://bitbucket.org/breakfastquay/dataquay
 sv-dependency-builds = https://code.soundsoftware.ac.uk/hg/sv-dependency-builds
+icons/scalable = https://code.soundsoftware.ac.uk/hg/sv-iconset
--- a/.hgsubstate	Mon Jul 13 14:39:41 2015 +0100
+++ b/.hgsubstate	Fri Jul 24 16:31:54 2015 +0100
@@ -1,5 +1,6 @@
 d16f0fd6db6104d87882bc43788a3bb1b0f8c528 dataquay
+06ed2d275a956fd1224376f74dfe170c19d3b2c2 icons/scalable
 55ece8862b6d3a54aad271a53f9c1615e5d3bcf8 sv-dependency-builds
-45054b36ddbfe1d93afcef2eb122579e4bdc4e06 svapp
-ed207f89aaefc110e8b3debb07c86299cb6b05ae svcore
-e5d40d89b1ec879dfe9e64b0fc440c69d1adf6e2 svgui
+85e7d2418d9acf74ffe27263f6245d8ea187f5a1 svapp
+e80abd6599224bd83dd96366c26a87b1b7175bd6 svcore
+b0662a3c4679c651616f02551d6173c318136a9c svgui
--- a/deploy/osx/copy-qt.sh	Mon Jul 13 14:39:41 2015 +0100
+++ b/deploy/osx/copy-qt.sh	Fri Jul 24 16:31:54 2015 +0100
@@ -7,9 +7,9 @@
 	exit 2
 fi
 
-frameworks="QtCore QtNetwork QtGui QtXml QtWidgets QtPrintSupport"
+frameworks="QtCore QtNetwork QtGui QtXml QtSvg QtWidgets QtPrintSupport"
 
-plugins="taccessiblewidgets dds gif icns ico jp2 jpeg mng tga tiff wbmp webp cocoa minimal offscreen"
+plugins="dds gif icns ico jp2 jpeg mng tga tiff wbmp webp cocoa minimal offscreen"
 
 qtdir=$(grep "Command:" Makefile | head -1 | awk '{ print $3; }' | sed s,/bin/.*,,)
 
--- a/deploy/osx/paths.sh	Mon Jul 13 14:39:41 2015 +0100
+++ b/deploy/osx/paths.sh	Fri Jul 24 16:31:54 2015 +0100
@@ -7,7 +7,7 @@
 	exit 2
 fi
 
-frameworks="QtCore QtNetwork QtGui QtXml QtWidgets QtPrintSupport"
+frameworks="QtCore QtNetwork QtGui QtXml QtSvg QtWidgets QtPrintSupport"
 
 echo
 echo "I expect you to have already copied these frameworks from the Qt installation to"
--- a/main/MainWindow.cpp	Mon Jul 13 14:39:41 2015 +0100
+++ b/main/MainWindow.cpp	Fri Jul 24 16:31:54 2015 +0100
@@ -68,7 +68,6 @@
 #include "data/fileio/MIDIFileWriter.h"
 #include "data/fileio/BZipFileDevice.h"
 #include "data/fileio/FileSource.h"
-#include "data/fft/FFTDataServer.h"
 #include "data/midi/MIDIInput.h"
 #include "base/RecentFiles.h"
 #include "transform/TransformFactory.h"
@@ -459,7 +458,6 @@
     IconLoader il;
 
     QIcon icon = il.load("filenew");
-    icon.addPixmap(il.loadPixmap("filenew-22"));
     QAction *action = new QAction(icon, tr("&New Session"), this);
     action->setShortcut(tr("Ctrl+N"));
     action->setStatusTip(tr("Abandon the current %1 session and start a new one").arg(QApplication::applicationName()));
@@ -469,7 +467,6 @@
     toolbar->addAction(action);
 
     icon = il.load("fileopen");
-    icon.addPixmap(il.loadPixmap("fileopen-22"));
     action = new QAction(icon, tr("&Open..."), this);
     action->setShortcut(tr("Ctrl+O"));
     action->setStatusTip(tr("Open a session file, audio file, or layer"));
@@ -510,7 +507,6 @@
     menu->addSeparator();
 
     icon = il.load("filesave");
-    icon.addPixmap(il.loadPixmap("filesave-22"));
     action = new QAction(icon, tr("&Save Session"), this);
     action->setShortcut(tr("Ctrl+S"));
     action->setStatusTip(tr("Save the current session into a %1 session file").arg(QApplication::applicationName()));
@@ -521,7 +517,6 @@
     toolbar->addAction(action);
 	
     icon = il.load("filesaveas");
-    icon.addPixmap(il.loadPixmap("filesaveas-22"));
     action = new QAction(icon, tr("Save Session &As..."), this);
     action->setShortcut(tr("Ctrl+Shift+S"));
     action->setStatusTip(tr("Save the current session into a new %1 session file").arg(QApplication::applicationName()));
--- a/main/PreferencesDialog.cpp	Mon Jul 13 14:39:41 2015 +0100
+++ b/main/PreferencesDialog.cpp	Fri Jul 24 16:31:54 2015 +0100
@@ -223,6 +223,15 @@
 
     settings.beginGroup("Preferences");
 
+#ifdef Q_OS_MAC
+    m_retina = settings.value("scaledHiDpi", true).toBool();
+    QCheckBox *retina = new QCheckBox;
+    retina->setCheckState(m_retina ? Qt::Checked : Qt::Unchecked);
+    connect(retina, SIGNAL(stateChanged(int)), this, SLOT(retinaChanged(int)));
+#else
+    m_retina = false;
+#endif
+
     QString userLocale = settings.value("locale", "").toString();
     m_currentLocale = userLocale;
     
@@ -353,6 +362,13 @@
                        row, 0);
     subgrid->addWidget(showSplash, row++, 1, 1, 1);
 
+#ifdef Q_OS_MAC
+    if (devicePixelRatio() > 1) {
+        subgrid->addWidget(new QLabel(tr("Draw layers at Retina resolution:")), row, 0);
+        subgrid->addWidget(retina, row++, 1, 1, 1);
+    }
+#endif
+
     subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
                                                 ("Property Box Layout"))),
                        row, 0);
@@ -564,6 +580,14 @@
 }
 
 void
+PreferencesDialog::retinaChanged(int state)
+{
+    m_retina = (state == Qt::Checked);
+    m_applyButton->setEnabled(true);
+    // Does not require a restart
+}
+
+void
 PreferencesDialog::showSplashChanged(int state)
 {
     m_showSplash = (state == Qt::Checked);
@@ -680,6 +704,9 @@
     settings.setValue(permishTag, m_networkPermission);
     settings.setValue("audio-target", devices[m_audioDevice]);
     settings.setValue("locale", m_currentLocale);
+#ifdef Q_OS_MAC
+    settings.setValue("scaledHiDpi", m_retina);
+#endif
     settings.endGroup();
 
     settings.beginGroup("MainWindow");
--- a/main/PreferencesDialog.h	Mon Jul 13 14:39:41 2015 +0100
+++ b/main/PreferencesDialog.h	Fri Jul 24 16:31:54 2015 +0100
@@ -64,6 +64,7 @@
     void defaultTemplateChanged(int);
     void localeChanged(int);
     void networkPermissionChanged(int state);
+    void retinaChanged(int state);
 
     void tempDirButtonClicked();
 
@@ -95,6 +96,7 @@
     int m_resampleQuality;
     bool m_resampleOnLoad;
     bool m_networkPermission;
+    bool m_retina;
     QString m_tempDirRoot;
     int m_backgroundMode;
     int m_timeToTextMode;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/SVSplash.cpp	Fri Jul 24 16:31:54 2015 +0100
@@ -0,0 +1,100 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#include "SVSplash.h"
+
+#include "../version.h"
+
+#include <QPainter>
+#include <QApplication>
+#include <QDesktopWidget>
+#include <QSvgRenderer>
+
+#include <cmath>
+
+#include <iostream>
+using namespace std;
+
+SVSplash::SVSplash()
+{
+    setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
+    
+    QPixmap *p1 = new QPixmap(":icons/scalable/sv-splash.png");
+
+    int w = p1->width(), h = p1->height();
+    QRect desk = QApplication::desktop()->availableGeometry();
+
+    double dpratio = devicePixelRatio();
+    double widthMultiple = double(desk.width()) / double(w);
+
+    int sw = w, sh = h;
+
+    if (widthMultiple > 2.5 || dpratio > 1.0) {
+
+	// Hi-dpi either via pixel doubling or simply via lots of
+	// pixels
+
+	double factor = widthMultiple / 2.5;
+	if (factor < 1.0) factor = 1.0;
+	sw = int(floor(w * factor));
+	sh = int(floor(h * factor));
+
+	delete p1;
+	m_pixmap = new QPixmap(int(floor(sw * dpratio)),
+			       int(floor(sh * dpratio)));
+
+	cerr << "pixmap size = " << m_pixmap->width() << " * "
+	     << m_pixmap->height() << endl;
+	
+	m_pixmap->fill(Qt::red);
+	QSvgRenderer renderer(QString(":icons/scalable/sv-splash.svg"));
+	QPainter painter(m_pixmap);
+	renderer.render(&painter);
+	painter.end();
+
+    } else {
+	// The "low dpi" case
+	m_pixmap = p1;
+    }
+    
+    setFixedWidth(sw);
+    setFixedHeight(sh);
+    setGeometry(desk.x() + desk.width()/2 - sw/2,
+		desk.y() + desk.height()/2 - sh/2,
+		sw, sh);
+}
+
+SVSplash::~SVSplash()
+{
+    delete m_pixmap;
+}
+
+void
+SVSplash::finishSplash(QWidget *w)
+{
+    finish(w);
+}
+
+void
+SVSplash::drawContents(QPainter *painter)
+{
+    painter->drawPixmap(rect(), *m_pixmap, m_pixmap->rect());
+    QString text = QString("v%1").arg(SV_VERSION);
+    painter->drawText
+	(width() - painter->fontMetrics().width(text) - (width()/50),
+	 (width()/70) + painter->fontMetrics().ascent(),
+	 text);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/SVSplash.h	Fri Jul 24 16:31:54 2015 +0100
@@ -0,0 +1,39 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
+
+#ifndef SV_SPLASH_H
+#define SV_SPLASH_H
+
+#include <QSplashScreen>
+
+class QPixmap;
+
+class SVSplash : public QSplashScreen
+{
+    Q_OBJECT
+
+public:
+    SVSplash();
+    virtual ~SVSplash();
+
+public slots:
+    void finishSplash(QWidget *);
+    
+protected:
+    void drawContents(QPainter *);
+    QPixmap *m_pixmap;
+};
+
+#endif
+    
--- a/main/main.cpp	Mon Jul 13 14:39:41 2015 +0100
+++ b/main/main.cpp	Fri Jul 24 16:31:54 2015 +0100
@@ -14,6 +14,7 @@
 */
 
 #include "MainWindow.h"
+#include "SVSplash.h"
 
 #include "system/System.h"
 #include "system/Init.h"
@@ -36,13 +37,10 @@
 #include <QIcon>
 #include <QSessionManager>
 #include <QDir>
-#include <QSplashScreen>
 #include <QTimer>
 #include <QPainter>
 #include <QFileOpenEvent>
 
-#include "../version.h"
-
 #include <iostream>
 #include <signal.h>
 
@@ -215,7 +213,7 @@
         if (!success) manager.cancel();
     }
 
-    void handleFilepathArgument(QString path, QSplashScreen *splash);
+    void handleFilepathArgument(QString path, SVSplash *splash);
 
     bool m_readyForFiles;
     QStringList m_filepathQueue;
@@ -223,7 +221,6 @@
 protected:
     MainWindow *m_mainWindow;
     bool event(QEvent *);
-
 };
 
 int
@@ -272,22 +269,15 @@
     QApplication::setOrganizationDomain("sonicvisualiser.org");
     QApplication::setApplicationName(QApplication::tr("Sonic Visualiser"));
 
-    QSplashScreen *splash = 0;
+    QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
+
+    SVSplash *splash = 0;
 
     QSettings settings;
 
     settings.beginGroup("Preferences");
     if (settings.value("show-splash", true).toBool()) {
-        QPixmap pixmap(":/icons/sv-splash.png");
-        QPainter painter;
-        painter.begin(&pixmap);
-        QString text = QString("v%1").arg(SV_VERSION);
-        painter.drawText
-            (pixmap.width() - painter.fontMetrics().width(text) - 10,
-             10 + painter.fontMetrics().ascent(),
-             text);
-        painter.end();
-        splash = new QSplashScreen(pixmap);
+        splash = new SVSplash();
         splash->show();
         QTimer::singleShot(5000, splash, SLOT(hide()));
         application.processEvents();
@@ -351,6 +341,8 @@
     TransformUserConfigurator::setParentWidget(gui);
     if (splash) {
         QObject::connect(gui, SIGNAL(hideSplash()), splash, SLOT(hide()));
+        QObject::connect(gui, SIGNAL(hideSplash(QWidget *)),
+                         splash, SLOT(finishSplash(QWidget *)));
     }
 
     QDesktopWidget *desktop = QApplication::desktop();
@@ -418,15 +410,6 @@
     settings.endGroup();
 #endif
 
-    if (splash) splash->finish(gui);
-    delete splash;
-
-/*
-    TipDialog tipDialog;
-    if (tipDialog.isOK()) {
-        tipDialog.exec();
-    }
-*/
     int rv = application.exec();
 
     gui->hide();
@@ -490,7 +473,7 @@
 }
 
 /** Application-global handler for filepaths passed in, e.g. as command-line arguments or apple events */
-void SVApplication::handleFilepathArgument(QString path, QSplashScreen *splash){
+void SVApplication::handleFilepathArgument(QString path, SVSplash *splash){
     static bool haveSession = false;
     static bool haveMainModel = false;
     static bool havePriorCommandLineModel = false;
--- a/sonic-visualiser.qrc	Mon Jul 13 14:39:41 2015 +0100
+++ b/sonic-visualiser.qrc	Fri Jul 24 16:31:54 2015 +0100
@@ -1,9 +1,56 @@
 <!DOCTYPE RCC><RCC version="1.0">
-<qresource>
+  <qresource>
+    <file>icons/scalable/align.svg</file>
+    <file>icons/scalable/colour3d.svg</file>
+    <file>icons/scalable/cross.svg</file>
+    <file>icons/scalable/dataedit.svg</file>
+    <file>icons/scalable/draw.svg</file>
+    <file>icons/scalable/erase.svg</file>
+    <file>icons/scalable/editcopy.svg</file>
+    <file>icons/scalable/editcut.svg</file>
+    <file>icons/scalable/editdelete.svg</file>
+    <file>icons/scalable/editpaste.svg</file>
+    <file>icons/scalable/exit.svg</file>
+    <file>icons/scalable/filenew.svg</file>
+    <file>icons/scalable/fileopen.svg</file>
+    <file>icons/scalable/filesaveas.svg</file>
+    <file>icons/scalable/filesave.svg</file>
+    <file>icons/scalable/filesavesv.svg</file>
+    <file>icons/scalable/ffwd-end.svg</file>
+    <file>icons/scalable/ffwd.svg</file>
+    <file>icons/scalable/navigate.svg</file>
+    <file>icons/scalable/pause.svg</file>
+    <file>icons/scalable/playloop.svg</file>
+    <file>icons/scalable/playpause.svg</file>
+    <file>icons/scalable/playselection.svg</file>
+    <file>icons/scalable/solo.svg</file>
+    <file>icons/scalable/play.svg</file>
+    <file>icons/scalable/rewind-start.svg</file>
+    <file>icons/scalable/rewind.svg</file>
+    <file>icons/scalable/undo.svg</file>
+    <file>icons/scalable/redo.svg</file>
+    <file>icons/scalable/select.svg</file>
+    <file>icons/scalable/instants.svg</file>
+    <file>icons/scalable/notes.svg</file>
+    <file>icons/scalable/values.svg</file>
+    <file>icons/scalable/regions.svg</file>
+    <file>icons/scalable/spectrogram.svg</file>
+    <file>icons/scalable/spectrum.svg</file>
+    <file>icons/scalable/text.svg</file>
+    <file>icons/scalable/timeruler.svg</file>
+    <file>icons/scalable/zoom.svg</file>
+    <file>icons/scalable/zoom-in.svg</file>
+    <file>icons/scalable/zoom-out.svg</file>
+    <file>icons/scalable/zoom-fit.svg</file>
+    <file>icons/scalable/sv-icon-light.svg</file>
+    <file>icons/scalable/sv-icon.svg</file>
+    <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/waveform.svg</file>
     <file>icons/waveform.png</file>
     <file>icons/spectrum.png</file>
     <file>icons/spectrogram.png</file>
-    <file>icons/timeruler.png</file>
     <file>icons/pane.png</file>
     <file>icons/instants.png</file>
     <file>icons/notes.png</file>
@@ -44,10 +91,6 @@
     <file>icons/measure2mask.xbm</file>
     <file>icons/move.png</file>
     <file>icons/navigate.png</file>
-    <file>icons/zoom.png</file>
-    <file>icons/zoom-in.png</file>
-    <file>icons/zoom-out.png</file>
-    <file>icons/zoom-fit.png</file>
     <file>icons/zoom-reset.png</file>
     <file>icons/undo.png</file>
     <file>icons/redo.png</file>
--- a/sv.pro	Mon Jul 13 14:39:41 2015 +0100
+++ b/sv.pro	Fri Jul 24 16:31:54 2015 +0100
@@ -37,7 +37,7 @@
 }
 
 CONFIG += qt thread warn_on stl rtti exceptions c++11
-QT += network xml gui widgets
+QT += network xml gui widgets svg
 
 TARGET = "Sonic Visualiser"
 linux*:TARGET = sonic-visualiser
@@ -86,12 +86,14 @@
 HEADERS += main/MainWindow.h \
            main/NetworkPermissionTester.h \
            main/Surveyer.h \
+           main/SVSplash.h \
            main/PreferencesDialog.h
 SOURCES += main/main.cpp \
            main/OSCHandler.cpp \
            main/MainWindow.cpp \
            main/NetworkPermissionTester.cpp \
            main/Surveyer.cpp \
+           main/SVSplash.cpp \
            main/PreferencesDialog.cpp 
 
 # for mac integration