def _get_menu_wgt(self, menu_name_, menu_=None): _menu = menu_ if menu_ else self._menu_bar _menu_group = menu_name_.split(Separator.OBJ) if len(_menu_group) == 1: return GuiUtils.get_widget_by_name(_menu, menu_name_) else: _sub_menu_name = _menu_group.pop(0) _sub_menu = GuiUtils.get_widget_by_name(_menu, _sub_menu_name) _rest_menu_name = Separator.OBJ.join(_menu_group) return self._get_menu_wgt(_rest_menu_name, _sub_menu)
def closeEvent(self, event): """...""" if GuiUtils.question_dialog(self, 'Quit', 'Are you sure to quit wechat tools?'): event.accept() else: event.ignore()
def _add_filter(self): _name = GuiUtils.input_dialog(self, 'Filter', 'Add filter:') if _name: _item = QListWidgetItem(_name) _item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable) self._filter.addItem(_item) self._save_filter()
def _set_main_window(self): _tab = QTabWidget() self._info_window = self._set_tool_window() self._console_window = GuiUtils.console_window() _tab.addTab(self._info_window, 'Tools Settings') _tab.addTab(self._console_window, 'Console Window') _tab.currentChanged.connect(self._save_tool) self.setCentralWidget(_tab)
def _add_menu(self, menu_name_, menu_params_, menu_=None): _menu = menu_ if menu_ else self._menu_bar _menu_group = menu_name_.split(Separator.OBJ) if len(_menu_group) == 1: _menu_btn = QAction(menu_name_, self) _menu_btn.triggered.connect(menu_params_[0]) _menu_btn.setShortcut(menu_params_[1]) GuiUtils.add_widget(_menu, _menu_btn, menu_name_, WidgetType.BTN) _menu.addAction(_menu_btn) else: _sub_menu_name = _menu_group.pop(0) _sub_menu = GuiUtils.get_widget_by_name( _menu, _sub_menu_name) or _menu.addMenu(_sub_menu_name) GuiUtils.add_widget(_menu, _sub_menu, _sub_menu_name, WidgetType.MENU) _rest_menu_name = Separator.OBJ.join(_menu_group) self._add_menu(_rest_menu_name, menu_params_, _sub_menu)
def _delete_filter(self): try: _item = self._filter.currentItem() if GuiUtils.question_dialog(self, 'Filter', 'Delete filter: ' + _item.text()): _item = self._filter.takeItem(self._filter.currentRow()) del _item self._save_filter() except Exception as e: _msg = 'Choose one item before deleting.' print(_msg)
def _test_action(self): GuiUtils.info_dialog(self, 'Test', 'No integrated yet.')