Starts the Application.

    :param engine: Engine.
    :type engine: QObject
    :param parameters: Command line parameters.
    :type parameters: tuple
    :param components_paths: Components components_paths.
    :type components_paths: tuple or list
    :param requisite_components: Requisite components names.
    :type requisite_components: tuple or list
    :param visible_components: Visible components names.
    :type visible_components: tuple or list
    :return: Definition success.
    :rtype: bool

def run(engine, parameters, components_paths=None, requisite_components=None, visible_components=None):
    """
    Starts the Application.

    :param engine: Engine.
    :type engine: QObject
    :param parameters: Command line parameters.
    :type parameters: tuple
    :param components_paths: Components components_paths.
    :type components_paths: tuple or list
    :param requisite_components: Requisite components names.
    :type requisite_components: tuple or list
    :param visible_components: Visible components names.
    :type visible_components: tuple or list
    :return: Definition success.
    :rtype: bool
    """

    # Command line parameters handling.
    RuntimeGlobals.parameters, RuntimeGlobals.arguments = parameters

    foundations.trace.evaluate_trace_request(RuntimeGlobals.parameters.trace_modules, foundations.verbose.tracer)

    if RuntimeGlobals.parameters.about:
        for line in SESSION_HEADER_TEXT:
            sys.stdout.write("{0}\n".format(line))
        foundations.core.exit(1)

    # Redirecting standard output and error messages.
    sys.stdout = foundations.verbose.StandardOutputStreamer(LOGGER)
    sys.stderr = foundations.verbose.StandardOutputStreamer(LOGGER)

    # Setting application verbose level.
    foundations.verbose.set_verbosity_level(4)

    # Setting user application data directory.
    if RuntimeGlobals.parameters.user_application_data_directory:
        user_application_data_directory = RuntimeGlobals.user_application_data_directory = \
            RuntimeGlobals.parameters.user_application_data_directory
    else:
        user_application_data_directory = RuntimeGlobals.user_application_data_directory = \
            foundations.environment.get_user_application_data_directory()

    if not set_user_application_data_directory(user_application_data_directory):
        raise umbra.exceptions.EngineConfigurationError(
            "{0} | '{1}' user Application data directory is not available, '{2}' will now close!".format(
                __name__, RuntimeGlobals.user_application_data_directory, Constants.application_name))

    if foundations.environment.get_temporary_directory() in user_application_data_directory:
        umbra.ui.widgets.message_box.message_box("Error",
                                                 "Error",
                                                 "{0} failed to use the default user Application data directory to store its preferences \
and has defaulted to the following directory:\n\n\t'{1}'.\n\nReasons for this are various:\n\
\t- Undefined 'APPDATA' ( Windows ) or 'HOME' ( Mac Os X, Linux ) environment variables.\n\
\t- User name with non 'UTF-8' encoding compliant characters.\n\
\t- Non 'UTF-8' encoding compliant characters in the preferences directory path.\n\n\
You will have to define your own preferences directory by launching {0} with the \
'-u \"path\\to\\the\\custom\\preferences\\directory\"' command line parameter.".format(
                                                     Constants.application_name,
                                                     user_application_data_directory))

    LOGGER.debug("> Application Python interpreter: '{0}'".format(sys.executable))
    LOGGER.debug("> Application PyQt version: '{0}'".format(PYQT_VERSION_STR))
    LOGGER.debug("> Application startup location: '{0}'".format(os.getcwd()))
    LOGGER.debug("> Session user Application data directory: '{0}'".format(
        RuntimeGlobals.user_application_data_directory))

    LOGGER.debug("> Initializing '{0}'!".format(Constants.application_name))

    # Getting the logging file path.
    RuntimeGlobals.logging_file = get_logging_file()
    RuntimeGlobals.logging_file_handler = foundations.verbose.get_logging_file_handler(
        file=RuntimeGlobals.logging_file)

    # Getting the patches file path.
    RuntimeGlobals.patches_file = os.path.join(RuntimeGlobals.user_application_data_directory,
                                               Constants.patches_directory,
                                               Constants.patches_file)
    # Initializing the patches manager.
    RuntimeGlobals.patches_manager = umbra.managers.patches_manager.PatchesManager(RuntimeGlobals.patches_file,
                                                                                   [os.path.join(path,
                                                                                                 Constants.patches_directory)
                                                                                    for path in
                                                                                    RuntimeGlobals.resources_directories])
    RuntimeGlobals.patches_manager.register_patches() and RuntimeGlobals.patches_manager.apply_patches()

    # Retrieving settings file.
    RuntimeGlobals.settings_file = os.path.join(RuntimeGlobals.user_application_data_directory,
                                                Constants.settings_directory,
                                                Constants.settings_file)

    RuntimeGlobals.settings = Preferences(RuntimeGlobals.settings_file)

    LOGGER.debug("> Retrieving default layouts.")
    RuntimeGlobals.settings.set_default_layouts(("startup_centric",))

    foundations.common.path_exists(RuntimeGlobals.settings_file) or RuntimeGlobals.settings.set_default_preferences()

    LOGGER.debug("> Retrieving stored verbose level.")
    RuntimeGlobals.verbosity_level = RuntimeGlobals.parameters.verbosity_level \
        if RuntimeGlobals.parameters.verbosity_level is not None else \
        foundations.common.get_first_item(RuntimeGlobals.settings.get_key("Settings", "verbosity_level").toInt())
    LOGGER.debug("> Setting logger verbosity level to: '{0}'.".format(RuntimeGlobals.verbosity_level))
    foundations.verbose.set_verbosity_level(RuntimeGlobals.verbosity_level)
    RuntimeGlobals.settings.set_key("Settings", "verbosity_level", RuntimeGlobals.verbosity_level)

    LOGGER.debug("> Retrieving stored logging formatter.")
    logging_formatter = RuntimeGlobals.parameters.logging_formatter if RuntimeGlobals.parameters.logging_formatter is not None else \
        foundations.strings.to_string(RuntimeGlobals.settings.get_key("Settings", "logging_formatter").toString())
    logging_formatter = logging_formatter if logging_formatter in RuntimeGlobals.logging_formatters else None
    RuntimeGlobals.logging_active_formatter = logging_formatter if logging_formatter is not None else Constants.logging_default_formatter
    LOGGER.debug("> Setting logging formatter: '{0}'.".format(RuntimeGlobals.logging_active_formatter))
    for handler in (RuntimeGlobals.logging_console_handler, RuntimeGlobals.logging_file_handler):
        handler and handler.setFormatter(RuntimeGlobals.logging_formatters[RuntimeGlobals.logging_active_formatter])

    # Starting the session handler.
    RuntimeGlobals.logging_session_handler = foundations.verbose.get_logging_stream_handler()
    RuntimeGlobals.logging_session_handler_stream = RuntimeGlobals.logging_session_handler.stream

    LOGGER.info(Constants.logging_separators)
    for line in SESSION_HEADER_TEXT:
        LOGGER.info(line)
    LOGGER.info("{0} | Session started at: {1}".format(Constants.application_name, time.strftime('%X - %x')))
    LOGGER.info(Constants.logging_separators)
    LOGGER.info("{0} | Starting Interface!".format(Constants.application_name))

    # Initializing splashscreen.
    if RuntimeGlobals.parameters.hide_splash_screen:
        LOGGER.debug("> SplashScreen skipped by 'hide_splash_screen' command line parameter.")
    else:
        LOGGER.debug("> Initializing splashscreen.")

        RuntimeGlobals.splashscreen_image = QPixmap(umbra.ui.common.get_resource_path(UiConstants.splash_screen_image))
        RuntimeGlobals.splashscreen = Delayed_QSplashScreen(RuntimeGlobals.splashscreen_image, text_color=Qt.white)
        RuntimeGlobals.splashscreen.show_message(
            "{0} - {1} | Initializing {0}.".format(Constants.application_name, Constants.version))
        RuntimeGlobals.splashscreen.show()

    # Initializing requests stack.
    RuntimeGlobals.requests_stack = collections.deque()

    # Initializing engine.
    RuntimeGlobals.engine = engine(parent=None,
                                   components_paths=components_paths,
                                   requisite_components=requisite_components,
                                   visible_components=visible_components,
                                   splashscreen=RuntimeGlobals.splashscreen,
                                   requests_stack=RuntimeGlobals.requests_stack,
                                   patches_manager=RuntimeGlobals.patches_manager,
                                   user_application_data_directory=RuntimeGlobals.user_application_data_directory,
                                   logging_session_handler=RuntimeGlobals.logging_session_handler,
                                   logging_file_handler=RuntimeGlobals.logging_file_handler,
                                   logging_console_handler=RuntimeGlobals.logging_console_handler,
                                   logging_session_handler_stream=RuntimeGlobals.logging_session_handler_stream,
                                   logging_active_formatter=RuntimeGlobals.logging_active_formatter,
                                   settings=RuntimeGlobals.settings,
                                   verbosity_level=RuntimeGlobals.verbosity_level,
                                   parameters=RuntimeGlobals.parameters,
                                   arguments=RuntimeGlobals.arguments)
    RuntimeGlobals.engine.show()
    RuntimeGlobals.engine.raise_()

    return sys.exit(RuntimeGlobals.application.exec_())