def dragEnterEvent(self, event: QDragEnterEvent) -> None: self.setDisabled(True) self.repaint() urls = event.mimeData().urls() if not urls: self.setDisabled(False) self.setFocus() event.ignore() return for url in urls: try: parse = urlparse(url.toString()) if parse.scheme not in ['file']: self.setDisabled(False) event.ignore() return filepath = Path(url.toLocalFile()) if isArchive(filepath) or containsValidMod(filepath, searchlimit=8)[0]: self.setDisabled(False) event.accept() return except Exception as e: logger.debug(str(e)) self.setDisabled(False) self.setFocus() event.ignore()
def dragEnterEvent(self, event: QDragEnterEvent): if event.source() is self: event.acceptProposedAction() elif event.mimeData().hasUrls(): event.acceptProposedAction() else: event.ignore()
def dragEnterEvent(self, event: QtGui.QDragEnterEvent): from randovania.layout.versioned_preset import VersionedPreset valid_extensions = [ LayoutDescription.file_extension(), VersionedPreset.file_extension(), ] valid_extensions_with_dot = { f".{extension}" for extension in valid_extensions } for url in event.mimeData().urls(): ext = os.path.splitext(url.toLocalFile())[1] if ext in valid_extensions_with_dot: event.acceptProposedAction() return
def dragEnterEvent(self, event: QtGui.QDragEnterEvent) -> None: print("dragEnterEvent", event) formats = event.mimeData().formats() if MIME_URI_LIST in formats: self.setBackgroundRole(QtGui.QPalette.Highlight) ## fixme mods = event.keyboardModifiers() ctrl = QtCore.Qt.ControlModifier shift = QtCore.Qt.ShiftModifier # this is not saved for future QDropEvent if mods & shift and mods & ctrl: event.setDropAction(QtCore.Qt.LinkAction) elif mods & shift: event.setDropAction(QtCore.Qt.MoveAction) elif mods & ctrl: event.setDropAction(QtCore.Qt.CopyAction) elif self.samedrivedrop(event): event.setDropAction(QtCore.Qt.MoveAction) else: event.setDropAction(QtCore.Qt.CopyAction) event.accept() #emit changed(event->mimeData()); else: print(formats) print(dropactionsstr(event.possibleActions()))
def lineEdit_dragEnterEvent(event: QDragEnterEvent): if event.mimeData().hasUrls: event.accept() else: event.ignore()
def dragEnterEvent(self, event: QtGui.QDragEnterEvent) -> None: mime_data = event.mimeData() if mime_data.hasUrls(): event.acceptProposedAction()