def mouseDoubleClickEvent(self, event): if event.button() == QtCore.Qt.LeftButton: action = actionAtPos(event.globalPos()) if action and action.menu(): launch(action.data()) action.menu().hide() self.hide() G.systray.menu.hide() event.accept() else: QtWidgets.QMenu.mouseDoubleClickEvent(self, event)
def prepare(self): ### Open file self.open_action = QtWidgets.QAction("Open", self) self.open_action.triggered.connect(lambda: launch(self.action.data())) ### Terminal self.term_action = QtWidgets.QAction("Open Terminal Here", self) self.term_action.triggered.connect(lambda: terminal_there(self.action.data())) ### Permissions self.perm_action = QtWidgets.QAction("Permissions", self) self.perm_menu = PermissionsMenu() self.perm_action.setMenu(self.perm_menu) self.title_action = QtWidgets.QAction("", self) self.title_action.setEnabled(False) self.title_action.setFont(G.bold_font) self.size_action = QtWidgets.QAction("", self) self.size_action.setEnabled(False) self.addAction(self.title_action) self.addAction(self.size_action) self.addSeparator() self.title_action.setText(self.action.data().fileName()) self.size_action.setText(readable_size(self.action)) self.perm_menu.fileinfo = self.action.data() if maybe_execute(self.action.data(), False): self.open_action.setText("Run") else: self.open_action.setText("Open") if not self.action.data().isDir(): self.mime_action = MimeAction(self.action, parent=self) self.addAction(self.mime_action) self.addAction(self.open_action) self.opact = QtWidgets.QAction("Open With", self) self.opact.setMenu(OpenMenu([self.action])) self.addAction(self.opact) self.addAction(self.term_action) self.addAction(self.perm_action)
def mouseReleaseEvent(self, event): if event.button() == QtCore.Qt.RightButton: return if event.button() == QtCore.Qt.MiddleButton: action = actionAtPos(event.globalPos()) if action: if action.menu(): launch(action.data()) elif self.menuAction().data(): launch(self.menuAction().data()) else: launch(action.root.data()) event.accept() else: QtWidgets.QMenu.mouseReleaseEvent(self, event)
def open_it(self, path, acts): xec = QtCore.QFileInfo(path) urllist = [act.urllist()[0] for act in acts] launch(xec, urllist=urllist)
def on_triggered(self, action): if isinstance(self.menuAction(), DraggyAction): launch(action.data())