eric6/Preferences/ConfigurationPages/DebuggerGeneralPage.py

branch
Variables Viewer
changeset 7012
cc3f83d1a605
parent 6942
2602857055c5
child 7015
b1a3094b33e1
equal deleted inserted replaced
6995:ee314cf3b1c9 7012:cc3f83d1a605
9 9
10 from __future__ import unicode_literals 10 from __future__ import unicode_literals
11 11
12 import socket 12 import socket
13 13
14 from PyQt5.QtCore import QRegExp, pyqtSlot 14 from PyQt5.QtCore import Qt, QAbstractItemModel, QModelIndex, QRegExp, pyqtSlot
15 from PyQt5.QtGui import QBrush, QColor
15 from PyQt5.QtWidgets import QLineEdit, QInputDialog 16 from PyQt5.QtWidgets import QLineEdit, QInputDialog
16 from PyQt5.QtNetwork import QNetworkInterface, QAbstractSocket, QHostAddress 17 from PyQt5.QtNetwork import QNetworkInterface, QAbstractSocket, QHostAddress
17 18
18 from E5Gui.E5Application import e5App 19 from E5Gui.E5Application import e5App
19 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter 20 from E5Gui.E5Completers import E5FileCompleter, E5DirCompleter
141 Preferences.getDebugger("SuppressClientExit")) 142 Preferences.getDebugger("SuppressClientExit"))
142 self.exceptionBreakCheckBox.setChecked( 143 self.exceptionBreakCheckBox.setChecked(
143 Preferences.getDebugger("BreakAlways")) 144 Preferences.getDebugger("BreakAlways"))
144 self.exceptionShellCheckBox.setChecked( 145 self.exceptionShellCheckBox.setChecked(
145 Preferences.getDebugger("ShowExceptionInShell")) 146 Preferences.getDebugger("ShowExceptionInShell"))
147 self.maxSizeSpinBox.setValue(
148 Preferences.getDebugger("MaxVariableSize"))
149 # Set the colours for debug viewer backgrounds
150 self.previewMdl = PreviewModel()
151 self.preView.setModel(self.previewMdl)
152 self.colourChanged.connect(self.previewMdl.setColor)
153 self.initColour("BgColorNew", self.backgroundNewButton,
154 Preferences.getDebugger, hasAlpha=True)
155 self.initColour("BgColorChanged", self.backgroundChangedButton,
156 Preferences.getDebugger, hasAlpha=True)
157
146 self.autoViewSourcecodeCheckBox.setChecked( 158 self.autoViewSourcecodeCheckBox.setChecked(
147 Preferences.getDebugger("AutoViewSourceCode")) 159 Preferences.getDebugger("AutoViewSourceCode"))
148 self.maxSizeSpinBox.setValue( 160
149 Preferences.getDebugger("MaxVariableSize"))
150
151 def save(self): 161 def save(self):
152 """ 162 """
153 Public slot to save the Debugger General (1) configuration. 163 Public slot to save the Debugger General (1) configuration.
154 """ 164 """
155 Preferences.setDebugger( 165 Preferences.setDebugger(
230 self.exceptionBreakCheckBox.isChecked()) 240 self.exceptionBreakCheckBox.isChecked())
231 Preferences.setDebugger( 241 Preferences.setDebugger(
232 "ShowExceptionInShell", 242 "ShowExceptionInShell",
233 self.exceptionShellCheckBox.isChecked()) 243 self.exceptionShellCheckBox.isChecked())
234 Preferences.setDebugger( 244 Preferences.setDebugger(
245 "MaxVariableSize",
246 self.maxSizeSpinBox.value())
247 # Store background colors for debug viewer
248 self.saveColours(Preferences.setDebugger)
249
250 Preferences.setDebugger(
235 "AutoViewSourceCode", 251 "AutoViewSourceCode",
236 self.autoViewSourcecodeCheckBox.isChecked()) 252 self.autoViewSourcecodeCheckBox.isChecked())
237 Preferences.setDebugger(
238 "MaxVariableSize",
239 self.maxSizeSpinBox.value())
240 253
241 def on_allowedHostsList_currentItemChanged(self, current, previous): 254 def on_allowedHostsList_currentItemChanged(self, current, previous):
242 """ 255 """
243 Private method set the state of the edit and delete button. 256 Private method set the state of the edit and delete button.
244 257
302 self.tr( 315 self.tr(
303 """<p>The entered address <b>{0}</b> is not""" 316 """<p>The entered address <b>{0}</b> is not"""
304 """ a valid IP v4 or IP v6 address.""" 317 """ a valid IP v4 or IP v6 address."""
305 """ Aborting...</p>""") 318 """ Aborting...</p>""")
306 .format(allowedHost)) 319 .format(allowedHost))
307 320
321
322 class PreviewModel(QAbstractItemModel):
323 """
324 Class to show an example of the selected background colours for the debug
325 viewer.
326 """
327 def __init__(self):
328 """
329 Constructor
330 """
331 super(PreviewModel, self).__init__()
332 self.bgColorNew = QBrush(QColor('#FFFFFF'))
333 self.bgColorChanged = QBrush(QColor('#FFFFFF'))
334
335 def setColor(self, key, bgcolour):
336 """
337 Public slot to update the background colour indexed by key.
338
339 @param key the name of background
340 @type str
341 @param bgcolour the new background colour
342 @type QColor
343 """
344 if key == 'BgColorNew':
345 self.bgColorNew = QBrush(bgcolour)
346 else:
347 self.bgColorChanged = QBrush(bgcolour)
348
349 # Force update of preview view
350 idxStart = self.index(0, 0, QModelIndex())
351 idxEnd = self.index(0, 2, QModelIndex())
352 self.dataChanged.emit(idxStart, idxEnd)
353
354 def index(self, row, column, parent=QModelIndex()):
355 """
356 Public Qt slot to get the index of item at row:column of parent.
357
358 @param row number of rows
359 @rtype int
360 @param column number of columns
361 @type int
362 @param parent the model parent
363 @type QModelIndex
364 @return new model index for child
365 @rtype QModelIndex
366 """
367 if not self.hasIndex(row, column, parent):
368 return QModelIndex()
369
370 return self.createIndex(row, column, None)
371
372 def parent(self, child):
373 """
374 Public Qt slot to get the parent of the given child.
375
376 @param child the model child node
377 @type QModelIndex
378 @return new model index for parent
379 @rtype QModelIndex
380 """
381 return QModelIndex()
382
383 def columnCount(self, parent=QModelIndex()):
384 """
385 Public Qt slot to get the column count.
386
387 @param parent the model parent
388 @type QModelIndex
389 @return number of columns
390 @rtype int
391 """
392 return 1
393
394 def rowCount(self, parent=QModelIndex()):
395 """
396 Public Qt slot to get the row count.
397
398 @param parent the model parent
399 @type QModelIndex
400 @return number of rows
401 @rtype int
402 """
403 return 4
404
405 def flags(self, index):
406 """
407 Public Qt slot to get the item flags.
408
409 @param index of item
410 @type QModelIndex
411 @return item flags
412 @rtype QtCore.Qt.ItemFlag
413 """
414 return Qt.ItemIsEnabled | Qt.ItemIsSelectable
415
416 def data(self, index, role=Qt.DisplayRole):
417 """
418 Public Qt slot get the role data of item.
419
420 @param index the model index
421 @type QModelIndex
422 @param role the requested data role
423 @type QtCore.Qt.ItemDataRole
424 @return role data of item
425 @rtype str, QBrush or None
426 """
427 if role == Qt.DisplayRole:
428 return self.tr('Variable name')
429 elif role == Qt.BackgroundRole:
430 if index.row() >= 2:
431 return self.bgColorChanged
432 else:
433 return self.bgColorNew
434
435 return None
436
308 437
309 def create(dlg): 438 def create(dlg):
310 """ 439 """
311 Module function to create the configuration page. 440 Module function to create the configuration page.
312 441
313 @param dlg reference to the configuration dialog 442 @param dlg reference to the configuration dialog
314 @return reference to the instantiated page (ConfigurationPageBase) 443 @return reference to the instantiated page (ConfigurationPageBase)
315 """ 444 """
316 page = DebuggerGeneralPage() 445 return DebuggerGeneralPage()
317 return page 446
447 #
448 # eflag: noqa = M822

eric ide

mercurial