Esempio n. 1
0
class DebuggerExceptions(QWidget):
    " Implements the debugger context viewer "

    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.__createLayout()
        self.connect(self.clientExcptViewer, SIGNAL('ClientExceptionsCleared'),
                     self.__onClientExceptionsCleared)
        return

    def __createLayout(self):
        " Creates the widget layout "

        verticalLayout = QVBoxLayout(self)
        verticalLayout.setContentsMargins(1, 1, 1, 1)

        self.splitter = QSplitter(Qt.Vertical)

        self.ignoredExcptViewer = IgnoredExceptionsViewer(self.splitter)
        self.clientExcptViewer = ClientExceptionsViewer(
            self.splitter, self.ignoredExcptViewer)

        self.splitter.addWidget(self.clientExcptViewer)
        self.splitter.addWidget(self.ignoredExcptViewer)

        self.splitter.setCollapsible(0, False)
        self.splitter.setCollapsible(1, False)

        verticalLayout.addWidget(self.splitter)
        return

    def clear(self):
        " Clears everything "
        self.clientExcptViewer.clear()
        return

    def addException(self, exceptionType, exceptionMessage, stackTrace):
        " Adds the exception to the view "
        self.clientExcptViewer.addException(exceptionType, exceptionMessage,
                                            stackTrace)
        return

    def isIgnored(self, exceptionType):
        " Returns True if this exception type should be ignored "
        return self.ignoredExcptViewer.isIgnored(exceptionType)

    def setFocus(self):
        " Sets the focus to the client exception window "
        self.clientExcptViewer.setFocus()
        return

    def getTotalClientExceptionCount(self):
        " Provides the total number of the client exceptions "
        return self.clientExcptViewer.getTotalCount()

    def __onClientExceptionsCleared(self):
        " Triggered when the user cleared exceptions "
        self.emit(SIGNAL('ClientExceptionsCleared'))
        return
    def __init__( self, parent = None ):
        QWidget.__init__( self, parent )

        self.__projectContextItem = None
        self.__fileContextItem = None

        self.upper = self.__createRecentFilesLayout()
        self.lower = self.__createRecentProjectsLayout()
        self.__createProjectPopupMenu()
        self.__createFilePopupMenu()

        layout = QVBoxLayout()
        layout.setContentsMargins( 1, 1, 1, 1 )
        splitter = QSplitter( Qt.Vertical )
        splitter.addWidget( self.upper )
        splitter.addWidget( self.lower )
        splitter.setCollapsible( 0, False )
        splitter.setCollapsible( 1, False )

        layout.addWidget( splitter )
        self.setLayout( layout )

        self.__populateProjects()
        self.__populateFiles()
        self.__updateProjectToolbarButtons()
        self.__updateFileToolbarButtons()

        # Debugging mode support
        self.__debugMode = False
        parent.debugModeChanged.connect( self.__onDebugMode )
        return
Esempio n. 3
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        self.__projectContextItem = None
        self.__fileContextItem = None

        self.upper = self.__createRecentFilesLayout()
        self.lower = self.__createRecentProjectsLayout()
        self.__createProjectPopupMenu()
        self.__createFilePopupMenu()

        layout = QVBoxLayout()
        layout.setContentsMargins(1, 1, 1, 1)
        splitter = QSplitter(Qt.Vertical)
        splitter.addWidget(self.upper)
        splitter.addWidget(self.lower)
        splitter.setCollapsible(0, False)
        splitter.setCollapsible(1, False)

        layout.addWidget(splitter)
        self.setLayout(layout)

        self.__populateProjects()
        self.__populateFiles()
        self.__updateProjectToolbarButtons()
        self.__updateFileToolbarButtons()

        # Debugging mode support
        self.__debugMode = False
        parent.debugModeChanged.connect(self.__onDebugMode)
        return
Esempio n. 4
0
class DebuggerBreakWatchPoints(QWidget):
    " Implements the debugger break and watch point viewer "

    def __init__(self, parent, debugger):
        QWidget.__init__(self, parent)

        self.__debugger = debugger
        self.__createLayout()
        return

    def __createLayout(self):
        " Creates the widget layout "

        verticalLayout = QVBoxLayout(self)
        verticalLayout.setContentsMargins(1, 1, 1, 1)

        self.splitter = QSplitter(Qt.Vertical)

        self.breakPointViewer = BreakPointViewer(
            self.splitter, self.__debugger.getBreakPointModel())
        self.__watchPointViewer = WatchPointViewer(
            self.splitter, self.__debugger.getWatchPointModel())
        # TODO: temporary
        self.__watchPointViewer.setVisible(False)

        self.splitter.addWidget(self.breakPointViewer)
        self.splitter.addWidget(self.__watchPointViewer)

        self.splitter.setCollapsible(0, False)
        self.splitter.setCollapsible(1, False)

        verticalLayout.addWidget(self.splitter)
        return

    def clear(self):
        " Clears everything "
        self.breakPointViewer.clear()
        self.__watchPointViewer.clear()
        return

    def setFocus(self):
        " Sets the focus to the break points window "
        self.breakPointViewer.setFocus()
        return
Esempio n. 5
0
class DebuggerBreakWatchPoints( QWidget ):
    " Implements the debugger break and watch point viewer "

    def __init__( self, parent, debugger ):
        QWidget.__init__( self, parent )

        self.__debugger = debugger
        self.__createLayout()
        return

    def __createLayout( self ):
        " Creates the widget layout "

        verticalLayout = QVBoxLayout( self )
        verticalLayout.setContentsMargins( 1, 1, 1, 1 )

        self.splitter = QSplitter( Qt.Vertical )

        self.breakPointViewer = BreakPointViewer( self.splitter,
                                                    self.__debugger.getBreakPointModel() )
        self.__watchPointViewer = WatchPointViewer( self.splitter,
                                                    self.__debugger.getWatchPointModel() )
        # TODO: temporary
        self.__watchPointViewer.setVisible( False )

        self.splitter.addWidget( self.breakPointViewer )
        self.splitter.addWidget( self.__watchPointViewer )

        self.splitter.setCollapsible( 0, False )
        self.splitter.setCollapsible( 1, False )

        verticalLayout.addWidget( self.splitter )
        return

    def clear( self ):
        " Clears everything "
        self.breakPointViewer.clear()
        self.__watchPointViewer.clear()
        return

    def setFocus( self ):
        " Sets the focus to the break points window "
        self.breakPointViewer.setFocus()
        return
Esempio n. 6
0
class DebuggerContext( QWidget ):
    " Implements the debugger context viewer "

    def __init__( self, debugger, parent = None ):
        QWidget.__init__( self, parent )
        self.__debugger = debugger
        self.connect( self.__debugger, SIGNAL( 'ClientLine' ),
                      self.__onClientLine )
        self.connect( self.__debugger, SIGNAL( 'ClientStack' ),
                      self.onClientStack )
        self.connect( self.__debugger, SIGNAL( 'ClientThreadList' ),
                      self.__onClientThreadList )
        self.connect( self.__debugger, SIGNAL( 'ClientVariables' ),
                      self.__onClientVariables )
        self.connect( self.__debugger, SIGNAL( 'ClientVariable' ),
                      self.__onClientVariable )
        self.connect( self.__debugger, SIGNAL( 'ClientThreadSet' ),
                      self.__onClientThreadSet )

        self.currentStack = None
        self.__createLayout()
        return

    def __createLayout( self ):
        " Creates the widget layout "

        verticalLayout = QVBoxLayout( self )
        verticalLayout.setContentsMargins( 1, 1, 1, 1 )

        self.splitter = QSplitter( Qt.Vertical )

        self.variablesViewer = VariablesViewer( self.__debugger,
                                                  self.splitter )
        self.stackViewer = StackViewer( self.__debugger, self.splitter )
        self.threadsViewer = ThreadsViewer( self.__debugger, self.splitter )

        self.splitter.addWidget( self.variablesViewer )
        self.splitter.addWidget( self.stackViewer )
        self.splitter.addWidget( self.threadsViewer )

        self.splitter.setCollapsible( 0, False )
        self.splitter.setCollapsible( 1, False )
        self.splitter.setCollapsible( 2, False )

        verticalLayout.addWidget( self.splitter )
        return

    def clear( self ):
        " Clears everything "
        self.variablesViewer.clear()
        self.stackViewer.clear()
        self.threadsViewer.clear()
        return

    def __onClientLine( self, fileName, line, forStack ):
        " Handles the signal from the debugged program "
        if not forStack:
            self.__debugger.remoteThreadList()
            self.__debugger.remoteClientVariables( 1, 0 )  # globals
            self.__debugger.remoteClientVariables( 0, 0 )  # locals
        return

    def onClientStack( self, stack ):
        " Handles the signal from the debugged program "
        self.stackViewer.populate( stack )
        return

    def __onClientThreadList( self, currentThreadID, threadList ):
        " Handles the thread list from the remote client "
        self.threadsViewer.populate( currentThreadID, threadList )
        return

    def __onClientVariables( self, scope, variables ):
        " Handles the client variables lists "
        frameNumber = self.stackViewer.getFrameNumber()
        if scope in [ -1, 0 ]:
            # Empty list for local variables
            self.variablesViewer.updateVariables( False, frameNumber, variables )
        else:
            self.variablesViewer.updateVariables( True, frameNumber, variables )
        return

    def __onClientVariable( self, scope, variables ):
        " Handles the client variable list "
        if scope in [ -1, 0 ]:
            self.variablesViewer.updateVariable( False, variables )
        else:
            self.variablesViewer.updateVariable( True, variables )
        return

    def __onClientThreadSet( self ):
        " Handles the event of setting the current thread by the client "
        self.__debugger.remoteClientVariables( 1, 0 )   # globals
        self.__debugger.remoteClientVariables( 0, 0 )   # locals
        return

    def switchControl( self, isInIDE ):
        " Switches the UI depending where the control flow is "
        self.variablesViewer.switchControl( isInIDE )
        self.stackViewer.switchControl( isInIDE )
        self.threadsViewer.switchControl( isInIDE )
        return

    def getCurrentFrameNumber( self ):
        " Provides the current frame number "
        return self.stackViewer.getFrameNumber()
Esempio n. 7
0
class Window(QMainWindow):

  def __init__(self):
    super(Window, self).__init__()

    central_widget = QWidget()

    self._current_path = None
    self._use_suffix = False

    self._file_model = QFileSystemModel()
    self._file_model.setNameFilters(['*.jpg', '*.png'])
    self._file_model.setNameFilterDisables(False)
    self._file_model.setRootPath(QDir.rootPath())

    self._file_selection_model = QItemSelectionModel(self._file_model)
    self._file_selection_model.currentChanged.connect(self._on_current_file_changed)

    self._file_tree = QTreeView(parent=self)
    self._file_tree.collapsed.connect(self._on_tree_expanded_collapsed)
    self._file_tree.expanded.connect(self._on_tree_expanded_collapsed)
    self._file_tree.setModel(self._file_model)
    self._file_tree.setSelectionModel(self._file_selection_model)
    self._file_tree.setColumnHidden(1, True)
    self._file_tree.setColumnHidden(2, True)
    self._file_tree.setColumnHidden(3, True)
    self._file_tree.header().hide()

    self._viewer = Viewer(Loader(24))

    self._splitter = QSplitter();
    self._splitter.addWidget(self._file_tree)
    self._splitter.addWidget(self._viewer)
    self._splitter.setStretchFactor(0, 0)
    self._splitter.setStretchFactor(1, 1)
    self._splitter.setCollapsible(0, False)

    self._layout = QGridLayout()
    self._layout.addWidget(self._splitter)
    self._switch_to_normal()
    central_widget.setLayout(self._layout)

    self._file_tree.installEventFilter(self);

    self.resize(800, 600)
    self.setWindowTitle('pyQtures')
    self.setCentralWidget(central_widget)
    self.show()

  def eventFilter(self, widget, event):
    if event.type() == QEvent.KeyPress:
      if event.key() == Qt.Key_Tab:
        self._toggle_path_suffix()
        return True
    return QMainWindow.eventFilter(self, widget, event)

  def _toggle_path_suffix(self):
    self._use_suffix = not self._use_suffix
    self._update_path()

  def _switch_to_fullscreen(self):
    self._splitter.widget(0).hide()
    self._layout.setMargin(0)
    self.showFullScreen()

  def _switch_to_normal(self):
    self._splitter.widget(0).show()
    self._layout.setMargin(4)
    self.showNormal()

  def keyPressEvent(self, key_event):  # Signal handler.
    key = key_event.key()
    if self.isFullScreen():
      self._full_screen_key_handler(key)
    else:
      self._normal_key_handler(key)

  def _full_screen_key_handler(self, key):
    if Qt.Key_Escape == key:
      self._switch_to_normal()
    elif Qt.Key_Return == key:
      self._switch_to_normal()
    elif Qt.Key_Up == key:
      self._go_to_sibling_image(-1)
    elif Qt.Key_Down == key:
      self._go_to_sibling_image(1)
    elif Qt.Key_Tab == key:
      self._toggle_path_suffix()

  def _go_to_sibling_image(self, offset):
    current = self._file_selection_model.currentIndex()
    nxt = current.sibling(current.row() + offset, current.column())
    if (nxt.parent() != current.parent()):
      return
    # TODO(eustas): Iterate through dirs?
    self._file_selection_model.setCurrentIndex(nxt, QItemSelectionModel.SelectCurrent)

  def _normal_key_handler(self, key):
    if Qt.Key_Escape == key:
      QCoreApplication.instance().quit()
    elif Qt.Key_Return == key:
      self._switch_to_fullscreen()

  def _on_current_file_changed(self, new_current):
    new_path = self._file_model.filePath(new_current)
    if not self._current_path == new_path:
        self._current_path = new_path
        self._update_path()

  def _update_path(self):
    if not self._use_suffix:
      self._viewer.set_path(self._current_path)
      return

    self._viewer.reset_path()
    if not self._current_path:
      return

    selected_file = QFileInfo(self._current_path)
    if not selected_file.exists():
      return

    selected_dir = selected_file.absoluteDir()
    file_name = selected_file.fileName()
    if not selected_dir.exists():
      return

    if not selected_dir.cd('converted'):
      return

    suffixed_path = selected_dir.absoluteFilePath(file_name)
    self._viewer.set_path(suffixed_path)

  def _on_tree_expanded_collapsed(self, unused_index):
    QTimer.singleShot(1, lambda: self._file_tree.resizeColumnToContents(0))
Esempio n. 8
0
class DebuggerExceptions( QWidget ):
    " Implements the debugger context viewer "

    def __init__( self, parent = None ):
        QWidget.__init__( self, parent )

        self.__createLayout()
        self.connect( self.clientExcptViewer,
                      SIGNAL( 'ClientExceptionsCleared' ),
                      self.__onClientExceptionsCleared )
        return

    def __createLayout( self ):
        " Creates the widget layout "

        verticalLayout = QVBoxLayout( self )
        verticalLayout.setContentsMargins( 1, 1, 1, 1 )

        self.splitter = QSplitter( Qt.Vertical )

        self.ignoredExcptViewer = IgnoredExceptionsViewer( self.splitter )
        self.clientExcptViewer = ClientExceptionsViewer( self.splitter,
                                                           self.ignoredExcptViewer )

        self.splitter.addWidget( self.clientExcptViewer )
        self.splitter.addWidget( self.ignoredExcptViewer )

        self.splitter.setCollapsible( 0, False )
        self.splitter.setCollapsible( 1, False )

        verticalLayout.addWidget( self.splitter )
        return

    def clear( self ):
        " Clears everything "
        self.clientExcptViewer.clear()
        return

    def addException( self, exceptionType, exceptionMessage,
                            stackTrace ):
        " Adds the exception to the view "
        self.clientExcptViewer.addException( exceptionType, exceptionMessage,
                                             stackTrace )
        return

    def isIgnored( self, exceptionType ):
        " Returns True if this exception type should be ignored "
        return self.ignoredExcptViewer.isIgnored( exceptionType )

    def setFocus( self ):
        " Sets the focus to the client exception window "
        self.clientExcptViewer.setFocus()
        return

    def getTotalClientExceptionCount( self ):
        " Provides the total number of the client exceptions "
        return self.clientExcptViewer.getTotalCount()

    def __onClientExceptionsCleared( self ):
        " Triggered when the user cleared exceptions "
        self.emit( SIGNAL( 'ClientExceptionsCleared' ) )
        return
Esempio n. 9
0
 def __init__(self, panel):
     super(Widget, self).__init__(panel)
     
     layout = QVBoxLayout()
     self.setLayout(layout)
     layout.setSpacing(0)
     
     self.searchEntry = SearchLineEdit()
     self.treeView = QTreeView(contextMenuPolicy=Qt.CustomContextMenu)
     self.textView = QTextBrowser()
     
     applyButton = QToolButton(autoRaise=True)
     editButton = QToolButton(autoRaise=True)
     addButton = QToolButton(autoRaise=True)
     self.menuButton = QPushButton(flat=True)
     menu = QMenu(self.menuButton)
     self.menuButton.setMenu(menu)
     
     splitter = QSplitter(Qt.Vertical)
     top = QHBoxLayout()
     layout.addLayout(top)
     splitter.addWidget(self.treeView)
     splitter.addWidget(self.textView)
     layout.addWidget(splitter)
     splitter.setSizes([200, 100])
     splitter.setCollapsible(0, False)
     
     top.addWidget(self.searchEntry)
     top.addWidget(applyButton)
     top.addSpacing(10)
     top.addWidget(addButton)
     top.addWidget(editButton)
     top.addWidget(self.menuButton)
     
     # action generator for actions added to search entry
     def act(slot, icon=None):
         a = QAction(self, triggered=slot)
         self.addAction(a)
         a.setShortcutContext(Qt.WidgetWithChildrenShortcut)
         icon and a.setIcon(icons.get(icon))
         return a
     
     # hide if ESC pressed in lineedit
     a = act(self.slotEscapePressed)
     a.setShortcut(QKeySequence(Qt.Key_Escape))
     
     # import action
     a = self.importAction = act(self.slotImport, 'document-open')
     menu.addAction(a)
     
     # export action
     a = self.exportAction = act(self.slotExport, 'document-save-as')
     menu.addAction(a)
     
     # apply button
     a = self.applyAction = act(self.slotApply, 'edit-paste')
     applyButton.setDefaultAction(a)
     menu.addSeparator()
     menu.addAction(a)
     
     # add button
     a = self.addAction_ = act(self.slotAdd, 'list-add')
     a.setShortcut(QKeySequence(Qt.Key_Insert))
     addButton.setDefaultAction(a)
     menu.addSeparator()
     menu.addAction(a)
     
     # edit button
     a = self.editAction = act(self.slotEdit, 'document-edit')
     a.setShortcut(QKeySequence(Qt.Key_F2))
     editButton.setDefaultAction(a)
     menu.addAction(a)
     
     # set shortcut action
     a = self.shortcutAction = act(self.slotShortcut, 'preferences-desktop-keyboard-shortcuts')
     menu.addAction(a)
     
     # delete action
     a = self.deleteAction = act(self.slotDelete, 'list-remove')
     a.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Delete))
     menu.addAction(a)
     
     # restore action
     a = self.restoreAction = act(self.slotRestore)
     menu.addSeparator()
     menu.addAction(a)
     
     # help button
     a = self.helpAction = act(self.slotHelp, 'help-contents')
     menu.addSeparator()
     menu.addAction(a)
     
     self.treeView.setSelectionBehavior(QTreeView.SelectRows)
     self.treeView.setSelectionMode(QTreeView.ExtendedSelection)
     self.treeView.setRootIsDecorated(False)
     self.treeView.setAllColumnsShowFocus(True)
     self.treeView.setModel(model.model())
     self.treeView.setCurrentIndex(QModelIndex())
     
     # signals
     self.searchEntry.returnPressed.connect(self.slotReturnPressed)
     self.searchEntry.textChanged.connect(self.updateFilter)
     self.treeView.doubleClicked.connect(self.slotDoubleClicked)
     self.treeView.customContextMenuRequested.connect(self.showContextMenu)
     self.treeView.selectionModel().currentChanged.connect(self.updateText)
     self.treeView.model().dataChanged.connect(self.updateFilter)
     
     # highlight text
     self.highlighter = highlight.Highlighter(self.textView.document())
     
     # complete on snippet variables
     self.searchEntry.setCompleter(QCompleter([
         ':icon', ':indent', ':menu', ':name', ':python', ':selection',
         ':set', ':symbol', ':template', ':template-run'], self.searchEntry))
     self.readSettings()
     app.settingsChanged.connect(self.readSettings)
     app.translateUI(self)
     self.updateColumnSizes()
     self.setAcceptDrops(True)