comparison main/main.cpp @ 953:4a8f87c175f7 scalable-icons

Fixes to scaling of splash screen
author Chris Cannam
date Wed, 06 May 2015 13:00:57 +0100
parents 45bb2eaf7fe1
children 2f8018eb1573
comparison
equal deleted inserted replaced
952:45bb2eaf7fe1 953:4a8f87c175f7
12 License, or (at your option) any later version. See the file 12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #include "MainWindow.h" 16 #include "MainWindow.h"
17 #include "SVSplash.h"
17 18
18 #include "system/System.h" 19 #include "system/System.h"
19 #include "system/Init.h" 20 #include "system/Init.h"
20 #include "base/TempDirectory.h" 21 #include "base/TempDirectory.h"
21 #include "base/PropertyContainer.h" 22 #include "base/PropertyContainer.h"
34 #include <QLocale> 35 #include <QLocale>
35 #include <QSettings> 36 #include <QSettings>
36 #include <QIcon> 37 #include <QIcon>
37 #include <QSessionManager> 38 #include <QSessionManager>
38 #include <QDir> 39 #include <QDir>
39 #include <QSplashScreen>
40 #include <QTimer> 40 #include <QTimer>
41 #include <QPainter> 41 #include <QPainter>
42 #include <QFileOpenEvent> 42 #include <QFileOpenEvent>
43
44 #include "../version.h"
45 43
46 #include <iostream> 44 #include <iostream>
47 #include <signal.h> 45 #include <signal.h>
48 46
49 #ifdef HAVE_FFTW3F 47 #ifdef HAVE_FFTW3F
213 bool success = m_mainWindow->commitData(mayAskUser); 211 bool success = m_mainWindow->commitData(mayAskUser);
214 manager.release(); 212 manager.release();
215 if (!success) manager.cancel(); 213 if (!success) manager.cancel();
216 } 214 }
217 215
218 void handleFilepathArgument(QString path, QSplashScreen *splash); 216 void handleFilepathArgument(QString path, SVSplash *splash);
219 217
220 bool m_readyForFiles; 218 bool m_readyForFiles;
221 QStringList m_filepathQueue; 219 QStringList m_filepathQueue;
222 220
223 protected: 221 protected:
224 MainWindow *m_mainWindow; 222 MainWindow *m_mainWindow;
225 bool event(QEvent *); 223 bool event(QEvent *);
226
227 }; 224 };
228 225
229 int 226 int
230 main(int argc, char **argv) 227 main(int argc, char **argv)
231 { 228 {
272 QApplication::setOrganizationDomain("sonicvisualiser.org"); 269 QApplication::setOrganizationDomain("sonicvisualiser.org");
273 QApplication::setApplicationName(QApplication::tr("Sonic Visualiser")); 270 QApplication::setApplicationName(QApplication::tr("Sonic Visualiser"));
274 271
275 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); 272 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
276 273
277 QSplashScreen *splash = 0; 274 SVSplash *splash = 0;
278 275
279 QSettings settings; 276 QSettings settings;
280 277
281 settings.beginGroup("Preferences"); 278 settings.beginGroup("Preferences");
282 if (settings.value("show-splash", true).toBool()) { 279 if (settings.value("show-splash", true).toBool()) {
283 QPixmap pixmap(":/icons/scalable/sv-splash@2x.png"); 280 splash = new SVSplash();
284 QPainter painter;
285 painter.begin(&pixmap);
286 QString text = QString("v%1").arg(SV_VERSION);
287 painter.drawText
288 (pixmap.width() - painter.fontMetrics().width(text) - 10,
289 10 + painter.fontMetrics().ascent(),
290 text);
291 painter.end();
292 splash = new QSplashScreen(pixmap);
293 splash->show(); 281 splash->show();
294 QTimer::singleShot(5000, splash, SLOT(hide())); 282 QTimer::singleShot(5000, splash, SLOT(hide()));
295 application.processEvents(); 283 application.processEvents();
296 } 284 }
297 settings.endGroup(); 285 settings.endGroup();
351 application.setMainWindow(gui); 339 application.setMainWindow(gui);
352 InteractiveFileFinder::setParentWidget(gui); 340 InteractiveFileFinder::setParentWidget(gui);
353 TransformUserConfigurator::setParentWidget(gui); 341 TransformUserConfigurator::setParentWidget(gui);
354 if (splash) { 342 if (splash) {
355 QObject::connect(gui, SIGNAL(hideSplash()), splash, SLOT(hide())); 343 QObject::connect(gui, SIGNAL(hideSplash()), splash, SLOT(hide()));
344 QObject::connect(gui, SIGNAL(hideSplash(QWidget *)),
345 splash, SLOT(finishSplash(QWidget *)));
356 } 346 }
357 347
358 QDesktopWidget *desktop = QApplication::desktop(); 348 QDesktopWidget *desktop = QApplication::desktop();
359 QRect available = desktop->availableGeometry(); 349 QRect available = desktop->availableGeometry();
360 350
418 } 408 }
419 #endif 409 #endif
420 settings.endGroup(); 410 settings.endGroup();
421 #endif 411 #endif
422 412
423 if (splash) splash->finish(gui);
424 delete splash;
425
426 /*
427 TipDialog tipDialog;
428 if (tipDialog.isOK()) {
429 tipDialog.exec();
430 }
431 */
432 int rv = application.exec(); 413 int rv = application.exec();
433 414
434 gui->hide(); 415 gui->hide();
435 416
436 cleanupMutex.lock(); 417 cleanupMutex.lock();
490 return QApplication::event(event); 471 return QApplication::event(event);
491 } 472 }
492 } 473 }
493 474
494 /** Application-global handler for filepaths passed in, e.g. as command-line arguments or apple events */ 475 /** Application-global handler for filepaths passed in, e.g. as command-line arguments or apple events */
495 void SVApplication::handleFilepathArgument(QString path, QSplashScreen *splash){ 476 void SVApplication::handleFilepathArgument(QString path, SVSplash *splash){
496 static bool haveSession = false; 477 static bool haveSession = false;
497 static bool haveMainModel = false; 478 static bool haveMainModel = false;
498 static bool havePriorCommandLineModel = false; 479 static bool havePriorCommandLineModel = false;
499 480
500 MainWindow::FileOpenStatus status = MainWindow::FileOpenFailed; 481 MainWindow::FileOpenStatus status = MainWindow::FileOpenFailed;