Implement drag-and-drop support for installing APKX-packaged add-ons
This commit is contained in:
parent
4a21c2013f
commit
cc0dc812ad
@ -348,9 +348,27 @@ class AddonsDialog(QDialog):
|
|||||||
f.delete_2.clicked.connect(self.onDelete)
|
f.delete_2.clicked.connect(self.onDelete)
|
||||||
f.config.clicked.connect(self.onConfig)
|
f.config.clicked.connect(self.onConfig)
|
||||||
self.form.addonList.currentRowChanged.connect(self._onAddonItemSelected)
|
self.form.addonList.currentRowChanged.connect(self._onAddonItemSelected)
|
||||||
|
self.setAcceptDrops(True)
|
||||||
self.redrawAddons()
|
self.redrawAddons()
|
||||||
self.show()
|
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):
|
def redrawAddons(self):
|
||||||
self.addons = [(self.annotatedName(d), d) for d in self.mgr.allAddons()]
|
self.addons = [(self.annotatedName(d), d) for d in self.mgr.allAddons()]
|
||||||
self.addons.sort()
|
self.addons.sort()
|
||||||
|
Loading…
Reference in New Issue
Block a user