Ejemplo n.º 1
0
    def _init_widgets(self):

        layout = QVBoxLayout()

        # address

        lbl_addr = QLabel()
        lbl_addr.setText("Address")

        txt_addr = QLineEdit()
        txt_addr.returnPressed.connect(self._on_address_entered)
        self._txt_addr = txt_addr

        top_layout = QHBoxLayout()
        top_layout.addWidget(lbl_addr)
        top_layout.addWidget(txt_addr)

        self._view = QMemoryView(self.workspace)

        area = QScrollArea()
        self._scrollarea = area
        area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setWidgetResizable(True)

        area.setWidget(self._view)

        layout.addLayout(top_layout)
        layout.addWidget(area)
        layout.setContentsMargins(0, 0, 0, 0)

        self.setLayout(layout)
    def _init_widgets(self):

        state = self._state

        if state is None:
            return

        if state.arch.name not in self.ARCH_REGISTERS:
            l.error(
                "Architecture %s is not listed in QRegisterViewer.ARCH_REGISTERS.",
                state.arch.name)
            return

        layout = QVBoxLayout()
        area = QScrollArea()
        area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setWidgetResizable(True)

        regs = self.ARCH_REGISTERS[state.arch.name]

        # common ones
        common_regs = regs['common']

        for reg_name in common_regs:
            sublayout = QHBoxLayout()

            lbl_reg_name = QLabel(self)
            lbl_reg_name.setProperty('class', 'reg_viewer_label')
            lbl_reg_name.setText(reg_name)
            lbl_reg_name.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
            sublayout.addWidget(lbl_reg_name)

            sublayout.addSpacing(10)
            reg_value = QASTViewer(None, parent=self)
            self._registers[reg_name] = reg_value
            sublayout.addWidget(reg_value)

            layout.addLayout(sublayout)

        layout.setSpacing(0)
        layout.addStretch(0)
        layout.setContentsMargins(2, 2, 2, 2)

        # the container
        container = QFrame()
        container.setAutoFillBackground(True)
        palette = container.palette()
        palette.setColor(container.backgroundRole(), Qt.white)
        container.setPalette(palette)
        container.setLayout(layout)

        area.setWidget(container)

        base_layout = QVBoxLayout()
        base_layout.addWidget(area)
        self.setLayout(base_layout)
Ejemplo n.º 3
0
 def __init__(self, qpframe):
     QVBoxLayout.__init__(self)
     scroll = QScrollArea()
     scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     scroll.setWidgetResizable(True)
     subWidget = QWidget()
     subWidget.setLayout(qpframe)
     scroll.setWidget(subWidget)
     self.addWidget(scroll)
     self.scroll = scroll
    def _init_widgets(self):

        area = QScrollArea()
        area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        area.setWidgetResizable(True)

        self._area = area

        base_layout = QVBoxLayout()
        base_layout.addWidget(area)
        self.setLayout(base_layout)
Ejemplo n.º 5
0
 def add_command_tab(self, command_list, tab_name = "Commands"):
     outer_widget = QWidget()
     outer_layout = QVBoxLayout()
     outer_widget.setLayout(outer_layout)
     outer_layout.setContentsMargins(2, 2, 2, 2)
     outer_layout.setSpacing(1)
     for c in command_list:
         new_command = qButtonWithArgumentsClass(c[1], c[0], c[2], self.help_instance, max_field_size = 100)
         outer_layout.addWidget(new_command)
         outer_layout.setAlignment(new_command,QtCore.Qt.AlignTop )
     outer_layout.addStretch()
     scroller = QScrollArea()
     scroller.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     # scroller.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
     scroller.setWidget(outer_widget)
     scroller.setWidgetResizable(True)
     self.addTab(scroller, tab_name)
Ejemplo n.º 6
0
class MetadataView(QAbstractItemView):
    MESSAGE_NO_SELECTION = 'Metadata'
    MESSAGE_SINGLE_SELECTION = 'Metadata for 1 box'
    MESSAGE_MULTIPLE_SELECTION = 'Metadata for {0} boxes'

    def __init__(self, parent=None):
        # This view is never made visible
        super(MetadataView, self).__init__()

        # A container for the controls
        self._form_container = FormContainer()

        # A scrollable container for the form
        self._form_scroll = QScrollArea(parent)
        self._form_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._form_scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self._form_scroll.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)
        self._form_scroll.setWidget(self._form_container)

        # Make the controls fill the available horizontal space
        # http://qt-project.org/forums/viewthread/11012
        self._form_scroll.setWidgetResizable(True)

        # Title
        self._title = QLabel()

        # Title is fixed at the top - form can be scrolled
        layout = QVBoxLayout()
        layout.addWidget(self._title)
        layout.addWidget(self._form_scroll)

        # Top-level container for the title and form
        self.widget = QWidget(parent)
        self.widget.setLayout(layout)

    def reset(self):
        """QAbstractItemView virtual
        """
        debug_print('MetadataView.reset')
        super(MetadataView, self).reset()

        # Clear the controls
        self.selectionChanged([], [])

    def selectionChanged(self, selected, deselected):
        """QAbstractItemView slot
        """
        debug_print('MetadataView.selectionChanged')

        selected = self.selectionModel().selectedIndexes()

        # Set title
        if 1 == len(selected):
            title = self.MESSAGE_SINGLE_SELECTION
        elif selected:
            title = self.MESSAGE_MULTIPLE_SELECTION.format(len(selected))
        else:
            title = self.MESSAGE_NO_SELECTION
        self._title.setText(title)

        # TODO Combo should indicate multiple and unrecognised values
        # Put values into the controls
        metadata = [i.data(MetadataRole) for i in selected]
        for field, control in self._form_container.controls.iteritems():
            values = {m.get(field, '') for m in metadata}
            control.selection_changed(selected, values)