示例#1
0
    def dropEvent(self, event: QtGui.QDropEvent) -> None:
        item: QtWidgets.QTreeWidgetItem = self.itemAt(event.pos())
        if not item:
            return event.setDropAction(Qt.IgnoreAction)

        source = self.preset_for_item(self.currentItem())
        target = self.preset_for_item(item)

        if source is None or target is None:
            return event.setDropAction(Qt.IgnoreAction)

        if source.game != target.game or source.base_preset_uuid is None:
            return event.setDropAction(Qt.IgnoreAction)

        try:
            source_preset = source.get_preset()
        except InvalidPreset:
            return event.setDropAction(Qt.IgnoreAction)

        self.window_manager.preset_manager.add_new_preset(
            VersionedPreset.with_preset(
                dataclasses.replace(source_preset,
                                    base_preset_uuid=target.uuid)))

        return super().dropEvent(event)
示例#2
0
 def dropEvent(self, event: QtGui.QDropEvent) -> None:
     """
     If the drag & drop started on a cell with a ticket, moves the ticket
     to the dropEvent's location.
     """
     ticket = self._get_ticket_from_cell(self.currentRow(),
                                         self.currentColumn())
     if ticket is not None:
         destination = (self.rowAt(event.pos().y()),
                        self.columnAt(event.pos().x()))
         ticket.move_to(*destination)
     self.clearSelection()
示例#3
0
    def dropEvent(self, event: QDropEvent):
        if event.source():
            super().dropEvent(event)
        else:
            for url in event.mimeData().urls():

                info = QFileInfo(url.toLocalFile())
                if not info.isReadable():
                    logging.warning("File {} is not readable".format(
                        info.filePath()))
                    continue
                if info.isDir():
                    if get_setting("dragAndDropBehavior"
                                   ) == SETTINGS_VALUES.DragAndDrop.ALBUM_MODE:
                        self.addAlbum(url.toLocalFile())
                    else:
                        for file_path in files_in_directory_and_subdirectories(
                                info.filePath()):
                            self.addSong(file_path)
                else:
                    self.addSong(info.filePath())
示例#4
0
    def dropEvent(self, event: QtGui.QDropEvent):
        from randovania.layout.versioned_preset import VersionedPreset

        for url in event.mimeData().urls():
            path = Path(url.toLocalFile())
            if path.suffix == f".{LayoutDescription.file_extension()}":
                self.open_game_details(LayoutDescription.from_file(path))
                return

            elif path.suffix == f".{VersionedPreset.file_extension()}":
                self.main_tab_widget.setCurrentWidget(self.tab_create_seed)
                self.generate_seed_tab.import_preset_file(path)
                return
示例#5
0
    def dropEvent(self, event: QtGui.QDropEvent):

        formats = event.mimeData().formats()

        if MIME_URI_LIST in formats:
            files = get_paths_from_drop_event(event)
            action = event.dropAction()
            target = self.root_dir()
            if event.source():  # internal drag and drop
                print(action, files, "to", target)
            else:  # external drag and drop
                print(action, files, "to", target)
            event.accept()
        else:
            for format in formats:
                print(format, event.mimeData().data(format))
示例#6
0
 def dropEvent(self, event: QDropEvent) -> None:
     event.accept()
     self.setDisabled(True)
     self.repaint()
     asyncio.create_task(self.checkInstallFromURLs(event.mimeData().urls()))
示例#7
0
def lineEdit_dropEvent(window: mainwindow, event: QDropEvent):
    window.clear_lineEdit()
    window.filename = event.mimeData().urls()[0].toLocalFile()
    window.lineEdit.setText(str(window.filename))
示例#8
0
 def dropEvent(self, event: QtGui.QDropEvent) -> None:
     path = event.mimeData().urls()[0]
     task_manager_path = Path(path.toLocalFile())
     self.load_from_file(task_manager_path)