def __createLayout(self): """Creates the dialog layout""" self.resize(450, 20) self.setSizeGripEnabled(True) verticalLayout = QVBoxLayout(self) # Note label noteLabel = QLabel( "<b>Note</b>: the analysis is " "suggestive and not precise. " "Use the results with caution.\n", self) verticalLayout.addWidget(noteLabel) # Info label self.__infoLabel = QLabel(self) verticalLayout.addWidget(self.__infoLabel) # Progress bar self.__progressBar = QProgressBar(self) self.__progressBar.setValue(0) self.__progressBar.setOrientation(Qt.Horizontal) verticalLayout.addWidget(self.__progressBar) # Found label self.__foundLabel = QLabel(self) verticalLayout.addWidget(self.__foundLabel) # Buttons buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Close) verticalLayout.addWidget(buttonBox) buttonBox.rejected.connect(self.__onClose)
def __createLayout(self, varName, varType, varValue, isGlobal): """Creates the dialog layout""" varTypeParts = varType.split() if varTypeParts[0].lower() in ["string", "unicode", "qstring"]: length = str(len(varValue)) lines = str(len(varValue.splitlines())) varType = varType.split("(")[0].strip() + \ " (lines: " + lines + ", characters: " + length + ")" self.resize(600, 250) self.setSizeGripEnabled(True) # Top level layout layout = QVBoxLayout(self) gridLayout = QGridLayout() gridLayout.setSpacing(4) varScopeLabel = QLabel("Scope:", self) gridLayout.addWidget(varScopeLabel, 0, 0, Qt.AlignCenter) varScopeValue = HeaderLabel('Global' if isGlobal else 'Local', parent=self) varScopeValue.setToolTip("Double click to copy") font = varScopeValue.font() font.setFamily(GlobalData().skin['monoFont'].family()) gridLayout.addWidget(varScopeValue, 0, 1) varNameLabel = QLabel("Name:", self) gridLayout.addWidget(varNameLabel, 1, 0, Qt.AlignCenter) varNameValue = HeaderLabel(varName, parent=self) varNameValue.setToolTip("Double click to copy") gridLayout.addWidget(varNameValue, 1, 1) varTypeLabel = QLabel("Type:", self) gridLayout.addWidget(varTypeLabel, 2, 0, Qt.AlignCenter) varTypeValue = HeaderLabel(varType, parent=self) varTypeValue.setToolTip("Double click to copy") gridLayout.addWidget(varTypeValue, 2, 1) varValueLabel = QLabel("Value:", self) gridLayout.addWidget(varValueLabel, 3, 0, Qt.AlignTop) varValueValue = QTextEdit() varValueValue.setReadOnly(True) varValueValue.setFont(getZoomedMonoFont()) # varValueValue.setLineWrapMode(QTextEdit.NoWrap) varValueValue.setAcceptRichText(False) varValueValue.setPlainText(varValue) gridLayout.addWidget(varValueValue, 3, 1) layout.addLayout(gridLayout) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.__OKButton = buttonBox.button(QDialogButtonBox.Ok) self.__OKButton.setDefault(True) buttonBox.accepted.connect(self.close) buttonBox.rejected.connect(self.close) layout.addWidget(buttonBox) varValueValue.setFocus()
def __init__(self, editor, parent): QWidget.__init__(self, parent) # It is always not visible at the beginning because there is no # editor content at the start self.setVisible(False) self.__editor = editor self.__parentWidget = parent self.__connected = False self.__needPathUpdate = False self.cflowSettings = getCflowSettings(self) self.__displayProps = (self.cflowSettings.hidedocstrings, self.cflowSettings.hidecomments, self.cflowSettings.hideexcepts, Settings()['smartZoom']) hLayout = QHBoxLayout() hLayout.setContentsMargins(0, 0, 0, 0) hLayout.setSpacing(0) vLayout = QVBoxLayout() vLayout.setContentsMargins(0, 0, 0, 0) vLayout.setSpacing(0) # Make pylint happy self.__toolbar = None self.__navBar = None self.__cf = None self.__canvas = None self.__validGroups = [] self.__allGroupId = set() # Create the update timer self.__updateTimer = QTimer(self) self.__updateTimer.setSingleShot(True) self.__updateTimer.timeout.connect(self.process) vLayout.addWidget(self.__createNavigationBar()) vLayout.addWidget(self.__createStackedViews()) hLayout.addLayout(vLayout) hLayout.addWidget(self.__createToolbar()) self.setLayout(hLayout) self.updateSettings() # Connect to the change file type signal self.__mainWindow = GlobalData().mainWindow editorsManager = self.__mainWindow.editorsManagerWidget.editorsManager editorsManager.sigFileTypeChanged.connect(self.__onFileTypeChanged) Settings().sigHideDocstringsChanged.connect( self.__onHideDocstringsChanged) Settings().sigHideCommentsChanged.connect(self.__onHideCommentsChanged) Settings().sigHideExceptsChanged.connect(self.__onHideExceptsChanged) Settings().sigSmartZoomChanged.connect(self.__onSmartZoomChanged) self.setSmartZoomLevel(Settings()['smartZoom'])
def __createLayout(self): """Creates the widget layout""" totalCalls = self.__stats.total_calls # The calls were not induced via recursion totalPrimitiveCalls = self.__stats.prim_calls totalTime = self.__stats.total_tt txt = "<b>Script:</b> " + self.__script + " " + \ self.__params['arguments'] + "<br/>" \ "<b>Run at:</b> " + self.__reportTime + "<br/>" + \ str(totalCalls) + " function calls (" + \ str(totalPrimitiveCalls) + " primitive calls) in " + \ FLOAT_FORMAT % totalTime + " CPU seconds" summary = HeaderFitLabel(self) summary.setText(txt) summary.setToolTip(txt) summary.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed) summary.setMinimumWidth(10) self.__scene = QGraphicsScene() self.__viewer = DiagramWidget() self.__viewer.sigEscapePressed.connect(self.__onESC) vLayout = QVBoxLayout() vLayout.setContentsMargins(0, 0, 0, 0) vLayout.setSpacing(0) vLayout.addWidget(summary) vLayout.addWidget(self.__viewer) self.setLayout(vLayout)
def __createLayout(self): """Creates the dialog layout""" self.resize(450, 150) self.setSizeGripEnabled(True) verticalLayout = QVBoxLayout(self) gridLayout = QGridLayout() # Link gridLayout.addWidget(QLabel('Link', self), 0, 0, 1, 1) self.linkEdit = QLineEdit(self) self.linkEdit.setClearButtonEnabled(True) self.linkEdit.setToolTip( 'A link to a file or to an external web resource') gridLayout.addWidget(self.linkEdit, 0, 1, 1, 1) self.linkEdit.textChanged.connect(self.__validate) self.fileButton = QPushButton(self) self.fileButton.setText('...') self.fileButton.setToolTip('Select an existing or non existing file') gridLayout.addWidget(self.fileButton, 0, 2, 1, 1) self.fileButton.clicked.connect(self.__onSelectPath) self.createCheckBox = QCheckBox( 'Create a markdown file if does not exist', self) self.createCheckBox.setChecked(False) gridLayout.addWidget(self.createCheckBox, 1, 1, 1, 1) self.createCheckBox.stateChanged.connect(self.__validate) # Anchor gridLayout.addWidget(QLabel('Anchor', self), 2, 0, 1, 1) self.anchorEdit = QLineEdit(self) self.anchorEdit.setClearButtonEnabled(True) gridLayout.addWidget(self.anchorEdit, 2, 1, 1, 1) self.anchorEdit.textChanged.connect(self.__validate) # Title titleLabel = QLabel('Title', self) titleLabel.setAlignment(Qt.AlignTop) gridLayout.addWidget(titleLabel, 3, 0, 1, 1) self.titleEdit = QTextEdit() self.titleEdit.setTabChangesFocus(True) self.titleEdit.setAcceptRichText(False) self.titleEdit.setFont(getZoomedMonoFont()) self.titleEdit.setToolTip( 'If provided then will be displayed in the rectangle') gridLayout.addWidget(self.titleEdit, 3, 1, 1, 1) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.__OKButton = buttonBox.button(QDialogButtonBox.Ok) self.__OKButton.setDefault(True) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.close) verticalLayout.addLayout(gridLayout) verticalLayout.addWidget(buttonBox) self.linkEdit.setFocus()
def __createLayout(self): """Creates the widget layout""" verticalLayout = QVBoxLayout(self) verticalLayout.setContentsMargins(0, 0, 0, 0) verticalLayout.setSpacing(0) self.headerFrame = QFrame() self.headerFrame.setObjectName('stackheader') self.headerFrame.setStyleSheet('QFrame#stackheader {' + getLabelStyle(self) + '}') self.headerFrame.setFixedHeight(HEADER_HEIGHT) self.__stackLabel = QLabel("Stack") expandingSpacer = QSpacerItem(10, 10, QSizePolicy.Expanding) self.__showHideButton = QToolButton() self.__showHideButton.setAutoRaise(True) self.__showHideButton.setIcon(getIcon('less.png')) self.__showHideButton.setFixedSize(HEADER_BUTTON, HEADER_BUTTON) self.__showHideButton.setToolTip("Hide frames list") self.__showHideButton.setFocusPolicy(Qt.NoFocus) self.__showHideButton.clicked.connect(self.__onShowHide) headerLayout = QHBoxLayout() headerLayout.setContentsMargins(0, 0, 0, 0) headerLayout.addSpacing(3) headerLayout.addWidget(self.__stackLabel) headerLayout.addSpacerItem(expandingSpacer) headerLayout.addWidget(self.__showHideButton) self.headerFrame.setLayout(headerLayout) self.__framesList = QTreeWidget(self) self.__framesList.setSortingEnabled(False) # I might not need that because of two reasons: # - the window has no focus # - the window has custom current indicator # self.__framesList.setAlternatingRowColors(True) self.__framesList.setRootIsDecorated(False) self.__framesList.setItemsExpandable(False) self.__framesList.setUniformRowHeights(True) self.__framesList.setSelectionMode(QAbstractItemView.NoSelection) self.__framesList.setSelectionBehavior(QAbstractItemView.SelectRows) self.__framesList.setItemDelegate(NoOutlineHeightDelegate(4)) self.__framesList.setFocusPolicy(Qt.NoFocus) self.__framesList.setContextMenuPolicy(Qt.CustomContextMenu) self.__framesList.itemClicked.connect(self.__onFrameClicked) self.__framesList.itemDoubleClicked.connect( self.__onFrameDoubleClicked) self.__framesList.customContextMenuRequested.connect( self.__showContextMenu) self.__framesList.setHeaderLabels( ["", "File:line", "Function", "Arguments", "Full path"]) verticalLayout.addWidget(self.headerFrame) verticalLayout.addWidget(self.__framesList)
def __createLayout(self): """Creates the widget layout""" verticalLayout = QVBoxLayout(self) verticalLayout.setContentsMargins(0, 0, 0, 0) self.__titleLabel = QLabel() self.__titleLabel.setAutoFillBackground(True) self.__titleLabel.setFrameShape(QFrame.StyledPanel) self.__titleLabel.setStyleSheet('padding: 2px') verticalLayout.addWidget(self.__titleLabel)
def __createLayout(self): """Creates the widget layout""" verticalLayout = QVBoxLayout(self) verticalLayout.setContentsMargins(0, 0, 0, 0) verticalLayout.setSpacing(0) self.__stackLabel = HeaderFitLabel(self) self.__stackLabel.setText('Stack') self.__stackLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.__stackLabel.setMinimumWidth(10) self.__showHideButton = QToolButton() self.__showHideButton.setAutoRaise(True) self.__showHideButton.setIcon(getIcon('less.png')) self.__showHideButton.setFixedSize(self.__stackLabel.height(), self.__stackLabel.height()) self.__showHideButton.setToolTip('Hide frames list') self.__showHideButton.setFocusPolicy(Qt.NoFocus) self.__showHideButton.clicked.connect(self.__onShowHide) self.headerToolbar = QToolBar(self) self.headerToolbar.setIconSize(QSize(16, 16)) self.headerToolbar.setContentsMargins(1, 1, 1, 1) self.headerToolbar.addWidget(self.__stackLabel) self.headerToolbar.addWidget(self.__showHideButton) self.__framesList = QTreeWidget(self) self.__framesList.setSortingEnabled(False) # I might not need that because of two reasons: # - the window has no focus # - the window has custom current indicator # self.__framesList.setAlternatingRowColors(True) self.__framesList.setRootIsDecorated(False) self.__framesList.setItemsExpandable(False) self.__framesList.setUniformRowHeights(True) self.__framesList.setSelectionMode(QAbstractItemView.NoSelection) self.__framesList.setSelectionBehavior(QAbstractItemView.SelectRows) self.__framesList.setItemDelegate(NoOutlineHeightDelegate(4)) self.__framesList.setFocusPolicy(Qt.NoFocus) self.__framesList.setContextMenuPolicy(Qt.CustomContextMenu) self.__framesList.itemClicked.connect(self.__onFrameClicked) self.__framesList.itemDoubleClicked.connect( self.__onFrameDoubleClicked) self.__framesList.customContextMenuRequested.connect( self.__showContextMenu) self.__framesList.setHeaderLabels( ['', 'File:line', 'Function', 'Arguments', 'Full path']) verticalLayout.addWidget(self.headerToolbar) verticalLayout.addWidget(self.__framesList)
def __createLayout(self): """Creates the tooltip layout""" verticalLayout = QVBoxLayout(self) verticalLayout.setContentsMargins(0, 0, 0, 0) self.info = QLabel() self.info.setAutoFillBackground(True) self.info.setFont(getZoomedMonoFont()) self.info.setFrameShape(QFrame.StyledPanel) self.info.setStyleSheet('padding: 4px') verticalLayout.addWidget(self.info) self.location = QLabel()
def __createLayout(self): """Creates the dialog layout""" self.resize(450, 20) self.setSizeGripEnabled(True) verticalLayout = QVBoxLayout(self) self.__infoLabel = QLabel("Retrieving log of '" + self.__path + "'...") verticalLayout.addWidget(self.__infoLabel) buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Close) verticalLayout.addWidget(buttonBox) buttonBox.rejected.connect(self.__onClose)
def __createLayout(self, paths, ignoredPaths): """Creates the dialog layout""" self.resize(640, 420) self.setSizeGripEnabled(True) vboxLayout = QVBoxLayout(self) # Paths to commit part vboxLayout.addWidget(QLabel("Paths (total: " + str(len(paths)) + ")")) self.__pathView = QTreeWidget() self.__pathView.setAlternatingRowColors(True) self.__pathView.setRootIsDecorated(False) self.__pathView.setItemsExpandable(False) self.__pathView.setSortingEnabled(True) self.__pathView.setItemDelegate(NoOutlineHeightDelegate(4)) self.__pathView.setUniformRowHeights(True) self.__pathHeader = QTreeWidgetItem(["", "Path", "Status", "Message"]) self.__pathView.setHeaderItem(self.__pathHeader) self.__pathView.header().setSortIndicator(1, Qt.AscendingOrder) vboxLayout.addWidget(self.__pathView) # Paths to ignore part vboxLayout.addWidget(QLabel("Ignored paths (total: " + str(len(ignoredPaths)) + ")")) self.__ignoredPathView = QTreeWidget() self.__ignoredPathView.setAlternatingRowColors(True) self.__ignoredPathView.setRootIsDecorated(False) self.__ignoredPathView.setItemsExpandable(False) self.__ignoredPathView.setSortingEnabled(True) self.__ignoredPathView.setItemDelegate(NoOutlineHeightDelegate(4)) self.__ignoredPathView.setUniformRowHeights(True) pathToIgnoreHeader = QTreeWidgetItem(["Path", "Status"]) self.__ignoredPathView.setHeaderItem(pathToIgnoreHeader) self.__ignoredPathView.header().setSortIndicator(0, Qt.AscendingOrder) vboxLayout.addWidget(self.__ignoredPathView) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Ok) buttonBox.button(QDialogButtonBox.Ok).setDefault(True) buttonBox.accepted.connect(self.accept) vboxLayout.addWidget(buttonBox)
def __createLayout(self): """Creates the dialog layout""" self.resize(400, 100) self.setSizeGripEnabled(True) verticalLayout = QVBoxLayout(self) # Check boxes self.includeClassesBox = QCheckBox(self) self.includeClassesBox.setText("Show &classes in modules") self.includeClassesBox.setChecked(self.options.includeClasses) self.includeClassesBox.stateChanged.connect(self.__updateOptions) self.includeFuncsBox = QCheckBox(self) self.includeFuncsBox.setText("Show &functions in modules") self.includeFuncsBox.setChecked(self.options.includeFuncs) self.includeFuncsBox.stateChanged.connect(self.__updateOptions) self.includeGlobsBox = QCheckBox(self) self.includeGlobsBox.setText("Show &global variables in modules") self.includeGlobsBox.setChecked(self.options.includeGlobs) self.includeGlobsBox.stateChanged.connect(self.__updateOptions) self.includeDocsBox = QCheckBox(self) self.includeDocsBox.setText("Show modules &docstrings") self.includeDocsBox.setChecked(self.options.includeDocs) self.includeDocsBox.stateChanged.connect(self.__updateOptions) self.includeConnTextBox = QCheckBox(self) self.includeConnTextBox.setText("Show connection &labels") self.includeConnTextBox.setChecked(self.options.includeConnText) self.includeConnTextBox.stateChanged.connect(self.__updateOptions) verticalLayout.addWidget(self.includeClassesBox) verticalLayout.addWidget(self.includeFuncsBox) verticalLayout.addWidget(self.includeGlobsBox) verticalLayout.addWidget(self.includeDocsBox) verticalLayout.addWidget(self.includeConnTextBox) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Cancel) generateButton = buttonBox.addButton("Generate", QDialogButtonBox.ActionRole) generateButton.setDefault(True) generateButton.clicked.connect(self.accept) verticalLayout.addWidget(buttonBox) buttonBox.rejected.connect(self.close)
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)
def __createLayout(self): """Creates the dialog layout""" self.setMinimumWidth(300) self.setMinimumHeight(200) self.resize(300, 200) self.setSizeGripEnabled(True) verticalLayout = QVBoxLayout(self) verticalLayout.setContentsMargins(5, 5, 5, 5) gridLayout = QGridLayout() bgLabel = QLabel('Select background color:', self) gridLayout.addWidget(bgLabel, 0, 0, 1, 1) self.__bgColorButton = ColorButton('', self) gridLayout.addWidget(self.__bgColorButton, 0, 1, 1, 1) fgLabel = QLabel('Select foreground color:', self) gridLayout.addWidget(fgLabel, 1, 0, 1, 1) self.__fgColorButton = ColorButton('', self) gridLayout.addWidget(self.__fgColorButton, 1, 1, 1, 1) borderLabel = QLabel('Select border color:', self) gridLayout.addWidget(borderLabel, 2, 0, 1, 1) self.__borderColorButton = ColorButton('', self) gridLayout.addWidget(self.__borderColorButton, 2, 1, 1, 1) verticalLayout.addLayout(gridLayout) # Sample area self.__scene = QGraphicsScene() self.__view = QGraphicsView() self.__view.setScene(self.__scene) verticalLayout.addWidget(self.__view) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) verticalLayout.addWidget(buttonBox) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)
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)
def __init__(self, navBar, parent): QWidget.__init__(self, parent) self.__navBar = navBar self.__textEdit = BinViewTextEditor(self) self.__summary = HeaderLabel(parent=self) self.__summary.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum) self.__summary.setMinimumWidth(10) self.__summary.setVisible(False) vLayout = QVBoxLayout() vLayout.setContentsMargins(0, 0, 0, 0) vLayout.setSpacing(0) vLayout.addWidget(self.__summary) vLayout.addWidget(self.__textEdit) self.setLayout(vLayout) Settings().sigTextZoomChanged.connect(self.onTextZoomChanged)
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)
def __init__(self, navBar, parent): QWidget.__init__(self, parent) self.__navBar = navBar self.__table = DisassemblyTreeWidget(self) self.__table.sigEscapePressed.connect(self.__onEsc) self.__table.itemActivated.connect(self.__activated) self.__table.itemSelectionChanged.connect(self.__selectionChanged) self.__summary = HeaderLabel(parent=self) self.__summary.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum) self.__summary.setMinimumWidth(10) self.__summary.setVisible(False) vLayout = QVBoxLayout() vLayout.setContentsMargins(0, 0, 0, 0) vLayout.setSpacing(0) vLayout.addWidget(self.__summary) vLayout.addWidget(self.__table) self.setLayout(vLayout)
def __createLayout(self): """Creates the dialog layout""" self.resize(320, 120) self.setSizeGripEnabled(True) pluginVersion = getPluginVersionAndPath(self.__pluginHomeDir) pylintVersion, pylintPath = getPylintVersionAndPath() vboxLayout = QVBoxLayout(self) hboxLayout = QHBoxLayout() iconLabel = QLabel() iconLabel.setPixmap(QPixmap(self.__pluginHomeDir + 'pylint.png')) iconLabel.setScaledContents(True) iconLabel.setFixedSize(48, 48) hboxLayout.addWidget(iconLabel) titleLabel = QLabel('<b>Codimension pylint plugin</b>') titleLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) titleLabel.setFixedHeight(48) titleLabel.setAlignment(Qt.AlignCenter) infoLabel = QLabel('<hr><br>More info:' '<ul>' '<li>Plugin<br>' 'Version: ' + pluginVersion + '<br>' 'Location: ' + self.__pluginHomeDir + '</li>' '<li>Pylint<br>' 'Version: ' + pylintVersion + '<br>' + 'Location: ' + pylintPath + '</li>' '</ul><br>') hboxLayout.addWidget(titleLabel) vboxLayout.addLayout(hboxLayout) vboxLayout.addWidget(infoLabel) self.__buttonBox = QDialogButtonBox(self) self.__buttonBox.setOrientation(Qt.Horizontal) self.__buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.__buttonBox.accepted.connect(self.close) self.__buttonBox.rejected.connect(self.close) vboxLayout.addWidget(self.__buttonBox)
def __createLayout(self, pathsToAdd): """Creates the dialog layout""" self.resize(640, 480) self.setSizeGripEnabled(True) vboxLayout = QVBoxLayout(self) # Paths to add part vboxLayout.addWidget( QLabel("Paths to add (total: " + str(len(pathsToAdd)) + ")")) self.__pathToAddView = QTreeWidget() self.__configTable(self.__pathToAddView) self.__pathToAddHeader = QTreeWidgetItem(["", "Path"]) self.__pathToAddView.setHeaderItem(self.__pathToAddHeader) self.__pathToAddView.header().setSortIndicator(PATH_COL, Qt.AscendingOrder) self.__pathToAddView.itemChanged.connect(self.__onAddPathChanged) vboxLayout.addWidget(self.__pathToAddView) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.__OKButton = buttonBox.button(QDialogButtonBox.Ok) self.__OKButton.setText("Add") buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) buttonBox.accepted.connect(self.userAccept) buttonBox.rejected.connect(self.close) vboxLayout.addWidget(buttonBox)
def __createLayout(self): """Creates the dialog layout""" self.resize(640, 420) self.setSizeGripEnabled(True) vboxLayout = QVBoxLayout(self) hboxLayout = QHBoxLayout() iconLabel = QLabel() logoPath = os.path.dirname(os.path.abspath(__file__)) + \ os.path.sep + "svn-logo.png" iconLabel.setPixmap(QPixmap(logoPath)) iconLabel.setScaledContents(True) iconLabel.setFixedSize(48, 48) hboxLayout.addWidget(iconLabel) titleLabel = QLabel("Codimension SVN plugin settings") titleLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) titleLabel.setFixedHeight(48) titleLabel.setAlignment(Qt.AlignCenter) hboxLayout.addWidget(titleLabel) vboxLayout.addLayout(hboxLayout) self.__tabWidget = QTabWidget(self) self.__tabWidget.setFocusPolicy(Qt.NoFocus) ideWide = self.__createIDEWide() self.__tabWidget.addTab(ideWide, "IDE Wide") projectSpecific = self.__createProjectSpecific() self.__tabWidget.addTab(projectSpecific, "Project Specific") version = self.__createVersionWidget() self.__tabWidget.addTab(version, "Versions") vboxLayout.addWidget(self.__tabWidget) # Buttons at the bottom self.__buttonBox = QDialogButtonBox(self) self.__buttonBox.setOrientation(Qt.Horizontal) self.__buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.__buttonBox.accepted.connect(self.userAccept) self.__buttonBox.rejected.connect(self.close) vboxLayout.addWidget(self.__buttonBox)
def __createLayout(self, labelText): """Creates the dialog layout""" self.resize(600, 250) self.setSizeGripEnabled(True) # Top level layout layout = QVBoxLayout(self) layout.addWidget(QLabel(labelText)) self.__newCaption = QTextEdit() self.__newCaption.setFont(getZoomedMonoFont()) self.__newCaption.setAcceptRichText(False) layout.addWidget(self.__newCaption) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Ok) self.__OKButton = buttonBox.button(QDialogButtonBox.Ok) self.__OKButton.setDefault(True) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.close) layout.addWidget(buttonBox) self.__newCaption.setFocus()
def __createLayout(self): """Creates the dialog layout""" self.resize(450, 150) self.setSizeGripEnabled(True) verticalLayout = QVBoxLayout(self) whereGroupbox = QGroupBox(self) whereGroupbox.setTitle("Introspection information destination") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( whereGroupbox.sizePolicy().hasHeightForWidth()) whereGroupbox.setSizePolicy(sizePolicy) layoutWhere = QVBoxLayout(whereGroupbox) self.__logRButton = QRadioButton(whereGroupbox) self.__logRButton.setText("Log tab") layoutWhere.addWidget(self.__logRButton) self.__consoleRButton = QRadioButton(whereGroupbox) self.__consoleRButton.setText("Console") layoutWhere.addWidget(self.__consoleRButton) self.__newtabRButton = QRadioButton(whereGroupbox) self.__newtabRButton.setText("New editor tab") layoutWhere.addWidget(self.__newtabRButton) verticalLayout.addWidget(whereGroupbox) buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.__OKButton = buttonBox.button(QDialogButtonBox.Ok) self.__OKButton.setDefault(True) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.close) verticalLayout.addWidget(buttonBox)
def __init__(self, editor, parent): QWidget.__init__(self, parent) self.setVisible(False) self.__editor = editor self.__parentWidget = parent self.__connected = False hLayout = QHBoxLayout() hLayout.setContentsMargins(0, 0, 0, 0) hLayout.setSpacing(0) vLayout = QVBoxLayout() vLayout.setContentsMargins(0, 0, 0, 0) vLayout.setSpacing(0) # Make pylint happy self.__toolbar = None self.__topBar = None # Create the update timer self.__updateTimer = QTimer(self) self.__updateTimer.setSingleShot(True) self.__updateTimer.timeout.connect(self.process) vLayout.addWidget(self.__createTopBar()) vLayout.addWidget(self.__createMDView()) hLayout.addLayout(vLayout) hLayout.addWidget(self.__createToolbar()) self.setLayout(hLayout) # Connect to the change file type signal self.__mainWindow = GlobalData().mainWindow editorsManager = self.__mainWindow.editorsManagerWidget.editorsManager editorsManager.sigFileTypeChanged.connect(self.__onFileTypeChanged)
def __createLayout(self): """Creates the dialog layout""" self.resize(400, 80) self.setSizeGripEnabled(True) vboxLayout = QVBoxLayout(self) hboxLayout = QHBoxLayout() hboxLayout.addWidget(QLabel("Status update interval, sec.")) self.__intervalEdit = QLineEdit() self.__intervalEdit.setValidator(QIntValidator(1, 3600, self)) self.__intervalEdit.setAlignment(Qt.AlignRight | Qt.AlignVCenter) hboxLayout.addWidget(self.__intervalEdit) # Buttons at the bottom self.__buttonBox = QDialogButtonBox(self) self.__buttonBox.setOrientation(Qt.Horizontal) self.__buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.__buttonBox.accepted.connect(self.userAccept) self.__buttonBox.rejected.connect(self.close) vboxLayout.addLayout(hboxLayout) vboxLayout.addWidget(self.__buttonBox)
def __createLayout(self, bpoint): """Creates the dialog layout""" self.resize(400, 150) self.setSizeGripEnabled(True) # Top level layout layout = QVBoxLayout(self) gridLayout = QGridLayout() fileLabel = QLabel("File name:") gridLayout.addWidget(fileLabel, 0, 0) fileValue = QLabel(bpoint.getAbsoluteFileName()) gridLayout.addWidget(fileValue, 0, 1) lineLabel = QLabel("Line:") gridLayout.addWidget(lineLabel, 1, 0) lineValue = QLabel(str(bpoint.getLineNumber())) gridLayout.addWidget(lineValue, 1, 1) conditionLabel = QLabel("Condition:") gridLayout.addWidget(conditionLabel, 2, 0) self.__conditionValue = CDMComboBox(True) self.__conditionValue.lineEdit().setText(bpoint.getCondition()) gridLayout.addWidget(self.__conditionValue, 2, 1) ignoreLabel = QLabel("Ignore count:") gridLayout.addWidget(ignoreLabel, 3, 0) self.__ignoreValue = QSpinBox() self.__ignoreValue.setMinimum(0) self.__ignoreValue.setValue(bpoint.getIgnoreCount()) gridLayout.addWidget(self.__ignoreValue, 3, 1) layout.addLayout(gridLayout) # Checkboxes part self.__tempCheckbox = QCheckBox("&Temporary") self.__tempCheckbox.setChecked(bpoint.isTemporary()) layout.addWidget(self.__tempCheckbox) self.__enabled = QCheckBox("&Enabled") self.__enabled.setChecked(bpoint.isEnabled()) layout.addWidget(self.__enabled) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.__OKButton = buttonBox.button(QDialogButtonBox.Ok) self.__OKButton.setDefault(True) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.close) layout.addWidget(buttonBox) self.__conditionValue.setFocus()
def __createLayout(self): """Creates the dialog layout""" self.resize(450, 20) self.setSizeGripEnabled(True) verticalLayout = QVBoxLayout(self) # Info label self.infoLabel = QLabel(self) verticalLayout.addWidget(self.infoLabel) # Progress bar self.progressBar = QProgressBar(self) self.progressBar.setValue(0) self.progressBar.setOrientation(Qt.Horizontal) verticalLayout.addWidget(self.progressBar) # Buttons buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Close) verticalLayout.addWidget(buttonBox) buttonBox.rejected.connect(self.__onClose)
def __createLayout(self, bpointsModel): """Creates the widget layout""" verticalLayout = QVBoxLayout(self) verticalLayout.setContentsMargins(0, 0, 0, 0) verticalLayout.setSpacing(0) self.headerFrame = QFrame() self.headerFrame.setObjectName('bpheader') self.headerFrame.setStyleSheet('QFrame#bpheader {' + getLabelStyle(self) + '}') self.headerFrame.setFixedHeight(HEADER_HEIGHT) self.__breakpointLabel = QLabel("Breakpoints") headerLayout = QHBoxLayout() headerLayout.setContentsMargins(0, 0, 0, 0) headerLayout.addSpacing(3) headerLayout.addWidget(self.__breakpointLabel) self.headerFrame.setLayout(headerLayout) self.bpointsList = BreakPointView(self, bpointsModel) self.__editButton = QAction(getIcon('bpprops.png'), "Edit breakpoint properties", self) self.__editButton.triggered.connect(self.__onEdit) self.__editButton.setEnabled(False) self.__jumpToCodeButton = QAction(getIcon('gotoline.png'), "Jump to the code", self) self.__jumpToCodeButton.triggered.connect(self.__onJumpToCode) self.__jumpToCodeButton.setEnabled(False) self.__enableButton = QAction(getIcon('bpenable.png'), "Enable selected breakpoint", self) self.__enableButton.triggered.connect(self.__onEnableDisable) self.__enableButton.setEnabled(False) self.__disableButton = QAction(getIcon('bpdisable.png'), "Disable selected breakpoint", self) self.__disableButton.triggered.connect(self.__onEnableDisable) self.__disableButton.setEnabled(False) self.__enableAllButton = QAction(getIcon('bpenableall.png'), "Enable all the breakpoint", self) self.__enableAllButton.triggered.connect(self.__onEnableAll) self.__enableAllButton.setEnabled(False) self.__disableAllButton = QAction(getIcon('bpdisableall.png'), "Disable all the breakpoint", self) self.__disableAllButton.triggered.connect(self.__onDisableAll) self.__disableAllButton.setEnabled(False) self.__delButton = QAction(getIcon('delitem.png'), "Delete selected breakpoint", self) self.__delButton.triggered.connect(self.__onDel) self.__delButton.setEnabled(False) self.__delAllButton = QAction(getIcon('bpdelall.png'), "Delete all the breakpoint", self) self.__delAllButton.triggered.connect(self.__onDelAll) self.__delAllButton.setEnabled(False) # Toolbar self.toolbar = QToolBar() self.toolbar.setOrientation(Qt.Horizontal) self.toolbar.setMovable(False) self.toolbar.setAllowedAreas(Qt.TopToolBarArea) self.toolbar.setIconSize(QSize(16, 16)) self.toolbar.setFixedHeight(28) self.toolbar.setContentsMargins(0, 0, 0, 0) self.toolbar.addAction(self.__editButton) self.toolbar.addAction(self.__jumpToCodeButton) fixedSpacer2 = QWidget() fixedSpacer2.setFixedWidth(5) self.toolbar.addWidget(fixedSpacer2) self.toolbar.addAction(self.__enableButton) self.toolbar.addAction(self.__enableAllButton) fixedSpacer3 = QWidget() fixedSpacer3.setFixedWidth(5) self.toolbar.addWidget(fixedSpacer3) self.toolbar.addAction(self.__disableButton) self.toolbar.addAction(self.__disableAllButton) expandingSpacer = QWidget() expandingSpacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) fixedSpacer4 = QWidget() fixedSpacer4.setFixedWidth(5) self.toolbar.addWidget(fixedSpacer4) self.toolbar.addWidget(expandingSpacer) self.toolbar.addAction(self.__delButton) fixedSpacer5 = QWidget() fixedSpacer5.setFixedWidth(5) self.toolbar.addWidget(fixedSpacer5) self.toolbar.addAction(self.__delAllButton) verticalLayout.addWidget(self.headerFrame) verticalLayout.addWidget(self.toolbar) verticalLayout.addWidget(self.bpointsList)
def __createLayout(self): """Creates the widget layout""" verticalLayout = QVBoxLayout(self) verticalLayout.setContentsMargins(0, 0, 0, 0) verticalLayout.setSpacing(0) self.__headerLabel = HeaderFitLabel(self) self.__headerLabel.setText('Variables') self.__headerLabel.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self.__headerLabel.setMinimumWidth(10) self.__filterMenu = QMenu(self) self.__showAllAct = self.__filterMenu.addAction('Show all variables') self.__showAllAct.setData('showall') self.__filterMenu.addSeparator() self.__filters = [] for title, settingName, _ in VARIABLE_FILTERS: action = self.__filterMenu.addAction(title) action.setCheckable(True) action.setData(settingName) self.__filters.append(action) self.__filterMenu.aboutToShow.connect(self.__filterMenuAboutToShow) self.__filterMenu.triggered.connect(self.__filterMenuTriggered) self.__filterButton = QToolButton(self) self.__filterButton.setIcon(getIcon('dbgvarflt.png')) self.__filterButton.setToolTip('Variable filter') self.__filterButton.setPopupMode(QToolButton.InstantPopup) self.__filterButton.setMenu(self.__filterMenu) self.__filterButton.setFocusPolicy(Qt.NoFocus) self.__filterButton.setFixedSize(self.__headerLabel.height(), self.__headerLabel.height()) self.__execStatement = CDMComboBox(True) self.__execStatement.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.__execStatement.lineEdit().setToolTip("Execute statement") self.__execStatement.setFixedHeight(26) self.__execStatement.editTextChanged.connect( self.__execStatementChanged) self.__execStatement.enterClicked.connect(self.__onEnterInExec) self.__execButton = QPushButton("Exec") self.__execButton.setEnabled(False) self.__execButton.setFixedHeight(26) self.__execButton.clicked.connect(self.__onExec) self.headerToolbar = QToolBar(self) self.headerToolbar.setIconSize(QSize(18, 18)) self.headerToolbar.setContentsMargins(1, 1, 1, 1) self.headerToolbar.addWidget(self.__headerLabel) self.headerToolbar.addWidget(self.__filterButton) execLayout = QGridLayout() execLayout.setContentsMargins(1, 1, 1, 1) execLayout.setSpacing(1) execLayout.addWidget(self.__execStatement, 0, 0) execLayout.addWidget(self.__execButton, 0, 1) verticalLayout.addWidget(self.headerToolbar) verticalLayout.addWidget(self.__browser) verticalLayout.addLayout(execLayout)
class TextEditorTabWidget(QWidget): """Plain text editor tab widget""" sigReloadRequest = pyqtSignal() reloadAllNonModifiedRequest = pyqtSignal() sigTabRunChanged = pyqtSignal(bool) def __init__(self, parent, debugger): QWidget.__init__(self, parent) extendInstance(self, MainWindowTabWidgetBase) MainWindowTabWidgetBase.__init__(self) self.__navigationBar = None self.__editor = TextEditor(self, debugger) self.__fileName = "" self.__shortName = "" self.__createLayout() self.__editor.redoAvailable.connect(self.__redoAvailable) self.__editor.undoAvailable.connect(self.__undoAvailable) self.__editor.modificationChanged.connect(self.modificationChanged) self.__editor.sigCFlowSyncRequested.connect(self.cflowSyncRequested) self.__editor.languageChanged.connect(self.__languageChanged) self.__diskModTime = None self.__diskSize = None self.__reloadDlgShown = False self.__debugMode = False self.__vcsStatus = None def onTextZoomChanged(self): """Triggered when a text zoom is changed""" self.__editor.onTextZoomChanged() def onFlowZoomChanged(self): """Triggered when a flow zoom is changed""" self.__flowUI.onFlowZoomChanged() def getNavigationBar(self): """Provides a reference to the navigation bar""" return self.__navigationBar def shouldAcceptFocus(self): """True if it can accept the focus""" return self.__outsideChangesBar.isHidden() def readFile(self, fileName): """Reads the text from a file""" self.__editor.readFile(fileName) self.setFileName(fileName) self.__editor.restoreBreakpoints() # Memorize the modification date path = os.path.realpath(fileName) self.__diskModTime = os.path.getmtime(path) self.__diskSize = os.path.getsize(path) def writeFile(self, fileName): """Writes the text to a file""" if self.__editor.writeFile(fileName): # Memorize the modification date path = os.path.realpath(fileName) self.__diskModTime = os.path.getmtime(path) self.__diskSize = os.path.getsize(path) self.setFileName(fileName) self.__editor.restoreBreakpoints() return True return False def __createLayout(self): """Creates the toolbar and layout""" # Buttons printButton = QAction(getIcon('printer.png'), 'Print (Ctrl+P)', self) printButton.triggered.connect(self.__onPrint) printPreviewButton = QAction(getIcon('printpreview.png'), 'Print preview', self) printPreviewButton.triggered.connect(self.__onPrintPreview) printPreviewButton.setEnabled(False) printPreviewButton.setVisible(False) printSpacer = QWidget() printSpacer.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) printSpacer.setFixedHeight(8) # Imports diagram and its menu importsMenu = QMenu(self) importsDlgAct = importsMenu.addAction(getIcon('detailsdlg.png'), 'Fine tuned imports diagram') importsDlgAct.triggered.connect(self.onImportDgmTuned) self.importsDiagramButton = QToolButton(self) self.importsDiagramButton.setIcon(getIcon('importsdiagram.png')) self.importsDiagramButton.setToolTip('Generate imports diagram') self.importsDiagramButton.setPopupMode(QToolButton.DelayedPopup) self.importsDiagramButton.setMenu(importsMenu) self.importsDiagramButton.setFocusPolicy(Qt.NoFocus) self.importsDiagramButton.clicked.connect(self.onImportDgm) self.importsDiagramButton.setEnabled(False) # Run script and its menu runScriptMenu = QMenu(self) runScriptDlgAct = runScriptMenu.addAction(getIcon('detailsdlg.png'), 'Set run/debug parameters') runScriptDlgAct.triggered.connect(self.onRunScriptDlg) self.runScriptButton = QToolButton(self) self.runScriptButton.setIcon(getIcon('run.png')) self.runScriptButton.setToolTip('Run script') self.runScriptButton.setPopupMode(QToolButton.DelayedPopup) self.runScriptButton.setMenu(runScriptMenu) self.runScriptButton.setFocusPolicy(Qt.NoFocus) self.runScriptButton.clicked.connect(self.onRunScript) self.runScriptButton.setEnabled(False) # Profile script and its menu profileScriptMenu = QMenu(self) profileScriptDlgAct = profileScriptMenu.addAction( getIcon('detailsdlg.png'), 'Set profile parameters') profileScriptDlgAct.triggered.connect(self.onProfileScriptDlg) self.profileScriptButton = QToolButton(self) self.profileScriptButton.setIcon(getIcon('profile.png')) self.profileScriptButton.setToolTip('Profile script') self.profileScriptButton.setPopupMode(QToolButton.DelayedPopup) self.profileScriptButton.setMenu(profileScriptMenu) self.profileScriptButton.setFocusPolicy(Qt.NoFocus) self.profileScriptButton.clicked.connect(self.onProfileScript) self.profileScriptButton.setEnabled(False) # Debug script and its menu debugScriptMenu = QMenu(self) debugScriptDlgAct = debugScriptMenu.addAction( getIcon('detailsdlg.png'), 'Set run/debug parameters') debugScriptDlgAct.triggered.connect(self.onDebugScriptDlg) self.debugScriptButton = QToolButton(self) self.debugScriptButton.setIcon(getIcon('debugger.png')) self.debugScriptButton.setToolTip('Debug script') self.debugScriptButton.setPopupMode(QToolButton.DelayedPopup) self.debugScriptButton.setMenu(debugScriptMenu) self.debugScriptButton.setFocusPolicy(Qt.NoFocus) self.debugScriptButton.clicked.connect(self.onDebugScript) self.debugScriptButton.setEnabled(False) # Disassembling disasmScriptMenu = QMenu(self) disasmScriptMenu.addAction(getIcon(''), 'Disassembly (no optimization)', self.__editor._onDisasm0) disasmScriptMenu.addAction(getIcon(''), 'Disassembly (optimization level 1)', self.__editor._onDisasm1) disasmScriptMenu.addAction(getIcon(''), 'Disassembly (optimization level 2)', self.__editor._onDisasm2) self.disasmScriptButton = QToolButton(self) self.disasmScriptButton.setIcon(getIcon('disassembly.png')) self.disasmScriptButton.setToolTip('Disassembly script') self.disasmScriptButton.setPopupMode(QToolButton.DelayedPopup) self.disasmScriptButton.setMenu(disasmScriptMenu) self.disasmScriptButton.setFocusPolicy(Qt.NoFocus) self.disasmScriptButton.clicked.connect(self.__editor._onDisasm0) self.disasmScriptButton.setEnabled(False) # Dead code self.deadCodeScriptButton = QAction(getIcon('deadcode.png'), 'Find dead code', self) self.deadCodeScriptButton.triggered.connect(self.__onDeadCode) self.deadCodeScriptButton.setEnabled(False) undoSpacer = QWidget() undoSpacer.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) undoSpacer.setFixedHeight(8) self.__undoButton = QAction(getIcon('undo.png'), 'Undo (Ctrl+Z)', self) self.__undoButton.setShortcut('Ctrl+Z') self.__undoButton.triggered.connect(self.__editor.onUndo) self.__undoButton.setEnabled(False) self.__redoButton = QAction(getIcon('redo.png'), 'Redo (Ctrl+Y)', self) self.__redoButton.setShortcut('Ctrl+Y') self.__redoButton.triggered.connect(self.__editor.onRedo) self.__redoButton.setEnabled(False) spacer = QWidget() spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.removeTrailingSpacesButton = QAction(getIcon('trailingws.png'), 'Remove trailing spaces', self) self.removeTrailingSpacesButton.triggered.connect( self.onRemoveTrailingWS) self.expandTabsButton = QAction(getIcon('expandtabs.png'), 'Expand tabs (4 spaces)', self) self.expandTabsButton.triggered.connect(self.onExpandTabs) # The toolbar toolbar = QToolBar(self) toolbar.setOrientation(Qt.Vertical) toolbar.setMovable(False) toolbar.setAllowedAreas(Qt.RightToolBarArea) toolbar.setIconSize(QSize(16, 16)) toolbar.setFixedWidth(30) toolbar.setContentsMargins(0, 0, 0, 0) toolbar.addAction(printPreviewButton) toolbar.addAction(printButton) toolbar.addWidget(printSpacer) toolbar.addWidget(self.importsDiagramButton) toolbar.addWidget(self.runScriptButton) toolbar.addWidget(self.profileScriptButton) toolbar.addWidget(self.debugScriptButton) toolbar.addWidget(self.disasmScriptButton) toolbar.addAction(self.deadCodeScriptButton) toolbar.addWidget(undoSpacer) toolbar.addAction(self.__undoButton) toolbar.addAction(self.__redoButton) toolbar.addWidget(spacer) toolbar.addAction(self.removeTrailingSpacesButton) toolbar.addAction(self.expandTabsButton) self.importsBar = ImportListWidget(self.__editor) self.importsBar.hide() self.__outsideChangesBar = OutsideChangeWidget(self.__editor) self.__outsideChangesBar.sigReloadRequest.connect(self.__onReload) self.__outsideChangesBar.reloadAllNonModifiedRequest.connect( self.reloadAllNonModified) self.__outsideChangesBar.hide() hLayout = QHBoxLayout() hLayout.setContentsMargins(0, 0, 0, 0) hLayout.setSpacing(0) vLayout = QVBoxLayout() vLayout.setContentsMargins(0, 0, 0, 0) vLayout.setSpacing(0) self.__navigationBar = NavigationBar(self.__editor, self) vLayout.addWidget(self.__navigationBar) vLayout.addWidget(self.__editor) hLayout.addLayout(vLayout) hLayout.addWidget(toolbar) widget = QWidget() widget.setLayout(hLayout) self.__splitter = QSplitter(Qt.Horizontal, self) self.__flowUI = FlowUIWidget(self.__editor, self) self.__mdView = MDWidget(self.__editor, self) self.__renderLayout = QVBoxLayout() self.__renderLayout.setContentsMargins(0, 0, 0, 0) self.__renderLayout.setSpacing(0) self.__renderLayout.addWidget(self.__flowUI) self.__renderLayout.addWidget(self.__mdView) self.__renderWidget = QWidget() self.__renderWidget.setLayout(self.__renderLayout) self.__splitter.addWidget(widget) self.__splitter.addWidget(self.__renderWidget) containerLayout = QHBoxLayout() containerLayout.setContentsMargins(0, 0, 0, 0) containerLayout.setSpacing(0) containerLayout.addWidget(self.__splitter) self.setLayout(containerLayout) self.__renderWidget.setVisible(False) self.__splitter.setSizes(Settings()['flowSplitterSizes']) self.__splitter.splitterMoved.connect(self.flowSplitterMoved) Settings().sigFlowSplitterChanged.connect(self.otherFlowSplitterMoved) def flowSplitterMoved(self, pos, index): """Splitter has been moved""" del pos # unused argument del index # unused argument Settings()['flowSplitterSizes'] = list(self.__splitter.sizes()) def otherFlowSplitterMoved(self): """Other window has changed the splitter position""" self.__splitter.setSizes(Settings()['flowSplitterSizes']) def updateStatus(self): """Updates the toolbar buttons status""" self.__updateRunDebugButtons() isPythonFile = isPythonMime(self.__editor.mime) self.importsDiagramButton.setEnabled( isPythonFile and GlobalData().graphvizAvailable) self.__editor.diagramsMenu.setEnabled( self.importsDiagramButton.isEnabled()) self.__editor.toolsMenu.setEnabled(self.runScriptButton.isEnabled()) def onNavigationBar(self): """Triggered when navigation bar focus is requested""" if self.__navigationBar.isVisible(): self.__navigationBar.setFocusToLastCombo() return True def __onPrint(self): """Triggered when the print button is pressed""" self.__editor._onShortcutPrint() def __onPrintPreview(self): """Triggered when the print preview button is pressed""" pass def __onDeadCode(self): """Triggered when vulture analysis is requested""" GlobalData().mainWindow.tabDeadCodeClicked() def __redoAvailable(self, available): """Reports redo ops available""" self.__redoButton.setEnabled(available) def __undoAvailable(self, available): """Reports undo ops available""" self.__undoButton.setEnabled(available) def __languageChanged(self, _=None): """Language changed""" isPython = self.__editor.isPythonBuffer() isMarkdown = self.__editor.isMarkdownBuffer() self.disasmScriptButton.setEnabled(isPython) self.__renderWidget.setVisible(not Settings()['floatingRenderer'] and (isPython or isMarkdown)) # Arguments: modified def modificationChanged(self, _=None): """Triggered when the content is changed""" self.__updateRunDebugButtons() def __updateRunDebugButtons(self): """Enables/disables the run and debug buttons as required""" enable = isPythonMime(self.__editor.mime) and \ not self.isModified() and \ not self.__debugMode and \ os.path.isabs(self.__fileName) if enable != self.runScriptButton.isEnabled(): self.runScriptButton.setEnabled(enable) self.profileScriptButton.setEnabled(enable) self.debugScriptButton.setEnabled(enable) self.deadCodeScriptButton.setEnabled(enable) self.sigTabRunChanged.emit(enable) def isTabRunEnabled(self): """Tells the status of run-like buttons""" return self.runScriptButton.isEnabled() def replaceAll(self, newText): """Replaces the current buffer content with a new text""" # Unfortunately, the setText() clears the undo history so it cannot be # used. The selectAll() and replacing selected text do not suite # because after undo the cursor does not jump to the previous position. # So, there is an ugly select -> replace manipulation below... with self.__editor: origLine, origPos = self.__editor.cursorPosition self.__editor.setSelection(0, 0, origLine, origPos) self.__editor.removeSelectedText() self.__editor.insert(newText) self.__editor.setCurrentPosition(len(newText)) line, pos = self.__editor.cursorPosition lastLine = self.__editor.lines() self.__editor.setSelection(line, pos, lastLine - 1, len(self.__editor.text(lastLine - 1))) self.__editor.removeSelectedText() self.__editor.cursorPosition = origLine, origPos # These two for the proper cursor positioning after redo self.__editor.insert("s") self.__editor.cursorPosition = origLine, origPos + 1 self.__editor.deleteBack() self.__editor.cursorPosition = origLine, origPos def onRemoveTrailingWS(self): """Triggers when the trailing spaces should be wiped out""" self.__editor.removeTrailingWhitespaces() def onExpandTabs(self): """Expands tabs if there are any""" self.__editor.expandTabs(4) def setFocus(self): """Overridden setFocus""" if self.__outsideChangesBar.isHidden(): self.__editor.setFocus() else: self.__outsideChangesBar.setFocus() def onImportDgmTuned(self): """Runs the settings dialog first""" if self.isModified(): what = ImportsDiagramDialog.SingleBuffer if not os.path.isabs(self.getFileName()): logging.warning("Imports diagram can only be generated for " "a file. Save the editor buffer " "and try again.") return else: what = ImportsDiagramDialog.SingleFile dlg = ImportsDiagramDialog(what, self.getFileName(), self) if dlg.exec_() == QDialog.Accepted: # Should proceed with the diagram generation self.__generateImportDiagram(what, dlg.options) # Arguments: action def onImportDgm(self, _=None): """Runs the generation process with default options""" if self.isModified(): what = ImportsDiagramDialog.SingleBuffer if not os.path.isabs(self.getFileName()): logging.warning("Imports diagram can only be generated for " "a file. Save the editor buffer " "and try again.") return else: what = ImportsDiagramDialog.SingleFile self.__generateImportDiagram(what, ImportDiagramOptions()) def __generateImportDiagram(self, what, options): """Show the generation progress and display the diagram""" if self.isModified(): progressDlg = ImportsDiagramProgress(what, options, self.getFileName(), self.__editor.text) tooltip = "Generated for modified buffer (" + \ self.getFileName() + ")" else: progressDlg = ImportsDiagramProgress(what, options, self.getFileName()) tooltip = "Generated for file " + self.getFileName() if progressDlg.exec_() == QDialog.Accepted: GlobalData().mainWindow.openDiagram(progressDlg.scene, tooltip) def onOpenImport(self): """Triggered when Ctrl+I is received""" if isPythonMime(self.__editor.mime): # Take all the file imports and resolve them fileImports = getImportsList(self.__editor.text) if not fileImports: GlobalData().mainWindow.showStatusBarMessage( "There are no imports") else: self.__onImportList(self.__fileName, fileImports) def __onImportList(self, fileName, imports): """Works with a list of imports""" # It has already been checked that the file is a Python one resolvedList, errors = resolveImports(fileName, imports) del errors # errors are OK here if resolvedList: # Display the import selection widget self.importsBar.showResolvedImports(resolvedList) else: GlobalData().mainWindow.showStatusBarMessage( "Could not resolve any imports") def resizeEvent(self, event): """Resizes the import selection dialogue if necessary""" self.__editor.hideCompleter() QWidget.resizeEvent(self, event) self.resizeBars() def resizeBars(self): """Resize the bars if they are shown""" if not self.importsBar.isHidden(): self.importsBar.resize() if not self.__outsideChangesBar.isHidden(): self.__outsideChangesBar.resize() self.__editor.resizeCalltip() def showOutsideChangesBar(self, allEnabled): """Shows the bar for the editor for the user to choose the action""" self.setReloadDialogShown(True) self.__outsideChangesBar.showChoice(self.isModified(), allEnabled) def __onReload(self): """Triggered when a request to reload the file is received""" self.sigReloadRequest.emit() def reload(self): """Called (from the editors manager) to reload the file""" # Re-read the file with updating the file timestamp self.readFile(self.__fileName) # Hide the bars, just in case both of them if not self.importsBar.isHidden(): self.importsBar.hide() if not self.__outsideChangesBar.isHidden(): self.__outsideChangesBar.hide() # Set the shown flag self.setReloadDialogShown(False) def reloadAllNonModified(self): """Request to reload all the non-modified files""" self.reloadAllNonModifiedRequest.emit() @staticmethod def onRunScript(action=None): """Runs the script""" del action # unused argument GlobalData().mainWindow.onRunTab() @staticmethod def onRunScriptDlg(): """Shows the run parameters dialogue""" GlobalData().mainWindow.onRunTabDlg() @staticmethod def onProfileScript(action=None): """Profiles the script""" del action # unused argument GlobalData().mainWindow.onProfileTab() @staticmethod def onProfileScriptDlg(): """Shows the profile parameters dialogue""" GlobalData().mainWindow.onProfileTabDlg() @staticmethod def onDebugScript(action=None): """Starts debugging""" del action # unused argument GlobalData().mainWindow.onDebugTab() @staticmethod def onDebugScriptDlg(): """Shows the debug parameters dialogue""" GlobalData().mainWindow.onDebugTabDlg() def getCFEditor(self): """Provides a reference to the control flow widget""" return self.__flowUI def cflowSyncRequested(self, absPos, line, pos): """Highlight the item closest to the absPos""" self.__flowUI.highlightAtAbsPos(absPos, line, pos) def passFocusToFlow(self): """Sets the focus to the graphics part""" if isPythonMime(self.__editor.mime): self.__flowUI.setFocus() return True return False def getMDView(self): """Provides a reference to the MD rendered view""" return self.__mdView # Mandatory interface part is below def getEditor(self): """Provides the editor widget""" return self.__editor def isModified(self): """Tells if the file is modified""" return self.__editor.document().isModified() def getRWMode(self): """Tells if the file is read only""" if not os.path.exists(self.__fileName): return None return 'RW' if QFileInfo(self.__fileName).isWritable() else 'RO' def getMime(self): """Provides the buffer mime""" return self.__editor.mime @staticmethod def getType(): """Tells the widget type""" return MainWindowTabWidgetBase.PlainTextEditor def getLanguage(self): """Tells the content language""" editorLanguage = self.__editor.language() if editorLanguage: return editorLanguage return self.__editor.mime if self.__editor.mime else 'n/a' def getFileName(self): """Tells what file name of the widget content""" return self.__fileName def setFileName(self, name): """Sets the file name""" self.__fileName = name self.__shortName = os.path.basename(name) def getEol(self): """Tells the EOL style""" return self.__editor.getEolIndicator() def getLine(self): """Tells the cursor line""" line, _ = self.__editor.cursorPosition return line def getPos(self): """Tells the cursor column""" _, pos = self.__editor.cursorPosition return pos def getEncoding(self): """Tells the content encoding""" if self.__editor.explicitUserEncoding: return self.__editor.explicitUserEncoding return self.__editor.encoding def getShortName(self): """Tells the display name""" return self.__shortName def setShortName(self, name): """Sets the display name""" self.__shortName = name def isDiskFileModified(self): """Return True if the loaded file is modified""" if not os.path.isabs(self.__fileName): return False if not os.path.exists(self.__fileName): return True path = os.path.realpath(self.__fileName) return self.__diskModTime != os.path.getmtime(path) or \ self.__diskSize != os.path.getsize(path) def doesFileExist(self): """Returns True if the loaded file still exists""" return os.path.exists(self.__fileName) def setReloadDialogShown(self, value=True): """Memorizes if the reloading dialogue has already been displayed""" self.__reloadDlgShown = value def getReloadDialogShown(self): """Tells if the reload dialog has already been shown""" return self.__reloadDlgShown and \ not self.__outsideChangesBar.isVisible() def updateModificationTime(self, fileName): """Updates the modification time""" path = os.path.realpath(fileName) self.__diskModTime = os.path.getmtime(path) self.__diskSize = os.path.getsize(path) def setDebugMode(self, debugOn, disableEditing): """Called to switch debug/development""" self.__debugMode = debugOn self.__editor.setDebugMode(debugOn, disableEditing) if debugOn: if disableEditing: # Undo/redo self.__undoButton.setEnabled(False) self.__redoButton.setEnabled(False) # Spaces/tabs/line self.removeTrailingSpacesButton.setEnabled(False) self.expandTabsButton.setEnabled(False) else: # Undo/redo self.__undoButton.setEnabled( self.__editor.document().isUndoAvailable()) self.__redoButton.setEnabled( self.__editor.document().isRedoAvailable()) # Spaces/tabs self.removeTrailingSpacesButton.setEnabled(True) self.expandTabsButton.setEnabled(True) # Run/debug buttons self.__updateRunDebugButtons() def isLineBreakable(self, line=None, enforceRecalc=False, enforceSure=False): """True if a breakpoint could be placed on the current line""" return self.__editor.isLineBreakable() def getVCSStatus(self): """Provides the VCS status""" return self.__vcsStatus def setVCSStatus(self, newStatus): """Sets the new VCS status""" self.__vcsStatus = newStatus # Floating renderer support def popRenderingWidgets(self): """Pops the rendering widgets""" self.__renderLayout.removeWidget(self.__flowUI) self.__renderLayout.removeWidget(self.__mdView) self.__renderWidget.setVisible(False) return [self.__flowUI, self.__mdView] def pushRenderingWidgets(self, widgets): """Returns back the rendering widgets""" for widget in widgets: self.__renderLayout.addWidget(widget) self.__languageChanged() # Sets the widget visibility