Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6295 #6320

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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