From fda6a4059d2fe013973fddbafc0d7e10c5817039 Mon Sep 17 00:00:00 2001 From: oop7 <110548351+oop7@users.noreply.github.com> Date: Thu, 9 Apr 2026 18:26:57 +0200 Subject: [PATCH] Add concurrent connections setting to dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a "Concurrent Connections" section to DownloadSettingsDialog with a QComboBox (1–20) and help text; initialize from ConfigManager("concurrent_fragments"). Introduce get_concurrent_fragments() to return the chosen value (with a safe fallback to 1) and persist the setting on dialog accept. Uses localized labels and minor styling for the help label. --- .../ytsage_dialogs_settings.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/ytsage/gui/ytsage_gui_dialogs/ytsage_dialogs_settings.py b/ytsage/gui/ytsage_gui_dialogs/ytsage_dialogs_settings.py index 0c3f9aa..23294c3 100644 --- a/ytsage/gui/ytsage_gui_dialogs/ytsage_dialogs_settings.py +++ b/ytsage/gui/ytsage_gui_dialogs/ytsage_dialogs_settings.py @@ -229,6 +229,28 @@ class DownloadSettingsDialog(QDialog): speed_group_box.setLayout(speed_layout) general_layout.addWidget(speed_group_box) + # --- Connections Section --- + connections_group_box = QGroupBox(_("settings.concurrent_fragments", default="Concurrent Connections")) + connections_layout = QVBoxLayout() + + self.connections_enabled = ConfigManager.get("concurrent_fragments") or 1 + + connections_spin_layout = QHBoxLayout() + self.connections_input = QComboBox() + self.connections_input.addItems([str(i) for i in range(1, 21)]) + self.connections_input.setCurrentText(str(self.connections_enabled)) + connections_spin_layout.addWidget(self.connections_input) + connections_spin_layout.addStretch() + connections_layout.addLayout(connections_spin_layout) + + connections_help_label = QLabel(_("settings.concurrent_fragments_help", default="Number of connections per download. Higher values bypass throttling but may cause temporary blocks if set too high. Default: 1.")) + connections_help_label.setWordWrap(True) + connections_help_label.setStyleSheet("color: #cccccc; margin: 5px; font-size: 11px;") + connections_layout.addWidget(connections_help_label) + + connections_group_box.setLayout(connections_layout) + general_layout.addWidget(connections_group_box) + # --- Generic Mode Section --- generic_mode_group_box = QGroupBox(_("settings.generic_mode")) generic_mode_layout = QVBoxLayout() @@ -474,6 +496,13 @@ class DownloadSettingsDialog(QDialog): """Returns whether generic mode is enabled.""" return self.generic_mode_checkbox.isChecked() + def get_concurrent_fragments(self) -> int: + """Returns the number of concurrent fragments.""" + try: + return int(self.connections_input.currentText()) + except ValueError: + return 1 + def get_preferred_format(self) -> str: """Returns the selected preferred format (lowercase).""" format_map = {0: "mp4", 1: "webm", 2: "mkv"} @@ -535,6 +564,7 @@ class DownloadSettingsDialog(QDialog): """Override accept to save format settings.""" try: ConfigManager.set("generic_mode", self.get_generic_mode_enabled()) + ConfigManager.set("concurrent_fragments", self.get_concurrent_fragments()) # Save output format settings force_format = self.get_force_format_enabled()