Implement drag-and-drop support for installing APKX-packaged add-ons

This commit is contained in:
Glutanimate 2019-02-18 07:17:53 +01:00
parent 4a21c2013f
commit cc0dc812ad

View File

@ -348,9 +348,27 @@ class AddonsDialog(QDialog):
f.delete_2.clicked.connect(self.onDelete)
f.config.clicked.connect(self.onConfig)
self.form.addonList.currentRowChanged.connect(self._onAddonItemSelected)
self.setAcceptDrops(True)
self.redrawAddons()
self.show()
def dragEnterEvent(self, event):
mime = event.mimeData()
if not mime.hasUrls():
return None
urls = mime.urls()
if all(url.toLocalFile().endswith(".apkx") for url in urls):
event.acceptProposedAction()
def dropEvent(self, event):
mime = event.mimeData()
paths = []
for url in mime.urls():
path = url.toLocalFile()
if os.path.exists(path):
paths.append(path)
self.onInstallFiles(paths)
def redrawAddons(self):
self.addons = [(self.annotatedName(d), d) for d in self.mgr.allAddons()]
self.addons.sort()