From 3cfd7d09fd4e6346088970033724bcb9b4836b10 Mon Sep 17 00:00:00 2001 From: falkTX Date: Wed, 18 Dec 2019 14:04:10 +0000 Subject: [PATCH] Use QSafeSettings in a few more places Signed-off-by: falkTX --- source/frontend/carla_control.py | 6 +- source/frontend/carla_database.py | 212 ++++++++++----------- source/frontend/carla_host.py | 4 +- source/frontend/carla_settings.py | 110 +++++------ source/frontend/carla_widgets.py | 2 +- source/frontend/patchcanvas.py | 31 ++- source/frontend/patchcanvas/patchcanvas.py | 6 +- source/frontend/widgets/pixmapkeyboard.py | 17 +- 8 files changed, 194 insertions(+), 194 deletions(-) diff --git a/source/frontend/carla_control.py b/source/frontend/carla_control.py index 37814692b..51066c354 100755 --- a/source/frontend/carla_control.py +++ b/source/frontend/carla_control.py @@ -95,9 +95,9 @@ class ConnectDialog(QDialog): self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) def loadSettings(self): - settings = QSettings("falkTX", "CarlaOSCConnect") + settings = QSafeSettings("falkTX", "CarlaOSCConnect") - if settings.value("ReportedHostAutomatic", True, type=bool): + if settings.value("ReportedHostAutomatic", True, bool): self.ui.rb_reported_custom.setChecked(False) self.ui.rb_reported_auto.setChecked(True) else: @@ -141,7 +141,7 @@ class ConnectDialog(QDialog): @pyqtSlot() def slot_saveSettings(self): - settings = QSettings("falkTX", "CarlaOSCConnect") + settings = QSafeSettings("falkTX", "CarlaOSCConnect") settings.setValue("Host", self.ui.le_host.text()) settings.setValue("ReportedHost", self.ui.le_reported_host.text()) settings.setValue("TCPPort", self.ui.sb_tcp_port.value()) diff --git a/source/frontend/carla_database.py b/source/frontend/carla_database.py index 5d574b7bb..96ec7629c 100755 --- a/source/frontend/carla_database.py +++ b/source/frontend/carla_database.py @@ -22,7 +22,7 @@ from copy import deepcopy from subprocess import Popen, PIPE -from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QEventLoop, QThread, QSettings +from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QEventLoop, QThread from PyQt5.QtGui import QPixmap from PyQt5.QtWidgets import QApplication, QDialog, QDialogButtonBox, QHeaderView, QTableWidgetItem @@ -412,11 +412,11 @@ class SearchPluginsThread(QThread): else: toolNative = "carla-discovery-native" - settings = QSettings("falkTX", "Carla2") + settings = QSafeSettings("falkTX", "Carla2") self.fWineSettings = { - 'executable' : settings.value(CARLA_KEY_WINE_EXECUTABLE, CARLA_DEFAULT_WINE_EXECUTABLE, type=str), - 'autoPrefix' : settings.value(CARLA_KEY_WINE_AUTO_PREFIX, CARLA_DEFAULT_WINE_AUTO_PREFIX, type=bool), - 'fallbackPrefix': settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX, CARLA_DEFAULT_WINE_FALLBACK_PREFIX, type=str) + 'executable' : settings.value(CARLA_KEY_WINE_EXECUTABLE, CARLA_DEFAULT_WINE_EXECUTABLE, str), + 'autoPrefix' : settings.value(CARLA_KEY_WINE_AUTO_PREFIX, CARLA_DEFAULT_WINE_AUTO_PREFIX, bool), + 'fallbackPrefix': settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX, CARLA_DEFAULT_WINE_FALLBACK_PREFIX, str) } del settings @@ -456,7 +456,7 @@ class SearchPluginsThread(QThread): self.fContinueChecking = False def run(self): - settingsDB = QSettings("falkTX", "CarlaPlugins4") + settingsDB = QSafeSettings("falkTX", "CarlaPlugins4") self.fContinueChecking = True self.fCurCount = 0 @@ -704,8 +704,8 @@ class SearchPluginsThread(QThread): if not self.fContinueChecking: return if self.fCheckSF2: - settings = QSettings("falkTX", "Carla2") - SF2_PATH = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH)) + settings = QSafeSettings("falkTX", "Carla2") + SF2_PATH = settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH, list) del settings kits = self._checkKIT(SF2_PATH, "sf2") @@ -724,8 +724,8 @@ class SearchPluginsThread(QThread): self._pluginLook(self.fLastCheckValue, "LADSPA plugins...") - settings = QSettings("falkTX", "Carla2") - LADSPA_PATH = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH)) + settings = QSafeSettings("falkTX", "Carla2") + LADSPA_PATH = settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH, list) del settings for iPATH in LADSPA_PATH: @@ -760,8 +760,8 @@ class SearchPluginsThread(QThread): self._pluginLook(self.fLastCheckValue, "DSSI plugins...") - settings = QSettings("falkTX", "Carla2") - DSSI_PATH = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH)) + settings = QSafeSettings("falkTX", "Carla2") + DSSI_PATH = settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH, list) del settings for iPATH in DSSI_PATH: @@ -799,8 +799,8 @@ class SearchPluginsThread(QThread): else: self._pluginLook(self.fLastCheckValue, "VST2 plugins...") - settings = QSettings("falkTX", "Carla2") - VST2_PATH = toList(settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH)) + settings = QSafeSettings("falkTX", "Carla2") + VST2_PATH = settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH, list) del settings for iPATH in VST2_PATH: @@ -841,8 +841,8 @@ class SearchPluginsThread(QThread): else: self._pluginLook(self.fLastCheckValue, "VST2 plugins...") - settings = QSettings("falkTX", "Carla2") - VST3_PATH = toList(settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH)) + settings = QSafeSettings("falkTX", "Carla2") + VST3_PATH = settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH, list) del settings for iPATH in VST3_PATH: @@ -920,8 +920,8 @@ class SearchPluginsThread(QThread): def _checkCached(self, isLV2): if isLV2: - settings = QSettings("falkTX", "Carla2") - PLUG_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))) + settings = QSafeSettings("falkTX", "Carla2") + PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list)) del settings PLUG_TEXT = "LV2" PLUG_TYPE = PLUGIN_LV2 @@ -956,8 +956,8 @@ class SearchPluginsThread(QThread): return plugins def _checkSfzCached(self): - settings = QSettings("falkTX", "Carla2") - PLUG_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH))) + settings = QSafeSettings("falkTX", "Carla2") + PLUG_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH, list)) del settings sfzKits = [] @@ -1215,57 +1215,57 @@ class PluginRefreshW(QDialog): # ----------------------------------------------------------------------------------------------------------------- def loadSettings(self): - settings = QSettings("falkTX", "CarlaRefresh2") + settings = QSafeSettings("falkTX", "CarlaRefresh2") - check = settings.value("PluginDatabase/SearchLADSPA", True, type=bool) and self.ui.ch_ladspa.isEnabled() + check = settings.value("PluginDatabase/SearchLADSPA", True, bool) and self.ui.ch_ladspa.isEnabled() self.ui.ch_ladspa.setChecked(check) - check = settings.value("PluginDatabase/SearchDSSI", True, type=bool) and self.ui.ch_dssi.isEnabled() + check = settings.value("PluginDatabase/SearchDSSI", True, bool) and self.ui.ch_dssi.isEnabled() self.ui.ch_dssi.setChecked(check) - check = settings.value("PluginDatabase/SearchLV2", True, type=bool) and self.ui.ch_lv2.isEnabled() + check = settings.value("PluginDatabase/SearchLV2", True, bool) and self.ui.ch_lv2.isEnabled() self.ui.ch_lv2.setChecked(check) - check = settings.value("PluginDatabase/SearchVST2", True, type=bool) and self.ui.ch_vst.isEnabled() + check = settings.value("PluginDatabase/SearchVST2", True, bool) and self.ui.ch_vst.isEnabled() self.ui.ch_vst.setChecked(check) - check = settings.value("PluginDatabase/SearchVST3", True, type=bool) and self.ui.ch_vst3.isEnabled() + check = settings.value("PluginDatabase/SearchVST3", True, bool) and self.ui.ch_vst3.isEnabled() self.ui.ch_vst3.setChecked(check) if MACOS: - check = settings.value("PluginDatabase/SearchAU", True, type=bool) and self.ui.ch_au.isEnabled() + check = settings.value("PluginDatabase/SearchAU", True, bool) and self.ui.ch_au.isEnabled() else: check = False self.ui.ch_au.setChecked(check) - check = settings.value("PluginDatabase/SearchSF2", False, type=bool) and self.ui.ch_sf2.isEnabled() + check = settings.value("PluginDatabase/SearchSF2", False, bool) and self.ui.ch_sf2.isEnabled() self.ui.ch_sf2.setChecked(check) - check = settings.value("PluginDatabase/SearchSFZ", False, type=bool) and self.ui.ch_sfz.isEnabled() + check = settings.value("PluginDatabase/SearchSFZ", False, bool) and self.ui.ch_sfz.isEnabled() self.ui.ch_sfz.setChecked(check) - check = settings.value("PluginDatabase/SearchNative", True, type=bool) and self.ui.ch_native.isEnabled() + check = settings.value("PluginDatabase/SearchNative", True, bool) and self.ui.ch_native.isEnabled() self.ui.ch_native.setChecked(check) - check = settings.value("PluginDatabase/SearchPOSIX32", False, type=bool) and self.ui.ch_posix32.isEnabled() + check = settings.value("PluginDatabase/SearchPOSIX32", False, bool) and self.ui.ch_posix32.isEnabled() self.ui.ch_posix32.setChecked(check) - check = settings.value("PluginDatabase/SearchPOSIX64", False, type=bool) and self.ui.ch_posix64.isEnabled() + check = settings.value("PluginDatabase/SearchPOSIX64", False, bool) and self.ui.ch_posix64.isEnabled() self.ui.ch_posix64.setChecked(check) - check = settings.value("PluginDatabase/SearchWin32", False, type=bool) and self.ui.ch_win32.isEnabled() + check = settings.value("PluginDatabase/SearchWin32", False, bool) and self.ui.ch_win32.isEnabled() self.ui.ch_win32.setChecked(check) - check = settings.value("PluginDatabase/SearchWin64", False, type=bool) and self.ui.ch_win64.isEnabled() + check = settings.value("PluginDatabase/SearchWin64", False, bool) and self.ui.ch_win64.isEnabled() self.ui.ch_win64.setChecked(check) - self.ui.ch_do_checks.setChecked(settings.value("PluginDatabase/DoChecks", False, type=bool)) + self.ui.ch_do_checks.setChecked(settings.value("PluginDatabase/DoChecks", False, bool)) # ----------------------------------------------------------------------------------------------------------------- @pyqtSlot() def slot_saveSettings(self): - settings = QSettings("falkTX", "CarlaRefresh2") + settings = QSafeSettings("falkTX", "CarlaRefresh2") settings.setValue("PluginDatabase/SearchLADSPA", self.ui.ch_ladspa.isChecked()) settings.setValue("PluginDatabase/SearchDSSI", self.ui.ch_dssi.isChecked()) settings.setValue("PluginDatabase/SearchLV2", self.ui.ch_lv2.isChecked()) @@ -1663,7 +1663,7 @@ class PluginDatabaseW(QDialog): @pyqtSlot() def slot_saveSettings(self): - settings = QSettings("falkTX", "CarlaDatabase2") + settings = QSafeSettings("falkTX", "CarlaDatabase2") settings.setValue("PluginDatabase/Geometry", self.saveGeometry()) settings.setValue("PluginDatabase/TableGeometry_6", self.ui.tableWidget.horizontalHeader().saveState()) settings.setValue("PluginDatabase/ShowEffects", self.ui.ch_effects.isChecked()) @@ -1695,37 +1695,37 @@ class PluginDatabaseW(QDialog): # -------------------------------------------------------------------------------------------------------- def loadSettings(self): - settings = QSettings("falkTX", "CarlaDatabase2") - self.fFavoritePlugins = settings.value("PluginDatabase/Favorites", [], type=list) + settings = QSafeSettings("falkTX", "CarlaDatabase2") + self.fFavoritePlugins = settings.value("PluginDatabase/Favorites", [], list) self.fFavoritePluginsChanged = False - self.restoreGeometry(settings.value("PluginDatabase/Geometry", b"")) - self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, type=bool)) - self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, type=bool)) - self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, type=bool)) - self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, type=bool)) - self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, type=bool)) - self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, type=bool)) - self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, type=bool)) - self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, type=bool)) - self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST2", True, type=bool)) - self.ui.ch_vst3.setChecked(settings.value("PluginDatabase/ShowVST3", (MACOS or WINDOWS), type=bool)) - self.ui.ch_au.setChecked(settings.value("PluginDatabase/ShowAU", MACOS, type=bool)) - self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, type=bool)) - self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, type=bool)) - self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, type=bool)) - self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, type=bool)) - self.ui.ch_favorites.setChecked(settings.value("PluginDatabase/ShowFavorites", False, type=bool)) - self.ui.ch_rtsafe.setChecked(settings.value("PluginDatabase/ShowRtSafe", False, type=bool)) - self.ui.ch_cv.setChecked(settings.value("PluginDatabase/ShowHasCV", False, type=bool)) - self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, type=bool)) - self.ui.ch_inline_display.setChecked(settings.value("PluginDatabase/ShowHasInlineDisplay", False, type=bool)) - self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, type=bool)) - self.ui.lineEdit.setText(settings.value("PluginDatabase/SearchText", "", type=str)) - - tableGeometry = settings.value("PluginDatabase/TableGeometry_6") + self.restoreGeometry(settings.value("PluginDatabase/Geometry", QByteArray(), QByteArray)) + self.ui.ch_effects.setChecked(settings.value("PluginDatabase/ShowEffects", True, bool)) + self.ui.ch_instruments.setChecked(settings.value("PluginDatabase/ShowInstruments", True, bool)) + self.ui.ch_midi.setChecked(settings.value("PluginDatabase/ShowMIDI", True, bool)) + self.ui.ch_other.setChecked(settings.value("PluginDatabase/ShowOther", True, bool)) + self.ui.ch_internal.setChecked(settings.value("PluginDatabase/ShowInternal", True, bool)) + self.ui.ch_ladspa.setChecked(settings.value("PluginDatabase/ShowLADSPA", True, bool)) + self.ui.ch_dssi.setChecked(settings.value("PluginDatabase/ShowDSSI", True, bool)) + self.ui.ch_lv2.setChecked(settings.value("PluginDatabase/ShowLV2", True, bool)) + self.ui.ch_vst.setChecked(settings.value("PluginDatabase/ShowVST2", True, bool)) + self.ui.ch_vst3.setChecked(settings.value("PluginDatabase/ShowVST3", (MACOS or WINDOWS), bool)) + self.ui.ch_au.setChecked(settings.value("PluginDatabase/ShowAU", MACOS, bool)) + self.ui.ch_kits.setChecked(settings.value("PluginDatabase/ShowKits", True, bool)) + self.ui.ch_native.setChecked(settings.value("PluginDatabase/ShowNative", True, bool)) + self.ui.ch_bridged.setChecked(settings.value("PluginDatabase/ShowBridged", True, bool)) + self.ui.ch_bridged_wine.setChecked(settings.value("PluginDatabase/ShowBridgedWine", True, bool)) + self.ui.ch_favorites.setChecked(settings.value("PluginDatabase/ShowFavorites", False, bool)) + self.ui.ch_rtsafe.setChecked(settings.value("PluginDatabase/ShowRtSafe", False, bool)) + self.ui.ch_cv.setChecked(settings.value("PluginDatabase/ShowHasCV", False, bool)) + self.ui.ch_gui.setChecked(settings.value("PluginDatabase/ShowHasGUI", False, bool)) + self.ui.ch_inline_display.setChecked(settings.value("PluginDatabase/ShowHasInlineDisplay", False, bool)) + self.ui.ch_stereo.setChecked(settings.value("PluginDatabase/ShowStereoOnly", False, bool)) + self.ui.lineEdit.setText(settings.value("PluginDatabase/SearchText", "", str)) + + tableGeometry = settings.value("PluginDatabase/TableGeometry_6", QByteArray(), QByteArray) horizontalHeader = self.ui.tableWidget.horizontalHeader() - if tableGeometry: + if not tableGeometry.isNull(): horizontalHeader.restoreState(tableGeometry) else: horizontalHeader.setSectionResizeMode(self.TABLEWIDGET_ITEM_FAVORITE, QHeaderView.Fixed) @@ -1902,8 +1902,8 @@ class PluginDatabaseW(QDialog): else: return 0 - plugins = toList(settingsDB.value("Plugins/" + ptypeStr, [])) - pluginCount = settingsDB.value("PluginCount/" + ptypeStr, 0, type=int) + plugins = settingsDB.value("Plugins/" + ptypeStr, [], list) + pluginCount = settingsDB.value("PluginCount/" + ptypeStr, 0, int) pluginCountNew = gCarla.utils.get_cached_plugin_count(ptype, path) @@ -1938,7 +1938,7 @@ class PluginDatabaseW(QDialog): return pluginCount def _reAddPlugins(self): - settingsDB = QSettings("falkTX", "CarlaPlugins4") + settingsDB = QSafeSettings("falkTX", "CarlaPlugins4") for x in range(self.ui.tableWidget.rowCount()): self.ui.tableWidget.removeRow(0) @@ -1946,8 +1946,8 @@ class PluginDatabaseW(QDialog): self.fLastTableIndex = 0 self.ui.tableWidget.setSortingEnabled(False) - settings = QSettings("falkTX", "Carla2") - LV2_PATH = splitter.join(toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH))) + settings = QSafeSettings("falkTX", "Carla2") + LV2_PATH = splitter.join(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list)) del settings # ---------------------------------------------------------------------------------------------------- @@ -1961,52 +1961,52 @@ class PluginDatabaseW(QDialog): # LADSPA ladspaPlugins = [] - ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_native", [])) - ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix32", [])) - ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_posix64", [])) - ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win32", [])) - ladspaPlugins += toList(settingsDB.value("Plugins/LADSPA_win64", [])) + ladspaPlugins += settingsDB.value("Plugins/LADSPA_native", [], list) + ladspaPlugins += settingsDB.value("Plugins/LADSPA_posix32", [], list) + ladspaPlugins += settingsDB.value("Plugins/LADSPA_posix64", [], list) + ladspaPlugins += settingsDB.value("Plugins/LADSPA_win32", [], list) + ladspaPlugins += settingsDB.value("Plugins/LADSPA_win64", [], list) # ---------------------------------------------------------------------------------------------------- # DSSI dssiPlugins = [] - dssiPlugins += toList(settingsDB.value("Plugins/DSSI_native", [])) - dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix32", [])) - dssiPlugins += toList(settingsDB.value("Plugins/DSSI_posix64", [])) - dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win32", [])) - dssiPlugins += toList(settingsDB.value("Plugins/DSSI_win64", [])) + dssiPlugins += settingsDB.value("Plugins/DSSI_native", [], list) + dssiPlugins += settingsDB.value("Plugins/DSSI_posix32", [], list) + dssiPlugins += settingsDB.value("Plugins/DSSI_posix64", [], list) + dssiPlugins += settingsDB.value("Plugins/DSSI_win32", [], list) + dssiPlugins += settingsDB.value("Plugins/DSSI_win64", [], list) # ---------------------------------------------------------------------------------------------------- # VST2 vst2Plugins = [] - vst2Plugins += toList(settingsDB.value("Plugins/VST2_native", [])) - vst2Plugins += toList(settingsDB.value("Plugins/VST2_posix32", [])) - vst2Plugins += toList(settingsDB.value("Plugins/VST2_posix64", [])) - vst2Plugins += toList(settingsDB.value("Plugins/VST2_win32", [])) - vst2Plugins += toList(settingsDB.value("Plugins/VST2_win64", [])) + vst2Plugins += settingsDB.value("Plugins/VST2_native", [], list) + vst2Plugins += settingsDB.value("Plugins/VST2_posix32", [], list) + vst2Plugins += settingsDB.value("Plugins/VST2_posix64", [], list) + vst2Plugins += settingsDB.value("Plugins/VST2_win32", [], list) + vst2Plugins += settingsDB.value("Plugins/VST2_win64", [], list) # ---------------------------------------------------------------------------------------------------- # VST3 vst3Plugins = [] - vst3Plugins += toList(settingsDB.value("Plugins/VST3_native", [])) - vst3Plugins += toList(settingsDB.value("Plugins/VST3_posix32", [])) - vst3Plugins += toList(settingsDB.value("Plugins/VST3_posix64", [])) - vst3Plugins += toList(settingsDB.value("Plugins/VST3_win32", [])) - vst3Plugins += toList(settingsDB.value("Plugins/VST3_win64", [])) + vst3Plugins += settingsDB.value("Plugins/VST3_native", [], list) + vst3Plugins += settingsDB.value("Plugins/VST3_posix32", [], list) + vst3Plugins += settingsDB.value("Plugins/VST3_posix64", [], list) + vst3Plugins += settingsDB.value("Plugins/VST3_win32", [], list) + vst3Plugins += settingsDB.value("Plugins/VST3_win64", [], list) # ---------------------------------------------------------------------------------------------------- # AU (extra non-cached) - auPlugins32 = toList(settingsDB.value("Plugins/AU_posix32", [])) if MACOS else [] + auPlugins32 = settingsDB.value("Plugins/AU_posix32", [], list) if MACOS else [] # ---------------------------------------------------------------------------------------------------- # Kits - sf2s = toList(settingsDB.value("Plugins/SF2", [])) - sfzs = toList(settingsDB.value("Plugins/SFZ", [])) + sf2s = settingsDB.value("Plugins/SF2", [], list) + sfzs = settingsDB.value("Plugins/SFZ", [], list) # ---------------------------------------------------------------------------------------------------- # count plugins first, so we can create rows in advance @@ -2183,9 +2183,9 @@ class JackApplicationW(QDialog): self.ui.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enabled) def loadSettings(self): - settings = QSettings("falkTX", "CarlaAddJackApp") + settings = QSafeSettings("falkTX", "CarlaAddJackApp") - smName = settings.value("SessionManager", "", type=str) + smName = settings.value("SessionManager", "", str) if smName == "LADISH (SIGUSR1)": self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_LADISH) @@ -2194,16 +2194,16 @@ class JackApplicationW(QDialog): else: self.ui.cb_session_mgr.setCurrentIndex(self.UI_SESSION_NONE) - self.ui.le_command.setText(settings.value("Command", "", type=str)) - self.ui.le_name.setText(settings.value("Name", "", type=str)) - self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, type=int)) - self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, type=int)) - self.ui.sb_audio_outs.setValue(settings.value("NumAudioOuts", 2, type=int)) - self.ui.sb_midi_ins.setValue(settings.value("NumMidiIns", 0, type=int)) - self.ui.sb_midi_outs.setValue(settings.value("NumMidiOuts", 0, type=int)) - self.ui.cb_manage_window.setChecked(settings.value("ManageWindow", True, type=bool)) - self.ui.cb_capture_first_window.setChecked(settings.value("CaptureFirstWindow", False, type=bool)) - self.ui.cb_out_midi_mixdown.setChecked(settings.value("MidiOutMixdown", False, type=bool)) + self.ui.le_command.setText(settings.value("Command", "", str)) + self.ui.le_name.setText(settings.value("Name", "", str)) + self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, int)) + self.ui.sb_audio_ins.setValue(settings.value("NumAudioIns", 2, int)) + self.ui.sb_audio_outs.setValue(settings.value("NumAudioOuts", 2, int)) + self.ui.sb_midi_ins.setValue(settings.value("NumMidiIns", 0, int)) + self.ui.sb_midi_outs.setValue(settings.value("NumMidiOuts", 0, int)) + self.ui.cb_manage_window.setChecked(settings.value("ManageWindow", True, bool)) + self.ui.cb_capture_first_window.setChecked(settings.value("CaptureFirstWindow", False, bool)) + self.ui.cb_out_midi_mixdown.setChecked(settings.value("MidiOutMixdown", False, bool)) self.checkIfButtonBoxShouldBeEnabled(self.ui.cb_session_mgr.currentIndex(), self.ui.le_command.text()) @@ -2220,7 +2220,7 @@ class JackApplicationW(QDialog): @pyqtSlot() def slot_saveSettings(self): - settings = QSettings("falkTX", "CarlaAddJackApp") + settings = QSafeSettings("falkTX", "CarlaAddJackApp") settings.setValue("Command", self.ui.le_command.text()) settings.setValue("Name", self.ui.le_name.text()) settings.setValue("SessionManager", self.ui.cb_session_mgr.currentText()) diff --git a/source/frontend/carla_host.py b/source/frontend/carla_host.py index f3d1eb8ae..75aa17a05 100644 --- a/source/frontend/carla_host.py +++ b/source/frontend/carla_host.py @@ -1730,7 +1730,9 @@ class HostWindow(QMainWindow): settings = QSafeSettings() if firstTime: - self.restoreGeometry(settings.value("Geometry", b"", QByteArray)) + geometry = settings.value("Geometry", QByteArray(), QByteArray) + if not geometry.isNull(): + self.restoreGeometry(geometry) showToolbar = settings.value("ShowToolbar", True, bool) self.ui.act_settings_show_toolbar.setChecked(showToolbar) diff --git a/source/frontend/carla_settings.py b/source/frontend/carla_settings.py index fdd5f0cd2..5179ea0c9 100755 --- a/source/frontend/carla_settings.py +++ b/source/frontend/carla_settings.py @@ -19,7 +19,7 @@ # ------------------------------------------------------------------------------------------------------------ # Imports (Global) -from PyQt5.QtCore import pyqtSlot, QByteArray, QDir, QSettings +from PyQt5.QtCore import pyqtSlot, QByteArray, QDir from PyQt5.QtGui import QColor, QCursor, QPainter, QPainterPath from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QFrame, QInputDialog, QLineEdit, QMenu, QVBoxLayout, QWidget @@ -88,12 +88,12 @@ class DriverSettingsW(QDialog): # ---------------------------------------------------------------------------------------------------- def loadSettings(self): - settings = QSettings("falkTX", "Carla2") + settings = QSafeSettings("falkTX", "Carla2") - audioDevice = settings.value("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), "", type=str) - audioBufferSize = settings.value("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_BUFFER_SIZE, type=int) - audioSampleRate = settings.value("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_SAMPLE_RATE, type=int) - audioTripleBuffer = settings.value("%s%s/TripleBuffer" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_TRIPLE_BUFFER, type=bool) + audioDevice = settings.value("%s%s/Device" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), "", str) + audioBufferSize = settings.value("%s%s/BufferSize" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_BUFFER_SIZE, int) + audioSampleRate = settings.value("%s%s/SampleRate" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_SAMPLE_RATE, int) + audioTripleBuffer = settings.value("%s%s/TripleBuffer" % (CARLA_KEY_ENGINE_DRIVER_PREFIX, self.fDriverName), CARLA_DEFAULT_AUDIO_TRIPLE_BUFFER, bool) if audioDevice and audioDevice in self.fDeviceNames: self.ui.cb_device.setCurrentIndex(self.fDeviceNames.index(audioDevice)) @@ -123,7 +123,7 @@ class DriverSettingsW(QDialog): @pyqtSlot() def slot_saveSettings(self): - settings = QSettings("falkTX", "Carla2") + settings = QSafeSettings("falkTX", "Carla2") bufferSize = self.ui.cb_buffersize.currentText() sampleRate = self.ui.cb_samplerate.currentText() @@ -494,7 +494,7 @@ class CarlaSettingsW(QDialog): # -------------------------------------------------------------------------------------------------------- def loadSettings(self): - settings = QSettings() + settings = QSafeSettings() # ---------------------------------------------------------------------------------------------------- # Main @@ -502,31 +502,31 @@ class CarlaSettingsW(QDialog): self.ui.ch_main_show_logs.setChecked(self.host.showLogs) self.ui.ch_engine_uis_always_on_top.setChecked(self.host.uisAlwaysOnTop) - self.ui.le_main_proj_folder.setText(settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, type=str)) - self.ui.ch_main_theme_pro.setChecked(settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, CARLA_DEFAULT_MAIN_USE_PRO_THEME, type=bool) and self.ui.group_main_theme.isEnabled()) - self.ui.cb_main_theme_color.setCurrentIndex(self.ui.cb_main_theme_color.findText(settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, CARLA_DEFAULT_MAIN_PRO_THEME_COLOR, type=str))) - self.ui.sb_main_refresh_interval.setValue(settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, type=int)) - self.ui.ch_main_confirm_exit.setChecked(settings.value(CARLA_KEY_MAIN_CONFIRM_EXIT, CARLA_DEFAULT_MAIN_CONFIRM_EXIT, type=bool)) + self.ui.le_main_proj_folder.setText(settings.value(CARLA_KEY_MAIN_PROJECT_FOLDER, CARLA_DEFAULT_MAIN_PROJECT_FOLDER, str)) + self.ui.ch_main_theme_pro.setChecked(settings.value(CARLA_KEY_MAIN_USE_PRO_THEME, CARLA_DEFAULT_MAIN_USE_PRO_THEME, bool) and self.ui.group_main_theme.isEnabled()) + self.ui.cb_main_theme_color.setCurrentIndex(self.ui.cb_main_theme_color.findText(settings.value(CARLA_KEY_MAIN_PRO_THEME_COLOR, CARLA_DEFAULT_MAIN_PRO_THEME_COLOR, str))) + self.ui.sb_main_refresh_interval.setValue(settings.value(CARLA_KEY_MAIN_REFRESH_INTERVAL, CARLA_DEFAULT_MAIN_REFRESH_INTERVAL, int)) + self.ui.ch_main_confirm_exit.setChecked(settings.value(CARLA_KEY_MAIN_CONFIRM_EXIT, CARLA_DEFAULT_MAIN_CONFIRM_EXIT, bool)) # ---------------------------------------------------------------------------------------------------- # Canvas - self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, type=str))) - self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, type=str))) - self.ui.cb_canvas_bezier_lines.setChecked(settings.value(CARLA_KEY_CANVAS_USE_BEZIER_LINES, CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES, type=bool)) - self.ui.cb_canvas_hide_groups.setChecked(settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, type=bool)) - self.ui.cb_canvas_auto_select.setChecked(settings.value(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS, CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS, type=bool)) - self.ui.cb_canvas_eyecandy.setChecked(settings.value(CARLA_KEY_CANVAS_EYE_CANDY, CARLA_DEFAULT_CANVAS_EYE_CANDY, type=bool)) - self.ui.cb_canvas_fancy_eyecandy.setChecked(settings.value(CARLA_KEY_CANVAS_FANCY_EYE_CANDY, CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY, type=bool)) - self.ui.cb_canvas_use_opengl.setChecked(settings.value(CARLA_KEY_CANVAS_USE_OPENGL, CARLA_DEFAULT_CANVAS_USE_OPENGL, type=bool) and self.ui.cb_canvas_use_opengl.isEnabled()) - self.ui.cb_canvas_render_aa.setCheckState(settings.value(CARLA_KEY_CANVAS_ANTIALIASING, CARLA_DEFAULT_CANVAS_ANTIALIASING, type=int)) - self.ui.cb_canvas_render_hq_aa.setChecked(settings.value(CARLA_KEY_CANVAS_HQ_ANTIALIASING, CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING, type=bool) and self.ui.cb_canvas_render_hq_aa.isEnabled()) - self.ui.cb_canvas_full_repaints.setChecked(settings.value(CARLA_KEY_CANVAS_FULL_REPAINTS, CARLA_DEFAULT_CANVAS_FULL_REPAINTS, type=bool)) - self.ui.cb_canvas_inline_displays.setChecked(settings.value(CARLA_KEY_CANVAS_INLINE_DISPLAYS, CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS, type=bool)) + self.ui.cb_canvas_theme.setCurrentIndex(self.ui.cb_canvas_theme.findText(settings.value(CARLA_KEY_CANVAS_THEME, CARLA_DEFAULT_CANVAS_THEME, str))) + self.ui.cb_canvas_size.setCurrentIndex(self.ui.cb_canvas_size.findText(settings.value(CARLA_KEY_CANVAS_SIZE, CARLA_DEFAULT_CANVAS_SIZE, str))) + self.ui.cb_canvas_bezier_lines.setChecked(settings.value(CARLA_KEY_CANVAS_USE_BEZIER_LINES, CARLA_DEFAULT_CANVAS_USE_BEZIER_LINES, bool)) + self.ui.cb_canvas_hide_groups.setChecked(settings.value(CARLA_KEY_CANVAS_AUTO_HIDE_GROUPS, CARLA_DEFAULT_CANVAS_AUTO_HIDE_GROUPS, bool)) + self.ui.cb_canvas_auto_select.setChecked(settings.value(CARLA_KEY_CANVAS_AUTO_SELECT_ITEMS, CARLA_DEFAULT_CANVAS_AUTO_SELECT_ITEMS, bool)) + self.ui.cb_canvas_eyecandy.setChecked(settings.value(CARLA_KEY_CANVAS_EYE_CANDY, CARLA_DEFAULT_CANVAS_EYE_CANDY, bool)) + self.ui.cb_canvas_fancy_eyecandy.setChecked(settings.value(CARLA_KEY_CANVAS_FANCY_EYE_CANDY, CARLA_DEFAULT_CANVAS_FANCY_EYE_CANDY, bool)) + self.ui.cb_canvas_use_opengl.setChecked(settings.value(CARLA_KEY_CANVAS_USE_OPENGL, CARLA_DEFAULT_CANVAS_USE_OPENGL, bool) and self.ui.cb_canvas_use_opengl.isEnabled()) + self.ui.cb_canvas_render_aa.setCheckState(settings.value(CARLA_KEY_CANVAS_ANTIALIASING, CARLA_DEFAULT_CANVAS_ANTIALIASING, int)) + self.ui.cb_canvas_render_hq_aa.setChecked(settings.value(CARLA_KEY_CANVAS_HQ_ANTIALIASING, CARLA_DEFAULT_CANVAS_HQ_ANTIALIASING, bool) and self.ui.cb_canvas_render_hq_aa.isEnabled()) + self.ui.cb_canvas_full_repaints.setChecked(settings.value(CARLA_KEY_CANVAS_FULL_REPAINTS, CARLA_DEFAULT_CANVAS_FULL_REPAINTS, bool)) + self.ui.cb_canvas_inline_displays.setChecked(settings.value(CARLA_KEY_CANVAS_INLINE_DISPLAYS, CARLA_DEFAULT_CANVAS_INLINE_DISPLAYS, bool)) # ---------------------------------------------------------------------------------------------------- - settings = QSettings("falkTX", "Carla2") + settings = QSafeSettings("falkTX", "Carla2") # ---------------------------------------------------------------------------------------------------- # Main @@ -550,7 +550,7 @@ class CarlaSettingsW(QDialog): audioDriver = self.host.audioDriverForced self.ui.cb_engine_audio_driver.setCurrentIndex(0) else: - audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, type=str) + audioDriver = settings.value(CARLA_KEY_ENGINE_AUDIO_DRIVER, CARLA_DEFAULT_AUDIO_DRIVER, str) for i in range(self.ui.cb_engine_audio_driver.count()): if self.ui.cb_engine_audio_driver.itemText(i) == audioDriver: @@ -588,32 +588,32 @@ class CarlaSettingsW(QDialog): self.ui.ch_osc_enable.setChecked(settings.value(CARLA_KEY_OSC_ENABLED, CARLA_DEFAULT_OSC_ENABLED, - type=bool)) + bool)) self.ui.group_osc_tcp_port.setChecked(settings.value(CARLA_KEY_OSC_TCP_PORT_ENABLED, CARLA_DEFAULT_OSC_TCP_PORT_ENABLED, - type=bool)) + bool)) self.ui.group_osc_udp_port.setChecked(settings.value(CARLA_KEY_OSC_UDP_PORT_ENABLED, CARLA_DEFAULT_OSC_UDP_PORT_ENABLED, - type=bool)) + bool)) self.ui.sb_osc_tcp_port_number.setValue(settings.value(CARLA_KEY_OSC_TCP_PORT_NUMBER, CARLA_DEFAULT_OSC_TCP_PORT_NUMBER, - type=int)) + int)) self.ui.sb_osc_udp_port_number.setValue(settings.value(CARLA_KEY_OSC_UDP_PORT_NUMBER, CARLA_DEFAULT_OSC_UDP_PORT_NUMBER, - type=int)) + int)) - if settings.value(CARLA_KEY_OSC_TCP_PORT_RANDOM, CARLA_DEFAULT_OSC_TCP_PORT_RANDOM, type=bool): + if settings.value(CARLA_KEY_OSC_TCP_PORT_RANDOM, CARLA_DEFAULT_OSC_TCP_PORT_RANDOM, bool): self.ui.rb_osc_tcp_port_specific.setChecked(False) self.ui.rb_osc_tcp_port_random.setChecked(True) else: self.ui.rb_osc_tcp_port_random.setChecked(False) self.ui.rb_osc_tcp_port_specific.setChecked(True) - if settings.value(CARLA_KEY_OSC_UDP_PORT_RANDOM, CARLA_DEFAULT_OSC_UDP_PORT_RANDOM, type=bool): + if settings.value(CARLA_KEY_OSC_UDP_PORT_RANDOM, CARLA_DEFAULT_OSC_UDP_PORT_RANDOM, bool): self.ui.rb_osc_udp_port_specific.setChecked(False) self.ui.rb_osc_udp_port_random.setChecked(True) else: @@ -623,8 +623,8 @@ class CarlaSettingsW(QDialog): # ---------------------------------------------------------------------------------------------------- # File Paths - audioPaths = toList(settings.value(CARLA_KEY_PATHS_AUDIO, CARLA_DEFAULT_FILE_PATH_AUDIO)) - midiPaths = toList(settings.value(CARLA_KEY_PATHS_MIDI, CARLA_DEFAULT_FILE_PATH_MIDI)) + audioPaths = settings.value(CARLA_KEY_PATHS_AUDIO, CARLA_DEFAULT_FILE_PATH_AUDIO, list) + midiPaths = settings.value(CARLA_KEY_PATHS_MIDI, CARLA_DEFAULT_FILE_PATH_MIDI, list) audioPaths.sort() midiPaths.sort() @@ -640,13 +640,13 @@ class CarlaSettingsW(QDialog): # ---------------------------------------------------------------------------------------------------- # Plugin Paths - ladspas = toList(settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH)) - dssis = toList(settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH)) - lv2s = toList(settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH)) - vst2s = toList(settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH)) - vst3s = toList(settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH)) - sf2s = toList(settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH)) - sfzs = toList(settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH)) + ladspas = settings.value(CARLA_KEY_PATHS_LADSPA, CARLA_DEFAULT_LADSPA_PATH, list) + dssis = settings.value(CARLA_KEY_PATHS_DSSI, CARLA_DEFAULT_DSSI_PATH, list) + lv2s = settings.value(CARLA_KEY_PATHS_LV2, CARLA_DEFAULT_LV2_PATH, list) + vst2s = settings.value(CARLA_KEY_PATHS_VST2, CARLA_DEFAULT_VST2_PATH, list) + vst3s = settings.value(CARLA_KEY_PATHS_VST3, CARLA_DEFAULT_VST3_PATH, list) + sf2s = settings.value(CARLA_KEY_PATHS_SF2, CARLA_DEFAULT_SF2_PATH, list) + sfzs = settings.value(CARLA_KEY_PATHS_SFZ, CARLA_DEFAULT_SFZ_PATH, list) ladspas.sort() dssis.sort() @@ -689,52 +689,52 @@ class CarlaSettingsW(QDialog): self.ui.le_wine_exec.setText(settings.value(CARLA_KEY_WINE_EXECUTABLE, CARLA_DEFAULT_WINE_EXECUTABLE, - type=str)) + str)) self.ui.cb_wine_prefix_detect.setChecked(settings.value(CARLA_KEY_WINE_AUTO_PREFIX, CARLA_DEFAULT_WINE_AUTO_PREFIX, - type=bool)) + bool)) self.ui.le_wine_prefix_fallback.setText(settings.value(CARLA_KEY_WINE_FALLBACK_PREFIX, CARLA_DEFAULT_WINE_FALLBACK_PREFIX, - type=str)) + str)) self.ui.group_wine_realtime.setChecked(settings.value(CARLA_KEY_WINE_RT_PRIO_ENABLED, CARLA_DEFAULT_WINE_RT_PRIO_ENABLED, - type=bool)) + bool)) self.ui.sb_wine_base_prio.setValue(settings.value(CARLA_KEY_WINE_BASE_RT_PRIO, CARLA_DEFAULT_WINE_BASE_RT_PRIO, - type=int)) + int)) self.ui.sb_wine_server_prio.setValue(settings.value(CARLA_KEY_WINE_SERVER_RT_PRIO, CARLA_DEFAULT_WINE_SERVER_RT_PRIO, - type=int)) + int)) # ---------------------------------------------------------------------------------------------------- # Experimental self.ui.ch_exp_jack_apps.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_JACK_APPS, CARLA_DEFAULT_EXPERIMENTAL_JACK_APPS, - type=bool)) + bool)) self.ui.ch_exp_export_lv2.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_EXPORT_LV2, CARLA_DEFAULT_EXPERIMENTAL_LV2_EXPORT, - type=bool)) + bool)) self.ui.ch_exp_load_lib_global.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_LOAD_LIB_GLOBAL, CARLA_DEFAULT_EXPERIMENTAL_LOAD_LIB_GLOBAL, - type=bool)) + bool)) self.ui.ch_exp_prevent_bad_behaviour.setChecked(settings.value(CARLA_KEY_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, CARLA_DEFAULT_EXPERIMENTAL_PREVENT_BAD_BEHAVIOUR, - type=bool)) + bool)) # -------------------------------------------------------------------------------------------------------- @pyqtSlot() def slot_saveSettings(self): - settings = QSettings() + settings = QSafeSettings() self.host.experimental = self.ui.ch_main_experimental.isChecked() @@ -768,7 +768,7 @@ class CarlaSettingsW(QDialog): # ---------------------------------------------------------------------------------------------------- - settings = QSettings("falkTX", "Carla2") + settings = QSafeSettings("falkTX", "Carla2") # ---------------------------------------------------------------------------------------------------- # Main diff --git a/source/frontend/carla_widgets.py b/source/frontend/carla_widgets.py index 7be06c07a..2e4138414 100755 --- a/source/frontend/carla_widgets.py +++ b/source/frontend/carla_widgets.py @@ -19,7 +19,7 @@ # ------------------------------------------------------------------------------------------------------------ # Imports (Global) -from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QSettings, QTimer +from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QByteArray, QTimer from PyQt5.QtGui import QColor, QCursor, QFontMetrics, QPainter, QPainterPath, QPalette, QPixmap from PyQt5.QtWidgets import QDialog, QGroupBox, QInputDialog, QLineEdit, QMenu, QScrollArea, QVBoxLayout, QWidget diff --git a/source/frontend/patchcanvas.py b/source/frontend/patchcanvas.py index 8123909d9..dae0c3b8b 100644 --- a/source/frontend/patchcanvas.py +++ b/source/frontend/patchcanvas.py @@ -19,29 +19,20 @@ # ------------------------------------------------------------------------------------------------------------ # Imports (Config) -from carla_config import * +from carla_shared import QSafeSettings # ------------------------------------------------------------------------------------------------------------ # Imports (Global) from math import floor -if config_UseQt5: - from PyQt5.QtCore import pyqtSignal, pyqtSlot, qCritical, qFatal, qWarning, Qt, QObject - from PyQt5.QtCore import QAbstractAnimation, QLineF, QPointF, QRectF, QSizeF, QSettings, QTimer - from PyQt5.QtGui import QColor, QLinearGradient, QPen, QPolygonF, QPainter, QPainterPath - from PyQt5.QtGui import QCursor, QFont, QFontMetrics - from PyQt5.QtSvg import QGraphicsSvgItem, QSvgRenderer - from PyQt5.QtWidgets import QGraphicsScene, QGraphicsItem, QGraphicsLineItem, QGraphicsPathItem, QGraphicsRectItem - from PyQt5.QtWidgets import QGraphicsColorizeEffect, QGraphicsDropShadowEffect, QMenu -else: - from PyQt4.QtCore import pyqtSignal, pyqtSlot, qCritical, qFatal, qWarning, Qt, QObject - from PyQt4.QtCore import QAbstractAnimation, QLineF, QPointF, QRectF, QSizeF, QSettings, QTimer - from PyQt4.QtGui import QColor, QLinearGradient, QPen, QPolygonF, QPainter, QPainterPath - from PyQt4.QtGui import QCursor, QFont, QFontMetrics - from PyQt4.QtGui import QGraphicsScene, QGraphicsItem, QGraphicsLineItem, QGraphicsPathItem, QGraphicsRectItem - from PyQt4.QtGui import QGraphicsColorizeEffect, QGraphicsDropShadowEffect, QMenu - from PyQt4.QtSvg import QGraphicsSvgItem, QSvgRenderer +from PyQt5.QtCore import pyqtSignal, pyqtSlot, qCritical, qFatal, qWarning, Qt, QObject +from PyQt5.QtCore import QAbstractAnimation, QLineF, QPointF, QRectF, QSizeF, QTimer +from PyQt5.QtGui import QColor, QLinearGradient, QPen, QPolygonF, QPainter, QPainterPath +from PyQt5.QtGui import QCursor, QFont, QFontMetrics +from PyQt5.QtSvg import QGraphicsSvgItem, QSvgRenderer +from PyQt5.QtWidgets import QGraphicsScene, QGraphicsItem, QGraphicsLineItem, QGraphicsPathItem, QGraphicsRectItem +from PyQt5.QtWidgets import QGraphicsColorizeEffect, QGraphicsDropShadowEffect, QMenu # ------------------------------------------------------------------------------------------------------------ # Imports (Theme) @@ -322,13 +313,13 @@ def split2str(split): def getStoredCanvasPosition(key, fallback_pos): try: - return canvas.settings.value("CanvasPositions/" + key, fallback_pos, type=QPointF) + return canvas.settings.value("CanvasPositions/" + key, fallback_pos, QPointF) except: return fallback_pos def getStoredCanvasSplit(group_name, fallback_split_mode): try: - return canvas.settings.value("CanvasPositions/%s_SPLIT" % group_name, fallback_split_mode, type=int) + return canvas.settings.value("CanvasPositions/%s_SPLIT" % group_name, fallback_split_mode, int) except: return fallback_split_mode @@ -372,7 +363,7 @@ def init(appName, scene, callback, debug=False): canvas.size_rect = QRectF() if not canvas.qobject: canvas.qobject = CanvasObject() - if not canvas.settings: canvas.settings = QSettings("falkTX", appName) + if not canvas.settings: canvas.settings = QSafeSettings("falkTX", appName) if canvas.theme: del canvas.theme diff --git a/source/frontend/patchcanvas/patchcanvas.py b/source/frontend/patchcanvas/patchcanvas.py index 2c9372eee..c530598f5 100644 --- a/source/frontend/patchcanvas/patchcanvas.py +++ b/source/frontend/patchcanvas/patchcanvas.py @@ -20,7 +20,7 @@ # Imports (Global) from PyQt5.QtCore import pyqtSlot, qCritical, qFatal, qWarning, QObject -from PyQt5.QtCore import QPointF, QRectF, QSettings, QTimer +from PyQt5.QtCore import QPointF, QRectF, QTimer # ------------------------------------------------------------------------------------------------------------ # Imports (Custom) @@ -62,6 +62,8 @@ from .utils import CanvasCallback, CanvasGetNewGroupPos, CanvasItemFX, CanvasRem from . import * from .scene import PatchScene +from carla_shared import QSafeSettings + # ------------------------------------------------------------------------------------------------------------ class CanvasObject(QObject): @@ -176,7 +178,7 @@ def init(appName, scene, callback, debug=False): if not canvas.qobject: canvas.qobject = CanvasObject() if not canvas.settings: - canvas.settings = QSettings("falkTX", appName) + canvas.settings = QSafeSettings("falkTX", appName) if canvas.theme: del canvas.theme diff --git a/source/frontend/widgets/pixmapkeyboard.py b/source/frontend/widgets/pixmapkeyboard.py index 1a057e9a5..3fdb7a662 100644 --- a/source/frontend/widgets/pixmapkeyboard.py +++ b/source/frontend/widgets/pixmapkeyboard.py @@ -19,10 +19,15 @@ # ------------------------------------------------------------------------------------------------------------ # Imports (Global) -from PyQt5.QtCore import pyqtSignal, pyqtSlot, qCritical, Qt, QPointF, QRectF, QTimer, QSettings, QSize +from PyQt5.QtCore import pyqtSignal, pyqtSlot, qCritical, Qt, QPointF, QRectF, QTimer, QSize from PyQt5.QtGui import QColor, QFont, QPainter, QPixmap from PyQt5.QtWidgets import QMenu, QScrollArea, QWidget +# ------------------------------------------------------------------------------------------------------------ +# Imports (Custom) + +from carla_shared import QSafeSettings + # ------------------------------------------------------------------------------------------------------------ kMidiKey2RectMapHorizontal = [ @@ -217,17 +222,17 @@ class PixmapKeyboard(QWidget): if self.fInitalizing: return - settings = QSettings("falkTX", "CarlaKeyboard") + settings = QSafeSettings("falkTX", "CarlaKeyboard") settings.setValue("PcKeyboardLayout", self.fkPcKeyLayout) settings.setValue("PcKeyboardOffset", self.fPcKeybOffset) settings.setValue("HighlightColor", self.fHighlightColor) del settings def loadSettings(self): - settings = QSettings("falkTX", "CarlaKeyboard") - self.setPcKeyboardLayout(settings.value("PcKeyboardLayout", self.fkPcKeyLayout, type=str)) - self.setPcKeyboardOffset(settings.value("PcKeyboardOffset", self.fPcKeybOffset, type=int)) - self.setColor(settings.value("HighlightColor", self.fHighlightColor, type=str)) + settings = QSafeSettings("falkTX", "CarlaKeyboard") + self.setPcKeyboardLayout(settings.value("PcKeyboardLayout", self.fkPcKeyLayout, str)) + self.setPcKeyboardOffset(settings.value("PcKeyboardOffset", self.fPcKeybOffset, int)) + self.setColor(settings.value("HighlightColor", self.fHighlightColor, str)) del settings def allNotesOff(self, sendSignal=True):