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 setting to remember download columns width #8020

Merged
merged 1 commit into from
May 8, 2024
Merged
Show file tree
Hide file tree
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/qt_resources/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,30 @@ color: white;margin-top:10px;</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QLabel" name="label_7">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">font-weight: bold;
color: white;margin-top:10px;</string>
</property>
<property name="text">
<string>Downloads table</string>
</property>
</widget>
</item>
<item row="18" column="0">
<widget class="QCheckBox" name="downloads_header_state_checkbox">
<property name="text">
<string>Remember header state (keeps columns width and order)</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="settings_connection_tab">
Expand Down
21 changes: 16 additions & 5 deletions src/tribler/gui/widgets/downloadspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,37 @@ 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()
self.window().download_details_widget.hide()

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()
Expand Down
8 changes: 8 additions & 0 deletions src/tribler/gui/widgets/settingspage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

Expand Down Expand Up @@ -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"))

Expand Down