Skip to content

Commit bc726dc

Browse files
committed
more update to console for sipapiv2
1 parent d28d202 commit bc726dc

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

python/console/console.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def _findPrev(self):
548548
self.tabEditorWidget.currentWidget().newEditor.findText(False)
549549

550550
def _textFindChanged(self):
551-
if not self.lineEditFind.text():
551+
if self.lineEditFind.text():
552552
self.findNextButton.setEnabled(True)
553553
self.findPrevButton.setEnabled(True)
554554
else:
@@ -614,7 +614,7 @@ def openScriptFile(self):
614614
openFileTr = QCoreApplication.translate("PythonConsole", "Open File")
615615
fileList = QFileDialog.getOpenFileNames(
616616
self, openFileTr, lastDirPath, "Script file (*.py)")
617-
if not fileList:
617+
if fileList:
618618
for pyFile in fileList:
619619
for i in range(self.tabEditorWidget.count()):
620620
tabWidget = self.tabEditorWidget.widget(i)
@@ -626,7 +626,7 @@ def openScriptFile(self):
626626
self.tabEditorWidget.newTabEditor(tabName, pyFile)
627627

628628
lastDirPath = QFileInfo(pyFile).path()
629-
self.settings.setValue("pythonConsole/lastDirPath", QVariant(pyFile))
629+
self.settings.setValue("pythonConsole/lastDirPath", pyFile)
630630
self.updateTabListScript(pyFile, action='append')
631631

632632
def saveScriptFile(self):
@@ -657,7 +657,7 @@ def saveAsScriptFile(self, index=None):
657657
filename = QFileDialog.getSaveFileName(self,
658658
saveAsFileTr,
659659
pathFileName, "Script file (*.py)")
660-
if not filename:
660+
if filename:
661661
try:
662662
tabWidget.save(filename)
663663
except (IOError, OSError), error:
@@ -701,7 +701,7 @@ def updateTabListScript(self, script, action=None):
701701
else:
702702
self.tabListScript = []
703703
self.settings.setValue("pythonConsole/tabScripts",
704-
QVariant(self.tabListScript))
704+
self.tabListScript)
705705

706706
def saveSettingsConsole(self):
707707
self.settings.setValue("pythonConsole/splitterConsole", self.splitter.saveState())

python/console/console_editor.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def __init__(self, parent=None):
183183
def settingsEditor(self):
184184
# Set Python lexer
185185
self.setLexers()
186-
threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2)
186+
threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int)
187187
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor", 'fromAPI')
188188
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True)
189189
self.setAutoCompletionThreshold(threshold)
@@ -217,7 +217,7 @@ def setLexers(self):
217217
self.lexer.setFoldQuotes(True)
218218

219219
loadFont = self.settings.value("pythonConsole/fontfamilytextEditor", "Monospace")
220-
fontSize = self.settings.value("pythonConsole/fontsizeEditor", 10)
220+
fontSize = self.settings.value("pythonConsole/fontsizeEditor", 10, type=int)
221221

222222
font = QFont(loadFont)
223223
font.setFixedPitch(True)
@@ -1201,7 +1201,7 @@ def refreshSettingsEditor(self):
12011201
def changeLastDirPath(self, tab):
12021202
tabWidget = self.widget(tab)
12031203
if tabWidget:
1204-
self.settings.setValue("pythonConsole/lastDirPath", QVariant(tabWidget.path))
1204+
self.settings.setValue("pythonConsole/lastDirPath", tabWidget.path)
12051205

12061206
def widgetMessageBar(self, iface, text, level, timed=True):
12071207
messageLevel = [QgsMessageBar.INFO, QgsMessageBar.WARNING, QgsMessageBar.CRITICAL]

python/console/console_output.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def setLexers(self):
144144
self.lexer = QsciLexerPython()
145145

146146
loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
147-
fontSize = self.settings.value("pythonConsole/fontsize", 10)
147+
fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)
148148
font = QFont(loadFont)
149149
font.setFixedPitch(True)
150150
font.setPointSize(fontSize)

python/console/console_sci.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(self, parent=None):
114114
def settingsShell(self):
115115
# Set Python lexer
116116
self.setLexers()
117-
threshold = self.settings.value("pythonConsole/autoCompThreshold", 2)
117+
threshold = self.settings.value("pythonConsole/autoCompThreshold", 2, type=int)
118118
self.setAutoCompletionThreshold(threshold)
119119
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSource", 'fromAPI')
120120
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled", True)
@@ -169,7 +169,7 @@ def setLexers(self):
169169
self.lexer = QsciLexerPython()
170170

171171
loadFont = self.settings.value("pythonConsole/fontfamilytext", "Monospace")
172-
fontSize = self.settings.value("pythonConsole/fontsize", 10)
172+
fontSize = self.settings.value("pythonConsole/fontsize", 10, type=int)
173173

174174
font = QFont(loadFont)
175175
font.setFixedPitch(True)
@@ -299,7 +299,7 @@ def readHistoryFile(self):
299299

300300
def clearHistory(self, clearSession=False):
301301
if clearSession:
302-
self.history = QStringList()
302+
self.history = []
303303
msgText = QCoreApplication.translate('PythonConsole',
304304
'Session and file history cleared successfully.')
305305
self.parent.callWidgetMessageBar(msgText)
@@ -320,7 +320,7 @@ def clearHistorySession(self):
320320
self.clearHistory(True)
321321

322322
def showPrevious(self):
323-
if self.historyIndex < len(self.history) and not self.history:
323+
if self.historyIndex < len(self.history) and self.history:
324324
line, pos = self.getCursorPosition()
325325
selCmdLenght = len(self.text(line))
326326
self.setSelection(line, 4, line, selCmdLenght)
@@ -335,7 +335,7 @@ def showPrevious(self):
335335
#self.SendScintilla(QsciScintilla.SCI_DELETEBACK)
336336

337337
def showNext(self):
338-
if self.historyIndex > 0 and not self.history:
338+
if self.historyIndex > 0 and self.history:
339339
line, pos = self.getCursorPosition()
340340
selCmdLenght = len(self.text(line))
341341
self.setSelection(line, 4, line, selCmdLenght)

python/console/console_settings.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ def saveSettings(self):
142142

143143
def restoreSettings(self):
144144
settings = QSettings()
145-
self.spinBox.setValue(settings.value("pythonConsole/fontsize", 10))
146-
self.spinBoxEditor.setValue(settings.value("pythonConsole/fontsizeEditor", 10))
145+
self.spinBox.setValue(settings.value("pythonConsole/fontsize", 10, type=int))
146+
self.spinBoxEditor.setValue(settings.value("pythonConsole/fontsizeEditor", 10, type=int))
147147
self.fontComboBox.setCurrentFont(QFont(settings.value("pythonConsole/fontfamilytext",
148148
"Monospace")))
149149
self.fontComboBoxEditor.setCurrentFont(QFont(settings.value("pythonConsole/fontfamilytextEditor",
@@ -159,8 +159,8 @@ def restoreSettings(self):
159159
self.tableWidget.setItem(i, 1, QTableWidgetItem(itemTable[i]))
160160
self.autoSaveScript.setChecked(settings.value("pythonConsole/autoSaveScript", False, type=bool))
161161

162-
self.autoCompThreshold.setValue(settings.value("pythonConsole/autoCompThreshold", 2))
163-
self.autoCompThresholdEditor.setValue(settings.value("pythonConsole/autoCompThresholdEditor", 2))
162+
self.autoCompThreshold.setValue(settings.value("pythonConsole/autoCompThreshold", 2, type=int))
163+
self.autoCompThresholdEditor.setValue(settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int))
164164

165165
self.enableObjectInspector.setChecked(settings.value("pythonConsole/enableObjectInsp", False, type=bool))
166166
self.autoCloseBracketEditor.setChecked(settings.value("pythonConsole/autoCloseBracketEditor", True, type=bool))

0 commit comments

Comments
 (0)