Browse Source

Implement drap&drop any file

tags/1.9.4
falkTX 11 years ago
parent
commit
2cd691ebf8
2 changed files with 22 additions and 0 deletions
  1. +3
    -0
      resources/ui/carla.ui
  2. +19
    -0
      source/carla.py

+ 3
- 0
resources/ui/carla.ui View File

@@ -10,6 +10,9 @@
<height>482</height> <height>482</height>
</rect> </rect>
</property> </property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Carla</string> <string>Carla</string>
</property> </property>


+ 19
- 0
source/carla.py View File

@@ -1745,6 +1745,25 @@ class CarlaMainW(QMainWindow):
tabBar = self.ui.tabMain.tabBar() tabBar = self.ui.tabMain.tabBar()
self.fInfoLabel.resize(self.ui.tabMain.width()-tabBar.width()-20, self.fInfoLabel.height()) 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): def resizeEvent(self, event):
if self.ui.tabMain.currentIndex() == 0: if self.ui.tabMain.currentIndex() == 0:
# Force update of 2nd tab # Force update of 2nd tab


Loading…
Cancel
Save