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

Add a way to hide columns in the download table #8025

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
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
24 changes: 24 additions & 0 deletions src/tribler/gui/widgets/downloadspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ def initialize_downloads_page(self):
connect(self.window().remove_download_button.clicked, self.on_remove_download_clicked)
connect(self.window().downloads_list.header().sectionResized, self.on_header_change)
connect(self.window().downloads_list.header().sortIndicatorChanged, self.on_header_change)
self.window().downloads_list.header().setContextMenuPolicy(Qt.CustomContextMenu)
connect(self.window().downloads_list.header().customContextMenuRequested, self.on_header_right_click_item)
connect(self.window().downloads_list.itemSelectionChanged, self.on_selection_change)
connect(self.window().downloads_list.customContextMenuRequested, self.on_right_click_item)

Expand Down Expand Up @@ -549,6 +551,28 @@ def on_export_download_request_done(self, filename, data):
tr("Torrent file exported"), tr("Torrent file exported to %s") % str(dest_path)
)

def show_all_headers(self, _=None):
for i in range(self.window().downloads_list.header().count()):
self.window().downloads_list.header().showSection(i)

def on_header_right_click_item(self, pos):
index = self.window().downloads_list.header().logicalIndexAt(pos)

menu = TriblerActionMenu(self)
if index > 0: # Do not show hide action on first column
hide_action = QAction(tr("Hide Column"), self)
connect(
hide_action.triggered,
lambda _: self.window().downloads_list.header().hideSection(index)
)
menu.addAction(hide_action)

restore_action = QAction(tr("Restore All"), self)
connect(restore_action.triggered, self.show_all_headers)
menu.addAction(restore_action)

menu.exec_(self.window().downloads_list.mapToGlobal(pos))

def on_right_click_item(self, pos):
item_clicked = self.window().downloads_list.itemAt(pos)
if not item_clicked or not self.selected_items:
Expand Down