From 2cd691ebf80ea0a8ace6f3a75b854b6ae64f8edf Mon Sep 17 00:00:00 2001 From: falkTX Date: Tue, 23 Apr 2013 01:06:45 +0100 Subject: [PATCH] Implement drap&drop any file --- resources/ui/carla.ui | 3 +++ source/carla.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/resources/ui/carla.ui b/resources/ui/carla.ui index 7e5914f93..47a9a5e3d 100644 --- a/resources/ui/carla.ui +++ b/resources/ui/carla.ui @@ -10,6 +10,9 @@ 482 + + true + Carla diff --git a/source/carla.py b/source/carla.py index 71eed8852..201a16b97 100755 --- a/source/carla.py +++ b/source/carla.py @@ -1745,6 +1745,25 @@ class CarlaMainW(QMainWindow): tabBar = self.ui.tabMain.tabBar() self.fInfoLabel.resize(self.ui.tabMain.width()-tabBar.width()-20, self.fInfoLabel.height()) + def dragEnterEvent(self, event): + if self.ui.tabMain.currentIndex() == 0 and self.ui.tab_plugins.contentsRect().contains(event.pos()): + event.accept() + else: + QMainWindow.dragEnterEvent(self, event) + + def dropEvent(self, event): + event.accept() + + urls = event.mimeData().urls() + + for url in urls: + filename = url.toLocalFile() + + if not Carla.host.load_filename(filename): + CustomMessageBox(self, QMessageBox.Critical, self.tr("Error"), + self.tr("Failed to load file"), + cString(Carla.host.get_last_error()), QMessageBox.Ok, QMessageBox.Ok) + def resizeEvent(self, event): if self.ui.tabMain.currentIndex() == 0: # Force update of 2nd tab