diff --git a/qutebrowser/browser/downloadview.py b/qutebrowser/browser/downloadview.py index d595fd740..a25ddf0f9 100644 --- a/qutebrowser/browser/downloadview.py +++ b/qutebrowser/browser/downloadview.py @@ -93,6 +93,7 @@ class DownloadView(QListView): self.setWrapping(True) self.setContextMenuPolicy(Qt.CustomContextMenu) self.customContextMenuRequested.connect(self.show_context_menu) + self.clicked.connect(self.on_clicked) def __repr__(self): model = self.model() @@ -102,6 +103,20 @@ class DownloadView(QListView): count = model.rowCount() return utils.get_repr(self, count=count) + @pyqtSlot('QModelIndex') + def on_clicked(self, index): + """Handle clicking of an item. + + Args: + index: The QModelIndex of the clicked item. + """ + if not index.isValid(): + return + item = self.model().data(index, downloads.ModelRole.item) + if item.done: + item.open_file() + self.model().remove_item(item) + @pyqtSlot('QPoint') def show_context_menu(self, point): """Show the context menu."""