Exemple #1
0
 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)
Exemple #2
0
    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()
Exemple #3
0
    def __add_account(self, sourcesList):
        module_name = sourcesList.currentItem().text()
        module_slug = sourcesList.currentItem().slug

        if module_slug not in modules.modules:
            pass  # TODO

        account = modules.create_object(module_slug)

        if not account.authenticate():
            # TODO do something else than failing silently
            return False

        accounts = QSettings()
        accounts.beginGroup("accounts")
        if account.getId() in accounts.childKeys():
            errorMsg = QMessageBox(
                QMessageBox.Critical, "Account already exists",
                "This account already exists. Please delete it first.",
                QMessageBox.Ok, self)
            errorMsg.show()
            return

        self.account_added.emit(account)
        self.close()
Exemple #4
0
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
Exemple #5
0
    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()
Exemple #6
0
    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 get_settings(game_state: GameState = None):
    settings = QSettings("Don Kirkby", "Zero Play")
    if game_state is not None:
        settings.beginGroup('games')
        settings.beginGroup(game_state.game_name.replace(' ', '_'))

    return settings
Exemple #8
0
    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)
Exemple #9
0
 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)
Exemple #10
0
    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
Exemple #11
0
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
Exemple #12
0
    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
Exemple #13
0
    def removeRecentProjectFile(self, projectFile):
        if not isinstance(projectFile, (QUrl, pyCompatibility.basestring)):
            raise TypeError("Unexpected data type: {}".format(
                projectFile.__class__))
        if isinstance(projectFile, QUrl):
            projectFileNorm = projectFile.toLocalFile()
            if not projectFileNorm:
                projectFileNorm = projectFile.toString()
        else:
            projectFileNorm = QUrl(projectFile).toLocalFile()
            if not projectFileNorm:
                projectFileNorm = QUrl.fromLocalFile(projectFile).toLocalFile()

        projects = self._recentProjectFiles()

        # remove duplicates while preserving order
        from collections import OrderedDict
        uniqueProjects = OrderedDict.fromkeys(projects)
        projects = list(uniqueProjects)
        # remove previous usage of the value
        if projectFileNorm not in uniqueProjects:
            return

        projects.remove(projectFileNorm)

        settings = QSettings()
        settings.beginGroup("RecentFiles")
        size = settings.beginWriteArray("Projects")
        for i, p in enumerate(projects):
            settings.setArrayIndex(i)
            settings.setValue("filepath", p)
        settings.endArray()
        settings.sync()

        self.recentProjectFilesChanged.emit()
Exemple #14
0
 def load(self):
     settings = QSettings()
     settings.beginGroup(self.__class__.__name__)
     geom = settings.value('geom')
     if geom is not None:
         self.restoreGeometry(geom)
     settings.endGroup()
Exemple #15
0
 def save(self):
     self.view.save()
     settings = QSettings()
     settings.beginGroup(self.__class__.__name__)
     geom = self.saveGeometry()
     settings.setValue('geom', geom)
     settings.endGroup()
Exemple #16
0
 def saveLastFits(self):
     if self.tedaCommandLine.ignoreSettings:
         return
     settings = QSettings()
     settings.beginGroup("Files")
     settings.setValue("lastFile", self.filename)
     settings.endGroup()
Exemple #17
0
    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()
Exemple #18
0
 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)
Exemple #19
0
    def mkdir(self, folder: str):
        assert folder
        assert "/" not in folder

        settings = QSettings()
        settings.beginGroup(f"apps/_folder/{folder}")
        settings.setValue("_dir", "true")
        self.app_change.emit()
Exemple #20
0
 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()
Exemple #21
0
 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()
Exemple #22
0
 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()
Exemple #23
0
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()
Exemple #24
0
 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()
Exemple #25
0
 def writeSettings(self):
     """
     Сохранение настроек окна.
     """
     settings = QSettings()
     settings.beginGroup("CreateForm")
     settings.setValue("size", self.size())
     settings.setValue("pos", self.pos())
     settings.endGroup()
Exemple #26
0
    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()
Exemple #27
0
 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()
Exemple #28
0
    def delete_app_from_folder(self, appid: str, folder: str):
        assert "/" not in folder
        settings = QSettings()
        settings.beginGroup(f"apps/_folder/{folder}")

        for key in settings.childKeys():
            if appid == settings.value(key):
                settings.remove(key)
                self.app_change.emit()
                return
Exemple #29
0
 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()
Exemple #30
0
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()