mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
parent
889ed5bce9
commit
f4deb1050f
@ -44,6 +44,18 @@
|
|||||||
|
|
||||||
#define SETTINGS_KEY(name) u"TorrentCreator/" name
|
#define SETTINGS_KEY(name) u"TorrentCreator/" name
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
// When the root file/directory of the created torrent is a symlink, we want to keep the symlink name in the torrent.
|
||||||
|
// On Windows, however, QFileDialog::DontResolveSymlinks disables shortcuts (.lnk files) expansion, making it impossible to pick a file if its path contains a shortcut.
|
||||||
|
// As of NTFS symlinks, they don't seem to be resolved anyways.
|
||||||
|
#ifndef Q_OS_WIN
|
||||||
|
const QFileDialog::Options FILE_DIALOG_OPTIONS {QFileDialog::DontResolveSymlinks};
|
||||||
|
#else
|
||||||
|
const QFileDialog::Options FILE_DIALOG_OPTIONS {};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const Path &defaultPath)
|
TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const Path &defaultPath)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_ui(new Ui::TorrentCreatorDialog)
|
, m_ui(new Ui::TorrentCreatorDialog)
|
||||||
@ -106,14 +118,15 @@ void TorrentCreatorDialog::updateInputPath(const Path &path)
|
|||||||
void TorrentCreatorDialog::onAddFolderButtonClicked()
|
void TorrentCreatorDialog::onAddFolderButtonClicked()
|
||||||
{
|
{
|
||||||
const QString oldPath = m_ui->textInputPath->text();
|
const QString oldPath = m_ui->textInputPath->text();
|
||||||
const Path path {QFileDialog::getExistingDirectory(this, tr("Select folder"), oldPath)};
|
const Path path {QFileDialog::getExistingDirectory(this, tr("Select folder")
|
||||||
|
, oldPath, (QFileDialog::ShowDirsOnly | FILE_DIALOG_OPTIONS))};
|
||||||
updateInputPath(path);
|
updateInputPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentCreatorDialog::onAddFileButtonClicked()
|
void TorrentCreatorDialog::onAddFileButtonClicked()
|
||||||
{
|
{
|
||||||
const QString oldPath = m_ui->textInputPath->text();
|
const QString oldPath = m_ui->textInputPath->text();
|
||||||
const Path path {QFileDialog::getOpenFileName(this, tr("Select file"), oldPath)};
|
const Path path {QFileDialog::getOpenFileName(this, tr("Select file"), oldPath, QString(), nullptr, FILE_DIALOG_OPTIONS)};
|
||||||
updateInputPath(path);
|
updateInputPath(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +183,12 @@ void TorrentCreatorDialog::dragEnterEvent(QDragEnterEvent *event)
|
|||||||
// Main function that create a .torrent file
|
// Main function that create a .torrent file
|
||||||
void TorrentCreatorDialog::onCreateButtonClicked()
|
void TorrentCreatorDialog::onCreateButtonClicked()
|
||||||
{
|
{
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// Resolve the path in case it contains a shortcut (otherwise, the following usages will consider it invalid)
|
||||||
const auto inputPath = Utils::Fs::toCanonicalPath(Path(m_ui->textInputPath->text().trimmed()));
|
const auto inputPath = Utils::Fs::toCanonicalPath(Path(m_ui->textInputPath->text().trimmed()));
|
||||||
|
#else
|
||||||
|
const auto inputPath = Path(m_ui->textInputPath->text().trimmed());
|
||||||
|
#endif
|
||||||
|
|
||||||
// test if readable
|
// test if readable
|
||||||
if (!Utils::Fs::isReadable(inputPath))
|
if (!Utils::Fs::isReadable(inputPath))
|
||||||
|
Loading…
Reference in New Issue
Block a user