Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[suggestion] drag and drop outside the window #75

Open
Vectasus opened this issue Apr 27, 2024 · 2 comments
Open

[suggestion] drag and drop outside the window #75

Vectasus opened this issue Apr 27, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Vectasus
Copy link

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.

@blipdrifter
Copy link

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

@Vectasus
Copy link
Author

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_())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants