Set new media as active (#1191)

This commit is contained in:
Benedikt Werner 2021-05-06 17:17:30 +02:00 committed by GitHub
parent 410cffe832
commit 249a3180f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -326,6 +326,7 @@ class EditMedia(EditPrimary):
with DbTxn(_("Add Media Object (%s)") % self.obj.get_description(),
self.db) as trans:
self.db.add_media(self.obj, trans)
self.uistate.set_active(self.obj.handle, "Media")
else:
if self.data_has_changed():
with DbTxn(_("Edit Media Object (%s)") % self.obj.get_description(),

View File

@ -169,7 +169,10 @@ class MediaView(ListView):
"""
if not sel_data:
return
files = sel_data.get_uris()
photo = None
for file in files:
protocol, site, mfile, j, k, l = urlparse(file)
if protocol == "file":
@ -191,6 +194,10 @@ class MediaView(ListView):
photo.set_description(root)
with DbTxn(_("Drag Media Object"), self.dbstate.db) as trans:
self.dbstate.db.add_media(photo, trans)
if photo:
self.uistate.set_active(photo.handle, "Media")
widget.emit_stop_by_name('drag_data_received')
def define_actions(self):