def __init__(self, profiles, parent=None): """ Constructor @param parent reference to the parent widget @type QWidget """ super(ProfilesDialog, self).__init__(parent) self.setupUi(self) self.model = ProfilesModel(profiles) self.view = self.table_view self.view.setModel(self.model) settings = QSettings() settings.beginGroup('ProfilesDialog') geom = settings.value('geom') if geom is not None: self.restoreGeometry(geom) sz = settings.beginReadArray('col_size') for i in range(sz): settings.setArrayIndex(i) w = settings.value('col') self.view.setColumnWidth(i, w) settings.endArray() settings.endGroup() self.view.horizontalHeader().setStretchLastSection(True)
def get_network_manager(): # Create network access manager network_manager = QNetworkAccessManager() # Get proxy settings data settings = QSettings("labsquare", "cutevariant") settings.beginGroup("proxy") p_type_index = settings.value("type", 0) p_host = settings.value("host") p_port = settings.value("port", 80) p_username = settings.value("username") p_password = settings.value("password") settings.endGroup() try: p_type = list(PROXY_TYPES.values())[int(p_type_index)] if p_port: p_port = int(p_port) if p_type is not QNetworkProxy.NoProxy: proxy = QNetworkProxy(p_type, p_host, p_port, p_username, p_password) network_manager.setProxy(proxy) except Exception as e: LOGGER.exception(e) pass return network_manager
def _rename_step(workflow_location, old_name, new_name, new_src_uri): updated = False workflow_conf_location = os.path.join(workflow_location, DEFAULT_WORKFLOW_PROJECT_FILENAME) workflow_conf = QSettings(workflow_conf_location, QSettings.IniFormat) workflow_conf.beginGroup('nodes') node_count = workflow_conf.beginReadArray('nodelist') name_indices = [] for i in range(node_count): workflow_conf.setArrayIndex(i) name = workflow_conf.value('name') if name == old_name: name_indices.append(i) workflow_conf.endArray() workflow_conf.beginWriteArray('nodelist') for i in range(node_count): workflow_conf.setArrayIndex(i) if i in name_indices: workflow_conf.setValue('name', new_name) workflow_conf.setValue('source_uri', new_src_uri) updated = True workflow_conf.endArray() workflow_conf.endGroup() return updated
def load(self): settings = QSettings() settings.beginGroup(self.__class__.__name__) geom = settings.value('geom') if geom is not None: self.restoreGeometry(geom) settings.endGroup()
def saveLastFits(self): if self.tedaCommandLine.ignoreSettings: return settings = QSettings() settings.beginGroup("Files") settings.setValue("lastFile", self.filename) settings.endGroup()
def readSlidersValues(self): settings = QSettings() settings.beginGroup("Sliders") self.setModelValue('cmap_idx', settings.value("cmap"), model=self.cmapModel) self.setModelValue('selected_stretch', settings.value("stretch")) self.setModelValue('selected_interval', settings.value("interval")) # self.color_combobox.setCurrentIndex(settings.value("cmap", 3)) self.setModelValue('stretch_asinh_a', float(settings.value('asinh/a'))) self.setModelValue('stretch_contrastbias_contrast', float(settings.value('contrast/contrast'))) self.setModelValue('stretch_contrastbias_bias', float(settings.value('contrast/bias'))) self.setModelValue('stretch_linear_slope', float(settings.value('linear/slope'))) self.setModelValue('stretch_linear_intercept', float(settings.value('linear/intercept'))) self.setModelValue('stretch_log_a', float(settings.value('log/a'))) self.setModelValue('stretch_powerdist_a', float(settings.value('powerdist/a'))) self.setModelValue('stretch_power_a', float(settings.value('power/a'))) self.setModelValue('stretch_sinh_a', float(settings.value('sinh/a'))) self.setModelValue('interval_manual_vmin', float(settings.value('manual/vmin'))) self.setModelValue('interval_manual_vmax', int(settings.value('manual/vmax'))) self.setModelValue('interval_percentile_percentile', float(settings.value('percentile/percentile'))) self.setModelValue('interval_percentile_nsamples', int(settings.value('percentile/nsamples'))) self.setModelValue('interval_asymetric_lower_percentile', float(settings.value('asymetric/lpercentile'))) self.setModelValue('interval_asymetric_upper_percentile', float(settings.value('asymetric/upercentile'))) self.setModelValue('interval_asymetric_nsamples', int(settings.value('asymetric/nsamples'))) self.setModelValue('interval_zscale_nsamples', int(settings.value('zscale/nsamples'))) self.setModelValue('interval_zscale_contrast', float(settings.value('zscale/contrast'))) self.setModelValue('interval_zscale_maxreject', float(settings.value('zscale/maxreject'))) self.setModelValue('interval_zscale_minpixels', int(settings.value('zscale/minpixels'))) self.setModelValue('interval_zscale_krej', float(settings.value('zscale/krej'))) self.setModelValue('interval_zscale_maxiterations', int(settings.value('zscale/maxiterations'))) settings.endGroup()
def closeEvent(self, event): settings = QSettings() settings.beginGroup('main_window') settings.setValue('geometry', self.saveGeometry()) settings.setValue('state', self.saveState()) settings.endGroup() super(MainWindow, self).closeEvent(event)
def saveSettings(self): settings = QSettings() settings.remove("Preferences") settings.beginGroup("Preferences") # General: Geometry & State settings.setValue("RestoreApplicationGeometry", self._restoreApplicationGeometry) settings.setValue("RestoreApplicationState", self._restoreApplicationState) # General: Recently Opened Documents settings.setValue("MaximumRecentDocuments", self._maximumRecentDocuments) settings.setValue("RestoreRecentDocuments", self._restoreRecentDocuments) # Document Presets: Header Labels settings.setValue("DefaultHeaderLabelHorizontal", self._defaultHeaderLabelHorizontal.value) settings.setValue("DefaultHeaderLabelVertical", self._defaultHeaderLabelVertical.value) # Document Presets: Cell Counts settings.setValue("DefaultCellCountColumn", self._defaultCellCountColumn) settings.setValue("DefaultCellCountRow", self._defaultCellCountRow) settings.endGroup()
def _set_window_geometry(self): """ Loads stored window geometry preferences and applies them to the QWindow. .setGeometry() sets the size of the window minus the window frame. For this reason it should be set on self.blender_widget. """ settings = QSettings('Tech-Artists.org', 'Blender Qt Wrapper') settings.beginGroup(self._settings_key_window_group_name) if settings.value(self._settings_key_full_screen, 'false').lower() == 'true': self.blender_widget.showFullScreen() return if settings.value(self._settings_key_maximized, 'false').lower() == 'true': self.blender_widget.showMaximized() return self.blender_widget.setGeometry( settings.value(self._settings_key_geometry, QRect(0, 0, 640, 480))) self.blender_widget.show() settings.endGroup() return
def writeSlidersValues(self): # TODO: Move Save/Load settings to model object settings = QSettings() settings.beginGroup("Sliders") settings.setValue("asinh/a", self.scalesModel.stretch_asinh_a) settings.setValue("contrast/contrast", self.scalesModel.stretch_contrastbias_contrast) settings.setValue("contrast/bias", self.scalesModel.stretch_contrastbias_bias) settings.setValue("linear/slope", self.scalesModel.stretch_linear_slope) settings.setValue("linear/intercept", self.scalesModel.stretch_linear_intercept) settings.setValue("log/a", self.scalesModel.stretch_log_a) settings.setValue("powerdist/a", self.scalesModel.stretch_powerdist_a) settings.setValue("power/a", self.scalesModel.stretch_power_a) settings.setValue("sinh/a", self.scalesModel.stretch_sinh_a) settings.setValue("manual/vmin", self.scalesModel.interval_manual_vmin) settings.setValue("manual/vmax", self.scalesModel.interval_manual_vmax) settings.setValue("percentile/percentile", self.scalesModel.interval_percentile_percentile) settings.setValue("percentile/nsamples", self.scalesModel.interval_percentile_nsamples) settings.setValue("asymetric/lpercentile", self.scalesModel.interval_asymetric_lower_percentile) settings.setValue("asymetric/upercentile", self.scalesModel.interval_asymetric_upper_percentile) settings.setValue("asymetric/nsamples", self.scalesModel.interval_asymetric_nsamples) settings.setValue("zscale/contrast", self.scalesModel.interval_zscale_contrast) settings.setValue("zscale/nsamples", self.scalesModel.interval_zscale_nsamples) settings.setValue("zscale/maxreject", self.scalesModel.interval_zscale_maxreject) settings.setValue("zscale/minpixels", self.scalesModel.interval_zscale_minpixels) settings.setValue("zscale/krej", self.scalesModel.interval_zscale_krej) settings.setValue("zscale/maxiterations", self.scalesModel.interval_zscale_maxiterations) settings.setValue("cmap", self.cmapModel.cmap_idx) settings.setValue("stretch", self.scalesModel.selected_stretch) settings.setValue("interval", self.scalesModel.selected_interval) # settings.setValue("cmap", self.color_combobox.currentIndex()) settings.endGroup()
def readWindowSettings(self): if self.tedaCommandLine.ignoreSettings: return settings = QSettings() settings.beginGroup("MainWindow") size, pos = settings.value("size"), settings.value("pos") settings.endGroup() if size is not None and pos is not None: print('settings: resize to {} and move to {}', size, pos) self.move(pos) # self.resize(size) print('Size reported ', self.size()) print('Size set ', size) self.resize(size) print('Size reported ', self.size()) else: self.resize(800, 600) geometry = settings.value("geometry") if geometry is not None: self.restoreGeometry(geometry) self.restoreState(settings.value("windowState")) self.headerWidget.readSettings(settings) self.file_widget.readSettings(settings)
def save(self): self.view.save() settings = QSettings() settings.beginGroup(self.__class__.__name__) geom = self.saveGeometry() settings.setValue('geom', geom) settings.endGroup()
def readSettings(self): """Read settings from disk, restore window geometry.""" settings = QSettings(self.companyName, self.toolName) settings.beginGroup(str(self.toolVersion)) self.widget.resize(settings.value("size", QSize(400, 200))) self.widget.move(settings.value("pos", QPoint(200, 200))) errors = [] if hasattr(self.widget, "restoreState"): settings.beginGroup("widgetState") string = settings.value("state", QByteArray('(dp0\n.)')) if string: try: state = pickle.loads(string) self.widget.restoreState(state) except: import traceback errors.append(traceback.format_exc()) # end widgetState settings.endGroup() # end toolVersion settings.endGroup() if errors: print(errors[-1]) return False return True
def writeSettings(self): """Write settings to disk, save window geometry""" settings = QSettings(self.companyName, self.toolName) settings.beginGroup('{}'.format(self.toolVersion)) settings.setValue("size", self.widget.size()) settings.setValue("pos", self.widget.pos()) errors = [] if hasattr(self.widget, "saveState"): settings.beginGroup("widgetState") try: state = pickle.dumps(self.widget.saveState()) except: import traceback errors.append(traceback.format_exc()) else: settings.setValue("state", QByteArray(state)) # end widgetState settings.endGroup() # end toolVersion settings.endGroup() if errors: print(errors[-1]) return False return True
def closeEvent(self, event): settings = QSettings() settings.beginGroup("main_window") settings.setValue("geometry", self.saveGeometry()) settings.setValue("state", self.saveState()) settings.setValue("recent_files", self.recent_files) settings.endGroup() super(MainWindow, self).closeEvent(event)
def read_settings(self): settings = QSettings() settings.beginGroup('player') self.order_list.setCurrentIndex(settings.value('order_list', 0)) self.display_splitter.restoreState( QByteArray(settings.value('splitter_sizes'))) settings.endGroup() self.playlist.read_settings()
def save(self): settings = QSettings() settings.beginGroup('MainWindow') geom = self.saveGeometry() settings.setValue('geom', geom) settings.setValue('lang', QApplication.instance().get_language()) settings.setValue('merge', self.merge_folder) settings.endGroup()
def assign_project(self, project): self.project_name = project settings = QSettings("Nebula", self.project_name) settings.beginGroup("SignalFiles") if self.list_path.__len__(): settings.setValue("Path", self.list_path) else: settings.setValue("Path", "None") settings.endGroup()
def store_window_settings(self) -> None: settings = QSettings() settings.beginGroup("main_window") settings.setValue("geometry", self.saveGeometry()) settings.setValue("window_state", self.saveState()) settings.setValue("splitter_state", self.ui.splitter.saveState()) settings.setValue("log_table_header_state", self.ui.logTable.header().saveState()) settings.endGroup()
def set_window_position(window): is_maximized = window.windowState() == Qt.WindowMaximized config = QSettings("justacid", "Segmate") config.beginGroup("MainWindow") if not is_maximized: config.setValue("size", window.size()) config.setValue("position", window.pos()) config.setValue("maximized", is_maximized) config.endGroup()
def writeSettings(self): """ Сохранение настроек окна. """ settings = QSettings() settings.beginGroup("CreateForm") settings.setValue("size", self.size()) settings.setValue("pos", self.pos()) settings.endGroup()
def store(self, settings: QSettings): settings.beginGroup("gui") self.gui.store(settings) settings.endGroup() settings.beginWriteArray("repos") for i, repo in enumerate(self.repositories): settings.setArrayIndex(i) repo.store(settings) settings.endArray()
def load_window_settings(self) -> None: # TODO errors here should be caught (individually) and logged settings = QSettings() settings.beginGroup("main_window") self.restoreGeometry(settings.value("geometry")) self.restoreState(settings.value("window_state")) self.ui.splitter.restoreState(settings.value("splitter_state")) self.ui.logTable.header().restoreState( settings.value("log_table_header_state")) settings.endGroup()
def readSetting(self): settings = QSettings("ZEraX", "E-ALPR") settings.beginGroup("Config") self.tfModelEdit.setText(settings.value("tfModel").__str__()) self.yoloConfEdit.setText(settings.value("yoloConf").__str__()) self.yoloWeightsEdit.setText(settings.value("yoloWeights").__str__()) self.imageEdit.setText(settings.value("image").__str__()) self.videoEdit.setText(settings.value("video").__str__()) self.cameraEdit.setText(settings.value("camera").__str__()) settings.endGroup()
def load_default_external_links(): """Load default external DB links if the list is empty""" app_settings = QSettings() app_settings.beginGroup("plugins/variant_view/links") # If no value: add default values if not app_settings.childKeys(): for db_name, db_url in cm.WEBSITES_URLS.items(): app_settings.setValue(db_name, db_url) app_settings.endGroup()
def save(self): settings = QSettings() settings.beginGroup('profiles') settings.remove('') for p in self.profiles: settings.setValue(f'{p.name}/path', p.path) settings.setValue(f'{p.name}/mask', p.mask) settings.setValue(f'{p.name}/pattern', p.pattern) settings.endGroup() if self.active_profile is not None: settings.setValue('active_profile', self.active_profile.name)
def all_apps(self) -> Iterator[Tuple[str, AppManifest]]: settings = QSettings() settings.beginGroup("apps") for appid in settings.childKeys(): if appid.startswith("_"): continue manifest = json.loads(settings.value(appid)) yield appid, manifest settings.endGroup()
def writeSettings(self): """ Сохранение настроек основного окна и БД приложения. """ settings = QSettings() settings.beginGroup("MainForm") settings.setValue("size", self.size()) settings.setValue("pos", self.pos()) self.storage.save_storage() self.save_services() settings.endGroup()
def save_session(self, settings: QSettings): settings.beginGroup('project_splitter') settings.setValue('horiz', self.main_splitter.saveState()) settings.setValue('vert_trees', self.left_splitter.saveState()) settings.setValue('vert_plots', self.right_splitter.saveState()) settings.endGroup() settings.beginGroup('tree_columns') settings.setValue('params', self.w_parameters_tree.header().saveState()) settings.setValue('curves', self.w_curves_tree.header().saveState()) settings.endGroup()
def writeAppState(self): if self.tedaCommandLine.ignoreSettings: return settings = QSettings() settings.beginGroup("WCS") settings.setValue("sexagesimal", self.wcsSexAct.isChecked()) settings.setValue("grid", self.wcsGridAct.isChecked()) settings.endGroup() settings.beginGroup("paint") settings.setValue("auto_center", self.painterComponent.auto_center) settings.endGroup()