def _setPanelVisState(self, state, saveSettings=True): state = min(constants.PANEL_VIS_STATE_BOTH_ON, max(0, int(state))) self._panelVisBtn.setIcon(self._panelStateIconSet[state]) self._leftWidget.setVisible( state != constants.PANEL_VIS_STATE_RIGHT_ON) self._rightWidget.setVisible( state != constants.PANEL_VIS_STATE_LEFT_ON) if saveSettings: appsettings.get().saveSimpleConfig( constants.CONFIG_KEY_PANEL_VIS_STATE, state)
def _onDeleteCurrentDirSettings(self): config = appsettings.get().testDirSettings() removeNames = [] startDir = self._testManager.startDirOrModule() for name, pair in config.items(): _, root = pair if root == startDir: removeNames.append(name) if not removeNames: logger.warning("Current dir settings was not saved before.") return msg = "Are you sure to delete these dir settings: %s" % removeNames answer = QtWidgets.QMessageBox.question(self, "Remove Current Dir Setting", msg) if answer != QtWidgets.QMessageBox.Yes: return with appsettings.SettingsGroupContext( constants.CONFIG_KEY_SAVED_TEST_DIR) as settings: for n in removeNames: settings.removeConfig(n) logger.info("Remove the dir setting: %s", n) self._deferredRegenerateMenu()
def _configNameFromStartAndTopDir(self, startDir, topDir): config = appsettings.get().testDirSettings() for name in config: _topDir, _startDirOrModule = config[name] if _topDir == topDir and _startDirOrModule == startDir: return name return startDir
def _setInitialTestMode(self): initRunnerMode = appsettings.get().simpleConfigIntValue( constants.CONFIG_KEY_LAST_RUNNER_MODE, -1) if initRunnerMode < 0: initRunnerMode = self._testManager.getFeasibleRunnerMode() self._testManager.setRunnerMode(initRunnerMode) return self._testManager.getRunner()
def _saveLastTestDir(self, startDir, topDir): settings = appsettings.get() settings.saveSimpleConfig(constants.CONFIG_KEY_LAST_TEST_ROOT_DIR, startDir, sync=False) settings.saveSimpleConfig(constants.CONFIG_KEY_LAST_TOP_DIR, topDir, sync=True) logger.info("Save the last test root: %s", startDir)
def _onTestRunnerSwitched(self): act = self.sender() if not act: return runnerMode = variantToPyValue(act.data()) self._testManager.setRunnerMode(runnerMode) runner = self._testManager.getRunner() self._updateConfigButton(runner) self._uiStream.write( ">> Switch to unittest runner <b>{}</b>.<br>".format( runner.name())) self._onReloadUiButtonClicked() appsettings.get().saveSimpleConfig( constants.CONFIG_KEY_LAST_RUNNER_MODE, runnerMode) for act in self._testRunnerActions: self._updateLabelOfTestRunnerAct(act, runnerMode)
def _addToggleConfigAction(self, lbl, icon, tooltip, configKey, slot): # Cannot use self._configMenu.addAction() directly here since over-zealous garbage collection in some DCC apps: act = QtWidgets.QAction(lbl, self) act.setIcon(icon) act.setCheckable(True) act.setToolTip(tooltip) act.toggled.connect(slot) value = appsettings.get().simpleConfigBoolValue(configKey) act.setChecked(value) self._configMenu.addAction(act) return (act, value)
def _loadLastDirsFromSettings(self): settings = appsettings.get() startDirOrModule = settings.simpleConfigStrValue( constants.CONFIG_KEY_LAST_TEST_ROOT_DIR) if not startDirOrModule: return topDir = settings.simpleConfigStrValue( constants.CONFIG_KEY_LAST_TOP_DIR) self._testManager.setDirs(startDirOrModule, topDir) self._updateDirUI() self._updateWindowTitle( self._configNameFromStartAndTopDir(startDirOrModule, topDir))
def regenerateBrowseMenu(self): self._browseMenu.clear() act = self._browseMenu.addAction("Pick Test Root Dir ...") act.triggered.connect(self._onBrowseTestsRootDir) act = self._browseMenu.addAction("Pick Top Root Dir ...") act.triggered.connect(self._onBrowseTopDir) self._browseMenu.addSeparator() act = self._browseMenu.addAction("Save Current Path Settings ...") act.triggered.connect(self.saveCurrentDirSettings) act = self._browseMenu.addAction("Delete Current Settings ...") act.triggered.connect(self.deleteCurrentDirSettings) self._browseMenu.addSeparator() # Read settings: config = appsettings.get().testDirSettings() for key, pair in config.items(): act = self._browseMenu.addAction(key) act.triggered.connect(self._loadSavedDirPair) act.setToolTip("\n".join(pair)) self._browseMenu.addSeparator()
def initEditorSetting(cls): cls._editorSetting = appsettings.get().simpleConfigStrValue( constants.CONFIG_KEY_CODE_EDITOR, constants.CONFIG_KEY_CODE_EDITOR_DEFAULT)
def _onCodeEditorEditFinished(self): txt = str(self._codeEditorLE.text()).strip() appsettings.get().saveSimpleConfig(constants.CONFIG_KEY_CODE_EDITOR, txt) gotocode.CodeLineVisitor.initEditorSetting()
def _restorePanelVisState(self): state = appsettings.get().simpleConfigIntValue( constants.CONFIG_KEY_PANEL_VIS_STATE, constants.PANEL_VIS_STATE_BOTH_ON) self._setPanelVisState(state, saveSettings=False)
def _onStopOnErrorActionToggled(self, stop): self._testManager.setStopOnError(stop) appsettings.get().saveSimpleConfig(constants.CONFIG_KEY_STOP_ON_ERROR, stop)
def _onAutoClearLogActionToggled(self, state): appsettings.get().saveSimpleConfig( constants.CONFIG_KEY_AUTO_CLEAR_LOG_STATE, state)
def _onAutoFilterActionToggled(self, state): appsettings.get().saveSimpleConfig( constants.CONFIG_KEY_AUTO_FILTERING_STATE, state)