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, 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, 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, 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 __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, 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, 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 __createLayout(self): """Creates the dialog layout""" self.resize(640, 480) self.setSizeGripEnabled(True) vboxLayout = QVBoxLayout(self) hLayout = QHBoxLayout() self.__propsView = QTreeWidget() self.__propsView.setAlternatingRowColors(True) self.__propsView.setRootIsDecorated(False) self.__propsView.setItemsExpandable(False) self.__propsView.setSortingEnabled(True) self.__propsView.setItemDelegate(NoOutlineHeightDelegate(4)) self.__propsView.itemSelectionChanged.connect( self.__propsSelectionChanged) propsViewHeader = QTreeWidgetItem(["Property Name", "Property Value"]) self.__propsView.setHeaderItem(propsViewHeader) self.__propsView.header().setSortIndicator(0, Qt.DescendingOrder) hLayout.addWidget(self.__propsView) self.__delButton = QToolButton() self.__delButton.setText("Delete") self.__delButton.setFocusPolicy(Qt.NoFocus) self.__delButton.setEnabled(False) self.__delButton.clicked.connect(self.__onDel) hLayout.addWidget(self.__delButton, 0, Qt.AlignBottom) vboxLayout.addLayout(hLayout) # Set property part setGroupbox = QGroupBox(self) setGroupbox.setTitle("Set Property") setLayout = QGridLayout(setGroupbox) setLayout.addWidget(QLabel("Name"), 0, 0, Qt.AlignTop | Qt.AlignRight) setLayout.addWidget(QLabel("Value"), 1, 0, Qt.AlignTop | Qt.AlignRight) self.__nameEdit = QLineEdit() self.__nameEdit.textChanged.connect(self.__nameChanged) setLayout.addWidget(self.__nameEdit, 0, 1) self.__valueEdit = QTextEdit() self.__valueEdit.setAcceptRichText(False) self.__valueEdit.textChanged.connect(self.__valueChanged) metrics = QFontMetrics(self.__valueEdit.font()) rect = metrics.boundingRect("X") self.__valueEdit.setFixedHeight(rect.height() * 4 + 5) setLayout.addWidget(self.__valueEdit, 1, 1) self.__setButton = QToolButton() self.__setButton.setText("Set") self.__setButton.setFocusPolicy(Qt.NoFocus) self.__setButton.setEnabled(False) self.__setButton.clicked.connect(self.__onSet) setLayout.addWidget(self.__setButton, 1, 2, Qt.AlignBottom | Qt.AlignHCenter) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( setGroupbox.sizePolicy().hasHeightForWidth()) setGroupbox.setSizePolicy(sizePolicy) vboxLayout.addWidget(setGroupbox) # 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.close) vboxLayout.addWidget(buttonBox)
class VCSUpdateIntervalConfigDialog(QDialog): """Dialog to configure update interval""" def __init__(self, value, parent=None): QDialog.__init__(self, parent) self.interval = value self.__createLayout() self.setWindowTitle("VCS file status update interval configuration") self.__intervalEdit.setText(str(self.interval)) self.__updateOKStatus() self.__intervalEdit.textChanged.connect(self.__updateOKStatus) self.__intervalEdit.setFocus() 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 __updateOKStatus(self): """Updates the OK button status""" okButton = self.__buttonBox.button(QDialogButtonBox.Ok) if self.__intervalEdit.text() == "": okButton.setEnabled(False) okButton.setToolTip("Interval must be defined") return value = int(self.__intervalEdit.text()) if value < 1 or value > 3600: okButton.setEnabled(False) okButton.setToolTip("Interval must be within 1..3600 sec") return okButton.setEnabled(True) okButton.setToolTip("") def userAccept(self): """Triggered when the user clicks OK""" self.interval = int(self.__intervalEdit.text()) self.accept()
def __createLayout(self, pathsToCommit, pathsToIgnore): """Creates the dialog layout""" self.resize(640, 480) self.setSizeGripEnabled(True) vboxLayout = QVBoxLayout(self) # Paths to commit part commitHeaderFrame = QFrame() commitHeaderFrame.setFrameStyle(QFrame.StyledPanel) commitHeaderFrame.setAutoFillBackground(True) self.__setLightPalette(commitHeaderFrame) commitHeaderFrame.setFixedHeight(24) expandingCommitSpacer = QSpacerItem(10, 10, QSizePolicy.Expanding) self.__selectAllButton = QToolButton() self.__selectAllButton.setAutoRaise(True) self.__selectAllButton.setIcon( getIcon(pluginHomeDir + 'svnselectall.png')) self.__selectAllButton.setFixedSize(20, 20) self.__selectAllButton.setToolTip("Select all") self.__selectAllButton.setFocusPolicy(Qt.NoFocus) self.__selectAllButton.clicked.connect(self.__onSelectAll) commitHeaderLayout = QHBoxLayout() commitHeaderLayout.setContentsMargins(3, 0, 0, 0) commitHeaderLayout.addWidget( QLabel("Paths to commit (total: " + str(len(pathsToCommit)) + ")")) commitHeaderLayout.addSpacerItem(expandingCommitSpacer) commitHeaderLayout.addWidget(self.__selectAllButton) commitHeaderFrame.setLayout(commitHeaderLayout) vboxLayout.addWidget(commitHeaderFrame) self.__pathToCommitView = QTreeWidget() self.__configTable(self.__pathToCommitView) self.__pathToCommitHeader = QTreeWidgetItem(["", "Path", "Status", ""]) self.__pathToCommitView.setHeaderItem(self.__pathToCommitHeader) self.__pathToCommitView.header().setSortIndicator( PATH_COL, Qt.AscendingOrder) self.__pathToCommitView.itemChanged.connect(self.__onCommitPathChanged) vboxLayout.addWidget(self.__pathToCommitView) # Paths to ignore part headerFrame = QFrame() headerFrame.setFrameStyle(QFrame.StyledPanel) headerFrame.setAutoFillBackground(True) self.__setLightPalette(headerFrame) headerFrame.setFixedHeight(24) ignoreLabel = QLabel("Ignored paths (total: " + str(len(pathsToIgnore)) + ")") expandingSpacer = QSpacerItem(10, 10, QSizePolicy.Expanding) self.__showHideIgnoredButton = QToolButton() self.__showHideIgnoredButton.setAutoRaise(True) self.__showHideIgnoredButton.setIcon(getIcon('less.png')) self.__showHideIgnoredButton.setFixedSize(20, 20) self.__showHideIgnoredButton.setToolTip("Show ignored path list") self.__showHideIgnoredButton.setFocusPolicy(Qt.NoFocus) self.__showHideIgnoredButton.clicked.connect(self.__onShowHideIgnored) ignoredHeaderLayout = QHBoxLayout() ignoredHeaderLayout.setContentsMargins(3, 0, 0, 0) ignoredHeaderLayout.addWidget(ignoreLabel) ignoredHeaderLayout.addSpacerItem(expandingSpacer) ignoredHeaderLayout.addWidget(self.__showHideIgnoredButton) headerFrame.setLayout(ignoredHeaderLayout) vboxLayout.addWidget(headerFrame) self.__pathToIgnoreView = QTreeWidget() self.__configTable(self.__pathToIgnoreView) self.__pathToIgnoreView.setVisible(False) pathToIgnoreHeader = QTreeWidgetItem(["Path", "Status"]) self.__pathToIgnoreView.setHeaderItem(pathToIgnoreHeader) self.__pathToIgnoreView.header().setSortIndicator(0, Qt.AscendingOrder) vboxLayout.addWidget(self.__pathToIgnoreView) # Message part vboxLayout.addWidget(QLabel("Message")) self.__message = QTextEdit() self.__message.setAcceptRichText(False) metrics = QFontMetrics(self.__message.font()) rect = metrics.boundingRect("X") self.__message.setFixedHeight(rect.height() * 4 + 5) vboxLayout.addWidget(self.__message) # Diff part diffHeaderFrame = QFrame() diffHeaderFrame.setFrameStyle(QFrame.StyledPanel) diffHeaderFrame.setAutoFillBackground(True) self.__setLightPalette(diffHeaderFrame) diffHeaderFrame.setFixedHeight(24) diffLabel = QLabel("Diff") diffExpandingSpacer = QSpacerItem(10, 10, QSizePolicy.Expanding) self.__showHideDiffButton = QToolButton() self.__showHideDiffButton.setAutoRaise(True) self.__showHideDiffButton.setIcon(getIcon('less.png')) self.__showHideDiffButton.setFixedSize(20, 20) self.__showHideDiffButton.setToolTip("Show diff") self.__showHideDiffButton.setFocusPolicy(Qt.NoFocus) self.__showHideDiffButton.clicked.connect(self.__onShowHideDiff) diffLayout = QHBoxLayout() diffLayout.setContentsMargins(3, 0, 0, 0) diffLayout.addWidget(diffLabel) diffLayout.addSpacerItem(diffExpandingSpacer) diffLayout.addWidget(self.__showHideDiffButton) diffHeaderFrame.setLayout(diffLayout) self.__diffViewer = DiffTabWidget() self.__diffViewer.setHTML(self.NODIFF) self.__diffViewer.setVisible(False) vboxLayout.addWidget(diffHeaderFrame) vboxLayout.addWidget(self.__diffViewer) # 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("Commit") 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, 480) self.setSizeGripEnabled(True) vboxLayout = QVBoxLayout(self) # Revisions to compare compareGroupbox = QGroupBox(self) compareGroupbox.setTitle("Revisions to compare") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( compareGroupbox.sizePolicy().hasHeightForWidth()) compareGroupbox.setSizePolicy(sizePolicy) revisionLayout = QHBoxLayout(compareGroupbox) self.__lhsRevisionLabel = QLabel() self.__lhsRevisionLabel.setFrameStyle(QFrame.StyledPanel) self.__lhsResetButton = QToolButton() self.__lhsResetButton.setIcon( getIcon(pluginHomeDir + 'svnclearrev.png')) self.__lhsResetButton.setFocusPolicy(Qt.NoFocus) self.__lhsResetButton.setEnabled(False) self.__lhsResetButton.setToolTip("Reset revision to compare") self.__lhsResetButton.clicked.connect(self.__onLHSReset) self.__rhsRevisionLabel = QLabel() self.__rhsRevisionLabel.setFrameStyle(QFrame.StyledPanel) self.__rhsResetButton = QToolButton() self.__rhsResetButton.setIcon( getIcon(pluginHomeDir + 'svnclearrev.png')) self.__rhsResetButton.setFocusPolicy(Qt.NoFocus) self.__rhsResetButton.setEnabled(False) self.__rhsResetButton.setToolTip("Reset revision to compare") self.__rhsResetButton.clicked.connect(self.__onRHSReset) lhsLayout = QHBoxLayout() lhsLayout.addWidget(self.__lhsRevisionLabel) lhsLayout.addWidget(self.__lhsResetButton) rhsLayout = QHBoxLayout() rhsLayout.addWidget(self.__rhsRevisionLabel) rhsLayout.addWidget(self.__rhsResetButton) bothLayout = QVBoxLayout() bothLayout.addLayout(lhsLayout) bothLayout.addLayout(rhsLayout) revisionLayout.addLayout(bothLayout) self.__diffButton = QToolButton() self.__diffButton.setText("Diff") self.__diffButton.setFocusPolicy(Qt.NoFocus) self.__diffButton.setEnabled(False) self.__diffButton.clicked.connect(self.__onDiff) revisionLayout.addWidget(self.__diffButton) vboxLayout.addWidget(compareGroupbox) # Log table logHeaderFrame = QFrame() logHeaderFrame.setFrameStyle(QFrame.StyledPanel) logHeaderFrame.setAutoFillBackground(True) self.__setLightPalette(logHeaderFrame) logHeaderFrame.setFixedHeight(24) logHeaderLayout = QHBoxLayout() logHeaderLayout.setContentsMargins(3, 0, 0, 0) logHeaderLayout.addWidget(QLabel("Subversion log of " + self.__path)) logHeaderFrame.setLayout(logHeaderLayout) vboxLayout.addWidget(logHeaderFrame) self.__logView = QTreeWidget() self.__logView.setAlternatingRowColors(True) self.__logView.setRootIsDecorated(False) self.__logView.setItemsExpandable(False) self.__logView.setSortingEnabled(True) self.__logView.setItemDelegate(NoOutlineHeightDelegate(4)) self.__logViewHeader = QTreeWidgetItem( ["", "", "Revision", "Date", "Author", "Message"]) self.__logView.setHeaderItem(self.__logViewHeader) self.__logView.header().setSortIndicator(REVISION_COL, Qt.AscendingOrder) self.__logView.itemChanged.connect(self.__onLogViewChanged) vboxLayout.addWidget(self.__logView) # Diff part diffHeaderFrame = QFrame() diffHeaderFrame.setFrameStyle(QFrame.StyledPanel) diffHeaderFrame.setAutoFillBackground(True) self.__setLightPalette(diffHeaderFrame) diffHeaderFrame.setFixedHeight(24) diffLabel = QLabel("Diff") diffExpandingSpacer = QSpacerItem(10, 10, QSizePolicy.Expanding) self.__showHideDiffButton = QToolButton() self.__showHideDiffButton.setAutoRaise(True) self.__showHideDiffButton.setIcon(getIcon('less.png')) self.__showHideDiffButton.setFixedSize(20, 20) self.__showHideDiffButton.setToolTip("Show diff") self.__showHideDiffButton.setFocusPolicy(Qt.NoFocus) self.__showHideDiffButton.clicked.connect(self.__onShowHideDiff) diffLayout = QHBoxLayout() diffLayout.setContentsMargins(3, 0, 0, 0) diffLayout.addWidget(diffLabel) diffLayout.addSpacerItem(diffExpandingSpacer) diffLayout.addWidget(self.__showHideDiffButton) diffHeaderFrame.setLayout(diffLayout) self.__diffViewer = DiffTabWidget() self.__diffViewer.setHTML(self.NODIFF) self.__diffViewer.setVisible(False) vboxLayout.addWidget(diffHeaderFrame) vboxLayout.addWidget(self.__diffViewer) # 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.close) vboxLayout.addWidget(buttonBox)
def __createLayout(self): """Creates the dialog layout""" self.resize(640, 480) self.setSizeGripEnabled(True) layout = QVBoxLayout() # Plugins list self.__pluginsView = QTreeWidget() self.__pluginsView.setAlternatingRowColors(True) self.__pluginsView.setRootIsDecorated(False) self.__pluginsView.setItemsExpandable(False) self.__pluginsView.setSortingEnabled(True) self.__pluginsView.setItemDelegate(NoOutlineHeightDelegate(4)) self.__pluginsView.setUniformRowHeights(True) # Alert | system/user | Enable | Name | Version self.__pluginsHeader = QTreeWidgetItem( ["", "", "", "Name", "Version", ""]) self.__pluginsView.setHeaderItem(self.__pluginsHeader) self.__pluginsView.header().setSortIndicator(NAME_COL, Qt.AscendingOrder) self.__pluginsView.itemSelectionChanged.connect( self.__pluginSelectionChanged) self.__pluginsView.itemChanged.connect(self.__onItemChanged) layout.addWidget(self.__pluginsView) # Detailed information detailsLabel = QLabel("Detailed information") layout.addWidget(detailsLabel) self.__details = QTreeWidget() self.__details.setAlternatingRowColors(False) self.__details.setRootIsDecorated(False) self.__details.setItemsExpandable(False) self.__details.setSortingEnabled(False) self.__details.setItemDelegate(NoOutlineHeightDelegate(4)) self.__details.setUniformRowHeights(True) detailsHeader = QTreeWidgetItem(["", ""]) self.__details.setHeaderItem(detailsHeader) self.__details.setHeaderHidden(True) metrics = QFontMetrics(self.__details.font()) rect = metrics.boundingRect("X") self.__details.setFixedHeight(rect.height() * 6 + 5) layout.addWidget(self.__details) # Errors/warnings errorsLabel = QLabel("Errors / warnings") layout.addWidget(errorsLabel) self.__errorsText = QTextEdit() self.__errorsText.setReadOnly(True) self.__errorsText.setAcceptRichText(False) metrics = QFontMetrics(self.__errorsText.font()) rect = metrics.boundingRect("X") self.__errorsText.setFixedHeight(rect.height() * 4 + 5) layout.addWidget(self.__errorsText) # Buttons box 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) self.setLayout(layout)
class SVNPluginConfigDialog(QDialog): """ SVN Plugin config dialog """ def __init__(self, ideWideSettings, projectSettings, parent=None): QDialog.__init__(self, parent) self.__projectLocalRButton = None self.__idewideUser = None self.__idewideLocalRButton = None self.__projectReposRButton = None self.__idewideAuthPasswdRButton = None self.__projectPasswd = None self.__projectUser = None self.__projectAuthExtRButton = None self.__idewidePasswd = None self.__idewideAuthExtRButton = None self.__projectAuthPasswdRButton = None self.__idewideReposRButton = None self.__createLayout() self.setWindowTitle("SVN plugin configuration") self.ideWideSettings = copy.deepcopy(ideWideSettings) if projectSettings is None: self.projectSettings = None else: self.projectSettings = copy.deepcopy(projectSettings) # Set the values self.__setIDEWideValues() if projectSettings is None: self.__tabWidget.setTabEnabled(1, False) else: self.__setProjectValues() self.__tabWidget.setCurrentIndex(1) self.__updateOKStatus() self.__idewideUser.textChanged.connect(self.__updateOKStatus) self.__projectUser.textChanged.connect(self.__updateOKStatus) def __setIDEWideValues(self): """Sets the values in the IDE wide tab""" if self.ideWideSettings.authKind == AUTH_EXTERNAL: self.__idewideAuthExtRButton.setChecked(True) self.__idewideUser.setEnabled(False) self.__idewidePasswd.setEnabled(False) else: self.__idewideAuthPasswdRButton.setChecked(True) if self.ideWideSettings.userName: self.__idewideUser.setText(self.ideWideSettings.userName) if self.ideWideSettings.password: self.__idewidePasswd.setText(self.ideWideSettings.password) if self.ideWideSettings.statusKind == STATUS_REPOSITORY: self.__idewideReposRButton.setChecked(True) else: self.__idewideLocalRButton.setChecked(True) def __setProjectValues(self): """Sets the values in the project tab""" if self.projectSettings.authKind == AUTH_EXTERNAL: self.__projectAuthExtRButton.setChecked(True) self.__projectUser.setEnabled(False) self.__projectPasswd.setEnabled(False) else: self.__projectAuthPasswdRButton.setChecked(True) if self.projectSettings.userName: self.__projectUser.setText(self.projectSettings.userName) if self.projectSettings.password: self.__projectPasswd.setText(self.projectSettings.password) if self.projectSettings.statusKind == STATUS_REPOSITORY: self.__projectReposRButton.setChecked(True) else: self.__projectLocalRButton.setChecked(True) 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 __createIDEWide(self): """Creates the IDE wide part""" widget = QWidget() verticalLayout = QVBoxLayout(widget) infoLabel = QLabel("Note: the settings below are used " "when there is no project loaded.") verticalLayout.addWidget(infoLabel) # Authorization group box authGroupbox = QGroupBox(self) authGroupbox.setTitle("Authorization") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( authGroupbox.sizePolicy().hasHeightForWidth()) authGroupbox.setSizePolicy(sizePolicy) layoutAuth = QVBoxLayout(authGroupbox) self.__idewideAuthExtRButton = QRadioButton("External", authGroupbox) self.__idewideAuthExtRButton.clicked.connect(self.__idewideAuthChanged) layoutAuth.addWidget(self.__idewideAuthExtRButton) self.__idewideAuthPasswdRButton = QRadioButton( "Use user name / password", authGroupbox) self.__idewideAuthPasswdRButton.clicked.connect( self.__idewideAuthChanged) layoutAuth.addWidget(self.__idewideAuthPasswdRButton) upLayout = QGridLayout() self.__idewideUser = QLineEdit() self.__idewideUser.setToolTip("Attention: user name is " "saved unencrypted") self.__idewidePasswd = QLineEdit() self.__idewidePasswd.setToolTip("Attention: password is " "saved unencrypted") spacer = QWidget() spacer.setFixedWidth(16) upLayout.addWidget(spacer, 0, 0) upLayout.addWidget(QLabel("User name"), 0, 1) upLayout.addWidget(self.__idewideUser, 0, 2) upLayout.addWidget(QLabel("Password"), 1, 1) upLayout.addWidget(self.__idewidePasswd, 1, 2) layoutAuth.addLayout(upLayout) # Update status group box updateGroupbox = QGroupBox(self) updateGroupbox.setTitle("Update status policy") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( updateGroupbox.sizePolicy().hasHeightForWidth()) updateGroupbox.setSizePolicy(sizePolicy) layoutUpdate = QVBoxLayout(updateGroupbox) self.__idewideReposRButton = QRadioButton("Check repository", updateGroupbox) layoutUpdate.addWidget(self.__idewideReposRButton) self.__idewideLocalRButton = QRadioButton("Local only", updateGroupbox) layoutUpdate.addWidget(self.__idewideLocalRButton) verticalLayout.addWidget(authGroupbox) verticalLayout.addWidget(updateGroupbox) return widget def __idewideAuthChanged(self): """Triggered when authorization has been changed""" if self.__idewideAuthExtRButton.isChecked(): self.__idewideUser.setEnabled(False) self.__idewidePasswd.setEnabled(False) else: self.__idewideUser.setEnabled(True) self.__idewidePasswd.setEnabled(True) self.__idewideUser.setFocus() self.__updateOKStatus() def __createProjectSpecific(self): """Creates the project specific part""" widget = QWidget() verticalLayout = QVBoxLayout(widget) infoLabel = QLabel("Note: the settings below are used " "only for the specific project.") verticalLayout.addWidget(infoLabel) # Authorization group box authGroupbox = QGroupBox(self) authGroupbox.setTitle("Authorization") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( authGroupbox.sizePolicy().hasHeightForWidth()) authGroupbox.setSizePolicy(sizePolicy) layoutAuth = QVBoxLayout(authGroupbox) self.__projectAuthExtRButton = QRadioButton("External", authGroupbox) self.__projectAuthExtRButton.clicked.connect(self.__projectAuthChanged) layoutAuth.addWidget(self.__projectAuthExtRButton) self.__projectAuthPasswdRButton = QRadioButton( "Use user name / password", authGroupbox) self.__projectAuthPasswdRButton.clicked.connect( self.__projectAuthChanged) layoutAuth.addWidget(self.__projectAuthPasswdRButton) upLayout = QGridLayout() self.__projectUser = QLineEdit() self.__projectUser.setToolTip("Attention: user name is " "saved unencrypted") self.__projectPasswd = QLineEdit() self.__projectPasswd.setToolTip("Attention: password is " "saved unencrypted") spacer = QWidget() spacer.setFixedWidth(16) upLayout.addWidget(spacer, 0, 0) upLayout.addWidget(QLabel("User name"), 0, 1) upLayout.addWidget(self.__projectUser, 0, 2) upLayout.addWidget(QLabel("Password"), 1, 1) upLayout.addWidget(self.__projectPasswd, 1, 2) layoutAuth.addLayout(upLayout) # Update status group box updateGroupbox = QGroupBox(self) updateGroupbox.setTitle("Update status policy") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( updateGroupbox.sizePolicy().hasHeightForWidth()) updateGroupbox.setSizePolicy(sizePolicy) layoutUpdate = QVBoxLayout(updateGroupbox) self.__projectReposRButton = QRadioButton("Check repository", updateGroupbox) layoutUpdate.addWidget(self.__projectReposRButton) self.__projectLocalRButton = QRadioButton("Local only", updateGroupbox) layoutUpdate.addWidget(self.__projectLocalRButton) verticalLayout.addWidget(authGroupbox) verticalLayout.addWidget(updateGroupbox) return widget def __projectAuthChanged(self): """Triggered when authorization has been changed""" if self.__projectAuthExtRButton.isChecked(): self.__projectUser.setEnabled(False) self.__projectPasswd.setEnabled(False) else: self.__projectUser.setEnabled(True) self.__projectPasswd.setEnabled(True) self.__projectUser.setFocus() self.__updateOKStatus() @staticmethod def __getSVNVersion(): """Provides an svn binary version""" try: output = check_output(['svn', '--version']) for line in output.decode('utf-8').splitlines(): parts = line.split(' ') for index, part in enumerate(parts): if part.lower() == 'version': return parts[index + 1] except Exception as exc: logging.error(str(exc)) return None return None def __createVersionWidget(self): """Creates the version tab content""" svnVersion = str(self.__getSVNVersion()) svnModuleVersion = str(svn.__version__) text = "<p>The major Codimension SVN plugin " \ "components are listed below:</p>" \ "<ul>" \ "<li><a href='http://subversion.apache.org/'>" \ "Subversion</a><br>" \ "Version: " + svnVersion + "<br></li>" \ "<li><a href='https://github.com/dsoprea/PySvn'>" \ "Subversion wrapper</a><br>" \ "Version: " + svnModuleVersion + "<br>" \ "License: <a href='http://www.gnu.org/licenses/gpl-2.0.html'>" \ "GPL 2</a>" \ "<br></li>" \ "</ul>" browser = QTextBrowser() browser.setHtml(text) browser.setOpenExternalLinks(True) return browser def userAccept(self): """Triggered when the user clicks OK""" # Collect IDE-wide values if self.__idewideAuthExtRButton.isChecked(): self.ideWideSettings.authKind = AUTH_EXTERNAL self.ideWideSettings.userName = None self.ideWideSettings.password = None else: self.ideWideSettings.authKind = AUTH_PASSWD strippedUser = self.__idewideUser.text().strip() self.ideWideSettings.userName = strippedUser strippedPasswd = self.__idewidePasswd.text().strip() self.ideWideSettings.password = strippedPasswd if self.__idewideReposRButton.isChecked(): self.ideWideSettings.statusKind = STATUS_REPOSITORY else: self.ideWideSettings.statusKind = STATUS_LOCAL_ONLY if self.projectSettings is not None: if self.__projectAuthExtRButton.isChecked(): self.projectSettings.authKind = AUTH_EXTERNAL self.projectSettings.userName = None self.projectSettings.password = None else: self.projectSettings.authKind = AUTH_PASSWD strippedUser = self.__projectUser.text().strip() self.projectSettings.userName = strippedUser strippedPasswd = self.__projectPasswd.text().strip() self.projectSettings.password = strippedPasswd if self.__projectReposRButton.isChecked(): self.projectSettings.statusKind = STATUS_REPOSITORY else: self.projectSettings.statusKind = STATUS_LOCAL_ONLY self.accept() def __updateOKStatus(self): """Updates the OK button status""" okButton = self.__buttonBox.button(QDialogButtonBox.Ok) if self.__idewideAuthPasswdRButton.isChecked(): userName = self.__idewideUser.text().strip() if not userName: okButton.setEnabled(False) okButton.setToolTip("IDE wide SVN user name cannot be empty") return if self.projectSettings is not None: if self.__projectAuthPasswdRButton.isChecked(): userName = self.__projectUser.text().strip() if not userName: okButton.setEnabled(False) okButton.setToolTip("Project specific SVN " "user name cannot be empty") return okButton.setEnabled(True) okButton.setToolTip("")