Pārlūkot izejas kodu

- remade the splash screen to show multiple messages on app initialization
- added a new splash image
- added a control in Preferences -> General -> GUI Settings -> Splash Screen that control if the splash screen is shown at startup

Marius Stanciu 6 gadi atpakaļ
vecāks
revīzija
7ad03f9f0a
5 mainītis faili ar 73 papildinājumiem un 12 dzēšanām
  1. 9 9
      FlatCAM.py
  2. 46 3
      FlatCAMApp.py
  3. 3 0
      README.md
  4. 15 0
      flatcamGUI/FlatCAMGUI.py
  5. BIN
      share/splash.png

+ 9 - 9
FlatCAM.py

@@ -60,17 +60,17 @@ if __name__ == '__main__':
 
     # Create and display the splash screen
     # from here: https://eli.thegreenplace.net/2009/05/09/creating-splash-screens-in-pyqt
-    splash_pix = QtGui.QPixmap('share/flatcam_icon256.png')
-    splash = QtWidgets.QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
-    # splash.setMask(splash_pix.mask())
-    splash.show()
-    app.processEvents()
-    splash.showMessage("FlatCAM is initializing ...",
-                       alignment=Qt.AlignBottom | Qt.AlignLeft,
-                       color=QtGui.QColor("gray"))
+    # splash_pix = QtGui.QPixmap('share/splash.png')
+    # splash = QtWidgets.QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
+    # # splash.setMask(splash_pix.mask())
+    # splash.show()
+    # app.processEvents()
+    # splash.showMessage("FlatCAM is initializing ...",
+    #                    alignment=Qt.AlignBottom | Qt.AlignLeft,
+    #                    color=QtGui.QColor("gray"))
 
     fc = App()
-    splash.finish(fc.ui)
+    # splash.finish(fc.ui)
     fc.ui.show()
 
     sys.exit(app.exec_())

+ 46 - 3
FlatCAMApp.py

@@ -337,6 +337,29 @@ class App(QtCore.QObject):
         # #############################################################################
         self.pool = Pool()
 
+        # ##########################################################################
+        # ################## Setting the Splash Screen #############################
+        # ##########################################################################
+
+        settings = QSettings("Open Source", "FlatCAM")
+        if settings.contains("splash_screen"):
+            show_splash = settings.value("splash_screen")
+        else:
+            settings.setValue('splash_screen', 1)
+
+            # This will write the setting to the platform specific storage.
+            del settings
+            show_splash = 1
+
+        if show_splash:
+            splash_pix = QtGui.QPixmap('share/splash.png')
+            splash = QtWidgets.QSplashScreen(splash_pix, Qt.WindowStaysOnTopHint)
+            # splash.setMask(splash_pix.mask())
+            splash.show()
+            splash.showMessage(_("FlatCAM is initializing ..."),
+                               alignment=Qt.AlignBottom | Qt.AlignLeft,
+                               color=QtGui.QColor("gray"))
+
         # #############################################################################
         # ##################### Initialize GUI ########################################
         # #############################################################################
@@ -1465,15 +1488,25 @@ class App(QtCore.QObject):
         # ###############################################
         # ############# SETUP Plot Area #################
         # ###############################################
-
+        if show_splash:
+            splash.showMessage(_("FlatCAM is initializing ...\n"
+                                 "Canvas initialization started."),
+                               alignment=Qt.AlignBottom | Qt.AlignLeft,
+                               color=QtGui.QColor("gray"))
         start_plot_time = time.time()   # debug
         self.plotcanvas = None
         self.app_cursor = None
         self.hover_shapes = None
         self.on_plotcanvas_setup()
         end_plot_time = time.time()
-        self.log.debug("Finished Canvas initialization in %s seconds." % (str(end_plot_time - start_plot_time)))
-
+        used_time = end_plot_time - start_plot_time
+        self.log.debug("Finished Canvas initialization in %s seconds." % str(used_time))
+        if show_splash:
+            splash.showMessage('%s: %ssec' % (_("FlatCAM is initializing ...\n"
+                                                "Canvas initialization started.\n"
+                                                "Canvas initialization finished in"), '%.2f' % used_time),
+                               alignment=Qt.AlignBottom | Qt.AlignLeft,
+                               color=QtGui.QColor("gray"))
         self.ui.splitter.setStretchFactor(1, 2)
 
         # to use for tools like Measurement tool who depends on the event sources who are changed inside the Editors
@@ -1810,6 +1843,9 @@ class App(QtCore.QObject):
         self.ui.fa_defaults_form.fa_gerber_group.grb_list_btn.clicked.connect(
             lambda: self.on_register_files(obj_type='gerber'))
 
+        # splash screen button signal
+        self.ui.general_defaults_form.general_gui_set_group.splash_cb.stateChanged.connect(self.on_splash_changed)
+
         # connect the abort_all_tasks related slots to the related signals
         self.proc_container.idle_flag.connect(self.app_is_idle)
 
@@ -5356,6 +5392,13 @@ class App(QtCore.QObject):
         self.ui.cncjob_defaults_form.cncjob_gen_group.annotation_fontcolor_entry.set_value(new_val_sel)
         self.defaults['global_proj_item_dis_color'] = new_val_sel
 
+    def on_splash_changed(self, state):
+        settings = QSettings("Open Source", "FlatCAM")
+        settings.setValue('splash_screen', 1) if state else settings.setValue('splash_screen', 0)
+
+        # This will write the setting to the platform specific storage.
+        del settings
+
     def on_notebook_tab_rmb_click(self, checked):
         self.ui.notebook.set_detachable(val=checked)
         self.defaults["global_tabs_detachable"] = checked

+ 3 - 0
README.md

@@ -17,6 +17,9 @@ CAD program, and create G-Code for Isolation routing.
 - now, Excellon and Gerber edited objects will have the source_code updated and ready to be saved
 - the edited Gerber (or Excellon) object now is kept in the app after editing and the edited object is a new object
 - added a message to the splash screen
+- remade the splash screen to show multiple messages on app initialization
+- added a new splash image
+- added a control in Preferences -> General -> GUI Settings -> Splash Screen that control if the splash screen is shown at startup
 
 11.09.2019
 

+ 15 - 0
flatcamGUI/FlatCAMGUI.py

@@ -3947,6 +3947,7 @@ class GeneralGUISetGroupUI(OptionsGroupUI):
         else:
             self.notebook_font_size_spinner.set_value(12)
 
+        # Axis Font Size
         self.axis_font_size_label = QtWidgets.QLabel('%s:' % _('Axis Font Size'))
         self.axis_font_size_label.setToolTip(
             _("This sets the font size for canvas axis.")
@@ -3965,6 +3966,18 @@ class GeneralGUISetGroupUI(OptionsGroupUI):
         # Just to add empty rows
         self.spacelabel = QtWidgets.QLabel('')
 
+        # Splash Screen
+        self.splash_label = QtWidgets.QLabel('%s:' % _('Splash Screen'))
+        self.splash_label.setToolTip(
+            _("Enable display of the splash screen at application startup.")
+        )
+        self.splash_cb = FCCheckBox()
+        settings = QSettings("Open Source", "FlatCAM")
+        if settings.value("splash_screen"):
+            self.splash_cb.set_value(True)
+        else:
+            self.splash_cb.set_value(False)
+
         # Add (label - input field) pair to the QFormLayout
         self.form_box.addRow(self.spacelabel, self.spacelabel)
 
@@ -3977,6 +3990,8 @@ class GeneralGUISetGroupUI(OptionsGroupUI):
         self.form_box.addRow(QtWidgets.QLabel(''))
         self.form_box.addRow(self.notebook_font_size_label, self.notebook_font_size_spinner)
         self.form_box.addRow(self.axis_font_size_label, self.axis_font_size_spinner)
+        self.form_box.addRow(QtWidgets.QLabel(''))
+        self.form_box.addRow(self.splash_label, self.splash_cb)
 
         # Add the QFormLayout that holds the Application general defaults
         # to the main layout of this TAB

BIN
share/splash.png