Example #1
0
    def __setupViews(self):
        """ Creates the UI widgets.
        """
        self._collector = Collector(self.windowNumber)
        self._collector.sigShowMessage.connect(self.sigShowMessage)

        self.configWidget = ConfigWidget(self._configTreeModel)
        self.repoWidget = RepoWidget(self.argosApplication.repo, self.collector)

        # self._configTreeModel.insertItem(self.repoWidget.repoTreeView.config) # No configurable items yet

        # Define a central widget that will be the parent of the inspector widget.
        # We don't set the inspector directly as the central widget to retain the size when the
        # inspector is changed.
        self.mainWidget = QtWidgets.QWidget()
        self.mainLayout = QtWidgets.QVBoxLayout(self.mainWidget)
        self.mainLayout.setContentsMargins(0, 0, 0, 0)
        self.mainLayout.setSpacing(0)
        self.setCentralWidget(self.mainWidget)

        self.topPane = QtWidgets.QFrame()
        # self.topPane.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Raised)
        # self.topPane.setLineWidth(1)
        self.mainLayout.addWidget(self.topPane)

        self.topLayout = QtWidgets.QHBoxLayout(self.topPane)
        self.topLayout.setContentsMargins(0, 0, 0, 0)
        self.topLayout.setSpacing(0)

        self.inspectorSelectionPane = InspectorSelectionPane(self.inspectorActionGroup)
        self.topLayout.addWidget(self.inspectorSelectionPane)
        self.sigInspectorChanged.connect(self.inspectorSelectionPane.updateFromInspectorRegItem)
        self.sigShowMessage.connect(self.inspectorSelectionPane.showMessage)

        showInspectorMenuAction = QtWidgets.QAction("ShowInspectorMenu", self,
            triggered=self.inspectorSelectionPane.menuButton.showMenu, checkable=False)
        showInspectorMenuAction.setShortcut("Ctrl+I")
        self.addAction(showInspectorMenuAction)

        self.wrapperWidget = QtWidgets.QWidget()
        self.mainLayout.addWidget(self.wrapperWidget)

        self.wrapperLayout = QtWidgets.QVBoxLayout(self.wrapperWidget)
        self.wrapperLayout.setContentsMargins(0, 0, 0, 0)
        self.wrapperLayout.setSpacing(0)
        self.wrapperLayout.addWidget(self.inspector)

        # Must be after setInspector since that already draws the inspector
        self.collector.sigContentsChanged.connect(self.collectorContentsChanged)
        self._configTreeModel.sigItemChanged.connect(self.configContentsChanged)

        # Populate table headers menu
        self.__addTableHeadersSubMenu("Data", self.repoWidget.repoTreeView)
        self.__addTableHeadersSubMenu("Settings", self.configWidget.configTreeView)
        self.__addTableHeadersSubMenu(
            "Properties", self.repoWidget.propertiesPane.table)
        self.__addTableHeadersSubMenu(
            "Attributes", self.repoWidget.attributesPane.table)
Example #2
0
    def __init__(self, collector, parent=None):
        """ Constructor.

            When subclassing the AbstractInspector try to minimize the work done in the constructor.
            Place all functionality that may raise an exception in updateContents or clearContents,
            these functions will show an error page and prevent the application from aborting. If
            an exception occurs in the constructor it is not caught!

            :param collector: the data collector from where this inspector gets its data
            :param parent: parent widget.
        """

        super(AbstractInspector, self).__init__(parent)

        self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)

        self._config = MainGroupCti(nodeName='inspector') # Is typically redefined.
        self._collector = collector

        self.errorWidget = MessageDisplay()
        self.addWidget(self.errorWidget)

        self.contentsWidget = QtWidgets.QWidget()
        self.addWidget(self.contentsWidget)

        self.contentsLayout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.TopToBottom)
        self.contentsLayout.setSpacing(DOCK_SPACING)
        self.contentsLayout.setContentsMargins(DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN)
        self.contentsWidget.setLayout(self.contentsLayout)

        self.setCurrentIndex(self.CONTENTS_PAGE_IDX)
Example #3
0
    def __init__(self, cti, delegate, parent=None):
        """ See the AbstractCtiEditor for more info on the parameters
        """
        super(GroupCtiEditor, self).__init__(cti, delegate, parent=parent)

        # Add hidden widget to store editor value
        self.widget = self.addSubEditor(QtWidgets.QWidget())
        self.widget.hide()
Example #4
0
    def __init__(self, repoTreeView, parent=None):
        """ Constructor takes a reference to the repository tree view it monitors
        """
        super(DetailBasePane, self).__init__(parent)

        self._isConnected = False
        self._repoTreeView = repoTreeView

        self.errorWidget = MessageDisplay()
        self.addWidget(self.errorWidget)

        self.contentsWidget = QtWidgets.QWidget()
        self.addWidget(self.contentsWidget)

        self.contentsLayout = QtWidgets.QBoxLayout(QtWidgets.QBoxLayout.TopToBottom)
        self.contentsLayout.setSpacing(DOCK_SPACING)
        self.contentsLayout.setContentsMargins(DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN, DOCK_MARGIN)
        self.contentsWidget.setLayout(self.contentsLayout)

        self.setCurrentIndex(self.CONTENTS_PAGE_IDX)
Example #5
0
    def __setupViews(self):
        """ Creates the UI widgets.
        """
        self._collector = Collector(self.windowNumber)
        self.configWidget = ConfigWidget(self._configTreeModel)
        self.repoWidget = RepoWidget(self.argosApplication.repo,
                                     self.collector)
        # self._configTreeModel.insertItem(self.repoWidget.repoTreeView.config) # No configurable items yet

        # Define a central widget that will be the parent of the inspector widget.
        # We don't set the inspector directly as the central widget to retain the size when the
        # inspector is changed.
        widget = QtWidgets.QWidget()
        layout = QtWidgets.QVBoxLayout(widget)
        layout.setContentsMargins(CENTRAL_MARGIN, CENTRAL_MARGIN,
                                  CENTRAL_MARGIN, CENTRAL_MARGIN)
        layout.setSpacing(CENTRAL_SPACING)
        self.setCentralWidget(widget)

        # Must be after setInspector since that already draws the inspector
        self.collector.sigContentsChanged.connect(
            self.collectorContentsChanged)
        self._configTreeModel.sigItemChanged.connect(
            self.configContentsChanged)
Example #6
0
    def __init__(self, label, registry,  parent=None):
        """ Constructor
        """
        super(PluginsDialog, self).__init__(parent=parent)
        check_class(registry, BaseRegistry)

        self._label = label
        self._orgRegistry = registry
        self._registry = copy.deepcopy(registry)  # make copy so changes can be canceled
        self._tableModel = self._registry.createTableModel(parent=self)
        self.mapper = QtWidgets.QDataWidgetMapper(parent=self)
        self.mapper.setModel(self._tableModel)

        self.setWindowTitle("Argos {} Plugins".format(label))

        layout = QtWidgets.QVBoxLayout(self)

        self.verSplitter = QtWidgets.QSplitter(Qt.Vertical)
        #self.verSplitter.setCollapsible(1, False)
        self.verSplitter.setChildrenCollapsible(False)
        layout.addWidget(self.verSplitter)

        self.tableWidget = TableEditWidget(self._tableModel)
        self.verSplitter.addWidget(self.tableWidget)

        self._tableView = self.tableWidget.tableView
        self._tableView.installEventFilter(self)

        # Form
        self.horSplitter = QtWidgets.QSplitter(Qt.Horizontal)
        self.horSplitter.setChildrenCollapsible(False)

        self.verSplitter.addWidget(self.horSplitter)

        self.formWidget = QtWidgets.QWidget()
        self.formLayout = QtWidgets.QFormLayout()
        self.formLayout.setContentsMargins(0, 0, 0, 0)
        self.formWidget.setLayout(self.formLayout)
        self.horSplitter.addWidget(self.formWidget)

        self._editWidgets = []
        itemCls = registry.ITEM_CLASS
        assert len(itemCls.LABELS) == len(itemCls.TYPES), \
            "Regtype Mismatch: {} != {}".format(len(itemCls.LABELS), len(itemCls.TYPES))
        for col, (label, regType) in enumerate(zip(itemCls.LABELS, itemCls.TYPES)):

            if regType == RegType.String:
                editWidget = QtWidgets.QLineEdit()
                self.mapper.addMapping(editWidget, col)
            elif regType == RegType.ShortCut:
                editWidget = ShortCutEditor()
                self.mapper.addMapping(editWidget, col)
            elif regType == RegType.ColorStr:
                editWidget = ColorSelectWidget()
                self.mapper.addMapping(editWidget.lineEditor, col)
            else:
                raise AssertionError("Unexpected regType: {}".format(regType))
            editWidget.installEventFilter(self)
            self.formLayout.addRow(label, editWidget)
            self._editWidgets.append(editWidget)

        # Detail info widget
        font = QtGui.QFont()
        font.setFamily(MONO_FONT)
        font.setFixedPitch(True)
        font.setPointSize(FONT_SIZE)

        self.editor = QtWidgets.QTextEdit()
        self.editor.setReadOnly(True)
        #self.editor.setFocusPolicy(Qt.NoFocus) # Allow focus so that user can copy text from it.
        #self.editor.setFont(font)
        self.editor.setWordWrapMode(QtGui.QTextOption.WordWrap)
        self.editor.clear()
        self.horSplitter.addWidget(self.editor)

        self.horSplitter.setStretchFactor(0, 2)
        self.horSplitter.setStretchFactor(1, 3)
        self.verSplitter.setSizes([300, 150])

        # Reset/Cancel/Save Buttons

        self.saveButton = QtWidgets.QPushButton("Save")
        self.saveButton.clicked.connect(self.accept)

        self.cancelButton = QtWidgets.QPushButton("Cancel")
        self.cancelButton.clicked.connect(self.reject)

        self.resetButton = QtWidgets.QPushButton("Reset Table to Defaults...")
        self.resetButton.clicked.connect(self.resetToDefaults)
        self.resetButton.setIcon(QtGui.QIcon(os.path.join(icons_directory(), 'reset-l.svg')))

        # We use a button layout instead of a QButtonBox because there always will be a default
        # button (e.g. the Save button) that will light up, even if another widget has the focus.
        # From https://doc.qt.io/archives/qt-4.8/qdialogbuttonbox.html#details
        #   However, if there is no default button set and to preserve which button is the default
        #   button across platforms when using the QPushButton::autoDefault property, the first
        #   push button with the accept role is made the default button when the QDialogButtonBox
        #   is shown,

        self.buttonLayout = QtWidgets.QHBoxLayout()
        self.buttonLayout.addWidget(self.resetButton)
        self.buttonLayout.addStretch()
        if sys.platform == 'darwin':
            self.buttonLayout.addWidget(self.cancelButton)
            self.buttonLayout.addWidget(self.saveButton)
        else:
            self.buttonLayout.addWidget(self.saveButton)
            self.buttonLayout.addWidget(self.cancelButton)
        layout.addLayout(self.buttonLayout)

        # Connect signals and populate

        self.tableWidget.tableView.selectionModel().currentChanged.connect(self.currentItemChanged)
        self.tableWidget.tableView.model().sigItemChanged.connect(self._updateEditor)

        self.resize(QtCore.QSize(1100, 700))
        self.tableWidget.tableView.setFocus(Qt.NoFocusReason)

        self.tryImportAllPlugins()
Example #7
0
    def main():
        import sys

        app = QtWidgets.QApplication(sys.argv)
        window = QtWidgets.QWidget()
        layout = QtWidgets.QVBoxLayout(window)

        if 0:
            if 1:
                window.setStyleSheet("""
                    QLabel {
                        background-color: #FF9900;
                    }
                """)
            else:
                window.setStyleSheet("""
                    QLabel {
                        margin: 5px;
                        border: 0px solid blue;
                        background-color: #FF9900;
                        padding: 0px;
                    }
                """)

        label0 = QtWidgets.QLabel('my great line edit')
        label1 = QtWidgets.QLabel('edit')
        label2 = QtWidgets.QLabel('combo')

        all_labels = [label0, label1, label2]
        for lbl in all_labels:
            _setLabelProps(lbl)
        harmonizeLabelsTextWidth(all_labels)

        maxWidth = labelsMaxTextWidth([label0, label1, label2])
        print("\mmaxWidth: {}".format(maxWidth))

        tableView = QtWidgets.QTableView()
        layout.addWidget(tableView)
        model = QtGui.QStandardItemModel(3, 2)
        tableView.setModel(model)
        tableView.horizontalHeader().resizeSection(0, 200)
        tableView.horizontalHeader().resizeSection(1, 300)
        layoutSpacing = 0

        editor0 = QtWidgets.QSpinBox()
        editor0.setValue(5)
        editor0.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                              QtWidgets.QSizePolicy.MinimumExpanding)
        lw0 = LabeledWidget(label0, editor0, layoutSpacing=layoutSpacing)
        model.setData(model.index(0, 0), "A small")
        tableView.setIndexWidget(model.index(0, 1), lw0)

        editor1 = QtWidgets.QSpinBox()
        editor1.setValue(7)
        editor1.setSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                              QtWidgets.QSizePolicy.MinimumExpanding)
        lw1 = LabeledWidget(label1, editor1, layoutSpacing=layoutSpacing)
        model.setData(model.index(1, 0), "A SMALL seasoned curly")
        tableView.setIndexWidget(model.index(1, 1), lw1)

        comboBox = QtWidgets.QComboBox()
        comboBox.addItems([
            "Half diet coke", "Half regular coke",
            "Junior western bacon cheese"
        ])
        lw2 = LabeledWidget(label2, comboBox, layoutSpacing=layoutSpacing)
        model.setData(model.index(2, 0), "What else?")
        tableView.setIndexWidget(model.index(2, 1), lw2)

        window.resize(550, 400)
        window.show()
        window.raise_()
        sys.exit(app.exec_())