Add compile definition to indicate using of libtorrent 2.0 (#15297)

The compile definition is temporary which will be removed when qbt
ditches libtorrent 1.x.
This commit is contained in:
Chocobo1
2021-08-08 13:27:22 +08:00
committed by GitHub
parent bed643e627
commit 138c911ef4
23 changed files with 85 additions and 93 deletions

View File

@@ -53,7 +53,7 @@ TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const QString &defau
, m_storePrivateTorrent(SETTINGS_KEY("PrivateTorrent"))
, m_storeStartSeeding(SETTINGS_KEY("StartSeeding"))
, m_storeIgnoreRatio(SETTINGS_KEY("IgnoreRatio"))
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
, m_storeTorrentFormat(SETTINGS_KEY("TorrentFormat"))
#else
, m_storeOptimizeAlignment(SETTINGS_KEY("OptimizeAlignment"))
@@ -84,7 +84,7 @@ TorrentCreatorDialog::TorrentCreatorDialog(QWidget *parent, const QString &defau
loadSettings();
updateInputPath(defaultPath);
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
m_ui->checkOptimizeAlignment->hide();
#else
m_ui->widgetTorrentFormat->hide();
@@ -127,7 +127,7 @@ int TorrentCreatorDialog::getPieceSize() const
return pieceSizes[m_ui->comboPieceSize->currentIndex()] * 1024;
}
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
BitTorrent::TorrentFormat TorrentCreatorDialog::getTorrentFormat() const
{
switch (m_ui->comboTorrentFormat->currentIndex())
@@ -201,7 +201,7 @@ void TorrentCreatorDialog::onCreateButtonClicked()
const BitTorrent::TorrentCreatorParams params
{
m_ui->checkPrivate->isChecked()
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
, getTorrentFormat()
#else
, m_ui->checkOptimizeAlignment->isChecked()
@@ -266,7 +266,7 @@ void TorrentCreatorDialog::updateProgressBar(int progress)
void TorrentCreatorDialog::updatePiecesCount()
{
const QString path = m_ui->textInputPath->text().trimmed();
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
const int count = BitTorrent::TorrentCreatorThread::calculateTotalPieces(
path, getPieceSize(), getTorrentFormat());
#else
@@ -291,7 +291,7 @@ void TorrentCreatorDialog::setInteractionEnabled(const bool enabled) const
m_ui->checkStartSeeding->setEnabled(enabled);
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enabled);
m_ui->checkIgnoreShareLimits->setEnabled(enabled && m_ui->checkStartSeeding->isChecked());
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
m_ui->widgetTorrentFormat->setEnabled(enabled);
#else
m_ui->checkOptimizeAlignment->setEnabled(enabled);
@@ -307,7 +307,7 @@ void TorrentCreatorDialog::saveSettings()
m_storePrivateTorrent = m_ui->checkPrivate->isChecked();
m_storeStartSeeding = m_ui->checkStartSeeding->isChecked();
m_storeIgnoreRatio = m_ui->checkIgnoreShareLimits->isChecked();
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
m_storeTorrentFormat = m_ui->comboTorrentFormat->currentIndex();
#else
m_storeOptimizeAlignment = m_ui->checkOptimizeAlignment->isChecked();
@@ -331,7 +331,7 @@ void TorrentCreatorDialog::loadSettings()
m_ui->checkStartSeeding->setChecked(m_storeStartSeeding);
m_ui->checkIgnoreShareLimits->setChecked(m_storeIgnoreRatio);
m_ui->checkIgnoreShareLimits->setEnabled(m_ui->checkStartSeeding->isChecked());
#if (LIBTORRENT_VERSION_NUM >= 20000)
#ifdef QBT_USES_LIBTORRENT2
m_ui->comboTorrentFormat->setCurrentIndex(m_storeTorrentFormat.get(1));
#else
m_ui->checkOptimizeAlignment->setChecked(m_storeOptimizeAlignment.get(true));