Esempio n. 1
0
class CheckSizes(Ui_Form, QtGui.QWidget):

    def __init__(self, control, edit_mode='edit'):
        QtGui.QWidget.__init__(self)
        self.setupUi(self)

        text = 'interface: %s, preferred widget: %s, edit mode: %s' % (control.interface, control.widget, edit_mode)
        self.l_title.setText(text)

        self._control = control

        self._qcontainer = QControlContainer()
        self._qcontainer.add_control(self._control)
        self._qcontainer.create_actions(self)

#        m = getattr(scontrol, '%s_qt' % edit_mode)
        m = getattr(scontrol, 'qt_editor')

        self._qtcontrols = []

        valid_widget_shape = None
        for shape in ['vline', 'hline', 'small', 'large', 'responsive']:
            layout = getattr(self, 'l_%s' % shape)
            widget = m(self._control, shape=shape)
            if widget:
                layout.addWidget(widget)
                valid_widget_shape = shape
                self._qtcontrols.append(widget)
            else:
                layout.addWidget(QtGui.QLabel("X"))

        if valid_widget_shape:
            self._test_widget = m(self._control, shape=valid_widget_shape)
            self.layout_sample.addWidget(self._test_widget)
            self.cb_read.toggled.connect(self.on_mode_changed)
            self.cb_apply.toggled.connect(self.on_mode_changed)

        self._model = ControlModel(manager=self._qcontainer)
        self._view = ControlView()
        self._view.setModel(self._model)
        self._view.hideColumn(0)
        self.l_large_box.addWidget(self._view, 1, 1, 2, 1)

    def contextMenuEvent(self, event):
        menu = QtGui.QMenu(self)
        menu.addActions(self._qcontainer.actions())
        menu.exec_(event.pos())

    def on_mode_changed(self, state):
        autoread = self.cb_read.isChecked()
        autoapply = self.cb_apply.isChecked()
        for widget in self._qtcontrols:
            widget.autoapply(self._control, autoapply)
            widget.autoread(self._control, autoread)
Esempio n. 2
0
class ControlManagerWidget(Splitter, AbstractListener):
    def __init__(self, manager=None, parent=None):
        AbstractListener.__init__(self)
        Splitter.__init__(self, parent=parent)

        if manager is None:
            self._manager = ControlManager()
        else:
            self._manager = manager

        self.model = ControlModel(self._manager)

        self.view = ControlView()
        self.view.setModel(self.model)
        self.view.controlsSelected.connect(self.on_controls_selected)

        self.model.rowsInserted.connect(self.view.onRowsInserted)

        self.addWidget(self.view)

        self._i = 1

        self._index = None
        self._widget_edit = None

    def on_controls_selected(self, controls):
        if self._widget_edit:
            widget = self._widget_edit()
            widget.close()
            self._widget_edit = None
            del widget

        if not controls:
            return

        widget = QtGui.QWidget()
        widget.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        layout = QtGui.QVBoxLayout(widget)
        for control in controls:
            subwidget = qt_editor(control,
                                  shape='large',
                                  preferred=control.widget)
            layout.addWidget(subwidget)
        self.addWidget(widget)
        self._widget_edit = weakref.ref(widget)
Esempio n. 3
0
class ControlManagerWidget(Splitter, AbstractListener):

    def __init__(self, manager=None, parent=None):
        AbstractListener.__init__(self)
        Splitter.__init__(self, parent=parent)

        if manager is None:
            self._manager = ControlManager()
        else:
            self._manager = manager

        self.model = ControlModel(self._manager)

        self.view = ControlView()
        self.view.setModel(self.model)
        self.view.controlsSelected.connect(self.on_controls_selected)

        self.model.rowsInserted.connect(self.view.onRowsInserted)

        self.addWidget(self.view)

        self._i = 1

        self._index = None
        self._widget_edit = None

    def on_controls_selected(self, controls):
        if self._widget_edit:
            widget = self._widget_edit()
            widget.close()
            self._widget_edit = None
            del widget

        if not controls:
            return

        widget = QtGui.QWidget()
        widget.setAttribute(QtCore.Qt.WA_DeleteOnClose)

        layout = QtGui.QVBoxLayout(widget)
        for control in controls:
            subwidget = qt_editor(control, shape='large', preferred=control.widget)
            layout.addWidget(subwidget)
        self.addWidget(widget)
        self._widget_edit = weakref.ref(widget)
Esempio n. 4
0
    def __init__(self, control, edit_mode='edit'):
        QtGui.QWidget.__init__(self)
        self.setupUi(self)

        text = 'interface: %s, preferred widget: %s, edit mode: %s' % (control.interface, control.widget, edit_mode)
        self.l_title.setText(text)

        self._control = control

        self._qcontainer = QControlContainer()
        self._qcontainer.add_control(self._control)
        self._qcontainer.create_actions(self)

#        m = getattr(scontrol, '%s_qt' % edit_mode)
        m = getattr(scontrol, 'qt_editor')

        self._qtcontrols = []

        valid_widget_shape = None
        for shape in ['vline', 'hline', 'small', 'large', 'responsive']:
            layout = getattr(self, 'l_%s' % shape)
            widget = m(self._control, shape=shape)
            if widget:
                layout.addWidget(widget)
                valid_widget_shape = shape
                self._qtcontrols.append(widget)
            else:
                layout.addWidget(QtGui.QLabel("X"))

        if valid_widget_shape:
            self._test_widget = m(self._control, shape=valid_widget_shape)
            self.layout_sample.addWidget(self._test_widget)
            self.cb_read.toggled.connect(self.on_mode_changed)
            self.cb_apply.toggled.connect(self.on_mode_changed)

        self._model = ControlModel(manager=self._qcontainer)
        self._view = ControlView()
        self._view.setModel(self._model)
        self._view.hideColumn(0)
        self.l_large_box.addWidget(self._view, 1, 1, 2, 1)
Esempio n. 5
0
    def __init__(self, manager=None, parent=None):
        AbstractListener.__init__(self)
        Splitter.__init__(self, parent=parent)

        if manager is None:
            self._manager = ControlManager()
        else:
            self._manager = manager

        self.model = ControlModel(self._manager)

        self.view = ControlView()
        self.view.setModel(self.model)
        self.view.controlsSelected.connect(self.on_controls_selected)

        self.model.rowsInserted.connect(self.view.onRowsInserted)

        self.addWidget(self.view)

        self._i = 1

        self._index = None
        self._widget_edit = None
Esempio n. 6
0
    def __init__(self, manager=None, parent=None):
        AbstractListener.__init__(self)
        Splitter.__init__(self, parent=parent)

        if manager is None:
            self._manager = ControlManager()
        else:
            self._manager = manager

        self.model = ControlModel(self._manager)

        self.view = ControlView()
        self.view.setModel(self.model)
        self.view.controlsSelected.connect(self.on_controls_selected)

        self.model.rowsInserted.connect(self.view.onRowsInserted)

        self.addWidget(self.view)

        self._i = 1

        self._index = None
        self._widget_edit = None