# HG changeset patch
# User John Donoghue <john.donoghue@ieee.org>
# Date 1424648501 18000
#      Sun Feb 22 18:41:41 2015 -0500
# Node ID 41f0271a5c007ca3e0d58fffb31ae5a85acc087f
# Parent  bfecf8c249f63a8415197fa507ff2e7d1909899a
Show splashscreen on startup (Bug #41088)

* libgui/src/module.mk: add src/icons/splashscreen.png

* libgui/src/octave-gui.cc (octave_start_gui): create splash screen, and on show splash settings, show it.

* libgui/src/resource.qrc: add splashscreen.png to reource file.

* libgui/src/settings-dialog.cc
  (settings_dialog::settings_dialog): set splashscreen checkbox to settings state.
  (settings_dialog::write_changed_settings): write splashscreen checkbox to settings.

* libgui/src/settings-dialog.ui: add cb_show_splashscreen checkbox to startup settings.

diff --git a/libgui/src/icons/splashscreen.png b/libgui/src/icons/splashscreen.png
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..7733c5dfe4a83f62de9be30e8e8ee517f9abaeed
GIT binary patch
diff --git a/libgui/src/module.mk b/libgui/src/module.mk
--- a/libgui/src/module.mk
+++ b/libgui/src/module.mk
@@ -46,6 +46,7 @@ octave_gui_ICONS = \
   libgui/src/icons/letter_logo_ReleaseWidget.png \
   libgui/src/icons/logo.png \
   libgui/src/icons/preferences-system.png \
+  libgui/src/icons/splashscreen.png \
   libgui/src/icons/system-run.png \
   libgui/src/icons/user-home.png \
   libgui/src/icons/view-refresh.png \
diff --git a/libgui/src/octave-gui.cc b/libgui/src/octave-gui.cc
--- a/libgui/src/octave-gui.cc
+++ b/libgui/src/octave-gui.cc
@@ -31,6 +31,9 @@ along with Octave; see the file COPYING.
 
 #include <cstdio>
 
+#include <QSplashScreen>
+#include <QPixmap>
+
 #include <iostream>
 
 #if defined (HAVE_SYS_IOCTL_H)
@@ -149,6 +152,9 @@ namespace octave
 
     bool start_gui = start_gui_p ();
 
+    QPixmap pixmap (":/actions/icons/splashscreen.png");
+    QSplashScreen splash (pixmap);
+
     // Show welcome wizard if this is the first run.
 
     if (resource_manager::is_first_run () && start_gui)
@@ -185,6 +191,15 @@ namespace octave
 
     if (start_gui)
       {
+        // Show splashscreen, unless has been turned off.
+
+        if (resource_manager::get_settings ()->value ("show_splashscreen", true).toBool ())
+          {
+            splash.show ();
+            splash.showMessage ("Loading ...");
+            qt_app.processEvents ();
+          }
+
         resource_manager::update_network_settings ();
 
         // We provide specific terminal capabilities, so ensure that
@@ -224,6 +239,9 @@ namespace octave
     else
       qt_app.setQuitOnLastWindowClosed (false);
 
+    // Close splashscreen on main window shown.
+    splash.finish (&w);
+
     return qt_app.exec ();
   }
 }
diff --git a/libgui/src/resource.qrc b/libgui/src/resource.qrc
--- a/libgui/src/resource.qrc
+++ b/libgui/src/resource.qrc
@@ -46,6 +46,7 @@
         <file>icons/letter_logo_ReleaseWidget.png</file>
         <file>icons/logo.png</file>
         <file>icons/preferences-system.png</file>
+        <file>icons/splashscreen.png</file>
         <file>icons/system-run.png</file>
         <file>icons/user-home.png</file>
         <file>icons/view-refresh.png</file>
diff --git a/libgui/src/settings-dialog.cc b/libgui/src/settings-dialog.cc
--- a/libgui/src/settings-dialog.cc
+++ b/libgui/src/settings-dialog.cc
@@ -366,6 +366,10 @@ settings_dialog::settings_dialog (QWidge
   connect (ui->pb_octave_dir, SIGNAL (pressed ()),
            this, SLOT (get_octave_dir ()));
 
+  // Splashscreen
+  ui->cb_show_splashscreen->setChecked (
+                 settings->value ("show_splashscreen",true).toBool ());
+
   //
   // editor
   //
@@ -759,6 +763,9 @@ settings_dialog::write_changed_settings 
                       ui->cb_restore_octave_dir->isChecked ());
   settings->setValue ("octave_startup_dir", ui->le_octave_dir->text ());
 
+  settings->setValue ("show_splashscreen", 
+                      ui->cb_show_splashscreen->isChecked ());
+
   //editor
   settings->setValue ("useCustomFileEditor",
                       ui->useCustomFileEditor->isChecked ());
diff --git a/libgui/src/settings-dialog.ui b/libgui/src/settings-dialog.ui
--- a/libgui/src/settings-dialog.ui
+++ b/libgui/src/settings-dialog.ui
@@ -460,6 +460,13 @@
                 <item row="1" column="1">
                  <widget class="QLineEdit" name="le_octave_dir"/>
                 </item>
+                <item row="2" column="1">
+                 <widget class="QCheckBox" name="cb_show_splashscreen">
+                  <property name="text">
+                   <string>Show splashscreen during startup</string>
+                  </property>
+                 </widget>
+                </item>
                </layout>
               </item>
              </layout>
