mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-14 02:27:09 -07:00
Merge 25c6ba7360
into a3e6d1a0ad
This commit is contained in:
commit
f5417c5350
13 changed files with 81 additions and 1 deletions
|
@ -425,6 +425,19 @@ void Preferences::setPreventFromSuspendWhenSeeding(const bool b)
|
|||
setValue(u"Preferences/General/PreventFromSuspendWhenSeeding"_s, b);
|
||||
}
|
||||
|
||||
bool Preferences::usePerStatusSortOrder() const
|
||||
{
|
||||
return value(u"Preferences/General/UsePerStatusSortOrder"_s, false);
|
||||
}
|
||||
|
||||
void Preferences::setUsePerStatusSortOrder(const bool use)
|
||||
{
|
||||
if (use == usePerStatusSortOrder())
|
||||
return;
|
||||
|
||||
setValue(u"Preferences/General/UsePerStatusSortOrder"_s, use);
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool Preferences::WinStartup() const
|
||||
{
|
||||
|
|
|
@ -162,6 +162,9 @@ public:
|
|||
int getActionOnDblClOnTorrentFn() const;
|
||||
void setActionOnDblClOnTorrentFn(int act);
|
||||
|
||||
bool usePerStatusSortOrder() const;
|
||||
void setUsePerStatusSortOrder(bool use);
|
||||
|
||||
// Connection options
|
||||
QTime getSchedulerStartTime() const;
|
||||
void setSchedulerStartTime(const QTime &time);
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
|
||||
|
||||
bool setType(Type type);
|
||||
Type getType() const { return m_type; }
|
||||
bool setTypeByName(const QString &filter);
|
||||
bool setTorrentIDSet(const std::optional<TorrentIDSet> &idSet);
|
||||
bool setCategory(const std::optional<QString> &category);
|
||||
|
|
|
@ -358,6 +358,7 @@ void OptionsDialog::loadBehaviorTabOptions()
|
|||
m_ui->checkBoxFreeDiskSpaceStatusBar->setChecked(pref->isStatusbarFreeDiskSpaceDisplayed());
|
||||
m_ui->checkBoxExternalIPStatusBar->setChecked(pref->isStatusbarExternalIPDisplayed());
|
||||
m_ui->checkBoxPerformanceWarning->setChecked(session->isPerformanceWarningEnabled());
|
||||
m_ui->checkBoxPerFilterSorting->setChecked(pref->usePerStatusSortOrder());
|
||||
|
||||
connect(m_ui->comboLanguage, qComboBoxCurrentIndexChanged, this, &ThisType::enableApplyButton);
|
||||
|
||||
|
@ -447,6 +448,7 @@ void OptionsDialog::loadBehaviorTabOptions()
|
|||
connect(m_ui->checkBoxFreeDiskSpaceStatusBar, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkBoxExternalIPStatusBar, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkBoxPerformanceWarning, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
connect(m_ui->checkBoxPerFilterSorting, &QAbstractButton::toggled, this, &ThisType::enableApplyButton);
|
||||
}
|
||||
|
||||
void OptionsDialog::saveBehaviorTabOptions() const
|
||||
|
@ -540,6 +542,7 @@ void OptionsDialog::saveBehaviorTabOptions() const
|
|||
|
||||
pref->setStatusbarFreeDiskSpaceDisplayed(m_ui->checkBoxFreeDiskSpaceStatusBar->isChecked());
|
||||
pref->setStatusbarExternalIPDisplayed(m_ui->checkBoxExternalIPStatusBar->isChecked());
|
||||
pref->setUsePerStatusSortOrder(m_ui->checkBoxPerFilterSorting->isChecked());
|
||||
session->setPerformanceWarningEnabled(m_ui->checkBoxPerformanceWarning->isChecked());
|
||||
}
|
||||
|
||||
|
|
|
@ -854,6 +854,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxPerFilterSorting">
|
||||
<property name="text">
|
||||
<string>Use Per-Status Sorting</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
|
|
|
@ -123,6 +123,11 @@ void TransferListSortModel::sort(const int column, const Qt::SortOrder order)
|
|||
QSortFilterProxyModel::sort(column, order);
|
||||
}
|
||||
|
||||
TorrentFilter::Type TransferListSortModel::getType() const
|
||||
{
|
||||
return m_filter.getType();
|
||||
}
|
||||
|
||||
void TransferListSortModel::setStatusFilter(const TorrentFilter::Type filter)
|
||||
{
|
||||
if (m_filter.setType(filter))
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
void disableTagFilter();
|
||||
void setTrackerFilter(const QSet<BitTorrent::TorrentID> &torrentIDs);
|
||||
void disableTrackerFilter();
|
||||
TorrentFilter::Type getType() const;
|
||||
|
||||
private:
|
||||
int compare(const QModelIndex &left, const QModelIndex &right) const;
|
||||
|
|
|
@ -1336,7 +1336,26 @@ void TransferListWidget::applyFilter(const QString &name, const TransferListMode
|
|||
void TransferListWidget::applyStatusFilter(const int filterIndex)
|
||||
{
|
||||
const auto filterType = static_cast<TorrentFilter::Type>(filterIndex);
|
||||
//Save sort order for old filter
|
||||
const bool usePerFilterSort = Preferences::instance()->usePerStatusSortOrder();
|
||||
const TorrentFilter::Type filter = m_sortFilterModel->getType();
|
||||
const int column = m_sortFilterModel->sortColumn();
|
||||
if (column != -1 && usePerFilterSort)
|
||||
{
|
||||
m_statusSortPairs[filter] = qMakePair(column, m_sortFilterModel->sortOrder());
|
||||
}
|
||||
|
||||
m_sortFilterModel->setStatusFilter(((filterType >= TorrentFilter::All) && (filterType < TorrentFilter::_Count)) ? filterType : TorrentFilter::All);
|
||||
|
||||
// Load sort for new status filter
|
||||
if (m_statusSortPairs.contains(filterType) && usePerFilterSort)
|
||||
{
|
||||
const QPair<int, Qt::SortOrder> sortPair = m_statusSortPairs.value(filterType);
|
||||
m_sortFilterModel->sort(sortPair.first, sortPair.second);
|
||||
// Rows are sorted correctly, but header state does not reflect actual sort setting
|
||||
header()->setSortIndicator(sortPair.first, sortPair.second);
|
||||
}
|
||||
|
||||
// Select first item if nothing is selected
|
||||
if (selectionModel()->selectedRows(0).empty() && (m_sortFilterModel->rowCount() > 0))
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <QTreeView>
|
||||
|
||||
#include "base/bittorrent/infohash.h"
|
||||
#include "base/torrentfilter.h"
|
||||
#include "guiapplicationcomponent.h"
|
||||
#include "transferlistmodel.h"
|
||||
|
||||
|
@ -137,6 +138,7 @@ private:
|
|||
void applyToSelectedTorrents(const std::function<void (BitTorrent::Torrent *const)> &fn);
|
||||
QList<BitTorrent::Torrent *> getVisibleTorrents() const;
|
||||
int visibleColumnsCount() const;
|
||||
QHash<TorrentFilter::Type, QPair<int, Qt::SortOrder>> m_statusSortPairs;
|
||||
|
||||
TransferListModel *m_listModel = nullptr;
|
||||
TransferListSortModel *m_sortFilterModel = nullptr;
|
||||
|
|
|
@ -144,6 +144,7 @@ void AppController::preferencesAction()
|
|||
data[u"locale"_s] = pref->getLocale();
|
||||
data[u"performance_warning"_s] = session->isPerformanceWarningEnabled();
|
||||
data[u"status_bar_external_ip"_s] = pref->isStatusbarExternalIPDisplayed();
|
||||
data[u"per_status_sorting"_s] = pref->usePerStatusSortOrder();
|
||||
// Transfer List
|
||||
data[u"confirm_torrent_deletion"_s] = pref->confirmTorrentDeletion();
|
||||
// Log file
|
||||
|
@ -537,6 +538,8 @@ void AppController::setPreferencesAction()
|
|||
pref->setStatusbarExternalIPDisplayed(it.value().toBool());
|
||||
if (hasKey(u"performance_warning"_s))
|
||||
session->setPerformanceWarningEnabled(it.value().toBool());
|
||||
if (hasKey(u"per_status_sorting"_s))
|
||||
pref->setUsePerStatusSortOrder(it.value().toBool());
|
||||
// Transfer List
|
||||
if (hasKey(u"confirm_torrent_deletion"_s))
|
||||
pref->setConfirmTorrentDeletion(it.value().toBool());
|
||||
|
|
|
@ -273,8 +273,24 @@ window.addEventListener("DOMContentLoaded", (event) => {
|
|||
|
||||
setStatusFilter = (name) => {
|
||||
const currentHash = torrentsTable.getCurrentTorrentID();
|
||||
const usePerFilterSorting = window.qBittorrent.Cache.preferences.get().per_status_sorting;
|
||||
|
||||
// Save current sorting for this filter.
|
||||
if ((torrentsTable.getSortedColumn()) && usePerFilterSorting) {
|
||||
LocalPreferences.set(`selected_filter_sort_${selectedStatus}`, torrentsTable.getSortedColumn());
|
||||
LocalPreferences.set(`selected_filter_sort_reverse_${selectedStatus}`, (torrentsTable.reverseSort ?? "0"));
|
||||
}
|
||||
LocalPreferences.set("selected_filter", name);
|
||||
|
||||
// If there is a saved sorting column, load it.
|
||||
const sortColumn = LocalPreferences.get(`selected_filter_sort_${name}`);
|
||||
if ((sortColumn !== null) && usePerFilterSorting) {
|
||||
torrentsTable.setSortedColumn(
|
||||
sortColumn,
|
||||
LocalPreferences.get(`selected_filter_sort_reverse_${name}`, "0")
|
||||
);
|
||||
}
|
||||
|
||||
selectedStatus = name;
|
||||
highlightSelectedStatus();
|
||||
updateMainData();
|
||||
|
|
|
@ -683,7 +683,7 @@ window.qBittorrent.DynamicTable ??= (() => {
|
|||
const oldColumn = this.sortedColumn;
|
||||
this.sortedColumn = column;
|
||||
this.reverseSort = reverse ?? "0";
|
||||
this.setSortedColumnIcon(column, oldColumn, false);
|
||||
this.setSortedColumnIcon(column, oldColumn, (reverse === "1"));
|
||||
}
|
||||
else {
|
||||
// Toggle sort order
|
||||
|
|
|
@ -109,6 +109,11 @@
|
|||
<label for="performanceWarning">QBT_TR(Log performance warnings)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
|
||||
<div class="formRow" style="margin-bottom: 5px;">
|
||||
<input type="checkbox" id="perStatusSorting">
|
||||
<label for="perStatusSorting">QBT_TR(Use Per-Status Sorting)QBT_TR[CONTEXT=OptionsDialog]</label>
|
||||
</div>
|
||||
|
||||
<fieldset class="settings">
|
||||
<legend title="QBT_TR(Following settings are WebUI only)QBT_TR[CONTEXT=OptionsDialog]">QBT_TR(Custom WebUI settings)QBT_TR[CONTEXT=OptionsDialog]</legend>
|
||||
<div class="formRow" style="margin-bottom: 3px;">
|
||||
|
@ -2234,6 +2239,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
|||
updateColoSchemeSelect();
|
||||
document.getElementById("statusBarExternalIP").checked = pref.status_bar_external_ip;
|
||||
document.getElementById("performanceWarning").checked = pref.performance_warning;
|
||||
document.getElementById("perStatusSorting").checked = pref.per_status_sorting;
|
||||
document.getElementById("displayFullURLTrackerColumn").checked = (LocalPreferences.get("full_url_tracker_column", "false") === "true");
|
||||
document.getElementById("useVirtualList").checked = (LocalPreferences.get("use_virtual_list", "false") === "true");
|
||||
document.getElementById("hideZeroFiltersCheckbox").checked = (LocalPreferences.get("hide_zero_status_filters", "false") === "true");
|
||||
|
@ -2668,6 +2674,7 @@ Use ';' to split multiple entries. Can use wildcard '*'.)QBT_TR[CONTEXT=OptionsD
|
|||
LocalPreferences.set("color_scheme", "dark");
|
||||
settings["status_bar_external_ip"] = document.getElementById("statusBarExternalIP").checked;
|
||||
settings["performance_warning"] = document.getElementById("performanceWarning").checked;
|
||||
settings["per_status_sorting"] = document.getElementById("perStatusSorting").checked;
|
||||
LocalPreferences.set("full_url_tracker_column", document.getElementById("displayFullURLTrackerColumn").checked.toString());
|
||||
LocalPreferences.set("use_virtual_list", document.getElementById("useVirtualList").checked.toString());
|
||||
LocalPreferences.set("hide_zero_status_filters", document.getElementById("hideZeroFiltersCheckbox").checked.toString());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue