def __init__(self, manager, parent=None): super().__init__(parent) self.manager = manager file = QtCore.QFile( os.path.join(os.path.dirname(__file__), "settings.ui")) file.open(QtCore.QFile.ReadOnly) self.ui = QtUiTools.QUiLoader().load(file, self) file.close() layout = QtWidgets.QVBoxLayout(self) layout.addWidget(self.ui) self.setMinimumSize(400, 250) self.setWindowTitle(i18n("Run Action Settings")) self.ui.label.setText(i18n("Available actions")) for action in self.manager.actions: item = QtWidgets.QListWidgetItem(self.ui.listWidget) item.setText(action.title) item.setIcon(action.icon) item.setData(QtCore.Qt.UserRole, action.id) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked if action.id in self. manager.disabledActions else QtCore.Qt.Checked) self.ui.listWidget.addItem(item) self.ui.buttonBox.accepted.connect(self.accept) self.ui.buttonBox.rejected.connect(self.reject)
def __init__(self, manager): super().__init__() self.manager = manager self.setIcon(QtGui.QIcon(os.path.join(os.path.dirname(__file__), "icon.svg"))) self.setTitle(i18n("Run Action")) self.setToolTip(i18n("Run action on current page")) self.clicked.connect(self.onClicked)
def onClicked(self, controller): self.menu = QtWidgets.QMenu() for action in self.manager.getActions(self.webView()): self.menu.addAction(action) self.menu.addSeparator() self.menu.addAction(QtGui.QIcon.fromTheme("configure"), i18n("Configure..."), self.manager.showSettings) self.menu.popup(controller.callPopupPosition(self.menu.sizeHint())) self.menu.aboutToHide.connect(controller.callPopupClosed)
def name(self): return i18n("RunAction button")