mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-31 20:58:07 -06:00
Add option to enable previous Add new torrent dialog behavior
PR #19874. Closes #19774.
This commit is contained in:
committed by
GitHub
parent
488c022d89
commit
6b3da26af8
@@ -69,6 +69,7 @@ namespace
|
||||
#define SETTINGS_KEY(name) u"AddNewTorrentDialog/" name
|
||||
const QString KEY_ENABLED = SETTINGS_KEY(u"Enabled"_s);
|
||||
const QString KEY_TOPLEVEL = SETTINGS_KEY(u"TopLevel"_s);
|
||||
const QString KEY_ATTACHED = SETTINGS_KEY(u"Attached"_s);
|
||||
const QString KEY_SAVEPATHHISTORY = SETTINGS_KEY(u"SavePathHistory"_s);
|
||||
const QString KEY_DOWNLOADPATHHISTORY = SETTINGS_KEY(u"DownloadPathHistory"_s);
|
||||
const QString KEY_SAVEPATHHISTORYLENGTH = SETTINGS_KEY(u"SavePathHistoryLength"_s);
|
||||
@@ -471,6 +472,18 @@ void AddNewTorrentDialog::setSavePathHistoryLength(const int value)
|
||||
, QStringList(settings()->loadValue<QStringList>(KEY_SAVEPATHHISTORY).mid(0, clampedValue)));
|
||||
}
|
||||
|
||||
#ifndef Q_OS_MACOS
|
||||
void AddNewTorrentDialog::setAttached(const bool value)
|
||||
{
|
||||
settings()->storeValue(KEY_ATTACHED, value);
|
||||
}
|
||||
|
||||
bool AddNewTorrentDialog::isAttached()
|
||||
{
|
||||
return settings()->loadValue(KEY_ATTACHED, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
void AddNewTorrentDialog::loadState()
|
||||
{
|
||||
if (const QSize dialogSize = m_storeDialogSize; dialogSize.isValid())
|
||||
@@ -489,19 +502,24 @@ void AddNewTorrentDialog::saveState()
|
||||
|
||||
void AddNewTorrentDialog::show(const QString &source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent)
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
const auto *pref = Preferences::instance();
|
||||
#ifdef Q_OS_MACOS
|
||||
const bool attached = false;
|
||||
#else
|
||||
const bool attached = isAttached();
|
||||
#endif
|
||||
|
||||
// By not setting a parent to the "AddNewTorrentDialog", all those dialogs
|
||||
// will be displayed on top and will not overlap with the main window.
|
||||
auto *dlg = new AddNewTorrentDialog(inParams, nullptr);
|
||||
auto *dlg = new AddNewTorrentDialog(inParams, (attached ? parent : nullptr));
|
||||
// Qt::Window is required to avoid showing only two dialog on top (see #12852).
|
||||
// Also improves the general convenience of adding multiple torrents.
|
||||
dlg->setWindowFlags(Qt::Window);
|
||||
if (!attached)
|
||||
dlg->setWindowFlags(Qt::Window);
|
||||
dlg->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
if (Net::DownloadManager::hasSupportedScheme(source))
|
||||
{
|
||||
const auto *pref = Preferences::instance();
|
||||
// Launch downloader
|
||||
Net::DownloadManager::instance()->download(
|
||||
Net::DownloadRequest(source).limit(pref->getTorrentFileSizeLimit())
|
||||
|
||||
Reference in New Issue
Block a user