diff --git a/src/tribler/gui/qt_resources/mainwindow.ui b/src/tribler/gui/qt_resources/mainwindow.ui
index 39b9528e6cd..94c589b4b19 100644
--- a/src/tribler/gui/qt_resources/mainwindow.ui
+++ b/src/tribler/gui/qt_resources/mainwindow.ui
@@ -1380,6 +1380,30 @@ color: white;margin-top:10px;
+ -
+
+
+
+ 75
+ true
+
+
+
+ font-weight: bold;
+color: white;margin-top:10px;
+
+
+ Downloads table
+
+
+
+ -
+
+
+ Remember header state (keeps columns width and order)
+
+
+
diff --git a/src/tribler/gui/widgets/downloadspage.py b/src/tribler/gui/widgets/downloadspage.py
index 98ff0499610..85871c96d40 100644
--- a/src/tribler/gui/widgets/downloadspage.py
+++ b/src/tribler/gui/widgets/downloadspage.py
@@ -85,13 +85,12 @@ def hideEvent(self, QHideEvent):
def initialize_downloads_page(self):
self.window().downloads_tab.initialize()
connect(self.window().downloads_tab.clicked_tab_button, self.on_downloads_tab_button_clicked)
-
connect(self.window().start_download_button.clicked, self.on_start_download_clicked)
connect(self.window().stop_download_button.clicked, self.on_stop_download_clicked)
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)
connect(self.window().downloads_list.itemSelectionChanged, self.on_selection_change)
-
connect(self.window().downloads_list.customContextMenuRequested, self.on_right_click_item)
self.window().download_details_widget.initialize_details_widget()
@@ -99,12 +98,24 @@ def initialize_downloads_page(self):
connect(self.window().downloads_filter_input.textChanged, self.on_filter_text_changed)
- self.window().downloads_list.header().setSortIndicator(12, Qt.AscendingOrder)
- self.window().downloads_list.header().resizeSection(12, 146)
+ state = self.window().gui_settings.value("downloads_header_state", None)
+ if state is None:
+ self.window().downloads_list.header().resizeSection(12, 146)
+ self.window().downloads_list.header().setSortIndicator(12, Qt.AscendingOrder)
+ else:
+ self.window().downloads_list.header().restoreState(state)
self.background_refresh_downloads_timer.setSingleShot(True)
connect(self.background_refresh_downloads_timer.timeout, self.on_background_refresh_downloads_timer)
+ def on_header_change(self, *args, **kwargs):
+ gui_settings = self.window().gui_settings
+ if gui_settings.value("downloads_header_state", None) is not None:
+ gui_settings.setValue(
+ "downloads_header_state",
+ self.window().downloads_list.header().saveState()
+ )
+
def on_filter_text_changed(self, text):
self.window().downloads_list.clearSelection()
self.window().download_details_widget.hide()
diff --git a/src/tribler/gui/widgets/settingspage.py b/src/tribler/gui/widgets/settingspage.py
index 11e617987dd..8b67c1b9b65 100644
--- a/src/tribler/gui/widgets/settingspage.py
+++ b/src/tribler/gui/widgets/settingspage.py
@@ -180,6 +180,10 @@ def initialize_with_settings(self, settings):
get_gui_setting(gui_settings, "disable_tags", True, is_bool=True)
)
+ # The header state of the downloads table
+ if gui_settings.value("downloads_header_state", None) is not None:
+ self.window().downloads_header_state_checkbox.setChecked(True)
+
# Log directory
self.window().log_location_input.setText(settings['general']['log_dir'])
@@ -508,6 +512,10 @@ def on_settings_saved(self, data):
gui_settings.setValue("ask_download_settings", self.window().always_ask_location_checkbox.isChecked())
gui_settings.setValue("use_monochrome_icon", self.window().use_monochrome_icon_checkbox.isChecked())
gui_settings.setValue("minimize_to_tray", self.window().minimize_to_tray_checkbox.isChecked())
+ if self.window().downloads_header_state_checkbox.isChecked():
+ gui_settings.setValue("downloads_header_state", self.window().downloads_list.header().saveState())
+ else:
+ gui_settings.remove("downloads_header_state")
self.save_language_selection()
self.window().tray_show_message(tr("Tribler settings"), tr("Settings saved"))