mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
Simplify checks.
This commit is contained in:
parent
51cde405f9
commit
6cdbf6f869
1 changed files with 8 additions and 6 deletions
|
@ -145,8 +145,8 @@ void AddNewTorrentDialog::showAdvancedSettings(bool show)
|
||||||
if (show) {
|
if (show) {
|
||||||
ui->adv_button->setText(QString::fromUtf8("▲"));
|
ui->adv_button->setText(QString::fromUtf8("▲"));
|
||||||
ui->settings_group->setVisible(true);
|
ui->settings_group->setVisible(true);
|
||||||
ui->info_group->setVisible(!m_isMagnet || (m_isMagnet && m_hasMetadata));
|
ui->info_group->setVisible(m_hasMetadata);
|
||||||
if ( (!m_isMagnet || (m_isMagnet && m_hasMetadata)) && (m_torrentInfo->num_files() > 1)) {
|
if (m_hasMetadata && (m_torrentInfo->num_files() > 1)) {
|
||||||
ui->content_tree->setVisible(true);
|
ui->content_tree->setVisible(true);
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
} else {
|
} else {
|
||||||
|
@ -178,6 +178,8 @@ bool AddNewTorrentDialog::loadTorrent(const QString& torrent_path, const QString
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_hasMetadata = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
m_torrentInfo = new torrent_info(m_filePath.toUtf8().data());
|
m_torrentInfo = new torrent_info(m_filePath.toUtf8().data());
|
||||||
m_hash = misc::toQString(m_torrentInfo->info_hash());
|
m_hash = misc::toQString(m_torrentInfo->info_hash());
|
||||||
|
@ -332,7 +334,7 @@ void AddNewTorrentDialog::updateFileNameInSavePaths(const QString &new_filename)
|
||||||
|
|
||||||
void AddNewTorrentDialog::updateDiskSpaceLabel()
|
void AddNewTorrentDialog::updateDiskSpaceLabel()
|
||||||
{
|
{
|
||||||
Q_ASSERT((m_isMagnet&m_hasMetadata)||!m_isMagnet);
|
Q_ASSERT(m_hasMetadata);
|
||||||
// Determine torrent size
|
// Determine torrent size
|
||||||
qulonglong torrent_size = 0;
|
qulonglong torrent_size = 0;
|
||||||
if (m_contentModel) {
|
if (m_contentModel) {
|
||||||
|
@ -406,7 +408,7 @@ void AddNewTorrentDialog::onSavePathChanged(int index)
|
||||||
relayout();
|
relayout();
|
||||||
// Remember index
|
// Remember index
|
||||||
old_index = ui->save_path_combo->currentIndex();
|
old_index = ui->save_path_combo->currentIndex();
|
||||||
if (m_isMagnet && m_hasMetadata)
|
if (m_hasMetadata)
|
||||||
updateDiskSpaceLabel();
|
updateDiskSpaceLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +599,7 @@ void AddNewTorrentDialog::accept()
|
||||||
}
|
}
|
||||||
disconnect(this, SLOT(updateMetadata(const QTorrentHandle&)));
|
disconnect(this, SLOT(updateMetadata(const QTorrentHandle&)));
|
||||||
}
|
}
|
||||||
if (m_isMagnet && !m_hasMetadata) {
|
if (!m_hasMetadata) {
|
||||||
// Metadata retrival was cancelled
|
// Metadata retrival was cancelled
|
||||||
// Kill existing handle and make a new one
|
// Kill existing handle and make a new one
|
||||||
QBtSession::instance()->deleteTorrent(m_hash, true);
|
QBtSession::instance()->deleteTorrent(m_hash, true);
|
||||||
|
@ -630,7 +632,7 @@ void AddNewTorrentDialog::accept()
|
||||||
pref.sync();
|
pref.sync();
|
||||||
|
|
||||||
// Add torrent
|
// Add torrent
|
||||||
if (m_isMagnet && !m_hasMetadata)
|
if (!m_hasMetadata)
|
||||||
QBtSession::instance()->addMagnetUri(m_url, false);
|
QBtSession::instance()->addMagnetUri(m_url, false);
|
||||||
else
|
else
|
||||||
QBtSession::instance()->addTorrent(m_filePath, false, m_url);
|
QBtSession::instance()->addTorrent(m_filePath, false, m_url);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue