From f3079b6fdc73b9e49751cd1f610cad8675fdb5a6 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 26 Mar 2014 18:39:34 +0000 Subject: [PATCH] Cleanup --- source/carla_backend.py | 15 +-------- source/carla_shared.py | 21 ++++++------ source/carla_style.py | 75 +++++++++++++++++++++++------------------ 3 files changed, 54 insertions(+), 57 deletions(-) diff --git a/source/carla_backend.py b/source/carla_backend.py index 61e4fb172..ebedd8ed0 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Carla Backend code -# Copyright (C) 2011-2013 Filipe Coelho +# Copyright (C) 2011-2014 Filipe Coelho # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -120,28 +120,15 @@ c_intp_types = tuple(POINTER(i) for i in c_int_types) c_floatp_types = tuple(POINTER(i) for i in c_float_types) def toPythonType(value, attr): - #if value is None: - #return None if isinstance(value, (bool, int, float)): return value if isinstance(value, bytes): return charPtrToString(value) - #if isinstance(value, c_bool): - #return bool(value) - #if isinstance(value, c_char_p): - #return charPtrToString(value) - #if isinstance(value, c_int_types): - #return int(value) - #if isinstance(value, c_float_types): - #return float(value) if isinstance(value, c_intp_types) or isinstance(value, c_floatp_types): return numPtrToList(value) if isinstance(value, POINTER(c_char_p)): return charPtrPtrToStringList(value) print("..............", attr, ".....................", value, ":", type(value)) - #raise Exception("error here!!!") - #from sys import exit - #exit(1) return value # ------------------------------------------------------------------------------------------------------------ diff --git a/source/carla_shared.py b/source/carla_shared.py index c8006d2af..165180c8f 100644 --- a/source/carla_shared.py +++ b/source/carla_shared.py @@ -187,15 +187,15 @@ CARLA_KEY_MAIN_USE_PRO_THEME = "Main/UseProTheme" # bool CARLA_KEY_MAIN_PRO_THEME_COLOR = "Main/ProThemeColor" # str CARLA_KEY_MAIN_REFRESH_INTERVAL = "Main/RefreshInterval" # int -CARLA_KEY_CANVAS_THEME = "Canvas/Theme" # str -CARLA_KEY_CANVAS_SIZE = "Canvas/Size" # str "NxN" -CARLA_KEY_CANVAS_USE_BEZIER_LINES = "Canvas/UseBezierLines" # bool -CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS = "Canvas/AutoHideGroups" # bool -CARLA_KEY_CANVAS_EYE_CANDY = "Canvas/EyeCandy" # enum -CARLA_KEY_CANVAS_USE_OPENGL = "Canvas/UseOpenGL" # bool -CARLA_KEY_CANVAS_ANTIALIASING = "Canvas/Antialiasing" # enum -CARLA_KEY_CANVAS_HQ_ANTIALIASING = "Canvas/HQAntialiasing" # bool -CARLA_KEY_CUSTOM_PAINTING = "UseCustomPainting" # bool +CARLA_KEY_CANVAS_THEME = "Canvas/Theme" # str +CARLA_KEY_CANVAS_SIZE = "Canvas/Size" # str "NxN" +CARLA_KEY_CANVAS_USE_BEZIER_LINES = "Canvas/UseBezierLines" # bool +CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS = "Canvas/AutoHideGroups" # bool +CARLA_KEY_CANVAS_EYE_CANDY = "Canvas/EyeCandy" # enum +CARLA_KEY_CANVAS_USE_OPENGL = "Canvas/UseOpenGL" # bool +CARLA_KEY_CANVAS_ANTIALIASING = "Canvas/Antialiasing" # enum +CARLA_KEY_CANVAS_HQ_ANTIALIASING = "Canvas/HQAntialiasing" # bool +CARLA_KEY_CUSTOM_PAINTING = "UseCustomPainting" # bool CARLA_KEY_ENGINE_DRIVER_PREFIX = "Engine/Driver-" CARLA_KEY_ENGINE_AUDIO_DRIVER = "Engine/AudioDriver" # str @@ -441,6 +441,7 @@ if readEnvVars: gCarla.DEFAULT_GIG_PATH = os.getenv("GIG_PATH", DEFAULT_GIG_PATH).split(splitter) gCarla.DEFAULT_SF2_PATH = os.getenv("SF2_PATH", DEFAULT_SF2_PATH).split(splitter) gCarla.DEFAULT_SFZ_PATH = os.getenv("SFZ_PATH", DEFAULT_SFZ_PATH).split(splitter) + else: gCarla.DEFAULT_LADSPA_PATH = DEFAULT_LADSPA_PATH.split(splitter) gCarla.DEFAULT_DSSI_PATH = DEFAULT_DSSI_PATH.split(splitter) @@ -461,7 +462,7 @@ CWD = sys.path[0] # make it work with cxfreeze if WINDOWS and CWD.endswith(".exe"): CWD = CWD.rsplit("\\", 1)[0] -elif CWD.endswith("/carla") or CWD.endswith("/carla-plugin") or CWD.endswith("/carla-patchbay") or CWD.endswith("/carla-rack"): +elif CWD.endswith(("/carla", "/carla-plugin", "/carla-patchbay", "/carla-rack")): CWD = CWD.rsplit("/", 1)[0] # find tool diff --git a/source/carla_style.py b/source/carla_style.py index 92efa0d3d..8425fba51 100644 --- a/source/carla_style.py +++ b/source/carla_style.py @@ -46,6 +46,7 @@ class CarlaApplication(object): def __init__(self, appName = "Carla2"): object.__init__(self) + # try to find style dir foundDir = False if os.path.exists(os.path.join(CWD, "modules", "theme", "styles")): @@ -60,16 +61,32 @@ class CarlaApplication(object): QApplication.addLibraryPath(os.path.join(CWD, "..")) foundDir = True - self.fApp = QApplication(sys.argv) - self.fApp.setApplicationName(appName) - self.fApp.setApplicationVersion(VERSION) - self.fApp.setOrganizationName("falkTX") + if not foundDir: + self._createApp(appName) + return - if appName.lower() == "carla-control": - self.fApp.setWindowIcon(QIcon(":/scalable/carla-control.svg")) - else: - self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg")) + # base settings + settings = QSettings("falkTX", appName) + useProTheme = settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool) + + if not useProTheme: + self._createApp(appName) + return + + # set initial Qt stuff + customFont = QFont("DejaVu Sans [Book]", 12 if MACOS else 8, QFont.Normal) + + #QApplication.setDesktopSettingsAware(False) + #QApplication.setFont(customFont) + QApplication.setStyle("carla") + + # create app + self._createApp(appName) + + #self.fApp.setFont(customFont) + self.fApp.setStyle("carla") + # create palettes self.fPalSystem = self.fApp.palette() self.fPalBlack = QPalette() @@ -190,41 +207,33 @@ class CarlaApplication(object): self.fPalBlue.setColor(QPalette.Active, QPalette.LinkVisited, QColor(64, 128, 255)) self.fPalBlue.setColor(QPalette.Inactive, QPalette.LinkVisited, QColor(64, 128, 255)) - if foundDir: - self.loadSettings() + proThemeColor = settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, "Black", type=str).lower() - def loadSettings(self): - settings = QSettings() + if proThemeColor == "black": + self.fApp.setPalette(self.fPalBlack) - useProTheme = settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, True, type=bool) - - if useProTheme: - #font = QFont("DejaVu Sans [Book]", 12 if MACOS else 8, QFont.Normal) - #self.fApp.setFont(font) - #QApplication.setFont(font) - - # TODO - if WINDOWS: return - - self.fApp.setStyle("carla") - QApplication.setStyle("carla") + elif proThemeColor == "blue": + self.fApp.setPalette(self.fPalBlue) - proThemeColor = settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, "Black", type=str).lower() - - if proThemeColor == "black": - self.fApp.setPalette(self.fPalBlack) + print("Using \"%s\" theme" % self.fApp.style().objectName()) - elif proThemeColor == "blue": - self.fApp.setPalette(self.fPalBlue) + def _createApp(self, appName): + self.fApp = QApplication(sys.argv) + self.fApp.setApplicationName(appName) + self.fApp.setApplicationVersion(VERSION) + self.fApp.setOrganizationName("falkTX") - print("Using \"%s\" theme" % self.fApp.style().objectName()) + if appName.lower() == "carla-control": + self.fApp.setWindowIcon(QIcon(":/scalable/carla-control.svg")) + else: + self.fApp.setWindowIcon(QIcon(":/scalable/carla.svg")) def addLibraryPath(self, libdir): if not os.path.exists(libdir): return - QApplication.addLibraryPath(libdir) - self.loadSettings() + #QApplication.addLibraryPath(libdir) + #self.loadSettings() def arguments(self): return self.fApp.arguments()