mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-27 02:08:19 +03:00
Add option to enable previous Add new torrent dialog behavior
PR #19874. Closes #19774.
This commit is contained in:
parent
488c022d89
commit
6b3da26af8
4 changed files with 32 additions and 4 deletions
|
@ -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())
|
||||
|
|
|
@ -74,6 +74,10 @@ public:
|
|||
static void setTopLevel(bool value);
|
||||
static int savePathHistoryLength();
|
||||
static void setSavePathHistoryLength(int value);
|
||||
#ifndef Q_OS_MACOS
|
||||
static bool isAttached();
|
||||
static void setAttached(bool value);
|
||||
#endif
|
||||
|
||||
static void show(const QString &source, const BitTorrent::AddTorrentParams &inParams, QWidget *parent);
|
||||
static void show(const QString &source, QWidget *parent);
|
||||
|
|
|
@ -94,6 +94,7 @@ namespace
|
|||
ENABLE_SPEED_WIDGET,
|
||||
#ifndef Q_OS_MACOS
|
||||
ENABLE_ICONS_IN_MENUS,
|
||||
USE_ATTACHED_ADD_NEW_TORRENT_DIALOG,
|
||||
#endif
|
||||
// embedded tracker
|
||||
TRACKER_STATUS,
|
||||
|
@ -310,6 +311,7 @@ void AdvancedSettings::saveAdvancedSettings() const
|
|||
pref->setSpeedWidgetEnabled(m_checkBoxSpeedWidgetEnabled.isChecked());
|
||||
#ifndef Q_OS_MACOS
|
||||
pref->setIconsInMenusEnabled(m_checkBoxIconsInMenusEnabled.isChecked());
|
||||
AddNewTorrentDialog::setAttached(m_checkBoxAttachedAddNewTorrentDialog.isChecked());
|
||||
#endif
|
||||
|
||||
// Tracker
|
||||
|
@ -796,6 +798,9 @@ void AdvancedSettings::loadAdvancedSettings()
|
|||
// Enable icons in menus
|
||||
m_checkBoxIconsInMenusEnabled.setChecked(pref->iconsInMenusEnabled());
|
||||
addRow(ENABLE_ICONS_IN_MENUS, tr("Enable icons in menus"), &m_checkBoxIconsInMenusEnabled);
|
||||
|
||||
m_checkBoxAttachedAddNewTorrentDialog.setChecked(AddNewTorrentDialog::isAttached());
|
||||
addRow(USE_ATTACHED_ADD_NEW_TORRENT_DIALOG, tr("Attach \"Add new torrent\" dialog to main window"), &m_checkBoxAttachedAddNewTorrentDialog);
|
||||
#endif
|
||||
// Tracker State
|
||||
m_checkBoxTrackerStatus.setChecked(session->isTrackerEnabled());
|
||||
|
|
|
@ -102,6 +102,7 @@ private:
|
|||
|
||||
#ifndef Q_OS_MACOS
|
||||
QCheckBox m_checkBoxIconsInMenusEnabled;
|
||||
QCheckBox m_checkBoxAttachedAddNewTorrentDialog;
|
||||
#endif
|
||||
|
||||
#ifdef QBT_USES_DBUS
|
||||
|
|
Loading…
Reference in a new issue