chiark / gitweb /
Revert "Removed splash screen"
authorYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Fri, 11 Sep 2015 20:45:55 +0000 (16:45 -0400)
committerYouness Alaoui <kakaroto@kakaroto.homelinux.net>
Fri, 11 Sep 2015 20:45:55 +0000 (16:45 -0400)
This reverts commit a9071456ab12e31eeec6b8e41dabf323774ca969.
Fixes T229 #BringBackSplashScreen

Cura/gui/app.py
Cura/gui/splashScreen.py [new file with mode: 0644]
resources/images/splash.png [new file with mode: 0644]

index cd5f399683c9e1c38789afa77cfabd8375a12146..9e5e8de66dc90e8376f057e1eb98e5397699f432 100644 (file)
@@ -24,6 +24,7 @@ class CuraApp(wx.App):
                        super(CuraApp, self).__init__(redirect=False)
 
                self.mainWindow = None
+               self.splash = None
                self.loadFiles = files
 
                if platform.system() == "Darwin":
@@ -54,7 +55,12 @@ class CuraApp(wx.App):
                        socketListener.daemon = True
                        socketListener.start()
 
-               self.afterSplashCallback()
+               if sys.platform.startswith('darwin'):
+                       #Do not show a splashscreen on OSX, as by Apple guidelines
+                       self.afterSplashCallback()
+               else:
+                       from Cura.gui import splashScreen
+                       self.splash = splashScreen.splashScreen(self.afterSplashCallback)
 
        def MacOpenFile(self, path):
                try:
@@ -93,6 +99,12 @@ class CuraApp(wx.App):
                except:
                        pass
 
+       def destroySplashScreen(self):
+               if self.splash is not None:
+                       self.splash.Show(False)
+                       self.splash.Destroy()
+                       self.splash = None
+
        def afterSplashCallback(self):
                #These imports take most of the time and thus should be done after showing the splashscreen
                import webbrowser
@@ -128,11 +140,13 @@ class CuraApp(wx.App):
                        exampleFile = os.path.normpath(os.path.join(resources.resourceBasePath, 'example', 'Rocktopus.stl'))
 
                        self.loadFiles = [exampleFile]
+                       self.destroySplashScreen()
                        configWizard.ConfigWizard()
 
                if profile.getPreference('check_for_updates') == 'True':
                        newVersion = version.checkForNewerVersion()
                        if newVersion is not None:
+                               self.destroySplashScreen()
                                if wx.MessageBox(_("A new version of Cura is available, would you like to download?"), _("New version available"), wx.YES_NO | wx.ICON_INFORMATION) == wx.YES:
                                        webbrowser.open(newVersion)
                                        return
@@ -147,6 +161,7 @@ class CuraApp(wx.App):
                        profile.performVersionUpgrade()
 
                self.mainWindow = mainWindow.mainWindow()
+               self.destroySplashScreen()
                self.SetTopWindow(self.mainWindow)
                self.mainWindow.Show()
                self.mainWindow.OnDropFiles(self.loadFiles)
diff --git a/Cura/gui/splashScreen.py b/Cura/gui/splashScreen.py
new file mode 100644 (file)
index 0000000..a3568a0
--- /dev/null
@@ -0,0 +1,26 @@
+__copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
+
+import wx._core #We only need the core here, which speeds up the import. As we want to show the splashscreen ASAP.
+
+from Cura.util.resources import getPathForImage
+
+class splashScreen(wx.SplashScreen):
+       def __init__(self, callback):
+               self.callback = callback
+               bitmap = wx.Bitmap(getPathForImage('splash.png'))
+               super(splashScreen, self).__init__(bitmap, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_TIMEOUT, 100, None)
+               # Add a timeout and call the callback in the close event to avoid having the callback called
+               # before the splashscreen paint events which could cause it not to appear or to appear as a grey
+               # rectangle while the app is loading
+               self.Bind(wx.EVT_CLOSE, self.OnClose)
+
+
+       def OnClose(self, e):
+               if self.callback:
+                       # Avoid calling the callback twice
+                       cb = self.callback
+                       self.callback = None
+                       # The callback will destroy us
+                       wx.CallAfter(cb)
+
+               e.Skip()
diff --git a/resources/images/splash.png b/resources/images/splash.png
new file mode 100644 (file)
index 0000000..b95c6a4
Binary files /dev/null and b/resources/images/splash.png differ