Exemple #1
0
    def load_settings(self):
        """
        Load settings to read settings each time dialog is opened and set the correct state for settings.

        :return:
        """
        if Settings().contains("general_settings/splashscreen"):
            if Settings().value("general_settings/splashscreen") == 0:
                self.splashscreen_cb.setChecked(False)
            elif Settings().value("general_settings/splashscreen") == 1:
                self.splashscreen_cb.setChecked(True)
            else:
                log.debug(
                    "value for splashscreen in "
                    "settings.ini: {}".format(
                        Settings().value("general_settings/splashscreen")))
        else:
            self.splashscreen_cb.setChecked(True)
            Settings().setValue("general_settings/splashscreen", 1)

        if Settings().contains("general_settings/close"):
            if Settings().value("general_settings/close") == 0:
                self.close_prog_cb.setChecked(True)
            elif Settings().value("general_settings/close") == 1:
                self.close_prog_cb.setChecked(False)
            else:
                log.debug("value for close in settings.ini: {}".format(
                    Settings().value("general_settings/close")))
        else:
            self.close_prog_cb.setChecked(True)
            Settings().setValue("general_settings/close", 0)
Exemple #2
0
    def run(self):
        """
        Run the AppFTD application.x
        """
        activate_first_notification = False

        # First time checks in settings
        has_run_wizard = Settings().value('general_settings/wizard_runned')
        if not has_run_wizard:
            first_wizard = Wizard(parent=None)
            if first_wizard.exec_() == QtWidgets.QDialog.Accepted:
                Settings().setValue('general_settings/wizard_runned', 1)
                # Create the first notification only after wizard has been completed
                activate_first_notification = True
            elif first_wizard.was_cancelled:
                QCoreApplication.exit()
                sys.exit()

        # Show the SplashScreen
        show_splash = Settings().value('general_settings/splashscreen')
        if show_splash:
            splash = SplashScreen()
            splash.start_splashscreen.emit()

        # Start the main app window
        self.global_frame = GlobalFrame()

        # Make sure Qt really display the splash screen
        self.processEvents()
        self.global_frame.repaint()
        self.processEvents()

        Registry().execute('__application_init__')
        Registry().execute('__application_post_init__')

        self.processEvents()

        self.global_frame.show()

        # Show first notification program
        if activate_first_notification:
            WelcomeNotification(self.global_frame).notify(
                WelcomeNotification.OK,
                self.welcome_message,
                self.welcome_title,
                button_text='OK')

        if show_splash:
            # now kill the splashscreen
            splash.finish(self.global_frame)
            log.debug('Splashscreen closed')

        # Need to implement update checker
        # update_check = Settings().value('general_settings/update_check')
        # if update_check:
        #     process

        return self.exec_()
Exemple #3
0
    def close_option():
        """
        Handles the closing from application titlebar (close button).

        :return:
        """
        if Settings().value("general_settings/close") == 0:
            Registry().execute("hide_app_in_systray")
        elif Settings().value("general_settings/close") == 1:
            Registry().execute("close_application")
        else:
            log.warning("Not defined, by default, use hide in system tray")
            Registry().execute("hide_app_in_systray")
Exemple #4
0
 def reject(self):
     """
     Stop the wizard on cancel button, close button or ESC key.
     Remove settings file if wizard is not completed.
     """
     log.debug('Wizard cancelled by user.')
     self.was_cancelled = True
     if os.path.exists(Settings().fileName()):
         try:
             os.remove(Settings().fileName())
         except (OSError, FileNotFoundError):
             log.error("File {} not found...".format(Settings().fileName()))
     return super(Wizard, self).reject()
Exemple #5
0
    def closeEvent(self, event):
        """
        Handles the closing from Windows taskbar.

        :param event:
        :return:
        """
        if Settings().value('general_settings/close') == 1:
            self.close_application()
        elif Settings().value('general_settings/close') == 0:
            self.hide_in_systray()
        else:
            log.warning("Not defined, by default, use hide in system tray")
            Registry().execute("hide_app_in_systray")
        event.ignore()
Exemple #6
0
    def save_settings(self):
        """
        Save current configuration.

        :return:
        """
        if self.close_prog_cb.isChecked():
            Settings().setValue("general_settings/close", 0)
        else:
            Settings().setValue("general_settings/close", 1)

        if self.splashscreen_cb.isChecked():
            Settings().setValue("general_settings/splashscreen", 1)
        else:
            Settings().setValue("general_settings/splashscreen", 0)
Exemple #7
0
 def accept(self):
     """
     The wizard finished correctly.
     Extend settings defined by user by default settings.
     """
     log.debug('Wizard finished. Saving settings ...')
     Settings().extend_current_settings()
     return super(Wizard, self).accept()