mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-12 18:24:58 +08:00
Merge pull request #8948 from glassez/save-path
Add last used save path to the front of history. Fixes #8922
This commit is contained in:
commit
12e40ca865
@ -35,11 +35,13 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
#include "base/bittorrent/magneturi.h"
|
#include "base/bittorrent/magneturi.h"
|
||||||
#include "base/bittorrent/session.h"
|
#include "base/bittorrent/session.h"
|
||||||
#include "base/bittorrent/torrenthandle.h"
|
#include "base/bittorrent/torrenthandle.h"
|
||||||
#include "base/bittorrent/torrentinfo.h"
|
#include "base/bittorrent/torrentinfo.h"
|
||||||
|
#include "base/global.h"
|
||||||
#include "base/net/downloadhandler.h"
|
#include "base/net/downloadhandler.h"
|
||||||
#include "base/net/downloadmanager.h"
|
#include "base/net/downloadmanager.h"
|
||||||
#include "base/preferences.h"
|
#include "base/preferences.h"
|
||||||
@ -399,23 +401,22 @@ void AddNewTorrentDialog::showAdvancedSettings(bool show)
|
|||||||
|
|
||||||
void AddNewTorrentDialog::saveSavePathHistory() const
|
void AddNewTorrentDialog::saveSavePathHistory() const
|
||||||
{
|
{
|
||||||
QDir selectedSavePath(m_ui->savePath->selectedPath());
|
|
||||||
// Get current history
|
// Get current history
|
||||||
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList();
|
QStringList history = settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList();
|
||||||
if (history.size() > savePathHistoryLength())
|
QVector<QDir> historyDirs;
|
||||||
history = history.mid(0, savePathHistoryLength());
|
for (const QString &path : qAsConst(history))
|
||||||
QList<QDir> historyDirs;
|
historyDirs << QDir {path};
|
||||||
foreach (const QString dir, history)
|
|
||||||
historyDirs << QDir(dir);
|
const QDir selectedSavePath {m_ui->savePath->selectedPath()};
|
||||||
if (!historyDirs.contains(selectedSavePath)) {
|
const int selectedSavePathIndex = historyDirs.indexOf(selectedSavePath);
|
||||||
// Add save path to history
|
if (selectedSavePathIndex > 0)
|
||||||
|
history.removeAt(selectedSavePathIndex);
|
||||||
|
if (selectedSavePathIndex != 0)
|
||||||
|
// Add last used save path to the front of history
|
||||||
history.push_front(selectedSavePath.absolutePath());
|
history.push_front(selectedSavePath.absolutePath());
|
||||||
// Limit list size
|
|
||||||
if (history.size() > savePathHistoryLength())
|
// Save history
|
||||||
history.pop_back();
|
settings()->storeValue(KEY_SAVEPATHHISTORY, QStringList {history.mid(0, savePathHistoryLength())});
|
||||||
// Save history
|
|
||||||
settings()->storeValue(KEY_SAVEPATHHISTORY, history);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// savePath is a folder, not an absolute file path
|
// savePath is a folder, not an absolute file path
|
||||||
|
Loading…
Reference in New Issue
Block a user