diff --git a/python/console/console.py b/python/console/console.py index 4cbe57b18b7..d98a1a2e710 100644 --- a/python/console/console.py +++ b/python/console/console.py @@ -548,7 +548,7 @@ class PythonConsoleWidget(QWidget): self.tabEditorWidget.currentWidget().newEditor.findText(False) def _textFindChanged(self): - if not self.lineEditFind.text(): + if self.lineEditFind.text(): self.findNextButton.setEnabled(True) self.findPrevButton.setEnabled(True) else: @@ -614,7 +614,7 @@ class PythonConsoleWidget(QWidget): openFileTr = QCoreApplication.translate("PythonConsole", "Open File") fileList = QFileDialog.getOpenFileNames( self, openFileTr, lastDirPath, "Script file (*.py)") - if not fileList: + if fileList: for pyFile in fileList: for i in range(self.tabEditorWidget.count()): tabWidget = self.tabEditorWidget.widget(i) @@ -626,7 +626,7 @@ class PythonConsoleWidget(QWidget): self.tabEditorWidget.newTabEditor(tabName, pyFile) lastDirPath = QFileInfo(pyFile).path() - self.settings.setValue("pythonConsole/lastDirPath", QVariant(pyFile)) + self.settings.setValue("pythonConsole/lastDirPath", pyFile) self.updateTabListScript(pyFile, action='append') def saveScriptFile(self): @@ -657,7 +657,7 @@ class PythonConsoleWidget(QWidget): filename = QFileDialog.getSaveFileName(self, saveAsFileTr, pathFileName, "Script file (*.py)") - if not filename: + if filename: try: tabWidget.save(filename) except (IOError, OSError), error: @@ -701,7 +701,7 @@ class PythonConsoleWidget(QWidget): else: self.tabListScript = [] self.settings.setValue("pythonConsole/tabScripts", - QVariant(self.tabListScript)) + self.tabListScript) def saveSettingsConsole(self): self.settings.setValue("pythonConsole/splitterConsole", self.splitter.saveState()) diff --git a/python/console/console_editor.py b/python/console/console_editor.py index f7408758df6..3cdde599ef6 100644 --- a/python/console/console_editor.py +++ b/python/console/console_editor.py @@ -183,7 +183,7 @@ class Editor(QsciScintilla): def settingsEditor(self): # Set Python lexer self.setLexers() - threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2) + threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int) radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor", 'fromAPI') autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True) self.setAutoCompletionThreshold(threshold) @@ -217,7 +217,7 @@ class Editor(QsciScintilla): self.lexer.setFoldQuotes(True) loadFont = self.settings.value("pythonConsole/fontfamilytextEditor", "Monospace") - fontSize = self.settings.value("pythonConsole/fontsizeEditor", 10) + fontSize = self.settings.value("pythonConsole/fontsizeEditor", 10, type=int) font = QFont(loadFont) font.setFixedPitch(True) @@ -1201,7 +1201,7 @@ class EditorTabWidget(QTabWidget): def changeLastDirPath(self, tab): tabWidget = self.widget(tab) if tabWidget: - self.settings.setValue("pythonConsole/lastDirPath", QVariant(tabWidget.path)) + self.settings.setValue("pythonConsole/lastDirPath", tabWidget.path) def widgetMessageBar(self, iface, text, level, timed=True): messageLevel = [QgsMessageBar.INFO, QgsMessageBar.WARNING, QgsMessageBar.CRITICAL] diff --git a/python/console/console_output.py b/python/console/console_output.py index f4a8644bb1b..1058d1f2e38 100644 --- a/python/console/console_output.py +++ b/python/console/console_output.py @@ -144,7 +144,7 @@ class ShellOutputScintilla(QsciScintilla): self.lexer = QsciLexerPython() loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace") - fontSize = self.settings.value("pythonConsole/fontsize", 10) + fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int) font = QFont(loadFont) font.setFixedPitch(True) font.setPointSize(fontSize) diff --git a/python/console/console_sci.py b/python/console/console_sci.py index 082fc9e3851..193aea63e95 100644 --- a/python/console/console_sci.py +++ b/python/console/console_sci.py @@ -114,7 +114,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): def settingsShell(self): # Set Python lexer self.setLexers() - threshold = self.settings.value("pythonConsole/autoCompThreshold", 2) + threshold = self.settings.value("pythonConsole/autoCompThreshold", 2, type=int) self.setAutoCompletionThreshold(threshold) radioButtonSource = self.settings.value("pythonConsole/autoCompleteSource", 'fromAPI') autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled", True) @@ -169,7 +169,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): self.lexer = QsciLexerPython() loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace") - fontSize = self.settings.value("pythonConsole/fontsize", 10) + fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int) font = QFont(loadFont) font.setFixedPitch(True) @@ -299,7 +299,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): def clearHistory(self, clearSession=False): if clearSession: - self.history = QStringList() + self.history = [] msgText = QCoreApplication.translate('PythonConsole', 'Session and file history cleared successfully.') self.parent.callWidgetMessageBar(msgText) @@ -320,7 +320,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): self.clearHistory(True) def showPrevious(self): - if self.historyIndex < len(self.history) and not self.history: + if self.historyIndex < len(self.history) and self.history: line, pos = self.getCursorPosition() selCmdLenght = len(self.text(line)) self.setSelection(line, 4, line, selCmdLenght) @@ -335,7 +335,7 @@ class ShellScintilla(QsciScintilla, code.InteractiveInterpreter): #self.SendScintilla(QsciScintilla.SCI_DELETEBACK) def showNext(self): - if self.historyIndex > 0 and not self.history: + if self.historyIndex > 0 and self.history: line, pos = self.getCursorPosition() selCmdLenght = len(self.text(line)) self.setSelection(line, 4, line, selCmdLenght) diff --git a/python/console/console_settings.py b/python/console/console_settings.py index 7d7d1be1942..369942ca2f1 100644 --- a/python/console/console_settings.py +++ b/python/console/console_settings.py @@ -142,8 +142,8 @@ class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole): def restoreSettings(self): settings = QSettings() - self.spinBox.setValue(settings.value("pythonConsole/fontsize", 10)) - self.spinBoxEditor.setValue(settings.value("pythonConsole/fontsizeEditor", 10)) + self.spinBox.setValue(settings.value("pythonConsole/fontsize", 10, type=int)) + self.spinBoxEditor.setValue(settings.value("pythonConsole/fontsizeEditor", 10, type=int)) self.fontComboBox.setCurrentFont(QFont(settings.value("pythonConsole/fontfamilytext", "Monospace"))) self.fontComboBoxEditor.setCurrentFont(QFont(settings.value("pythonConsole/fontfamilytextEditor", @@ -159,8 +159,8 @@ class optionsDialog(QDialog, Ui_SettingsDialogPythonConsole): self.tableWidget.setItem(i, 1, QTableWidgetItem(itemTable[i])) self.autoSaveScript.setChecked(settings.value("pythonConsole/autoSaveScript", False, type=bool)) - self.autoCompThreshold.setValue(settings.value("pythonConsole/autoCompThreshold", 2)) - self.autoCompThresholdEditor.setValue(settings.value("pythonConsole/autoCompThresholdEditor", 2)) + self.autoCompThreshold.setValue(settings.value("pythonConsole/autoCompThreshold", 2, type=int)) + self.autoCompThresholdEditor.setValue(settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int)) self.enableObjectInspector.setChecked(settings.value("pythonConsole/enableObjectInsp", False, type=bool)) self.autoCloseBracketEditor.setChecked(settings.value("pythonConsole/autoCloseBracketEditor", True, type=bool))