[TorrentCreator] Show number of pieces. Closes #6774.

This commit is contained in:
Chocobo1
2017-05-25 22:48:10 +08:00
parent 1f9ccb44a3
commit c618214061
5 changed files with 36 additions and 0 deletions

View File

@@ -70,6 +70,7 @@ TorrentCreatorDlg::TorrentCreatorDlg(QWidget *parent, const QString &defaultPath
connect(m_ui->addFileButton, SIGNAL(clicked(bool)), SLOT(onAddFileButtonClicked()));
connect(m_ui->addFolderButton, SIGNAL(clicked(bool)), SLOT(onAddFolderButtonClicked()));
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(creationFailure(QString)), this, SLOT(handleCreationFailure(QString)));
@@ -207,6 +208,14 @@ void TorrentCreatorDlg::updateProgressBar(int 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)
{
m_ui->textInputPath->setEnabled(enabled);