TagStudio icon indicating copy to clipboard operation
TagStudio copied to clipboard

[suggestion] drag and drop outside the window

Open Vectasus opened this issue 1 year ago • 2 comments

It would be nice if one could find a file in TagStudio and then drag it towards a new destination, such as a file explorer, a website drop area or a chatroom.

Vectasus avatar Apr 27 '24 20:04 Vectasus

i agree with this, hydrus already has this feature and it's super useful for dragging images into chat apps.

blipdrifter avatar Apr 27 '24 20:04 blipdrifter

You can use event.mimeData().hasUrls() to detect files being dragged. Here is a mock-up of a drop-target window

import sys
from PySide6.QtWidgets import QApplication, QWidget
from PySide6.QtCore import Qt

class DragDropWindow(QWidget):
    def __init__(self):
        super().__init__()
        self.setAcceptDrops(True)
        self.setWindowTitle("Drag and Drop Files")
        self.setGeometry(100, 100, 400, 300)

    def dragEnterEvent(self, event):
        if event.mimeData().hasUrls():
            event.accept()
        else:
            event.ignore()

    def dragMoveEvent(self, event):
        if event.mimeData().hasUrls():
            event.accept()
        else:
            event.ignore()

    def dropEvent(self, event):
        for url in event.mimeData().urls():
            file_path = url.toLocalFile()
            print("Dropped file:", file_path)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = DragDropWindow()
    window.show()
    sys.exit(app.exec_())

Vectasus avatar Apr 27 '24 20:04 Vectasus

Implemented in #153

CyanVoxel avatar Jun 13 '24 18:06 CyanVoxel