Merge pull request #20498 from sledgehammer999/backport

Backport changes to v4.6.x branch
This commit is contained in:
sledgehammer999 2024-03-24 01:31:22 +02:00 committed by GitHub
commit 4e30e6cb8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 149 additions and 89 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
.vscode/
src/gui/geoip/GeoIP.dat src/gui/geoip/GeoIP.dat
src/gui/geoip/GeoIP.dat.gz src/gui/geoip/GeoIP.dat.gz
src/qbittorrent src/qbittorrent

View file

@ -3,9 +3,9 @@
;LangString inst_qbt_req ${LANG_ENGLISH} "qBittorrent (required)" ;LangString inst_qbt_req ${LANG_ENGLISH} "qBittorrent (required)"
LangString inst_qbt_req ${LANG_FRENCH} "qBittorrent (requis)" LangString inst_qbt_req ${LANG_FRENCH} "qBittorrent (requis)"
;LangString inst_desktop ${LANG_ENGLISH} "Create Desktop Shortcut" ;LangString inst_desktop ${LANG_ENGLISH} "Create Desktop Shortcut"
LangString inst_desktop ${LANG_FRENCH} "Créer un Raccourci sur le Bureau" LangString inst_desktop ${LANG_FRENCH} "Créer un raccourci sur le Bureau"
;LangString inst_startmenu ${LANG_ENGLISH} "Create Start Menu Shortcut" ;LangString inst_startmenu ${LANG_ENGLISH} "Create Start Menu Shortcut"
LangString inst_startmenu ${LANG_FRENCH} "Créer un Raccourci dans le Menu Démarrer" LangString inst_startmenu ${LANG_FRENCH} "Créer un raccourci dans le Menu Démarrer"
;LangString inst_startup ${LANG_ENGLISH} "Start qBittorrent on Windows start up" ;LangString inst_startup ${LANG_ENGLISH} "Start qBittorrent on Windows start up"
LangString inst_startup ${LANG_FRENCH} "Démarrer qBittorrent au démarrage de Windows" LangString inst_startup ${LANG_FRENCH} "Démarrer qBittorrent au démarrage de Windows"
;LangString inst_torrent ${LANG_ENGLISH} "Open .torrent files with qBittorrent" ;LangString inst_torrent ${LANG_ENGLISH} "Open .torrent files with qBittorrent"
@ -57,6 +57,6 @@ LangString remove_cache ${LANG_FRENCH} "Supprimer les torrents et données en ca
;LangString uninst_warning ${LANG_ENGLISH} "qBittorrent is running. Please close the application before uninstalling." ;LangString uninst_warning ${LANG_ENGLISH} "qBittorrent is running. Please close the application before uninstalling."
LangString uninst_warning ${LANG_FRENCH} "qBittorrent est en cours d'exécution. Fermez l'application avant de la désinstaller." LangString uninst_warning ${LANG_FRENCH} "qBittorrent est en cours d'exécution. Fermez l'application avant de la désinstaller."
;LangString uninst_tor_warn ${LANG_ENGLISH} "Not removing .torrent association. It is associated with:" ;LangString uninst_tor_warn ${LANG_ENGLISH} "Not removing .torrent association. It is associated with:"
LangString uninst_tor_warn ${LANG_FRENCH} "Ne peut pas supprimer l'association du .torrent. Elle est associée avec :" LangString uninst_tor_warn ${LANG_FRENCH} "Impossible de supprimer l'association .torrent. Elle est associée avec :"
;LangString uninst_mag_warn ${LANG_ENGLISH} "Not removing magnet association. It is associated with:" ;LangString uninst_mag_warn ${LANG_ENGLISH} "Not removing magnet association. It is associated with:"
LangString uninst_mag_warn ${LANG_FRENCH} "Ne peut pas supprimer l'association du magnet. Elle est associée avec :" LangString uninst_mag_warn ${LANG_FRENCH} "Impossible de supprimer l'association magnet. Elle est associée avec :"

View file

@ -31,7 +31,7 @@ LangString inst_requires_64bit ${LANG_HUNGARIAN} "A telepítő csak 64-bites Win
;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7." ;LangString inst_requires_win7 ${LANG_ENGLISH} "This qBittorrent version requires at least Windows 7."
LangString inst_requires_win7 ${LANG_HUNGARIAN} "A qBittorrent ezen verziójához minimum Windows 7 szükséges." LangString inst_requires_win7 ${LANG_HUNGARIAN} "A qBittorrent ezen verziójához minimum Windows 7 szükséges."
;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 (1809) / Windows Server 2019." ;LangString inst_requires_win10 ${LANG_ENGLISH} "This installer requires at least Windows 10 (1809) / Windows Server 2019."
LangString inst_requires_win10 ${LANG_HUNGARIAN} "This installer requires at least Windows 10 (1809) / Windows Server 2019." LangString inst_requires_win10 ${LANG_HUNGARIAN} "A telepítéshez minimum Windows 10 (1809) / Windows Server 2019 szükséges."
;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent" ;LangString inst_uninstall_link_description ${LANG_ENGLISH} "Uninstall qBittorrent"
LangString inst_uninstall_link_description ${LANG_HUNGARIAN} "qBittorrent eltávolítása" LangString inst_uninstall_link_description ${LANG_HUNGARIAN} "qBittorrent eltávolítása"

View file

@ -264,11 +264,8 @@ Application::Application(int &argc, char **argv)
Logger::initInstance(); Logger::initInstance();
const auto portableProfilePath = Path(QCoreApplication::applicationDirPath()) / DEFAULT_PORTABLE_MODE_PROFILE_DIR; const auto portableProfilePath = Path(QCoreApplication::applicationDirPath()) / DEFAULT_PORTABLE_MODE_PROFILE_DIR;
const bool portableModeEnabled = m_commandLineArgs.profileDir.isEmpty() && portableProfilePath.exists(); const bool portableModeEnabled = m_commandLineArgs.profileDir.isEmpty() && Utils::Fs::isDir(portableProfilePath);
const Path profileDir = portableModeEnabled ? portableProfilePath : m_commandLineArgs.profileDir;
const Path profileDir = portableModeEnabled
? portableProfilePath
: m_commandLineArgs.profileDir;
Profile::initInstance(profileDir, m_commandLineArgs.configurationName, Profile::initInstance(profileDir, m_commandLineArgs.configurationName,
(m_commandLineArgs.relativeFastresumePaths || portableModeEnabled)); (m_commandLineArgs.relativeFastresumePaths || portableModeEnabled));

View file

@ -33,6 +33,7 @@
#include <functional> #include <functional>
#include <QAction> #include <QAction>
#include <QByteArray>
#include <QDateTime> #include <QDateTime>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
@ -41,6 +42,7 @@
#include <QPushButton> #include <QPushButton>
#include <QScreen> #include <QScreen>
#include <QShortcut> #include <QShortcut>
#include <QSize>
#include <QString> #include <QString>
#include <QUrl> #include <QUrl>
#include <QVector> #include <QVector>

View file

@ -39,6 +39,9 @@
#include "base/path.h" #include "base/path.h"
#include "base/settingvalue.h" #include "base/settingvalue.h"
class LineEdit;
class TorrentFileGuard;
namespace BitTorrent namespace BitTorrent
{ {
class InfoHash; class InfoHash;
@ -54,9 +57,6 @@ namespace Ui
class AddNewTorrentDialog; class AddNewTorrentDialog;
} }
class LineEdit;
class TorrentFileGuard;
class AddNewTorrentDialog final : public QDialog class AddNewTorrentDialog final : public QDialog
{ {
Q_OBJECT Q_OBJECT

View file

@ -31,6 +31,7 @@
#include <chrono> #include <chrono>
#include <QtGlobal>
#include <QMenu> #include <QMenu>
#include <QTimer> #include <QTimer>
@ -300,11 +301,11 @@ QIcon DesktopIntegration::getSystrayIcon() const
icon = UIThemeManager::instance()->getIcon(u"qbittorrent-tray-light"_s); icon = UIThemeManager::instance()->getIcon(u"qbittorrent-tray-light"_s);
break; break;
} }
#if ((QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)) #ifdef Q_OS_UNIX
// Workaround for invisible tray icon in KDE, https://bugreports.qt.io/browse/QTBUG-53550 // Workaround for invisible tray icon in KDE, https://bugreports.qt.io/browse/QTBUG-53550
return {icon.pixmap(32)}; if (qEnvironmentVariable("XDG_CURRENT_DESKTOP").compare(u"KDE", Qt::CaseInsensitive) == 0)
#else return icon.pixmap(32);
return icon;
#endif #endif
return icon;
} }
#endif // Q_OS_MACOS #endif // Q_OS_MACOS

View file

@ -1,7 +1,8 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2022 Mike Tzou (Chocobo1) * Copyright (C) 2024 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2016 Eugene Shalygin * Copyright (C) 2022 Mike Tzou (Chocobo1)
* Copyright (C) 2016 Eugene Shalygin
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -32,6 +33,7 @@
#include <QCompleter> #include <QCompleter>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QDir> #include <QDir>
#include <QFileIconProvider>
#include <QFileInfo> #include <QFileInfo>
#include <QFileSystemModel> #include <QFileSystemModel>
#include <QMenu> #include <QMenu>
@ -160,36 +162,33 @@ QValidator::State Private::FileSystemPathValidator::validate(QString &input, int
} }
Private::FileLineEdit::FileLineEdit(QWidget *parent) Private::FileLineEdit::FileLineEdit(QWidget *parent)
: QLineEdit {parent} : QLineEdit(parent)
, m_completerModel {new QFileSystemModel(this)}
, m_completer {new QCompleter(this)}
{ {
m_iconProvider.setOptions(QFileIconProvider::DontUseCustomDirectoryIcons);
m_completerModel->setIconProvider(&m_iconProvider);
m_completerModel->setOptions(QFileSystemModel::DontWatchForChanges);
m_completer->setModel(m_completerModel);
setCompleter(m_completer);
connect(this, &QLineEdit::textChanged, this, &FileLineEdit::validateText); connect(this, &QLineEdit::textChanged, this, &FileLineEdit::validateText);
} }
Private::FileLineEdit::~FileLineEdit() Private::FileLineEdit::~FileLineEdit()
{ {
delete m_completerModel; // has to be deleted before deleting the m_iconProvider object delete m_completerModel; // has to be deleted before deleting the m_iconProvider object
delete m_iconProvider;
} }
void Private::FileLineEdit::completeDirectoriesOnly(const bool completeDirsOnly) void Private::FileLineEdit::completeDirectoriesOnly(const bool completeDirsOnly)
{ {
const QDir::Filters filters = QDir::NoDotAndDotDot m_completeDirectoriesOnly = completeDirsOnly;
| (completeDirsOnly ? QDir::Dirs : QDir::AllEntries); if (m_completerModel)
m_completerModel->setFilter(filters); {
const QDir::Filters filters = QDir::NoDotAndDotDot
| (completeDirsOnly ? QDir::Dirs : QDir::AllEntries);
m_completerModel->setFilter(filters);
}
} }
void Private::FileLineEdit::setFilenameFilters(const QStringList &filters) void Private::FileLineEdit::setFilenameFilters(const QStringList &filters)
{ {
m_completerModel->setNameFilters(filters); m_filenameFilters = filters;
if (m_completerModel)
m_completerModel->setNameFilters(m_filenameFilters);
} }
void Private::FileLineEdit::setBrowseAction(QAction *action) void Private::FileLineEdit::setBrowseAction(QAction *action)
@ -223,6 +222,24 @@ void Private::FileLineEdit::keyPressEvent(QKeyEvent *e)
if ((e->key() == Qt::Key_Space) && (e->modifiers() == Qt::CTRL)) if ((e->key() == Qt::Key_Space) && (e->modifiers() == Qt::CTRL))
{ {
if (!m_completer)
{
m_iconProvider = new QFileIconProvider;
m_iconProvider->setOptions(QFileIconProvider::DontUseCustomDirectoryIcons);
m_completerModel = new QFileSystemModel(this);
m_completerModel->setIconProvider(m_iconProvider);
m_completerModel->setOptions(QFileSystemModel::DontWatchForChanges);
m_completerModel->setNameFilters(m_filenameFilters);
const QDir::Filters filters = QDir::NoDotAndDotDot
| (m_completeDirectoriesOnly ? QDir::Dirs : QDir::AllEntries);
m_completerModel->setFilter(filters);
m_completer = new QCompleter(this);
m_completer->setModel(m_completerModel);
setCompleter(m_completer);
}
m_completerModel->setRootPath(Path(text()).data()); m_completerModel->setRootPath(Path(text()).data());
showCompletionPopup(); showCompletionPopup();
} }

View file

@ -1,6 +1,7 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2016 Eugene Shalygin * Copyright (C) 2024 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2016 Eugene Shalygin
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -29,7 +30,6 @@
#pragma once #pragma once
#include <QComboBox> #include <QComboBox>
#include <QFileIconProvider>
#include <QLineEdit> #include <QLineEdit>
#include <QtContainerFwd> #include <QtContainerFwd>
#include <QValidator> #include <QValidator>
@ -39,6 +39,7 @@
class QAction; class QAction;
class QCompleter; class QCompleter;
class QContextMenuEvent; class QContextMenuEvent;
class QFileIconProvider;
class QFileSystemModel; class QFileSystemModel;
class QKeyEvent; class QKeyEvent;
@ -143,7 +144,9 @@ namespace Private
QCompleter *m_completer = nullptr; QCompleter *m_completer = nullptr;
QAction *m_browseAction = nullptr; QAction *m_browseAction = nullptr;
QAction *m_warningAction = nullptr; QAction *m_warningAction = nullptr;
QFileIconProvider m_iconProvider; QFileIconProvider *m_iconProvider = nullptr;
bool m_completeDirectoriesOnly = false;
QStringList m_filenameFilters;
}; };
class FileComboEdit final : public QComboBox, public IFileEditorWithCompletion class FileComboEdit final : public QComboBox, public IFileEditorWithCompletion

View file

@ -29,20 +29,41 @@
#include "lineedit.h" #include "lineedit.h"
#include <chrono>
#include <QAction> #include <QAction>
#include <QKeyEvent> #include <QKeyEvent>
#include <QTimer>
#include "base/global.h" #include "base/global.h"
#include "uithememanager.h" #include "uithememanager.h"
using namespace std::chrono_literals;
namespace
{
const std::chrono::milliseconds FILTER_INPUT_DELAY {400};
}
LineEdit::LineEdit(QWidget *parent) LineEdit::LineEdit(QWidget *parent)
: QLineEdit(parent) : QLineEdit(parent)
, m_delayedTextChangedTimer {new QTimer(this)}
{ {
auto *action = new QAction(UIThemeManager::instance()->getIcon(u"edit-find"_s), QString(), this); auto *action = new QAction(UIThemeManager::instance()->getIcon(u"edit-find"_s), QString(), this);
addAction(action, QLineEdit::LeadingPosition); addAction(action, QLineEdit::LeadingPosition);
setClearButtonEnabled(true); setClearButtonEnabled(true);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
m_delayedTextChangedTimer->setSingleShot(true);
connect(m_delayedTextChangedTimer, &QTimer::timeout, this, [this]
{
emit textChanged(text());
});
connect(this, &QLineEdit::textChanged, this, [this]
{
m_delayedTextChangedTimer->start(FILTER_INPUT_DELAY);
});
} }
void LineEdit::keyPressEvent(QKeyEvent *event) void LineEdit::keyPressEvent(QKeyEvent *event)

View file

@ -31,6 +31,9 @@
#include <QLineEdit> #include <QLineEdit>
class QKeyEvent;
class QTimer;
class LineEdit final : public QLineEdit class LineEdit final : public QLineEdit
{ {
Q_OBJECT Q_OBJECT
@ -39,6 +42,11 @@ class LineEdit final : public QLineEdit
public: public:
explicit LineEdit(QWidget *parent = nullptr); explicit LineEdit(QWidget *parent = nullptr);
signals:
void textChanged(const QString &text);
private: private:
void keyPressEvent(QKeyEvent *event) override; void keyPressEvent(QKeyEvent *event) override;
QTimer *m_delayedTextChangedTimer = nullptr;
}; };

View file

@ -57,6 +57,7 @@
#include <QShortcut> #include <QShortcut>
#include <QSplitter> #include <QSplitter>
#include <QStatusBar> #include <QStatusBar>
#include <QString>
#include <QtGlobal> #include <QtGlobal>
#include <QTimer> #include <QTimer>

View file

@ -42,6 +42,7 @@ class QCloseEvent;
class QComboBox; class QComboBox;
class QFileSystemWatcher; class QFileSystemWatcher;
class QSplitter; class QSplitter;
class QString;
class QTabWidget; class QTabWidget;
class QTimer; class QTimer;

View file

@ -104,7 +104,7 @@ void ArticleListWidget::handleArticleRead(RSS::Article *rssArticle)
const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_s)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_s)};
item->setData(Qt::ForegroundRole, foregroundBrush); item->setData(Qt::ForegroundRole, foregroundBrush);
item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"loading"_s, u"sphere"_s)); item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"rss_read_article"_s, u"sphere"_s));
checkInvariant(); checkInvariant();
} }
@ -131,13 +131,13 @@ QListWidgetItem *ArticleListWidget::createItem(RSS::Article *article) const
{ {
const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_s)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.ReadArticle"_s)};
item->setData(Qt::ForegroundRole, foregroundBrush); item->setData(Qt::ForegroundRole, foregroundBrush);
item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"loading"_s, u"sphere"_s)); item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"rss_read_article"_s, u"sphere"_s));
} }
else else
{ {
const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.UnreadArticle"_s)}; const QBrush foregroundBrush {UIThemeManager::instance()->getColor(u"RSS.UnreadArticle"_s)};
item->setData(Qt::ForegroundRole, foregroundBrush); item->setData(Qt::ForegroundRole, foregroundBrush);
item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"loading"_s, u"sphere"_s)); item->setData(Qt::DecorationRole, UIThemeManager::instance()->getIcon(u"rss_unread_article"_s, u"sphere"_s));
} }
return item; return item;

View file

@ -128,9 +128,9 @@ SearchJobWidget::SearchJobWidget(SearchHandler *searchHandler, QWidget *parent)
m_lineEditSearchResultsFilter->setPlaceholderText(tr("Filter search results...")); m_lineEditSearchResultsFilter->setPlaceholderText(tr("Filter search results..."));
m_lineEditSearchResultsFilter->setContextMenuPolicy(Qt::CustomContextMenu); m_lineEditSearchResultsFilter->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_lineEditSearchResultsFilter, &QWidget::customContextMenuRequested, this, &SearchJobWidget::showFilterContextMenu); connect(m_lineEditSearchResultsFilter, &QWidget::customContextMenuRequested, this, &SearchJobWidget::showFilterContextMenu);
connect(m_lineEditSearchResultsFilter, &LineEdit::textChanged, this, &SearchJobWidget::filterSearchResults);
m_ui->horizontalLayout->insertWidget(0, m_lineEditSearchResultsFilter); m_ui->horizontalLayout->insertWidget(0, m_lineEditSearchResultsFilter);
connect(m_lineEditSearchResultsFilter, &LineEdit::textChanged, this, &SearchJobWidget::filterSearchResults);
connect(m_ui->filterMode, qOverload<int>(&QComboBox::currentIndexChanged) connect(m_ui->filterMode, qOverload<int>(&QComboBox::currentIndexChanged)
, this, &SearchJobWidget::updateFilter); , this, &SearchJobWidget::updateFilter);
connect(m_ui->minSeeds, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter); connect(m_ui->minSeeds, &QAbstractSpinBox::editingFinished, this, &SearchJobWidget::updateFilter);

View file

@ -149,6 +149,8 @@ inline QSet<QString> defaultUIThemeIcons()
u"queued"_s, u"queued"_s,
u"ratio"_s, u"ratio"_s,
u"reannounce"_s, u"reannounce"_s,
u"rss_read_article"_s,
u"rss_unread_article"_s,
u"security-high"_s, u"security-high"_s,
u"security-low"_s, u"security-low"_s,
u"set-location"_s, u"set-location"_s,

View file

@ -331,6 +331,8 @@
<file>queued.svg</file> <file>queued.svg</file>
<file>ratio.svg</file> <file>ratio.svg</file>
<file>reannounce.svg</file> <file>reannounce.svg</file>
<file>rss_read_article.png</file>
<file>rss_unread_article.png</file>
<file>security-high.svg</file> <file>security-high.svg</file>
<file>security-low.svg</file> <file>security-low.svg</file>
<file>set-location.svg</file> <file>set-location.svg</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

View file

@ -7,7 +7,7 @@ win32: include(../winconf.pri)
macx: include(../macxconf.pri) macx: include(../macxconf.pri)
unix:!macx: include(../unixconf.pri) unix:!macx: include(../unixconf.pri)
QT += network sql xml QT += core-private network sql xml
macx|*-clang*: QMAKE_CXXFLAGS_WARN_ON += -Wno-range-loop-analysis macx|*-clang*: QMAKE_CXXFLAGS_WARN_ON += -Wno-range-loop-analysis

View file

@ -658,6 +658,8 @@ window.addEvent('load', function() {
$('error_div').set('html', ''); $('error_div').set('html', '');
if (response) { if (response) {
clearTimeout(torrentsFilterInputTimer); clearTimeout(torrentsFilterInputTimer);
torrentsFilterInputTimer = -1;
let torrentsTableSelectedRows; let torrentsTableSelectedRows;
let update_categories = false; let update_categories = false;
let updateTags = false; let updateTags = false;
@ -1357,18 +1359,14 @@ window.addEvent('load', function() {
$('torrentFilesFilterToolbar').addClass("invisible"); $('torrentFilesFilterToolbar').addClass("invisible");
}; };
let prevTorrentsFilterValue;
let torrentsFilterInputTimer = null;
// listen for changes to torrentsFilterInput // listen for changes to torrentsFilterInput
$('torrentsFilterInput').addEvent('input', function() { let torrentsFilterInputTimer = -1;
const value = $('torrentsFilterInput').get("value"); $('torrentsFilterInput').addEvent('input', () => {
if (value !== prevTorrentsFilterValue) { clearTimeout(torrentsFilterInputTimer);
prevTorrentsFilterValue = value; torrentsFilterInputTimer = setTimeout(() => {
clearTimeout(torrentsFilterInputTimer); torrentsFilterInputTimer = -1;
torrentsFilterInputTimer = setTimeout(function() { torrentsTable.updateTable();
torrentsTable.updateTable(false); }, window.qBittorrent.Misc.FILTER_INPUT_DELAY);
}, 400);
}
}); });
$('transfersTabLink').addEvent('click', showTransfersTab); $('transfersTabLink').addEvent('click', showTransfersTab);

View file

@ -175,12 +175,14 @@ window.qBittorrent.ContextMenu = (function() {
const touchstartEvent = e; const touchstartEvent = e;
this.touchstartTimer = setTimeout(function() { this.touchstartTimer = setTimeout(function() {
this.touchstartTimer = -1;
this.triggerMenu(touchstartEvent, elem); this.triggerMenu(touchstartEvent, elem);
}.bind(this), this.options.touchTimer); }.bind(this), this.options.touchTimer);
}.bind(this)); }.bind(this));
elem.addEvent('touchend', function(e) { elem.addEvent('touchend', function(e) {
e.preventDefault(); e.preventDefault();
clearTimeout(this.touchstartTimer); clearTimeout(this.touchstartTimer);
this.touchstartTimer = -1;
}.bind(this)); }.bind(this));
}, },

View file

@ -701,10 +701,7 @@ window.qBittorrent.DynamicTable = (function() {
return null; return null;
}, },
updateTable: function(fullUpdate) { updateTable: function(fullUpdate = false) {
if (fullUpdate === undefined)
fullUpdate = false;
const rows = this.getFilteredAndSortedRows(); const rows = this.getFilteredAndSortedRows();
for (let i = 0; i < this.selectedRows.length; ++i) for (let i = 0; i < this.selectedRows.length; ++i)

View file

@ -46,6 +46,8 @@ window.qBittorrent.Misc = (function() {
toFixedPointString: toFixedPointString, toFixedPointString: toFixedPointString,
containsAllTerms: containsAllTerms, containsAllTerms: containsAllTerms,
sleep: sleep, sleep: sleep,
// variables
FILTER_INPUT_DELAY: 400,
MAX_ETA: 8640000 MAX_ETA: 8640000
}; };
}; };

View file

@ -366,6 +366,7 @@ window.qBittorrent.PropFiles = (function() {
}, },
onSuccess: function(files) { onSuccess: function(files) {
clearTimeout(torrentFilesFilterInputTimer); clearTimeout(torrentFilesFilterInputTimer);
torrentFilesFilterInputTimer = -1;
if (files.length === 0) { if (files.length === 0) {
torrentFilesTable.clear(); torrentFilesTable.clear();
@ -640,26 +641,27 @@ window.qBittorrent.PropFiles = (function() {
if (torrentFilesTable.getSortedColumn() === null) if (torrentFilesTable.getSortedColumn() === null)
torrentFilesTable.setSortedColumn('name'); torrentFilesTable.setSortedColumn('name');
let prevTorrentFilesFilterValue;
let torrentFilesFilterInputTimer = null;
// listen for changes to torrentFilesFilterInput // listen for changes to torrentFilesFilterInput
$('torrentFilesFilterInput').addEvent('input', function() { let torrentFilesFilterInputTimer = -1;
const value = $('torrentFilesFilterInput').get("value"); $('torrentFilesFilterInput').addEvent('input', () => {
if (value !== prevTorrentFilesFilterValue) { clearTimeout(torrentFilesFilterInputTimer);
prevTorrentFilesFilterValue = value;
torrentFilesTable.setFilter(value);
clearTimeout(torrentFilesFilterInputTimer);
torrentFilesFilterInputTimer = setTimeout(function() {
if (current_hash === "")
return;
torrentFilesTable.updateTable(false);
if (value.trim() === "") const value = $('torrentFilesFilterInput').get("value");
collapseAllNodes(); torrentFilesTable.setFilter(value);
else
expandAllNodes(); torrentFilesFilterInputTimer = setTimeout(() => {
}, 400); torrentFilesFilterInputTimer = -1;
}
if (current_hash === "")
return;
torrentFilesTable.updateTable();
if (value.trim() === "")
collapseAllNodes();
else
expandAllNodes();
}, window.qBittorrent.Misc.FILTER_INPUT_DELAY);
}); });
/** /**

View file

@ -183,7 +183,7 @@
}; };
let customSyncLogDataInterval = null; let customSyncLogDataInterval = null;
let logFilterTimer; let logFilterTimer = -1;
let inputtedFilterText = ""; let inputtedFilterText = "";
let selectBox; let selectBox;
let selectedLogLevels = JSON.parse(LocalPreferences.get('qbt_selected_log_levels')) || ['1', '2', '4', '8']; let selectedLogLevels = JSON.parse(LocalPreferences.get('qbt_selected_log_levels')) || ['1', '2', '4', '8'];
@ -297,9 +297,11 @@
const logFilterChanged = () => { const logFilterChanged = () => {
clearTimeout(logFilterTimer); clearTimeout(logFilterTimer);
logFilterTimer = setTimeout((curTab) => { logFilterTimer = setTimeout((curTab) => {
logFilterTimer = -1;
tableInfo[curTab].instance.updateTable(false); tableInfo[curTab].instance.updateTable(false);
updateLabelCount(curTab); updateLabelCount(curTab);
}, 400, currentSelectedTab); }, window.qBittorrent.Misc.FILTER_INPUT_DELAY, currentSelectedTab);
}; };
const setCurrentTab = (tab) => { const setCurrentTab = (tab) => {
@ -321,6 +323,7 @@
} }
clearTimeout(logFilterTimer); clearTimeout(logFilterTimer);
logFilterTimer = -1;
load(); load();
if (tableInfo[currentSelectedTab].instance.filterText !== getFilterText()) { if (tableInfo[currentSelectedTab].instance.filterText !== getFilterText()) {
@ -377,6 +380,8 @@
if (response.length > 0) { if (response.length > 0) {
clearTimeout(logFilterTimer); clearTimeout(logFilterTimer);
logFilterTimer = -1;
for (let i = 0; i < response.length; ++i) { for (let i = 0; i < response.length; ++i) {
let row; let row;
if (curTab === 'main') { if (curTab === 'main') {

View file

@ -233,7 +233,6 @@
max: 0.00, max: 0.00,
maxUnit: 3 maxUnit: 3
}; };
let prevNameFilterValue;
let selectedCategory = "QBT_TR(All categories)QBT_TR[CONTEXT=SearchEngineWidget]"; let selectedCategory = "QBT_TR(All categories)QBT_TR[CONTEXT=SearchEngineWidget]";
let selectedPlugin = "all"; let selectedPlugin = "all";
let prevSelectedPlugin; let prevSelectedPlugin;
@ -258,18 +257,17 @@
searchResultsTable.setup('searchResultsTableDiv', 'searchResultsTableFixedHeaderDiv', searchResultsTableContextMenu); searchResultsTable.setup('searchResultsTableDiv', 'searchResultsTableFixedHeaderDiv', searchResultsTableContextMenu);
getPlugins(); getPlugins();
let searchInNameFilterTimer = null;
// listen for changes to searchInNameFilter // listen for changes to searchInNameFilter
$('searchInNameFilter').addEvent('input', function() { let searchInNameFilterTimer = -1;
const value = $('searchInNameFilter').get("value"); $('searchInNameFilter').addEvent('input', () => {
if (value !== prevNameFilterValue) { clearTimeout(searchInNameFilterTimer);
prevNameFilterValue = value; searchInNameFilterTimer = setTimeout(() => {
clearTimeout(searchInNameFilterTimer); searchInNameFilterTimer = -1;
searchInNameFilterTimer = setTimeout(function() {
searchText.filterPattern = value; const value = $('searchInNameFilter').get("value");
searchFilterChanged(); searchText.filterPattern = value;
}, 400); searchFilterChanged();
} }, window.qBittorrent.Misc.FILTER_INPUT_DELAY);
}); });
new Keyboard({ new Keyboard({