From f49c93db01d27189674684f096e468a90639321c Mon Sep 17 00:00:00 2001
From: Lorenz Meier <lm@inf.ethz.ch>
Date: Sun, 18 Oct 2015 15:03:22 +0200
Subject: [PATCH] Remove splash screen

---
 src/QGCApplication.cc            | 18 ++----------------
 src/QGCFileDialog.cc             |  1 -
 src/QGCMessageBox.h              |  1 -
 src/apps/qgcvideo/QGCVideoApp.cc |  1 -
 src/ui/MainWindow.cc             | 21 +++------------------
 src/ui/MainWindow.h              | 11 ++---------
 6 files changed, 7 insertions(+), 46 deletions(-)

diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc
index e3e6fba534..7865832acd 100644
--- a/src/QGCApplication.cc
+++ b/src/QGCApplication.cc
@@ -31,7 +31,6 @@
 
 #include <QFile>
 #include <QFlags>
-#include <QSplashScreen>
 #include <QPixmap>
 #include <QDesktopWidget>
 #include <QPainter>
@@ -433,21 +432,12 @@ bool QGCApplication::_initForNormalAppBoot(void)
 
     _styleIsDark = settings.value(_styleKey, _styleIsDark).toBool();
     _loadCurrentStyle();
-    
-    // Show splash screen
-    QPixmap splashImage(":/res/SplashScreen");
-    QSplashScreen* splashScreen = new QSplashScreen(splashImage);
-    // Delete splash screen after mainWindow was displayed
-    splashScreen->setAttribute(Qt::WA_DeleteOnClose);
-    splashScreen->show();
-    processEvents();
-    splashScreen->showMessage(tr("Loading application fonts"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
+
     // Exit main application when last window is closed
     connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
 
     // Start the user interface
-    splashScreen->showMessage(tr("Starting user interface"), Qt::AlignLeft | Qt::AlignBottom, QColor(62, 93, 141));
-    MainWindow* mainWindow = MainWindow::_create(splashScreen);
+    MainWindow* mainWindow = MainWindow::_create();
     Q_CHECK_PTR(mainWindow);
 
     // If we made it this far and we still don't have a location. Either the specfied location was invalid
@@ -461,10 +451,6 @@ bool QGCApplication::_initForNormalAppBoot(void)
         mainWindow->showSettings();
     }
 
-    // Remove splash screen
-    splashScreen->finish(mainWindow);
-    mainWindow->splashScreenFinished();
-
 #ifndef __mobile__
     // Now that main window is up check for lost log files
     connect(this, &QGCApplication::checkForLostLogFiles, MAVLinkProtocol::instance(), &MAVLinkProtocol::checkForLostLogFiles);
diff --git a/src/QGCFileDialog.cc b/src/QGCFileDialog.cc
index 74fdfb3fcd..b385d82cdf 100644
--- a/src/QGCFileDialog.cc
+++ b/src/QGCFileDialog.cc
@@ -228,6 +228,5 @@ void QGCFileDialog::_validate(Options& options)
     options |= DontUseNativeDialog;
 #endif
     if (MainWindow::instance()) {
-        MainWindow::instance()->hideSplashScreen();
     }
 }
diff --git a/src/QGCMessageBox.h b/src/QGCMessageBox.h
index e74295f726..984bdfd766 100644
--- a/src/QGCMessageBox.h
+++ b/src/QGCMessageBox.h
@@ -101,7 +101,6 @@ private:
         parent = _validateParameters(buttons, &defaultButton, parent);
 
         if (MainWindow::instance()) {
-            MainWindow::instance()->hideSplashScreen();
             if (parent == NULL) {
                 parent = MainWindow::instance();
             }
diff --git a/src/apps/qgcvideo/QGCVideoApp.cc b/src/apps/qgcvideo/QGCVideoApp.cc
index 4830ebc049..5f458c7efd 100644
--- a/src/apps/qgcvideo/QGCVideoApp.cc
+++ b/src/apps/qgcvideo/QGCVideoApp.cc
@@ -33,7 +33,6 @@
 #include <QFile>
 #include <QFlags>
 #include <QThread>
-#include <QSplashScreen>
 #include <QPixmap>
 #include <QDesktopWidget>
 #include <QPainter>
diff --git a/src/ui/MainWindow.cc b/src/ui/MainWindow.cc
index 9361da24f8..b1500252fa 100644
--- a/src/ui/MainWindow.cc
+++ b/src/ui/MainWindow.cc
@@ -32,7 +32,6 @@ This file is part of the QGROUNDCONTROL project
 #include <QDebug>
 #include <QTimer>
 #include <QHostInfo>
-#include <QSplashScreen>
 #include <QQuickView>
 #include <QDesktopWidget>
 #include <QScreen>
@@ -100,10 +99,10 @@ const char* MainWindow::_visibleWidgetsKey =                "VisibleWidgets";
 
 static MainWindow* _instance = NULL;   ///< @brief MainWindow singleton
 
-MainWindow* MainWindow::_create(QSplashScreen* splashScreen)
+MainWindow* MainWindow::_create()
 {
     Q_ASSERT(_instance == NULL);
-    new MainWindow(splashScreen);
+    new MainWindow();
     // _instance is set in constructor
     Q_ASSERT(_instance);
     return _instance;
@@ -122,20 +121,15 @@ void MainWindow::deleteInstance(void)
 /// @brief Private constructor for MainWindow. MainWindow singleton is only ever created
 ///         by MainWindow::_create method. Hence no other code should have access to
 ///         constructor.
-MainWindow::MainWindow(QSplashScreen* splashScreen)
+MainWindow::MainWindow()
     : _autoReconnect(false)
     , _lowPowerMode(false)
     , _showStatusBar(false)
-    , _splashScreen(splashScreen)
     , _mainQmlWidgetHolder(NULL)
 {
     Q_ASSERT(_instance == NULL);
     _instance = this;
 
-    if (splashScreen) {
-        connect(this, &MainWindow::initStatusChanged, splashScreen, &QSplashScreen::showMessage);
-    }
-
     // Qt 4/5 on Ubuntu does place the native menubar correctly so on Linux we revert back to in-window menu bar.
 #ifdef Q_OS_LINUX
     menuBar()->setNativeMenuBar(false);
@@ -595,15 +589,6 @@ void MainWindow::_storeCurrentViewState(void)
     settings.setValue(_getWindowGeometryKey(), saveGeometry());
 }
 
-/// @brief Hides the spash screen if it is currently being shown
-void MainWindow::hideSplashScreen(void)
-{
-    if (_splashScreen) {
-        _splashScreen->hide();
-        _splashScreen = NULL;
-    }
-}
-
 void MainWindow::manageLinks()
 {
     SettingsDialog settings(this, SettingsDialog::ShowCommLinks);
diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h
index 838f77c064..60af67ac1a 100644
--- a/src/ui/MainWindow.h
+++ b/src/ui/MainWindow.h
@@ -55,7 +55,6 @@ This file is part of the QGROUNDCONTROL project
     #include "Mouse6dofInput.h"
 #endif // QGC_MOUSE_ENABLED_WIN
 
-class QSplashScreen;
 class QGCStatusBar;
 class Linecharts;
 class QGCDataPlot2D;
@@ -77,10 +76,7 @@ public:
     void deleteInstance(void);
 
     /// @brief Creates the MainWindow singleton. Should only be called once by QGCApplication.
-    static MainWindow* _create(QSplashScreen* splashScreen);
-
-    /// @brief Called to indicate that splash screen is no longer being displayed.
-    void splashScreenFinished(void) { _splashScreen = NULL; }
+    static MainWindow* _create();
 
     ~MainWindow();
 
@@ -97,8 +93,6 @@ public:
         return _lowPowerMode;
     }
 
-    void hideSplashScreen(void);
-
     /// @brief Saves the last used connection
     void saveLastUsedConnection(const QString connection);
 
@@ -222,7 +216,7 @@ private slots:
 
 private:
     /// Constructor is private since all creation should be through MainWindow::_create
-    MainWindow(QSplashScreen* splashScreen);
+    MainWindow();
 
     void _openUrl(const QString& url, const QString& errorMessage);
 
@@ -265,7 +259,6 @@ private:
     bool                    _lowPowerMode;           ///< If enabled, QGC reduces the update rates of all widgets
     bool                    _showStatusBar;
     QVBoxLayout*            _centralLayout;
-    QSplashScreen*          _splashScreen;          ///< Splash screen, NULL is splash screen not currently being shown
     Ui::MainWindow          _ui;
 
     QGCQmlWidgetHolder*     _mainQmlWidgetHolder;
-- 
GitLab