Exemple #1
0
    # Create QT application
    codimensionApp = CodimensionApplication( sys.argv, settings.style )
    globalData.application = codimensionApp

    logging.debug( "Starting codimension v." + __version__ )

    try:
        # Process command line arguments
        projectFile = processCommandLineArgs( args )
    except Exception, exc:
        logging.error( str( exc ) )
        parser.print_help()
        return 1

    # Show splash screen
    splash = SplashScreen()
    globalData.splash = splash

    screenSize = codimensionApp.desktop().screenGeometry()
    globalData.screenWidth = screenSize.width()
    globalData.screenHeight = screenSize.height()

    try:
        splash.showMessage( "Applying patch to rope..." )
        import rope_patch
        rope_patch.applyRopePatch()
    except:
        pass

    splash.showMessage( "Applying skin to lexers..." )
    from editor.lexer import updateLexersStyles
Exemple #2
0
# required for fbs installer
import processing
import OpenGL
import OpenGL_accelerate

from PySide2.QtWidgets import QApplication

from ui.splashscreen import SplashScreen
from ui.mainwindow import MainWindow

if __name__ == "__main__":
    QtCore.QCoreApplication.setAttribute(Qt.AA_ShareOpenGLContexts)
    app = QApplication()

    splash = SplashScreen()
    splash.show()

    app.exec_()

    if DEBUG:
        QMessageBox.warning(None, app.tr("HoruCNC"), app.tr(fp.name),
                            QMessageBox.Close)

    # check that the resources has been extracted. Otherwise we
    # are running direct from the "*.dmg" image -which is not supported-
    #
    if not os.access("resources/config/configuration.ini", os.W_OK | os.R_OK):
        QMessageBox.warning(None, app.tr("HoruCNC"),
                            app.tr("Running from DMG Image is not supported.\n" + \
                                   "Copy HoruCNC to your application folder"),
Exemple #3
0
def codimensionMain():
    """The codimension driver"""
    # Parse command line arguments
    helpMessaege = """
%prog [options] [project file | python files]
Runs codimension UI"""
    parser = OptionParser(helpMessaege, version="%prog " + VER)

    parser.add_option("--debug",
                      action="store_true",
                      dest="debug",
                      default=False,
                      help="switch on debug and info messages (default: Off)")
    parser.add_option("--clean-start",
                      action="store_true",
                      dest="cleanStart",
                      default=False,
                      help="do not restore previous IDE state (default: Off)")

    options, args = parser.parse_args()

    # Configure logging
    setupLogging(options.debug)

    # The default exception handler can be replaced
    sys.excepthook = exceptionHook

    # Create global data singleton.
    # It's unlikely to throw any exceptions.
    globalData = GlobalData()
    globalData.version = VER

    # Loading settings - they have to be loaded before the application is
    # created. This is because the skin name is saved there.
    settings = Settings()
    copySkin()

    # Load the skin
    globalData.skin = Skin()
    globalData.skin.load(SETTINGS_DIR + "skins" + os.path.sep +
                         settings['skin'])

    global __delayedWarnings
    __delayedWarnings += settings.validateZoom(globalData.skin.minTextZoom,
                                               globalData.skin.minCFlowZoom)

    # QT on UBUNTU has a bug - the main menu bar does not generate the
    # 'aboutToHide' signal (though 'aboutToShow' is generated properly. This
    # prevents codimension working properly so this hack below disables the
    # global menu bar for codimension and makes it working properly.
    os.environ["QT_X11_NO_NATIVE_MENUBAR"] = "1"

    # Create QT application
    codimensionApp = CodimensionApplication(sys.argv, settings['style'])
    globalData.application = codimensionApp

    logging.debug("Starting codimension v.%s", VER)

    try:
        # Process command line arguments
        projectFile = processCommandLineArgs(args)
    except Exception as exc:
        logging.error(str(exc))
        parser.print_help()
        return 1

    # Show splash screen
    splash = SplashScreen()
    globalData.splash = splash

    screenSize = codimensionApp.desktop().screenGeometry()
    globalData.screenWidth = screenSize.width()
    globalData.screenHeight = screenSize.height()

    splash.showMessage("Importing packages...")
    from ui.mainwindow import CodimensionMainWindow

    splash.showMessage("Generating main window...")
    mainWindow = CodimensionMainWindow(splash, settings)
    codimensionApp.setMainWindow(mainWindow)
    globalData.mainWindow = mainWindow
    codimensionApp.lastWindowClosed.connect(codimensionApp.quit)

    # Loading project if given or the recent one
    needSignal = True
    if options.cleanStart:
        # Codimension will not load anything.
        pass
    elif projectFile:
        splash.showMessage("Loading project...")
        globalData.project.loadProject(projectFile)
        needSignal = False
    elif args:
        # There are arguments and they are python files
        # The project should not be loaded but the files should
        # be opened
        for fName in args:
            mainWindow.openFile(os.path.abspath(fName), -1)
    elif settings['projectLoaded']:
        if not settings['recentProjects']:
            # Some project was loaded but now it is not available.
            pass
        else:
            splash.showMessage("Loading recent project...")
            if os.path.exists(settings['recentProjects'][0]):
                globalData.project.loadProject(settings['recentProjects'][0])
                needSignal = False
            else:
                __delayedWarnings.append(
                    "Cannot open the most recent project: " +
                    settings['recentProjects'][0] + ". Ignore and continue.")
    else:
        mainWindow.editorsManagerWidget.editorsManager.restoreTabs(
            settings.tabStatus)

    # Signal for triggering browsers layout
    if needSignal:
        globalData.project.sigProjectChanged.emit(
            CodimensionProject.CompleteProject)

    mainWindow.show()
    mainWindow.restoreWindowPosition()
    mainWindow.restoreSplitterSizes()

    # The editors positions can be restored properly only when the editors have
    # actually been drawn. Otherwise the first visible line is unknown.
    # So, I load the project first and let object browsers initialize
    # themselves and then manually call the main window handler to restore the
    # editors. The last step is to connect the signal.
    mainWindow.onProjectChanged(CodimensionProject.CompleteProject)
    globalData.project.sigProjectChanged.connect(mainWindow.onProjectChanged)

    # Launch the user interface
    QTimer.singleShot(1, launchUserInterface)

    # Run the application main cycle
    retVal = codimensionApp.exec_()
    return retVal
Exemple #4
0
"""

Created on 15 Sept 2018.
This starts the python application.

@author: Graeme Zinck

"""

# Python main file
from tkinter import *
from PIL import ImageTk, Image
from ui.loadingscreen import LoadingScreen
from ui.matchscreen import MatchScreen
from ui.mainscreen import MainScreen
from ui.splashscreen import SplashScreen

# Get the root
root = Tk()
root.title("Hack the Beat")
root.geometry("400x600")
isd = SplashScreen(root)
isd.pack()
# ms = MainScreen(root)
root.mainloop()
Exemple #5
0
class CodimensionUILauncher:

    """Wrapper class to launch Codimension"""

    def __init__(self):
        self.rootLoggingHandlers = []

        # In case of windows XServers (at least X-Win32) early usage of
        # redirected logging.something(...) leads to a silent crash. It does
        # not happen in a pure Linux environment though. So some warning
        # messages are delayed till the main application loop has started.
        self.__delayedWarnings = []

        self.__args = []
        self.__options = None
        self.__projectFile = None
        self.__splash = None

    def setupLogging(self):
        """Configures the logging module"""
        if self.__options.debug:
            logLevel = logging.DEBUG
        else:
            logLevel = logging.INFO

        # Default output stream is stderr
        logging.basicConfig(level=logLevel,
                            format='%(levelname) -10s %(asctime)s %(message)s')

        # Memorize the root logging handlers
        self.rootLoggingHandlers = logging.root.handlers

    def isOpenable(self, fName):
        """Checks that the file can be opened"""
        # I cannot import it at the top because the fileutils want
        # to use the pixmap cache which needs the application to be
        # created, so the import is deferred
        from utils.fileutils import isFileOpenable

        if not os.path.exists(fName):
            self.__delayedWarnings.append('File does not exist: ' + fName)
            return False
        if not os.path.isfile(fName):
            self.__delayedWarnings.append('The ' + fName + ' is not a file')
            return False
        if not isFileOpenable(fName):
            self.__delayedWarnings.append('The file ' + fName +
                                          ' could not be opened in Codimension')
            return False
        return True

    def processCommandLineArgs(self):
        """Checks what is in the command line"""
        # I cannot import it at the top because the fileutils want
        # to use the pixmap cache which needs the application to be
        # created, so the import is deferred
        from utils.fileutils import getFileProperties, isCDMProjectMime

        if self.__args:
            totalArgs = len(self.__args)
            goodArgs = []
            for fName in self.__args:
                if self.isOpenable(fName):
                    goodArgs.append(fName)
            self.__args = goodArgs

            if totalArgs == 1 and len(self.__args) == 1:
                mime, _, _ = getFileProperties(self.__args[0])
                if isCDMProjectMime(mime):
                    return self.__args[0]

            # Check that the is no project file because it can only come alone
            for fName in self.__args:
                mime, _, _ = getFileProperties(fName)
                if isCDMProjectMime(mime):
                    raise Exception('A Codimension project file (' +
                                    fName + ') must not come '
                                    'together with other files')
        return None

    def main(self):
        """The codimension driver"""
        usageMessage = 'Usage: %prog [options] [project file | python files]'
        parser = OptionParser(usage=usageMessage, version='%prog ' + VER)

        parser.add_option(
            '--debug', action='store_true', dest='debug',
            default=False,
            help='switch on debug and info messages (default: Off)')
        parser.add_option(
            '--clean-start', action='store_true', dest='cleanStart',
            default=False,
            help='do not restore previous IDE state (default: Off)')

        self.__options, self.__args = parser.parse_args()
        self.setupLogging()

        # The default exception handler can be replaced
        sys.excepthook = exceptionHook

        # Create global data singleton.
        # It's unlikely to throw any exceptions.
        globalData = GlobalData()
        globalData.version = VER

        # Loading settings - they have to be loaded before the application is
        # created. This is because the skin name is saved there.
        settings = Settings()
        populateSampleSkin()

        # Load the skin
        globalData.skin = Skin()
        globalData.skin.loadByName(settings['skin'])

        self.__delayedWarnings += settings.validateZoom(
            globalData.skin.minTextZoom, globalData.skin.minCFlowZoom)

        # QT on UBUNTU has a bug - the main menu bar does not generate the
        # 'aboutToHide' signal (though 'aboutToShow' is generated properly. This
        # prevents codimension working properly so the hack below disables the
        # global menu bar for codimension and makes it working properly.
        os.environ['QT_X11_NO_NATIVE_MENUBAR'] = '1'

        # Create QT application
        codimensionApp = CodimensionApplication(sys.argv, settings['style'])
        globalData.application = codimensionApp

        logging.debug('Starting codimension v.%s', VER)

        try:
            # Process command line arguments
            self.__projectFile = self.processCommandLineArgs()
        except Exception as exc:
            logging.error(str(exc))
            parser.print_help()
            return 1

        # Show splash screen
        self.__splash = SplashScreen()

        screenSize = codimensionApp.desktop().screenGeometry()
        globalData.screenWidth = screenSize.width()
        globalData.screenHeight = screenSize.height()

        self.__splash.showMessage('Importing packages...')
        from ui.mainwindow import CodimensionMainWindow

        self.__splash.showMessage('Generating main window...')
        mainWindow = CodimensionMainWindow(self.__splash, settings)
        codimensionApp.setMainWindow(mainWindow)
        globalData.mainWindow = mainWindow
        codimensionApp.lastWindowClosed.connect(codimensionApp.quit)

        mainWindow.show()
        mainWindow.restoreWindowPosition()
        mainWindow.restoreSplitterSizes()

        # Launch the user interface
        QTimer.singleShot(1, self.launchUserInterface)

        # Run the application main cycle
        retVal = codimensionApp.exec_()
        return retVal

    def launchUserInterface(self):
        """UI launchpad"""
        globalData = GlobalData()

        self.__splash.showMessage('Loading plugins...')
        globalData.pluginManager.load()

        settings = Settings()
        mainWindow = globalData.mainWindow
        mainWindow.getToolbar().setVisible(settings['showMainToolBar'])

        needSignal = True
        if self.__options.cleanStart:
            # Codimension will not load anything.
            pass
        elif self.__projectFile:
            self.__splash.showMessage('Loading project...')
            globalData.project.loadProject(self.__projectFile)
            needSignal = False
        elif self.__args:
            # There are arguments and they are python files
            # The project should not be loaded but the files should
            # be opened
            for fName in self.__args:
                mainWindow.openFile(os.path.abspath(fName), -1)
        elif settings['projectLoaded']:
            if not settings['recentProjects']:
                # Some project was loaded but now it is not available.
                pass
            else:
                self.__splash.showMessage('Loading project...')
                if os.path.exists(settings['recentProjects'][0]):
                    globalData.project.loadProject(
                        settings['recentProjects'][0])
                    needSignal = False
                else:
                    self.__delayedWarnings.append(
                        'Cannot open the most recent project: ' +
                        settings['recentProjects'][0] +
                        '. Ignore and continue.')
        else:
            mainWindow.em.restoreTabs(settings.tabStatus)

        # Signal for triggering browsers layout
        if needSignal:
            globalData.project.sigProjectChanged.emit(
                CodimensionProject.CompleteProject)

        # The editors positions can be restored properly only when the editors
        # have actually been drawn. Otherwise the first visible line is
        # unknown. So, I load the project first and let object browsers
        # initialize themselves and then manually call the main window handler
        # to restore the editors. The last step is to connect the signal.
        mainWindow.onProjectChanged(CodimensionProject.CompleteProject)
        globalData.project.sigProjectChanged.connect(
            mainWindow.onProjectChanged)

        self.__splash.finish(globalData.mainWindow)
        self.__splash = None
        del self.__splash

        for message in self.__delayedWarnings:
            logging.warning(message)

        # Some startup time objects could be collected here. In my test runs
        # there were around 700 objects.
        gc.collect()
Exemple #6
0
    def main(self):
        """The codimension driver"""
        usageMessage = 'Usage: %prog [options] [project file | python files]'
        parser = OptionParser(usage=usageMessage, version='%prog ' + VER)

        parser.add_option(
            '--debug', action='store_true', dest='debug',
            default=False,
            help='switch on debug and info messages (default: Off)')
        parser.add_option(
            '--clean-start', action='store_true', dest='cleanStart',
            default=False,
            help='do not restore previous IDE state (default: Off)')

        self.__options, self.__args = parser.parse_args()
        self.setupLogging()

        # The default exception handler can be replaced
        sys.excepthook = exceptionHook

        # Create global data singleton.
        # It's unlikely to throw any exceptions.
        globalData = GlobalData()
        globalData.version = VER

        # Loading settings - they have to be loaded before the application is
        # created. This is because the skin name is saved there.
        settings = Settings()
        populateSampleSkin()

        # Load the skin
        globalData.skin = Skin()
        globalData.skin.loadByName(settings['skin'])

        self.__delayedWarnings += settings.validateZoom(
            globalData.skin.minTextZoom, globalData.skin.minCFlowZoom)

        # QT on UBUNTU has a bug - the main menu bar does not generate the
        # 'aboutToHide' signal (though 'aboutToShow' is generated properly. This
        # prevents codimension working properly so the hack below disables the
        # global menu bar for codimension and makes it working properly.
        os.environ['QT_X11_NO_NATIVE_MENUBAR'] = '1'

        # Create QT application
        codimensionApp = CodimensionApplication(sys.argv, settings['style'])
        globalData.application = codimensionApp

        logging.debug('Starting codimension v.%s', VER)

        try:
            # Process command line arguments
            self.__projectFile = self.processCommandLineArgs()
        except Exception as exc:
            logging.error(str(exc))
            parser.print_help()
            return 1

        # Show splash screen
        self.__splash = SplashScreen()

        screenSize = codimensionApp.desktop().screenGeometry()
        globalData.screenWidth = screenSize.width()
        globalData.screenHeight = screenSize.height()

        self.__splash.showMessage('Importing packages...')
        from ui.mainwindow import CodimensionMainWindow

        self.__splash.showMessage('Generating main window...')
        mainWindow = CodimensionMainWindow(self.__splash, settings)
        codimensionApp.setMainWindow(mainWindow)
        globalData.mainWindow = mainWindow
        codimensionApp.lastWindowClosed.connect(codimensionApp.quit)

        mainWindow.show()
        mainWindow.restoreWindowPosition()
        mainWindow.restoreSplitterSizes()

        # Launch the user interface
        QTimer.singleShot(1, self.launchUserInterface)

        # Run the application main cycle
        retVal = codimensionApp.exec_()
        return retVal
Exemple #7
0
    # Create QT application
    codimensionApp = CodimensionApplication(sys.argv, settings.style)
    globalData.application = codimensionApp

    logging.debug("Starting codimension v." + VER)

    try:
        # Process command line arguments
        projectFile = processCommandLineArgs(args)
    except Exception, exc:
        logging.error(str(exc))
        parser.print_help()
        return 1

    # Show splash screen
    splash = SplashScreen()
    globalData.splash = splash

    screenSize = codimensionApp.desktop().screenGeometry()
    globalData.screenWidth = screenSize.width()
    globalData.screenHeight = screenSize.height()

    try:
        splash.showMessage("Applying patch to rope...")
        import rope_patch
        rope_patch.applyRopePatch()
    except:
        pass

    splash.showMessage("Applying skin to lexers...")
    from editor.lexer import updateLexersStyles
Exemple #8
0
class CodimensionUILauncher:
    """Wrapper class to launch Codimension"""
    def __init__(self):
        self.rootLoggingHandlers = []

        # In case of windows XServers (at least X-Win32) early usage of
        # redirected logging.something(...) leads to a silent crash. It does
        # not happen in a pure Linux environment though. So some warning
        # messages are delayed till the main application loop has started.
        self.__delayedWarnings = []

        self.__args = []
        self.__options = None
        self.__projectFile = None
        self.__splash = None

    def setupLogging(self):
        """Configures the logging module"""
        if self.__options.debug:
            logLevel = logging.DEBUG
        else:
            logLevel = logging.INFO

        # Default output stream is stderr
        logging.basicConfig(level=logLevel,
                            format='%(levelname) -10s %(asctime)s %(message)s')

        # Memorize the root logging handlers
        self.rootLoggingHandlers = logging.root.handlers

    def isOpenable(self, fName):
        """Checks that the file can be opened"""
        # I cannot import it at the top because the fileutils want
        # to use the pixmap cache which needs the application to be
        # created, so the import is deferred
        from utils.fileutils import isFileOpenable

        if not os.path.exists(fName):
            self.__delayedWarnings.append('File does not exist: ' + fName)
            return False
        if not os.path.isfile(fName):
            self.__delayedWarnings.append('The ' + fName + ' is not a file')
            return False
        if not isFileOpenable(fName):
            self.__delayedWarnings.append(
                'The file ' + fName + ' could not be opened in Codimension')
            return False
        return True

    def processCommandLineArgs(self):
        """Checks what is in the command line"""
        # I cannot import it at the top because the fileutils want
        # to use the pixmap cache which needs the application to be
        # created, so the import is deferred
        from utils.fileutils import getFileProperties, isCDMProjectMime

        if self.__args:
            totalArgs = len(self.__args)
            goodArgs = []
            for fName in self.__args:
                if self.isOpenable(fName):
                    goodArgs.append(fName)
            self.__args = goodArgs

            if totalArgs == 1 and len(self.__args) == 1:
                mime, _, _ = getFileProperties(self.__args[0])
                if isCDMProjectMime(mime):
                    return self.__args[0]

            # Check that the is no project file because it can only come alone
            for fName in self.__args:
                mime, _, _ = getFileProperties(fName)
                if isCDMProjectMime(mime):
                    raise Exception('A Codimension project file (' + fName +
                                    ') must not come '
                                    'together with other files')
        return None

    def main(self):
        """The codimension driver"""
        usageMessage = 'Usage: %prog [options] [project file | python files]'
        parser = OptionParser(usage=usageMessage, version='%prog ' + VER)

        parser.add_option(
            '--debug',
            action='store_true',
            dest='debug',
            default=False,
            help='switch on debug and info messages (default: Off)')
        parser.add_option(
            '--clean-start',
            action='store_true',
            dest='cleanStart',
            default=False,
            help='do not restore previous IDE state (default: Off)')

        self.__options, self.__args = parser.parse_args()
        self.setupLogging()

        # The default exception handler can be replaced
        sys.excepthook = exceptionHook

        # Create global data singleton.
        # It's unlikely to throw any exceptions.
        globalData = GlobalData()
        globalData.version = VER

        # Loading settings - they have to be loaded before the application is
        # created. This is because the skin name is saved there.
        settings = Settings()
        self.copySkin()

        # Load the skin
        globalData.skin = Skin()
        globalData.skin.load(SETTINGS_DIR + 'skins' + os.path.sep +
                             settings['skin'])

        self.__delayedWarnings += settings.validateZoom(
            globalData.skin.minTextZoom, globalData.skin.minCFlowZoom)

        # QT on UBUNTU has a bug - the main menu bar does not generate the
        # 'aboutToHide' signal (though 'aboutToShow' is generated properly. This
        # prevents codimension working properly so this hack below disables the
        # global menu bar for codimension and makes it working properly.
        os.environ['QT_X11_NO_NATIVE_MENUBAR'] = '1'

        # Create QT application
        codimensionApp = CodimensionApplication(sys.argv, settings['style'])
        globalData.application = codimensionApp

        logging.debug('Starting codimension v.%s', VER)

        try:
            # Process command line arguments
            self.__projectFile = self.processCommandLineArgs()
        except Exception as exc:
            logging.error(str(exc))
            parser.print_help()
            return 1

        # Show splash screen
        self.__splash = SplashScreen()

        screenSize = codimensionApp.desktop().screenGeometry()
        globalData.screenWidth = screenSize.width()
        globalData.screenHeight = screenSize.height()

        self.__splash.showMessage('Importing packages...')
        from ui.mainwindow import CodimensionMainWindow

        self.__splash.showMessage('Generating main window...')
        mainWindow = CodimensionMainWindow(self.__splash, settings)
        codimensionApp.setMainWindow(mainWindow)
        globalData.mainWindow = mainWindow
        codimensionApp.lastWindowClosed.connect(codimensionApp.quit)

        mainWindow.show()
        mainWindow.restoreWindowPosition()
        mainWindow.restoreSplitterSizes()

        # Launch the user interface
        QTimer.singleShot(1, self.launchUserInterface)

        # Run the application main cycle
        retVal = codimensionApp.exec_()
        return retVal

    def launchUserInterface(self):
        """UI launchpad"""
        globalData = GlobalData()

        self.__splash.showMessage('Loading plugins...')
        globalData.pluginManager.load()

        settings = Settings()
        mainWindow = globalData.mainWindow
        mainWindow.getToolbar().setVisible(settings['showMainToolBar'])

        needSignal = True
        if self.__options.cleanStart:
            # Codimension will not load anything.
            pass
        elif self.__projectFile:
            self.__splash.showMessage('Loading project...')
            globalData.project.loadProject(self.__projectFile)
            needSignal = False
        elif self.__args:
            # There are arguments and they are python files
            # The project should not be loaded but the files should
            # be opened
            for fName in self.__args:
                mainWindow.openFile(os.path.abspath(fName), -1)
        elif settings['projectLoaded']:
            if not settings['recentProjects']:
                # Some project was loaded but now it is not available.
                pass
            else:
                self.__splash.showMessage('Loading project...')
                if os.path.exists(settings['recentProjects'][0]):
                    globalData.project.loadProject(
                        settings['recentProjects'][0])
                    needSignal = False
                else:
                    self.__delayedWarnings.append(
                        'Cannot open the most recent project: ' +
                        settings['recentProjects'][0] +
                        '. Ignore and continue.')
        else:
            mainWindow.em.restoreTabs(settings.tabStatus)

        # Signal for triggering browsers layout
        if needSignal:
            globalData.project.sigProjectChanged.emit(
                CodimensionProject.CompleteProject)

        # The editors positions can be restored properly only when the editors have
        # actually been drawn. Otherwise the first visible line is unknown.
        # So, I load the project first and let object browsers initialize
        # themselves and then manually call the main window handler to restore the
        # editors. The last step is to connect the signal.
        mainWindow.onProjectChanged(CodimensionProject.CompleteProject)
        globalData.project.sigProjectChanged.connect(
            mainWindow.onProjectChanged)

        self.__splash.finish(globalData.mainWindow)
        self.__splash = None
        del self.__splash

        for message in self.__delayedWarnings:
            logging.warning(message)

        # Some startup time objects could be collected here. In my test runs
        # there were around 700 objects.
        gc.collect()

    def copySkin(self):
        """Copies the new system-wide skins to the user settings dir.

        Also tests if the configured skin is in place. Sets the default if not.
        """
        # I cannot import it at the top because the fileutils want
        # to use the pixmap cache which needs the application to be
        # created, so the import is deferred
        from utils.fileutils import saveToFile

        systemWideSkinsDir = srcDir + os.path.sep + 'skins' + os.path.sep
        userSkinsDir = os.path.normpath(QDir.homePath()) + \
            os.path.sep + CONFIG_DIR + os.path.sep + 'skins' + os.path.sep

        skinFiles = ['app.css', 'skin.json', 'cflow.json']
        platformSuffix = '.' + sys.platform.lower()

        if os.path.exists(systemWideSkinsDir):
            for item in os.listdir(systemWideSkinsDir):
                candidate = systemWideSkinsDir + item
                if os.path.isdir(candidate):
                    userCandidate = userSkinsDir + item
                    if not os.path.exists(userCandidate):
                        try:
                            os.makedirs(userCandidate, exist_ok=True)
                            filesToCopy = []
                            for fName in skinFiles:
                                generalFile = candidate + os.path.sep + fName
                                platformSpecificFile = generalFile + platformSuffix
                                userFile = userCandidate + os.path.sep + fName
                                if os.path.exists(platformSpecificFile):
                                    filesToCopy.append(
                                        [platformSpecificFile, userFile])
                                elif os.path.exists(generalFile):
                                    filesToCopy.append([generalFile, userFile])
                                else:
                                    raise Exception('The skin file ' + fName +
                                                    ' is not found in the '
                                                    'installation package')
                            for srcDst in filesToCopy:
                                shutil.copyfile(srcDst[0], srcDst[1])
                        except Exception as exc:
                            logging.error(
                                'Could not copy system wide skin from '
                                '%s to  the user skin to %s. '
                                'Continue without copying skin.', candidate,
                                userCandidate)
                            logging.error(str(exc))

        # Deal with the default settings
        defaultSkinDir = userSkinsDir + 'default'
        defaultSkinDirOK = True
        if not os.path.exists(defaultSkinDir):
            # Create the default skin dir
            try:
                os.makedirs(defaultSkinDir, exist_ok=True)
            except Exception as exc:
                defaultSkinDirOK = False
                logging.error('Error creating a default skin directory: %s',
                              defaultSkinDir)
                logging.error(str(exc))

        if defaultSkinDirOK:
            defaultCSS = defaultSkinDir + os.path.sep + 'app.css'
            if not os.path.exists(defaultCSS):
                try:
                    saveToFile(defaultCSS, _DEFAULT_APP_CSS)
                except Exception as exc:
                    logging.error(
                        'Error creating default skin app.css file at %s',
                        defaultCSS)
                    logging.error(str(exc))
            defaultCommonSkin = defaultSkinDir + os.path.sep + 'skin.json'
            if not os.path.exists(defaultCommonSkin):
                try:
                    with open(defaultCommonSkin,
                              'w',
                              encoding=DEFAULT_ENCODING) as diskfile:
                        json.dump(_DEFAULT_SKIN_SETTINGS,
                                  diskfile,
                                  indent=4,
                                  default=toJSON)
                except Exception as exc:
                    logging.error(
                        'Error creating default skin skin.json '
                        'file at %s', defaultCommonSkin)
                    logging.error(str(exc))
            defaultCFlowSkin = defaultSkinDir + os.path.sep + 'cflow.json'
            if not os.path.exists(defaultCFlowSkin):
                try:
                    with open(defaultCFlowSkin, 'w',
                              encoding=DEFAULT_ENCODING) as diskfile:
                        json.dump(_DEFAULT_CFLOW_SETTINGS,
                                  diskfile,
                                  indent=4,
                                  default=toJSON)
                except Exception as exc:
                    logging.error(
                        'Error creating default skin cflow.json '
                        'file at %s', defaultCFlowSkin)
                    logging.error(str(exc))

        # Check that the configured skin is in place
        userSkinDir = userSkinsDir + Settings()['skin']
        if os.path.exists(userSkinDir) and os.path.isdir(userSkinDir):
            # That's just fine
            return

        # Here: the configured skin is not found in the user dir.
        # Try to set the default.
        if os.path.exists(defaultSkinDir):
            if os.path.isdir(defaultSkinDir):
                logging.warning(
                    "The configured skin '%s' has not been found. "
                    "Fallback to the 'default' skin.",
                    Settings()['skin'])
                Settings()['skin'] = 'default'
                return

        # Default is not there. Try to pick any.
        anySkinName = None
        for item in os.listdir(userSkinsDir):
            if os.path.isdir(userSkinsDir + item):
                anySkinName = item
                break

        if anySkinName is None:
            # Really bad situation. No system wide skins, no local skins.
            logging.error('Cannot find the any Codimension skin. '
                          'Please check Codimension installation.')
            return

        # Here: last resort - fallback to the first found skin
        logging.warning(
            "The configured skin '%s' has not been found. "
            "Fallback to the '%s' skin.",
            Settings()['skin'], anySkinName)
        Settings()['skin'] = anySkinName