Skip to content

Commit

Permalink
Merge pull request #6320 from ichorid/fix_6295
Browse files Browse the repository at this point in the history
Fix #6295
  • Loading branch information
ichorid authored Sep 17, 2021
2 parents 8786994 + a74f300 commit ae9b8cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/tribler-gui/tribler_gui/widgets/downloadspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from PyQt5.QtCore import QTimer, QUrl, Qt, pyqtSignal
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtNetwork import QNetworkRequest
from PyQt5.QtWidgets import QAbstractItemView, QAction, QFileDialog, QTreeWidgetItem, QWidget
from PyQt5.QtWidgets import QAbstractItemView, QAction, QFileDialog, QWidget

from tribler_common.sentry_reporter.sentry_mixin import AddBreadcrumbOnShowMixin

Expand All @@ -30,7 +30,7 @@
from tribler_gui.tribler_action_menu import TriblerActionMenu
from tribler_gui.tribler_request_manager import TriblerFileDownloadRequest, TriblerNetworkRequest
from tribler_gui.utilities import compose_magnetlink, connect, format_speed, tr
from tribler_gui.widgets.downloadwidgetitem import DownloadWidgetItem
from tribler_gui.widgets.downloadwidgetitem import DownloadWidgetItem, LoadingDownloadWidgetItem
from tribler_gui.widgets.loading_list_item import LoadingListItem

button_name2filter = {
Expand All @@ -42,6 +42,7 @@
"downloads_channels_button": DOWNLOADS_FILTER_CHANNELS,
}


# pylint: disable=too-many-instance-attributes, too-many-public-methods
class DownloadsPage(AddBreadcrumbOnShowMixin, QWidget):
"""
Expand Down Expand Up @@ -108,7 +109,7 @@ def on_filter_text_changed(self, text):

def start_loading_downloads(self):
self.window().downloads_list.setSelectionMode(QAbstractItemView.NoSelection)
self.loading_message_widget = QTreeWidgetItem()
self.loading_message_widget = LoadingDownloadWidgetItem()
self.window().downloads_list.addTopLevelItem(self.loading_message_widget)
self.window().downloads_list.setItemWidget(
self.loading_message_widget, 2, LoadingListItem(self.window().downloads_list)
Expand Down Expand Up @@ -483,7 +484,7 @@ def on_add_button_pressed(channel_id):

def on_right_click_item(self, pos):
item_clicked = self.window().downloads_list.itemAt(pos)
if not item_clicked or self.selected_items is None:
if not item_clicked or not self.selected_items:
return

if item_clicked not in self.selected_items:
Expand Down
14 changes: 14 additions & 0 deletions src/tribler-gui/tribler_gui/widgets/downloadwidgetitem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging
from datetime import datetime

from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QProgressBar, QTreeWidgetItem, QVBoxLayout, QWidget

from tribler_common.simpledefs import dlstatus_strings
Expand All @@ -9,6 +10,19 @@
from tribler_gui.utilities import duration_to_string, format_size, format_speed


class LoadingDownloadWidgetItem(QTreeWidgetItem):
"""
This class is used for the placeholder "Loading" item for the downloads list
"""

def __init__(self):
QTreeWidgetItem.__init__(self)
self.setFlags(Qt.NoItemFlags)

def get_raw_download_status(self):
return "PLACEHOLDER"


class DownloadWidgetItem(QTreeWidgetItem):
"""
This class is responsible for managing the item in the downloads list and fills the item with the relevant data.
Expand Down

0 comments on commit ae9b8cd

Please sign in to comment.