# 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
@@ -63,6 +63,7 @@
   src/icons/search.png \
   src/icons/undo.png \
   src/icons/up.png \
+  src/icons/splashscreen.png \
   src/icons/warning.png \
   src/icons/widget-close.png \
   src/icons/widget-dock.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
@@ -29,6 +29,9 @@
 #include <QThread>
 #include <QTranslator>
 
+#include <QSplashScreen>
+#include <QPixmap>
+
 #include <iostream>
 
 #include <unistd.h>
@@ -117,6 +120,10 @@
       QTextCodec::setCodecForCStrings (QTextCodec::codecForName ("UTF-8"));
 #endif
 
+      // splash screen
+      QPixmap pixmap (":/actions/icons/splashscreen.png");
+      QSplashScreen splash (pixmap);
+
       // show wizard if this is the first run
       if (resource_manager::is_first_run ())
         {
@@ -140,6 +147,14 @@
           application.installTranslator (&qt_tr);
           application.installTranslator (&qsci_tr);
           application.installTranslator (&gui_tr);
+
+          // show splashscreen, unless has been turned off
+          if (resource_manager::get_settings ()->value ("show_splashscreen", true).toBool ())
+            {
+              splash.show ();
+              splash.showMessage ("Loading ...");
+              application.processEvents ();
+            }
         }
 
       // update network-settings
@@ -179,6 +194,9 @@
 
       w.focus_command_window ();
 
+      // close splashscreen on main window shown
+      splash.finish (&w);
+
       return application.exec ();
     }
   else
diff --git a/libgui/src/resource.qrc b/libgui/src/resource.qrc
--- a/libgui/src/resource.qrc
+++ b/libgui/src/resource.qrc
@@ -59,6 +59,7 @@
         <file>icons/graphic_logo_WorkspaceView.png</file>
         <file>icons/graphic_logo_DocumentationDockWidget.png</file>
         <file>icons/graphic_logo_ReleaseWidget.png</file>
+        <file>icons/splashscreen.png</file>
         <file>icons/warning.png</file>
         <file>icons/widget-close.png</file>
         <file>icons/widget-dock.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
@@ -152,6 +152,9 @@
   connect (ui->pb_octave_dir, SIGNAL (pressed ()),
            this, SLOT (get_octave_dir ()));
 
+  ui->cb_show_splashscreen->setChecked (
+                 settings->value ("show_splashscreen",true).toBool ());
+
   // editor
   ui->useCustomFileEditor->setChecked (settings->value ("useCustomFileEditor",
                                                         false).toBool ());
@@ -654,6 +657,9 @@
                       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
@@ -414,6 +414,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>
