def __init__(self, context, parent=None): super(MainWindow, self).__init__(parent) self.log = util.make_logging_source_adapter(__name__, self) self.context = context self.mdiArea = MCMdiArea() self.toolbar = self.addToolBar("toolbar") self.toolbar.setObjectName("toolbar") self.setWindowTitle("mesycontrol") self.setWindowIcon(make_icon(":/window-icon.png")) self.mdiArea.setLayout(QtWidgets.QGridLayout()) self.setCentralWidget(self.mdiArea) self.status_bar = QtWidgets.QStatusBar() self.setStatusBar(self.status_bar) self.actionQuickstart = QtWidgets.QAction("Quickstart") self.actionQuickstart.setShortcut("F1") self.menu_file = QtWidgets.QMenu("&File") self.menu_window = QtWidgets.QMenu("&Window") self.menu_help = QtWidgets.QMenu("&Help") self.menu_help.addAction(self.actionQuickstart) self.menu_help.addSeparator() self.menu_help.addAction("&About", self.on_actionAbout_triggered) self.menu_help.addAction("About &Qt", self.on_actionAbout_Qt_triggered) self.menu_bar = self.menuBar() self.menu_bar.addMenu(self.menu_file) self.menu_bar.addMenu(self.menu_help) # Treeview self.treeview = MCTreeView(app_registry=context.app_registry, device_registry=context.device_registry) dw_tree = QtWidgets.QDockWidget("Device tree", self) dw_tree.setObjectName("dw_treeview") dw_tree.setWidget(self.treeview) dw_tree.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) self.addDockWidget(Qt.BottomDockWidgetArea, dw_tree) # Log view self.logview = log_view.LogView(parent=self) dw_logview = QtWidgets.QDockWidget("Application Log", self) dw_logview.setObjectName("dw_logview") dw_logview.setWidget(self.logview) dw_logview.setFeatures(QtWidgets.QDockWidget.DockWidgetMovable | QtWidgets.QDockWidget.DockWidgetFloatable) self.addDockWidget(Qt.BottomDockWidgetArea, dw_logview)
def contextMenuEvent(self, event): menu = QtWidgets.QMenu() for a in self._actions.values(): if a.isEnabled(): menu.addAction(a) if not menu.isEmpty(): menu.exec_(self.mapToGlobal(event.pos()))
def __init__(self, device, display_mode=util.COMBINED, write_mode=util.COMBINED, parent=None): super(DeviceTableWidget, self).__init__(parent) self.log = util.make_logging_source_adapter(__name__, self) settings = util.loadUi(":/ui/device_tableview_settings.ui") self.log.debug("display_mode=%d, write_mode=%d", display_mode, write_mode) model = DeviceTableModel(device, display_mode=display_mode, write_mode=write_mode) self.view = DeviceTableView(model=model) sort_model = self.view.sort_model self.view.display_mode_changed.connect(self.display_mode_changed) self.view.write_mode_changed.connect(self.write_mode_changed) menu = QtWidgets.QMenu('Filter options', self) action = menu.addAction("Hide unknown") action.setCheckable(True) action.setChecked(sort_model.filter_unknown) action.triggered.connect(sort_model.set_filter_unknown) action = menu.addAction("Hide read-only") action.setCheckable(True) action.setChecked(sort_model.filter_readonly) action.triggered.connect(sort_model.set_filter_readonly) action = menu.addAction("Hide volatile") action.setCheckable(True) action.setChecked(sort_model.filter_volatile) action.triggered.connect(sort_model.set_filter_volatile) action = menu.addAction("Hide static") action.setCheckable(True) action.setChecked(sort_model.filter_static) action.triggered.connect(sort_model.set_filter_static) menu.addSeparator() action = menu.addAction("Ignore param ranges on edit") action.setCheckable(True) action.triggered.connect(model.set_editing_ignore_parameter_ranges) action = menu.addAction("Hexadecimal values") action.setCheckable(True) action.triggered.connect(model.set_display_hex_values) menu.addSeparator() action = menu.addAction("Resize table cells") action.triggered.connect(self.view.resizeColumnsToContents) action.triggered.connect(self.view.resizeRowsToContents) settings.pb_settings.setMenu(menu) settings.le_filter.textChanged.connect(sort_model.setFilterWildcard) layout = QtWidgets.QVBoxLayout() layout.addWidget(settings) layout.addWidget(self.view) self.setLayout(layout)