parent
888a17b7c3
commit
e0271eff34
@ -93,6 +93,7 @@ class DownloadView(QListView):
|
|||||||
self.setWrapping(True)
|
self.setWrapping(True)
|
||||||
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
self.setContextMenuPolicy(Qt.CustomContextMenu)
|
||||||
self.customContextMenuRequested.connect(self.show_context_menu)
|
self.customContextMenuRequested.connect(self.show_context_menu)
|
||||||
|
self.clicked.connect(self.on_clicked)
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
model = self.model()
|
model = self.model()
|
||||||
@ -102,6 +103,20 @@ class DownloadView(QListView):
|
|||||||
count = model.rowCount()
|
count = model.rowCount()
|
||||||
return utils.get_repr(self, count=count)
|
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')
|
@pyqtSlot('QPoint')
|
||||||
def show_context_menu(self, point):
|
def show_context_menu(self, point):
|
||||||
"""Show the context menu."""
|
"""Show the context menu."""
|
||||||
|
Loading…
Reference in New Issue
Block a user