This PR adds the ability to direct modify a tracker's tier from the WebUI. This process is notably different than the GUI, which provides arrows for increasing/decreasing a tracker's tier.
Closes#12233.
PR #22963.
Implemented: Tracker endpoints in the list, missing "Tracker Error" and "Unreachable" status, "Next Announce" and "Min Announce" column and double click to edit tracker url.
PR #23045.
This PR uses the new APIs from #21015 to provide a WebUI Add Torrent experience more closely matching the GUI's.
New functionality:
- View torrent size, date, infohash, files, etc.
- Reprioritize and ignore files before adding
- Specify tags when adding torrent
- Specify save path for incomplete torrent
Closes#20557, closes#10997, closes#12499, closes#14201, closes#15071, closes#15718, closes#16207.
PR #21645.
The methods for checking if qBittorrent is set as the standard application for opening torrent files and magnet links and setting qBittorrent as the standard application for those is using deprecated methods now. For example `LSCopyDefaultHandlerForURLScheme` and `kUTTagClassFilenameExtension`.
The new methods have been moved to `macutilities.mm` because in `os.cpp` cocoa couldn't be imported.
PR #23059.
Currently the hardened runtime is enabled for code signing in the github workflow for macOS. However in this thread https://github.com/qbittorrent/qBittorrent/discussions/23041#discussioncomment-13969415 a user had a problem to open the nightly builds from github. Relevant part of the error:
```
Reason: tried: '/private/var/folders/y0/jmsflc717tn_tj2x9d1g3d9w0000gn/T/AppTranslocation/8B53E367-2E0C-42C1-A4D5-6787109EE46E/d/qbittorrent.app/Contents/Frameworks/QtWidgets.framework/Versions/A/QtWidgets' (code signature in '/private/var/folders/y0/jmsflc717tn_tj2x9d1g3d9w0000gn/T/AppTranslocation/8B53E367-2E0C-42C1-A4D5-6787109EE46E/d/qbittorrent.app/Contents/Frameworks/QtWidgets.framework/Versions/A/QtWidgets' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/private/var/folders/y0/jmsflc717tn_tj2x9d1g3d9w0000gn/T/AppTranslocation/8B53E367-2E0C-42C1-A4D5-6787109EE46E/d/qbittorrent.app/Contents/Frameworks/QtWidgets.framework/Versions/
(terminated at launch; ignore backtrace)
```
Further investigation showed that when disabling the hardened runtime this won't occur any more. I haven't noticed this before because the error wouldn't occur when SIP (system integrity protection) is disabled and I have it disabled now.
PR #23058.
Currently `NSUserNotifications API` is used on MacOS to display notifications. However this is marked as deprecated and should be replaced with `UserNotifications.frameworks API`. With the new API it is required to ask for permission before notifications can be send. The program will ask for permission to send notifications on the start.
Related: #15630.
PR #23019.
The following message appears when using the outdated value:
>[@stylistic/eslint-plugin]: You are using deprecated value(boolean) for "allowTemplateLiterals"
>in "quotes", please use "always"/"never" instead.
Also prefer using double quotes over backticks for strings.
PR #23038.
Now when user specified 'help' or 'version' flag, the program will process them first and
ignore all other flags (even invalid flags).
This improves program usability since user will be able to consult the help description without
ensuring existing flags are all valid (or removing all flags). And user can refine the flags
after reading the help description.
PR #23037.
Currently `iconForFileType` is used on macOS to display the file icons in the content tab. However this is marked as deprecated and should be replaced with `iconForContentType`.
Related #15630.
PR #22992.
Currently when you delete or move a torrent sometimes an empty folder will stay. This is because hidden files will stay which didn't got deleted.
The reason that it is not working is that QDir::Files is used which doesn't lists hidden files. Adding QDir::Hidden will make the code work as expected. At least on Windows and macOS QDir::Files doesn't lists hidden files. I can't test on linux.
PR #22983.
When a category's download path option is set to "Default", its `downloadPath` is serialized into JSON as `undefined`. This results in the `downloadPath` field being omitted from `torrents/categories` and `torrents/maindata` payloads (as is expected with an `undefined` value).
The use of `undefined` here causes an issue in the WebUI. Specifically, when the category previously contained a value for this field (i.e. download path option set to either "Yes" or "No"), the `processMap` logic in `SyncController` does not detect the removal this field. This results in the category's new `downloadPath` not being properly sent to the client. By switching from `undefined` to `null`, we ensure that the `downloadPath` value is always included in the category's payload. This allows `processMap` to properly detect whenever the value changes.
This change is backwards compatible with existing categories.json files. Older qBittorrent versions should also be able to parse new categories.json files containing `null`.
More context: https://github.com/qbittorrent/qBittorrent/pull/22938/commits/cd3fbfbf9b63a42f1d4d9d48d0c2d20a5c1a4b28#r2173148696
PR #22958.
This change makes the WebUI easier to use on small screens (e.g. mobile). In cases where the window's default size is larger than the user's screen, the window will be resized appropriate (see example below). Every window has been tested for compatibility. The only windows that don't support this are the multi file rename window and the RSS Downloader window.
Closes#19813.
PR #22919.
This change better handles resizing of elements on the search page to ensure no controls are hidden at typical mobile screen sizes.
Improvements seen below:
- "Search" button is now accessible
- Content no longer overflows w/ "Search plugins..." button pushed offscreen
- Tabs overflow horizontally and are scrollable, rather than pushing down the search results table
PR #22916.
The toolbar should be hidden when not on the "Transfers" tab. The hiding of this toolbar can result in resizing the panels, especially on mobile, so we should recompute panel heights.
PR #22915.
Previously, the tabs would overflow to the next line, often being hidden by other content. For example, the "Content" tab is now accessible on mobile.
PR #22914.
`m_torrentMetadataCache` previously used a torrent's InfoHash as its key. However, InfoHashes for hybrid torrents cannot be serialized and deserialized via their TorrentID (e.g. `InfoHash(TorrentID(infoHash.toTorrentID().toString())) != infoHash`). This is due to hybrid InfoHashes containing both a v1 and v2 hash, while the serialized TorrentID only contains a single truncated v2 hash. Thus we cannot expect an InfoHash serialized by its TorrentID to be able to construct an equivalent InfoHash. By switching to the TorrentID, we always have a single ID to use.
Follow up #21015.
PR #22926.
This brings a fallback version check to the update mechanism,
which should be as stable as it can be.
It will allow migrating to another primary mechanism without
having to have updated the older primary mechanism too.
Hacked qbt instances may contain malicious script placed in Run External Program and the script
will attempt to hide itself by adding a lot whitespaces at the start of the command string.
Users may mistake the field of being empty but is actually not.
So trim the leading whitespaces to easily expose the malicious script.
Note that GUI already trim the fields and only WebAPI doesn't trim them. This patch will unify
the behavior.
Related: https://github.com/qbittorrent/docker-qbittorrent-nox/issues/71#issuecomment-2993567440
PR #22939.
* WebUI: use defer when loading scripts
So that the HTML layout can be rendered earlier.
* WebUI: move scripts into <head> section
For consistency reasons.
This change drastically improves the performance of changing a table's sorted column. This performance is achieved through improved data structures, namely removing operations that repeatedly spliced an array. We also no longer iterate over a potentially large array.
On a torrent with ~50,000 files, re-rendering after a sort improves from ~20 seconds to 2 seconds.
PR #22827.
When double clicking on a filter, all other filters will be reset. For example, double clicking on a status filter will reset the categories, tags, and trackers filters to "All". This behavior can be disabled in WebUI options.
Closes#22449.
PR #22818.
This change ensures that the WebUI caches relevant server stats for immediate display once the statistics window is opened. Previously, all stats would remain blank until maindata was fetched. This could take a while if e.g. the user was on the search tab.
Closes#22764.
PR #22817.
The Language option now has its own layout since it is independent to other options (Style and Color scheme).
This avoids text in Language combobox to be left out and replaced by `...` due to Style Hint text being too long.
PR #22823.
## Description
Send file/folder metadata instead of just the name of a filesystem entry.
Currently the endpoint only sends a list of string, containing the path of each entry, without specifying its type (file or folder).
The optional `withMetadata` flag has been added to provide metadata and to prevent breaking changes with older versions.
If `true`, JSON response will be an array of objects instead of an array of strings.
This object contains:
- `name`: the name of the file system entry (without path)
- `type`: Whether the file system entry is a "file" or a "dir"
- `creation_date`: file system entry's creation date
- `last_access_date`: file system entry's last access date
- `last_modification_date`: file system entry's last modification date
If the entry is a file, a `size` field is present with the file size in bytes.
## Objective
Build a server file browser inside WebUIs, feature is currently being developed for VueTorrent.
It will include file metadata, filtering and sorting on the different fields.
PR #22813.
In #22567, I made it so the web UI wouldn't refresh the main data while the page is hidden. This causes the session to time out (after 1 hour by default).
This PR changes that to instead refresh every Preferences/WebUI/SessionTimeout / 2 instead of not at all, which should keep the session alive.
PR #22804.
See #22734, there is a memory leak in the MooTools .destroy(), this replaces all uses of that with the browser native .remove().
This also overrides the MooTools Document.id function, which is used by $(id). The original function always allocates an ID to elements it selects, the override doesn't, and is also a little more efficient.
Closes#22734.
PR #22754.
---------
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Now it checks for all python installations and related procedures has been revised.
If the python version does not meet the minimum requirement, it will be logged.
PR #22729.
This PR improves the user experience on mobile devices by ensuring the username field in the login form does not automatically capitalize the first letter when the keyboard opens.
Mobile browsers tend to automatically capitalize the first letter of text inputs, which can lead to login failures if the username is case-sensitive. By explicitly disabling autocapitalization, the WebUI ensures a more predictable and user-friendly experience on mobile devices.
Tested on:
iOS (Safari)
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
PR #22725.
Before the release of 5.1.0 I believe these two fields both used monospace fonts and also had an increased font size, maybe 14px (I couldn't find in blame where/how this regressed). Ideally, I'd like to bring this back, as it makes elaborate regexes easier to grok. This PR currently just tells the browser to use its monospace font, but I could also add a similar in-line style for font size. I just don't know if this is the best way to solve this problem; if there's a better place for this sort of styling to happen let me know
PR #22719.
For windows environment the `--help` output will show :
```
set QBT_NO_SPLASH=1
C:\Program Files\qBittorrent\qbittorrent.exe
```
instead of
```
QBT_NO_SPLASH=1 C:\Program Files\qBittorrent\qbittorrent.exe
```
Fixes#22662.
PR #22695.
Memory working set limit is not effective on Linux at all. See [`getrlimit(2)`](https://man7.org/linux/man-pages/man2/getrlimit.2.html) → `RLIMIT_RSS`.
Introduced in #16874, disabled for macOS in #19805. This PR hides the option for Linux too.
Worth to mention that #19805 did not deliver the change for WebUI. So there is also a small fixup, I covered both cases.
Also removed pointless "This option is less effective on Linux" remark.
PR #22680.
Mootools is no longer used to create PiecesBar class (+ I cleaned it up a bit and turned into custom element but everything should work as before).
PR #22670.
Making General-tab text `unselectable` is not an improvement.
It begs to add a new `Copy -> Save path` feature, because using `Set location` to copy save path (*which requires a request*) is not faster than simply copying it from the `General` tab by double-left clicking and pressing `CTRL+C`.
I don't see a reason why its necessary to software-restrict people from copying details from the `General`-tab - there are several reasons why you would - incl. the above mentioned usecase for quickly copying save-path, but other than that its counterproductive to limit people from copying the details displayed.
PR #22663.
Convenience feature in the "Rename Files" menu in the WebUI.
If you click one file's checkbox, and then click another with Shift held, all the checkboxes between those two will be selected/unselected based on the state of the first checkbox.
It's based on what the Windows file explorer does when holding Ctrl and Shift
Closes#22455.
PR #22610.
Makes asynchronous logic to look more straightforward.
Allows caller to choose blocking or non-blocking way of obtaining asynchronous results via the same interface.
PR #22598.
Deferring the opening of the preview slightly gives the preview select
dialog time to close and for focus to shift back to the main window.
PR #22608.
Closes#22607.
---------
Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
Currently, there is unnecessary CPU/network usage by the web UI when it's running in the background, this PR prevents it from refreshing in the background.
Closes#22565.
PR #22567.
Adding virtual list support to dynamic tables to improve performance on large lists, I observed a 100x performance improvement on rendering on a torrent table with 5000 torrents.
This optimization is disabled by default and can be enabled in options.
PR #22502.
Add clamping for seeding and inactive seeding time limit on setting from dialog and loading from config.
Closes#21953.
PR #22558.
Signed-off-by: Kostiantyn <kos.chernenok@gmail.com>
Swap "Add torrent file" with "Add torrent link" button to be consistent with order in File menu.
Closes#22420.
PR #22557.
Signed-off-by: Kostiantyn <kos.chernenok@gmail.com>
Previously it require each plugin to import helpers.py to setup SOCKS proxy.
Now it is enforced by default for all plugins.
Also added a function for plugins to ignore/restore the socket to
default state.
PR #22554.
Pass 'Perform hostname lookup via proxy' setting along the way.
Also add underline to variables and functions that are private to the python module.
PR #22510.
Introduced Author, 'Open link' headers.
Note that the Author and 'Open link' are not mandatory fields in RSS/Atom feeds. So these
headers will only be displayed when the feed includes them.
PR #22503.
Fixup for #21145
To reproduce:
1. Select status filter with 0 torrents
2. Enable 'Auto hide zero status filters' and save settings. Hidden filter is still selected:
PR #22487.
Some people are still unhappy with "standalone window mode" of "Add new torrent dialog" so just provide them with an option to use old "modal dialog mode" in all the current qBittorrent branches.
PR #22492 (based on original PR #19874).
The affected options are not really incompatible with SOCKS4 but it is due to Qt missing
implementation. Therefore 'unavailable' is more suitable.
PR #22483.
Now the behavior is more intuitive for a few options when the client send in partial settings.
This change is backward compatible.
For example, now it is possible to have only one of `max_ratio_enabled` or `max_ratio` instead
of requiring both.
PR #22460.
1. Utilize string matcher
2. Remove split behavior parameter
Previously `KeepEmptyParts` behavior doesn't match Qt's
implementation and since our codebase doesn't really make use of it,
we can just remove the parameter.
3. Add tests.
PR #22352.
In Trackers table, moving the 'URL' column from its default (2) position caused the 'Tracker editing' dialog to display incorrect data.
Steps to reproduce:
1. Move 'URL' column in Trackers table to any position from default
2. Choose tracker URL and click 'Edit tracker URL'
PR #22338.
We can only edit one URL through the dialog, so there's no point in showing this context option when more than one tracker is selected in trackers table.
PR #22311.
This PR fixes a bug where the sort icon did not update correctly after reordering columns.
Steps to reproduce:
1. Sort a column
2. Move it to a different position
3. The sort icon remains in its original location
PR #22299.
The `round()` returning floating point number is not a good idea. This is due to floating point
representation is imprecise and sometimes it cannot faithfully represent a number, for example
`0.09 + 0.01 !== 0.1 `. Therefore, it should be avoided and/or utilize other function
to achieve the goal.
Also, improve `window.qBittorrent.Misc.toFixedPointString()` and add test cases.
PR #22281.
This PR fixes a memory leak in context menus. Previously, for some reason, each menu retained references to its target elements without utilizing them further. Since the targets property was accessible/reachable from the root (window object), these references persisted even after the elements were removed from the DOM, preventing them from being garbage collected.
It's easily reproducible - just add a decent amount of torrents, switch between categories multiple times, then capture heap/detached elements snapshot in the Memory tab (Chrome dev tools). The number of detached elements will continue to increase after each category switch and they won't be cleaned up.
[More context](https://github.com/qbittorrent/qBittorrent/pull/22220/files#r1941137796)
PR #22234.
The `announce_port` setting permits to overwrite the port passed along to trackers as the `&port=` parameter. If left as the default, the listening port is used. This setting is only meant for very special cases where a seed's listening port differs from the effectively exposed port (e.g., through external NAT-PMP). See https://github.com/arvidn/libtorrent/pull/7771 for an example use-case.
This PR adds the relevant setting alongside the existing `announce_ip` setting.
PR #21692.
From https://stylelint.io/user-guide/configure :
>Stylelint currently supports other configuration locations and formats, but we may remove these
>in the future:
>...
>.stylelintrc.json file
This is another optimization for torrent management on large scale instances with the goal to minimize the amount of required API calls. Ref #22128.
This new function and endpoint torrents/setTags does an upsert to replace the torrent tags and handles the removal and add internally, instead of doing multiple calls to add and remove tags on torrents from the client.
PR #22156.
---------
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
This PR adds an optional parameter includeTrackers to the Torrent info endpoint /torrents/info to include the trackers list of each torrent in the response under the key trackers.
PR #22128.
Current URL seed error message assumes that only possible error is DNS lookup failure, which is not true.
So replace it with a more generic message. Real reason is provided by the 'Error:' part.
PR #22119.
Trackers specified at the URL will be added to newly added public torrents.
This feature is adapted from qBittorrent-Enhanced-Edition to allow for automatically adding trackers retrieved from a URL. @ngosang's trackerlist repo is a good example, however I've opted not to include a default URL.
Partially addresses #14535.
PR #21828.
Changing input type from text to search for all search and filter inputs
to enable user to easily clear input.
This feature is yet to be implemented in Firefox.
See tracking bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1654288
Also fix search icon horizontal positioning and minor input box paddings.
Closes#15481.
PR #22033.
Now all items under `QGridLayout` are required to be sorted. This allow
us to omit tabstop order. The tabstop order will follow the layout order.
The script can be invoked to fix wrong grid items order in .ui files:
```console
python check_grid_items_order.py file.ui
```
Now on Windows, it won't follow/include .lnk files when creating torrents.
Note that libtorrent will throw errors if we force adding .lnk files.
Non-Windows OS will still follow symlinks.
Closes#13286.
PR #21944.
The `Content-type` header isn't required since `URLSearchParams` is present.
The `method` property is preferred to be always specified for clarity.
The `cache: "no-store"` is preferred for most GET requests to avoid caching.
PR #21891.
Previously we would still download the file but it would contain the error response, resulting in an invalid file.
To test: export a .torrent file for a torrent that hasn't yet downloaded metadata
PR #21696.
Signed-off-by: Thomas Piccirello <thomas@piccirello.com>
The speed icons in the status bar look weird. Whenever I look at them, there seems to be something off with them. The circle seems to have been stretched. Also, the gap between the needle and the circle is not big enough to be clearly visible (at least on my display).
PR #21853.
Event delegation is now used to handle basic table events.
2 minor fixes were added to match GUI behavior:
* Clicking on the table body deselects everything
* Table rows are now scrolled into view when using up/down arrows
PR #21829.
`TorrentImpl::isDownloading()` was excessively broad which included unexpected events for the
case here. So use the underlying state directly.
Closes#21788.
PR #21836.
Fixes bug where the first time visiting Execution Log view all log levels are deselected but log items with all levels are still displayed.
This requires you to select a log level and then deselect it to hide that log level.
PR #21812.
Thin scrollbars are now used if they are supported by user's browser. The main goal was to make them less intrusive in Chrome-likes on some platforms.
PR #21763.
---------
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
LocalPreferences class is now created using modern class syntax (minimal changes to remove Mootools bits). In addition, I removed redundant suffix from class name.
PR #21780.
This change displays the last detected IPv4 and/or IPv6 address(es) in the GUI and WebUI's status bar. This does not yet handle systems with multiple addresses of the same type (e.g. multiple IPv6 addresses).
PR #21383.
---------
Co-authored-by: Odin Vex <44311901+OdinVex@users.noreply.github.com>
There may be quite a few endpoint names (one for each available network card), and they usually remain unchanged throughout the session, while previously producing such names was performed every time they were accessed. Now they are retrieved from the cache.
PR #21770.
Those are the `default` cases which are not expected to hit (nor reachable) normally.
When the code is compiled with release mode and it reaches `Q_UNREACHABLE()`, it becomes
undefined behavior. So it rely on the developers to catch the errors in debug mode.
The upside of this is that the `switch` statement will be more optimized than not using it.
This also means the statements after `Q_UNREACHABLE()` isn't important. It allow anything to
preserve the intention of the code.
This macro is preferred over C++23 `std::unreachable` because it will automatically insert a
`Q_ASSERT(false)` with it.
PR #21752.
This fixes a bug where the torrents table header menu
could not be closed by clicking on a table row.
This also fixes the same bug for other context menus.
PR #21731.
This PR relies on flexbox to ensure all WebUI tables are the correct height without overflowing. Table headers are now always visible and JS-based dynamic resizing is no longer needed.
PR #21652.
Compared to plain function, arrow function is simpler to understand (without bindings to `this`, `arguments`, `super`) and to read.
Now, plain function will only be used when this object is required.
PR #21691.
The required JS may not yet be loaded, resulting in an error when calling `window.qBittorrent.Rss.init()`.
Signed-off-by: Thomas Piccirello <thomas@piccirello.com>
PR #21689.
Auto resize can be triggered by:
1. Double clicking the column's resize handle (its rightmost edge)
2. The table header's context menu
Closes#21627.
PR #21655.
This fixes a bug where the file filter is only shown when the Content tab is switched to. The filter is not being shown if the Content tab is already selected on page load (due to being previously selected).
PR #21657.
Simplify code by utilizing QSslConfiguration object.
Also don't mess with global default value via `QSslConfiguration::setDefaultConfiguration`. It
should not be done at such local class.
Also, by switching to template we can avoid the cost of converting to some specific type and
perfectly forward the parameter to the final function.
PR #21572.
The function already has a parameter named `result`.
Also remove a duplicate variable since it already has a pref pointer at the start of the function.
PR #21571.
It is enough to set them up just once during initial load. Number of elements with copyToClipboard class is fixed - they are context menu items.
PR #21558.
Box-sizing: border-box is now applied globally. A lot of tiny changes were made but they were necessary to correct resulting inconsistencies. Everything should be pretty much as it was with just some minor exceptions.
Looks like this PR also indirectly fixed#21414.
PR #21464.
This PR adds following improvements:
* Remove unused tracker entries while processing sync data
* Take into account filter selection & terms when performing 'Start/stop/delete' context actions in filter lists
Now, only filtered torrents will be affected by them, just like in the GUI.
* Provide better feedback when performing 'Start/stop/delete' context actions in filter lists
Small improvement over GUI - now these actions will be disabled if it's not possible to use them.
* Add context menu to status filter list
* Fix error when toggling filter title
Fixup for small bug introduced in https://github.com/qbittorrent/qBittorrent/pull/21269
PR #21438.
This help identifying threads when debugging.
The naming scheme is using 'class/function name + variable name'.
Note that the length limitaion is 16 chars on linux. On Windows, the limit is 32767 chars.
PR #21403.
router.utorrent.com has been dead for a long time. router.bittorrent.com died about a month or two ago. dht.aelitis.com doesn't work either. It is no longer possible to get DHT nodes from them.
Added router.silotis.us. Only ipv6!
PR #21296.
Just like in GUI, confirmation dialog shows up if it's possible to enable Auto TMM for any selected torrent. Right now it's not possible to properly test all cases in the WebUI because context menu completely hides TMM option when some torrents have it enabled and some not (no tri-state) - but that's something to add in another PR.
PR #21378.
Now drop action is only allowed on transfer list, previously it was on main window.
Having drop action on the whole main window is not preferred because it could allow drop action
on other unrelated widgets, such as execution log or RSS widget which is unexpected behavior.
PR #21332.
We're probably stuck offering the duo of RC_1_2 and RC_2_0 for some
time in the future. So hardcode the choices and make the Program Updater
choose the variant the user currently uses.
This change extends the Advanced section of the Preferences menu with a new field, allowing changing the time statistics save interval. A zero value will prevent recurrent saving.
This aims to provide the feature requested in issue #21285.
PR #21291.
Now they should fully match GUI behavior, please let me know if I missed something.
Still plenty of room to improve them further (e.g styling/CSS) but for now I wanted to keep the changes to the minimum.
Also included small tweaks to category context menu actions.
PR #21269.
SegmentHeap provides a faster malloc implementation that only available with Dynamic UCRT in Windows 10, version 2004 (build 19041) and later.
PR #21263.
A couple of tweaks to make them a little bit better:
1. Make highlighting functions more consistent (this also fixes minuscule bug when no filter item in tracker list is highlighted due to a type mismatch)
2. Use [event delegation](https://javascript.info/event-delegation) to handle filter toggling & item selection
3. Other minor improvements (everything should work like it was previously)
PR #21191.
This PR improves torrent deletion dialog.
1. Now shows different message depending on the number of selected torrents
2. Visually pretty much inline with the GUI
3. Adjusts to content on load
4. Now uses XHR load method. Panels / windows loaded using this method become part of the current document so there is no need to import styles or scripts (they should load marginally faster now).
PR #21185.
---------
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
It is now possible to expand & collapse it by clicking directly on tabs, just like in GUI.
In addition, collapse state is saved and applied on page load.
Fixed one minor bug and now files search input is properly hidden even when panel is collapsed.
PR #21209.
The `event` object will be passed as the first parameter to the event handler. So wrap the
event handler with a closure to prevent `event` leaking to other functions.
This allows passing request_data to retrieve_url in order to create a post request.
PR #21184.
---------
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
qbt only need to escape double quotes for the sake of HTML attributes. As for single quotes it
can leave them as-is since WebUI enforce using double quotes for strings.
PR #21180.
`innerHTML` & `outerHTML` setter will more or less evaluate the value which could be used to
inject malicious code. So replace them with safer alternatives.
PR #21163.
This PR makes it possible to see common category of selected torrents in context menu. Everything should behave exactly like in GUI.
Closes#12701.
PR #21136.
Remove the torrent row regardless of it being visible.
I've also removed the return value because:
* it doesn't appear to be used by any caller;
* other functions (e.g. updateRowData) do not return any value;
* it's not clear whether true refers to the torrent being removed from the list of all torrents or just the visible ones.
Closes#21070.
PR #21071.
`setInterval()` will always fire a new timeout regardless previous `updateRssFeedList()` has
completed or not. This patch will now wait for previous request to complete before another
timeout.
Notable changes:
1. Prevent excessive engine module imports.
2. Replace trivial usage of `join()`.
3. Keep the output text sorted whenever possible.
4. Close handles properly.
5. Print error to stderr, not stdout.
6. Report search job exit code.
7. Print exception message to stderr if exception was thrown when
running a search job.
8. Utilize XML library to build XML data
And use 2 spaces as indentation.
PR #21098.
It does not affect the produced artifacts. The only difference is the
tool itself won't depend on some specific OS image or library version.
PR #20983.
Fixes the download progress calculation for folders with zero size.
Previously, the progress would be Zero. Now, folders with zero size
show 100% progress.
PR #20567.
1. Previously unhandled connections will stay in pending state. It won't
be closed until timeout happened. This may lead to wasting system
resources. Now the (over-limit) connection is actively rejected.
2. When out-of-memory occurs here, reject the new connection instead of
throwing exception and crash.
3. Also clean up some unused bits.
PR #20961.
The version calculation is an estimation and it will drift off after some time. Hopefully the
drift offset won't be noticeable within a few years.
Also switched the user agent to Windows 10 which has the largest portion of users to avoid
standing out from the crowd.
PR #20864.
Restructures the code to separate the basic logic from the logic that depends on the parameters and properties of the torrent being added.
Also fixes "Never show again" checkbox functionality.
PR #20848.
* Simplify nova2dl script
* Use search engine name instead of site URL (like nova2 does)
* Add a way to download torrent using search plugin
PR #20824.
Adds a date column to the built-in search engine to show when a torrent was published/uploaded on the engine site.
When a plugin wants to show a date, it can now add a `pub_date` entry to its result dict. The value format is a unix timestamp (an integer representing seconds since epoch).
Plugins with no date support will keep working.
PR #20703.
Prevents overwriting of the stored layout in case the main window was hidden at startup and
has not been shown since, because incorrect dimensions can be provided by it in this case.
PR #20725.
Closes#20720.
This PR improves touch interaction with table rows that have a context menu. Previously, those rows couldn't be selected or scrolled on mobile. Additionally, this PR modifies the context menu to appear when the user removes their finger/touch, rather than the current behavior of appearing mid-touch. This allows us to only display the context menu if the user's finger remains on the same element, which should significantly reduce erroneous context menu triggering.
Closes#19819.
Closes#19820,
Closes#19823.
PR #20639.
There were a few reports that the user has messed up their browser's language and this PR gives an escape hatch in case the user is unable to configure the browser's language for various reasons.
Example for choosing French: http://127.0.0.1:8080/?lang=fr
PR #20591.
This prevents hitting a TypeError when the category stored in localstorage does not exist. The behavior for a nonexistent category now mirrors that of a nonexistent tag or filter - no option is selected and no torrents are shown.
Closes#20623.
PR #20638.
This PR fixes various accounting issues with the trackers list. Removing a torrent would not update the trackers list, nor would removing a tracker from a torrent. And removing a tracker with a shared host but unique url (e.g. example.com/1 and example.com/2) would erroneously remove the tracker's host from the list.
Closes#20053.
Closes#20054.
PR #20601.
This PR adds support for running multiple concurrent searches in the Web UI. This is already supported in the GUI as well as by the Web API. Behavior mimics the GUI as closely as possible.
All filters and sorting are preserved per-tab, allowing you to apply unique filters and sorts to each of your searches. Row selection is also preserved across tab navigation.
Closes#12840.
PR #20593.
The 'SSL torrent' feature is not standardized. I.e. there are no BEP (BitTorrent Enhancement Proposals) associated with it, so we do not greatly encourage its usage as it will only work with libtorrent clients and derivatives. It will not work with other torrent clients that do not support the libtorrent specific implementation.
This PR aims to provide minimal support for those who need SSL torrents. Furthermore, it is intended that there will be no UI support (nor indication) of adding/creating SSL torrents.
* Prerequisites:
I omit the instructions of creating those files as the intended audience (experts & advanced users) should have no problem with it. All files are as follow:
1. Root (torrent publisher) certificate
2. Root private key
3. A .torrent file created with root certificate
5. Peer certificate (signed by the root certificate)
6. Peer private key
7. Diffie-Hellman parameters file
All files are stored in .pem format.
* Enable SSL torrent protocol in qbt
There are 2 hidden keys to put in qbt config file, under `[BitTorrent]` section:
1. `Session\SSL\Enabled`: set it to `true`.
2. `Session\SSL\Port`: set it to some unused port or omit the key entirely to let qbt pick one for you.
* Add an SSL torrent to qbt
The only way of adding an SSL torrent is via WebAPI. The `/api/v2/torrents/add` endpoint will support 3 additional parameters. You must provide them for an SSL torrent.
1. `ssl_certificate`: Contents of the peer certificate file (in PEM format).
2. `ssl_private_key`: Contents of the peer private key file.
3. `ssl_dh_params`: Contents of the Diffie-Hellman parameters file.
* Change the SSL parameters to a torrent
In case you provided wrong SSL parameters when adding a torrent, there is a new endpoint `/api/v2/torrents/setSSLParameters` that you can update the SSL parameters. The parameters (`ssl_*`) are the same as `/api/v2/torrents/add` endpoint.
* Query the SSL parameters of a torrent
There is a new endpoint `/api/v2/torrents/SSLParameters` that you can query the SSL parameters of a torrent.
References:
* https://www.libtorrent.org/manual-ref.html#ssl-torrents
* https://blog.libtorrent.org/2012/01/bittorrent-over-ssl/
PR #20338.
---------
Co-authored-by: Radu Carpa <radu.carpa@cern.ch>
* Use compiler generated comparison function
* Use designated initializers
* Convert to proper type
* Use reference
* Remove redundant text
The `msg` already contain the text `Reason:` so it isn't needed.
PR #20312.
1. Use proper case folding function instead of `toLower()`.
2. Use locale aware comparison instead of comparing unicode code points.
Now `a` comes before `A` which is the same as the result from QCollator. A nice side effect
is now it properly compares locale specific characters (for example `C`, `Č`).
3. Improve testing. Now the test is runnable and stable on all platforms.
PR #20208.
Add a 'remember choice' button to the WebUI Torrent Deletion dialog that sets the default file deletion setting. The setting is shared with GUI, so if you set it in WebUI and open the Qt app, the 'delete files' checkbox will match WebUI (checked or unchecked).
PR #20150.
---------
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
According to https://doc.qt.io/qt-6/qcollator.html#posix-fallback-implementation
The 'POSIX fallback implementation' is only used when ICU is not available. So the correct way is to detect ICU directly and not depend on the OS. The exceptions are macOS and Windows since they support the required functionalities natively.
Closes#20205.
PR #20207.
Sometimes users had not properly configured their system locale and thus
qbt will specify a default locale just in case.
Closes#16127.
Closes#19609.
Closes#19834.
PR #20203.
lukka/run-vcpkg v11.3 has deliberately changed to avoid writing outside of `GITHUB_WORKSPACE`
directory and this conflict with our usage. So ditch it and invoke vcpkg directly.
https://github.com/lukka/run-vcpkg/releases/tag/v11.3
PR #20202.
For GUI and non-daemon console, the legal notice won't ask for user acceptance anymore and only
provide an OK button (or Enter key in console) from now on.
For daemon mode, qbt will print the legal notice and continue to run. It will also notify user
to use command line option `--confirm-legal-notice` to suppress the message. The message will be
printed on every start up unless user specify the command line option once.
PR #20080.
The C libraries is now updated by the OS and therefore there is no
reason to bundle static versions which might be outdated later.
Also enable Control Flow Guard for 3rd party libraries.
`choco install` is slow: A basically simple download and extract operation takes 20sec compared to ~3sec
when done manually. So we add a conditional for it.
Given the amount of PR and compile matrix, the CI cache size limit is
easy to hit. So for now on, only store compile cache for stable branches
to avoid cache thrashing.
The parent widget of lockMenu is going to be used to derive the
transient parent window. Currently the parent widget of lockMenu is
the main window, therefore the main window is also going to be the
transient parent for lockMenu's window handle.
In other words, the "View" menu and "Lock qBittorrent" menu are
going to be considered as siblings by the window manager even though
the latter is nested inside the former.
On platforms like wayland, such popup hierarchies are illegal, popups
must be properly nested. qtwayland works around it, but it also prints
warning messages.
This change makes lockMenu a child of the view menu so they are
properly nested from the window manager point of view.
PR #19967.
Closes#19955.
This suppresses compiler warnings in GHA CI:
>ld: warning: direct access in function 'std::__1::__function::__func<libtorrent::storage_interface* (*)(libtorrent::storage_params const&, libtorrent::file_pool&), std::__1::allocator<libtorrent::storage_interface* (*)(libtorrent::storage_params const&, libtorrent::file_pool&)>, libtorrent::storage_interface* (libtorrent::storage_params const&, libtorrent::file_pool&)>::target(std::type_info const&) const' from file '/usr/local/lib/libtorrent-rasterbar.a(create_torrent.cpp.o)' to global weak symbol 'typeinfo name for libtorrent::storage_interface* (*)(libtorrent::storage_params const&, libtorrent::file_pool&)' from file 'src/base/libqbt_base.a(mocs_compilation.cpp.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
And also makes the binary a bit smaller.
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Code-Gen-Options.html#index-fvisibility
PR #19921.
Here is some benchmark for various archive formats:
```
gz
0m11.384s
0m11.495s
0m11.193s
zip
0m14.159s
0m14.416s
0m13.917s
7z
0m17.569s
0m17.295s
0m18.496s
bz2
0m31.519s
0m28.885s
0m29.510s
```
Looking by compressed size, bz2 is the best. However its decompressing
speed is the slowest. bz2 and gz file size only differs by ~20MB
and this difference is neglectable given the network speed on
Github. So switch to gz format to speed up CI build time.
PR #19867.
Mobile Safari on iOS does report `ios` platform, but iPadOS reports `mac`
instead. It is common sense to check for touch points when this happens
to differentiate Mac and iPad.
PR #19822.
Closes#19057.
---------
Co-authored-by: Vladimir Golovnev <glassez@yandex.ru>
The overlay scrollbars introduced in Firefox 100 take up no space,
breaking the existing overflow detection.
Add an extra check for `scrollHeight != clientHeight` which is able to
detect an overflow independent of scrollbar style.
PR #19779.
---------
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
Otherwise, there is a conflict of run-time libraries used (since Qt DLLs are still use dynamic MSVCRT) that leads to strange errors.
PR #19718.
Closes#19701.
The `repo` value will be used by `git clone` command and therefore the
URL should end with `.git` for repos on Github.
https://pre-commit.com/#repos-repo
PR #19710.
* Use correct pointer type in NSIS scripts
* Only remove qbt specific registry keys when uninstalling or disassociating
* Set .torrent Content Type when associating .torrent format
* Move ".torrent association" functions to Utils::OS class
PR #19709.
Allows you to bring the main window to the front when one or more "Add new torrent" dialogs are open.
Also allows you to minimize/maximize the "Add new torrent" dialog.
PR #19670.
Closes#17919.
Prevents qBittorrent from being failed to start after torrents database metadata is corrupted by one of the first releases of v4.5.x series.
PR #19668.
Closes#19622.
* Fixes a couple of memory leaks (although not dangerous in practice, since we are talking about objects with a lifetime up to the end of the application)
* Fixes heap use after free
PR #19650.
Closes#19632.
Improves "Metadata received" stop condition handling by "Add new torrent" dialog.
The problem is when "Metadata received" stop condition is set the metadata can still be received 0.1 sec before clicking the "OK" button so torrent is actually added with metadata and therefore it cannot respect "Metadata received" stop condition.
The solution is to uncheck "Start torrent" checkbox once metadata is received.
PR #19597.
Closes#19583.
PR #19496.
* Add torrent entry status to represent tracker error
* Add torrent entry status to represent unreachable endpoint
* Display tracker entry next/min announce time
* Reset tracker entries when torrent is stopped
Warning: users are at their own discretion to create .torrent with >= 64 MiB piece size as not
every torrent client supports it.
Larger piece sizes are only available when using libtorrent 2.x. libtorrent 1.x is not
efficient with memory usage and in order to avoid user complaints it is limited to 128 MiB.
Also note that, as of this writing, libtorrent 2.0.9 has an internal limitation that only
allows loading maximum 256 MiB piece size. And therefore > 256 MiB size options are forbidden
for now.
Closes#19527.
PR #19535.
The change is in preparation for adding the possibility to create
torrent files via the API.
Rework TorrentCreatorThread to be a more lightweight QRunnable class.
The parameters are now defined on construction time and are fixed
throughout the lifecycle of the TorrentCreator. The lifecycle of the
object is not bound to the one of QDialog anymore; it is now handled
by the QThreadPool. This will enable easier queueing of multiple torrent
creation jobs without risk of spawning many threads.
PR #19500.
PR #19468.
* Use QHash to map tracker endpoints
* Don't clear numPeers unexpectedly
* Remove outdated tracker entry endpoints
* Move presentation logic from Core to GUI code
* Show all endpoints per tracker in tree structure
---------
Co-authored-by: Kacper Michajłow <kasper93@gmail.com>
Changing the data may affect the layout of the sort/filter model, which in turn may invalidate the indexes previously obtained from selection model before we process them all. Therefore, we must map all the selected indexes to source before start processing them.
PR #19372.
Closes#19359.
`Algorithm::removeIf()` is still valuable as `QHash::removeIf()` predicate require an
iterator or a `std::pair`, which both require more code to unpack the variable and therefore
cumbersome to use.
PR #19353.
"We do not support any versions older than the current release series"
"We do not support any 3rd party/forked versions e.g. `portableapps`/`Enhanced Edition`etc."
"We do not support any 3rd party/forked versions e.g. `portableapps`/`Enhanced Edition`etc."
"Please post all details in **English**."
#### Prerequisites before submitting an issue!
- Read the issue reporting section in the **[contributing guidelines](https://github.com/qbittorrent/qBittorrent/blob/master/CONTRIBUTING.md)**, to know how to submit a good bug report with the required information.
- Verify that the issue is not fixed and is reproducible in the **[latest official qBittorrent version](https://www.qbittorrent.org/download.php).**
- (Optional, but recommended) Verify that the issue is not fixed and is reproducible in the latest CI (currently only on **[Windows](https://github.com/qbittorrent/qBittorrent/actions/workflows/ci_windows.yaml?query=branch%3Amaster+event%3Apush)**) builds.
- Check the **[frequent/common issues list](https://github.com/qbittorrent/qBittorrent/projects/2)** and perform a **[search of the issue tracker (including closed ones)](https://github.com/qbittorrent/qBittorrent/issues)** to avoid posting a duplicate.
- (Optional, but recommended) Verify that the issue is not fixed and is reproducible in the latest CI (**[macOS](https://github.com/qbittorrent/qBittorrent/actions/workflows/ci_macos.yaml?query=branch%3Amaster+event%3Apush)** / **[Ubuntu](https://github.com/qbittorrent/qBittorrent/actions/workflows/ci_ubuntu.yaml?query=branch%3Amaster+event%3Apush)** / **[Windows](https://github.com/qbittorrent/qBittorrent/actions/workflows/ci_windows.yaml?query=branch%3Amaster+event%3Apush)**) builds.
- Perform a **[search of the issue tracker (including closed ones)](https://github.com/qbittorrent/qBittorrent/issues?q=is%3Aissue+is%3Aopen+-label%3A%22Feature+request%22)** to avoid posting a duplicate.
- Make sure this is not a support request or question, both of which are better suited for either the **[discussions section](https://github.com/qbittorrent/qBittorrent/discussions)**, **[forum](https://qbforums.shiki.hu/)**, or **[subreddit](https://www.reddit.com/r/qBittorrent/)**.
- Verify that the **[wiki](https://github.com/qbittorrent/qBittorrent/wiki)** did not contain a suitable solution either.
- If relevant to issue/when asked, the qBittorrent preferences file, qBittorrent.log & watched_folders.json (if using "Watched Folders" feature) must be provided.
See **[Where does qBittorrent save its settings?](https://github.com/qbittorrent/qBittorrent/wiki/Frequently-Asked-Questions#Where_does_qBittorrent_save_its_settings)**
- type:textarea
attributes:
@ -28,10 +26,10 @@ body:
Qt and libtorrent-rasterbar versions are required when:1. You are using linux. 2. You are not using an official build downloaded from our website.
Example of preferred formatting:
qBittorrent:4.3.7x64
Operating system:Windows 10 Pro 21H1/2009 x64
Qt:5.15.2
libtorrent-rasterbar:1.2.14
qBittorrent:4.6.6x64
Operating system:Windows 10 Pro x64 (22H2) 10.0.19045
Qt:6.4.3
libtorrent-rasterbar:1.2.19
placeholder:|
qBittorrent:
Operating system:
@ -73,4 +71,4 @@ body:
See **[Where does qBittorrent save its settings?](https://github.com/qbittorrent/qBittorrent/wiki/Frequently-Asked-Questions#Where_does_qBittorrent_save_its_settings)**
#### Note: It's the user's responsibility to redact any sensitive information
stale-pr-message:"This PR is stale because it has been 60 days with no activity. This PR will be automatically closed within 7 days if there is no further activity."
close-pr-message:"This PR was closed because it has been stalled for some time with no activity."
feature_option(VERBOSE_CONFIGURE "Show information about PACKAGES_FOUND and PACKAGES_NOT_FOUND in the configure output (only useful for debugging the CMake build scripts)" OFF)
@ -318,7 +318,7 @@ The headers should be ordered alphabetically within each group. \
If there are conditionals for the same header group, then put them at the bottom of the respective group. \
If there are conditionals that contain headers from several different header groups, then put them above the "qBittorrent's own headers" group.
One exception is the header containing the library version (for example, QtGlobal), this particular header isn't constrained by the aforementioned order.
One exception is the header containing the library version (for example, QtVersionChecks), this particular header isn't constrained by the aforementioned order.
[](https://github.com/qbittorrent/qBittorrent/actions)
[](https://github.com/qbittorrent/qBittorrent/actions)
@ -16,15 +15,8 @@ support as well as many features.
The free [IP to Country Lite database](https://db-ip.com/db/download/ip-to-country-lite) by [DB-IP](https://db-ip.com/) is used for resolving the countries of peers. The database is licensed under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).
### Installation:
For installation, follow the instructions from INSTALL file, but simple:
```
./configure
make && make install
qbittorrent
```
will install and execute qBittorrent hopefully without any problem.
Refer to the [INSTALL](INSTALL) file.
### Public key:
Starting from v3.3.4 all source tarballs and binaries are signed.<br/>
qBittorrent takes the security of our software seriously, including all source code repositories managed through our GitHub organisation.
If you believe you have found a security vulnerability in qBittorrent, please report it to us as described below.
## Reporting Security Issues
Please do not report security vulnerabilities through public GitHub issues. Instead, please use GitHubs private vulnerability reporting functionality associated to this repository. Additionally, you may email us with all security-related inquiries and notifications at `security@qbittorrent.org`.
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
1. Type of issue
2. Step-by-step instructions to reproduce the issue
3. Proof-of-concept or exploit code (if possible)
4. Potential impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly. Any and all CVEs will be requested and issued through GitHubs private vulnerability reporting functionality, which will be published alongside the disclosure.
This security policy only applies to the most recent stable branch of qBittorrent. Flaws in old versions that are not present in the current stable branch will not be fixed.
* `torrents/trackers` returns three new fields: `next_announce`, `min_announce` and `endpoints`
* `endpoints` is an array of tracker endpoints, each with `name`, `updating`, `status`, `msg`, `bt_version`, `num_peers`, `num_peers`, `num_leeches`, `num_downloaded`, `next_announce` and `min_announce` fields
* `torrents/trackers` now returns `5` and `6` in `status` field as possible values
* `5` for `Tracker error` and `6` for `Unreachable`
# Check if already in >= C++17 mode because of the flags returned by one of the above packages
TMP_CXXFLAGS="$CXXFLAGS"
CXXFLAGS=""
AC_MSG_CHECKING([if compiler defaults to C++17 or later mode])
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
[AC_MSG_RESULT([yes])
QBT_CXX17_FOUND="yes"],
[AC_MSG_RESULT([no])
QBT_CXX17_FOUND="no"])
# In case of no, check if the compiler can support at least C++17
# and if yes, enable it leaving a warning to the user
AS_IF([test "x$QBT_CXX17_FOUND" = "xno"],
[AC_MSG_CHECKING([if compiler supports C++17])
CXXFLAGS="-std=c++17"
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
[AC_MSG_RESULT([yes])
AC_MSG_CHECKING([if C++17 is disabled by the set compiler flags])
# prepend the flag so it won't override conflicting user defined flags
CXXFLAGS="-std=c++17 $TMP_CXXFLAGS"
AC_COMPILE_IFELSE([DETECT_CPP17_PROGRAM()],
[AC_MSG_RESULT([no])
QBT_ADD_CONFIG="$QBT_ADD_CONFIG c++17"
AC_MSG_WARN([C++17 mode is now force enabled. The C++ mode should match the mode that other libraries were built with, otherwise you'll likely get linking errors.])],
[AC_MSG_RESULT([yes])
AC_MSG_ERROR([The compiler supports C++17 but the user or a dependency has explicitly enabled a lower mode.])])],
[AC_MSG_RESULT([no])
AC_MSG_ERROR([A compiler supporting C++17 is required.])])
])
CXXFLAGS="$TMP_CXXFLAGS"
# These are required because autoconf doesn't expand these **particular**
# vars automatically. And qmake cannot autoexpand them.
AX_DEFINE_DIR([EXPAND_PREFIX], [prefix])
AX_DEFINE_DIR([EXPAND_BINDIR], [bindir])
AX_DEFINE_DIR([EXPAND_DATADIR], [datadir])
AX_DEFINE_DIR([EXPAND_MANDIR], [mandir])
# Original extract() function contributed by pmzqla
# $*: Strings to parse
# Set $QBT_CONF_DEFINES, $QBT_CONF_INCLUDES, $QBT_CONF_EXTRA_CFLAGS
extract() {
if [[ -z "$*" ]]; then
echo "Input string required"
return 1
fi
# BSD sed needs an actual newline character in the substitute command
new_line='
'
# Convert " -" to "\n" if not between quotes and remove possible leading white spaces