Skip to content

Commit

Permalink
Add a way to hide columns in the download table
Browse files Browse the repository at this point in the history
Co-Authored-By: Alexander Kozlovsky <[email protected]>
  • Loading branch information
heldersepu and kozlovsky committed May 15, 2024
1 parent ee87d25 commit 7e69e3b
Showing 1 changed file with 24 additions and 0 deletions.
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

0 comments on commit 7e69e3b

Please sign in to comment.