mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-23 21:14:33 +00:00
[TorrentCreator] Show number of pieces. Closes #6774.
This commit is contained in:
parent
1f9ccb44a3
commit
c618214061
@ -160,3 +160,13 @@ void TorrentCreatorThread::run()
|
|||||||
emit creationFailure(QString::fromStdString(e.what()));
|
emit creationFailure(QString::fromStdString(e.what()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TorrentCreatorThread::calculateTotalPieces(const QString &inputPath, const int pieceSize)
|
||||||
|
{
|
||||||
|
if (inputPath.isEmpty())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
libt::file_storage fs;
|
||||||
|
libt::add_files(fs, Utils::Fs::toNativePath(inputPath).toStdString(), fileFilter);
|
||||||
|
return libt::create_torrent(fs, pieceSize).num_pieces();
|
||||||
|
}
|
||||||
|
@ -47,6 +47,8 @@ namespace BitTorrent
|
|||||||
void create(const QString &inputPath, const QString &savePath, const QStringList &trackers,
|
void create(const QString &inputPath, const QString &savePath, const QStringList &trackers,
|
||||||
const QStringList &urlSeeds, const QString &comment, bool isPrivate, int pieceSize);
|
const QStringList &urlSeeds, const QString &comment, bool isPrivate, int pieceSize);
|
||||||
|
|
||||||
|
static int calculateTotalPieces(const QString &inputPath, const int pieceSize);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run();
|
void run();
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent, const QString &defaultPath
|
|||||||
connect(m_ui->addFileButton, SIGNAL(clicked(bool)), SLOT(onAddFileButtonClicked()));
|
connect(m_ui->addFileButton, SIGNAL(clicked(bool)), SLOT(onAddFileButtonClicked()));
|
||||||
connect(m_ui->addFolderButton, SIGNAL(clicked(bool)), SLOT(onAddFolderButtonClicked()));
|
connect(m_ui->addFolderButton, SIGNAL(clicked(bool)), SLOT(onAddFolderButtonClicked()));
|
||||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(onCreateButtonClicked()));
|
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(onCreateButtonClicked()));
|
||||||
|
connect(m_ui->buttonCalcTotalPieces, &QAbstractButton::clicked, this, &TorrentCreatorDlg::updatePiecesCount);
|
||||||
|
|
||||||
connect(m_creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString)));
|
connect(m_creatorThread, SIGNAL(creationSuccess(QString, QString)), this, SLOT(handleCreationSuccess(QString, QString)));
|
||||||
connect(m_creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
|
connect(m_creatorThread, SIGNAL(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
|
||||||
@ -207,6 +208,14 @@ void TorrentCreatorDlg::updateProgressBar(int progress)
|
|||||||
m_ui->progressBar->setValue(progress);
|
m_ui->progressBar->setValue(progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TorrentCreatorDlg::updatePiecesCount()
|
||||||
|
{
|
||||||
|
const QString path = m_ui->textInputPath->text().trimmed();
|
||||||
|
|
||||||
|
const int count = BitTorrent::TorrentCreatorThread::calculateTotalPieces(path, getPieceSize());
|
||||||
|
m_ui->labelTotalPieces->setText(QString::number(count));
|
||||||
|
}
|
||||||
|
|
||||||
void TorrentCreatorDlg::setInteractionEnabled(bool enabled)
|
void TorrentCreatorDlg::setInteractionEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
m_ui->textInputPath->setEnabled(enabled);
|
m_ui->textInputPath->setEnabled(enabled);
|
||||||
|
@ -55,6 +55,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateProgressBar(int progress);
|
void updateProgressBar(int progress);
|
||||||
|
void updatePiecesCount();
|
||||||
void onCreateButtonClicked();
|
void onCreateButtonClicked();
|
||||||
void onAddFileButtonClicked();
|
void onAddFileButtonClicked();
|
||||||
void onAddFolderButtonClicked();
|
void onAddFolderButtonClicked();
|
||||||
|
@ -166,6 +166,20 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="buttonCalcTotalPieces">
|
||||||
|
<property name="text">
|
||||||
|
<string>Calculate total pieces:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelTotalPieces">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="spacer1">
|
<spacer name="spacer1">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user