Clean up code

* Use compiler generated comparison function
* Use designated initializers
* Convert to proper type
* Use reference
* Remove redundant text
  The `msg` already contain the text `Reason:` so it isn't needed.

PR #20312.
This commit is contained in:
Chocobo1
2024-01-25 02:56:12 +08:00
committed by GitHub
parent bab9c15913
commit 94e80d01a8
7 changed files with 42 additions and 58 deletions

View File

@@ -227,20 +227,20 @@ void TorrentCreatorDialog::onCreateButtonClicked()
.replace(QRegularExpression(u"\n\n[\n]+"_s), u"\n\n"_s).split(u'\n');
const BitTorrent::TorrentCreatorParams params
{
m_ui->checkPrivate->isChecked()
.isPrivate = m_ui->checkPrivate->isChecked(),
#ifdef QBT_USES_LIBTORRENT2
, getTorrentFormat()
.torrentFormat = getTorrentFormat(),
#else
, m_ui->checkOptimizeAlignment->isChecked()
, getPaddedFileSizeLimit()
.isAlignmentOptimized = m_ui->checkOptimizeAlignment->isChecked(),
.paddedFileSizeLimit = getPaddedFileSizeLimit(),
#endif
, getPieceSize()
, inputPath
, destPath
, m_ui->txtComment->toPlainText()
, m_ui->lineEditSource->text()
, trackers
, m_ui->URLSeedsList->toPlainText().split(u'\n', Qt::SkipEmptyParts)
.pieceSize = getPieceSize(),
.inputPath = inputPath,
.savePath = destPath,
.comment = m_ui->txtComment->toPlainText(),
.source = m_ui->lineEditSource->text(),
.trackers = trackers,
.urlSeeds = m_ui->URLSeedsList->toPlainText().split(u'\n', Qt::SkipEmptyParts)
};
auto *torrentCreator = new BitTorrent::TorrentCreator(params);
@@ -257,7 +257,7 @@ void TorrentCreatorDialog::handleCreationFailure(const QString &msg)
{
// Remove busy cursor
setCursor(QCursor(Qt::ArrowCursor));
QMessageBox::information(this, tr("Torrent creation failed"), tr("Reason: %1").arg(msg));
QMessageBox::information(this, tr("Torrent creation failed"), msg);
setInteractionEnabled(true);
}