diff --git a/qt/MakeDialog.cc b/qt/MakeDialog.cc
index 72fc879cd..dccfe561f 100644
--- a/qt/MakeDialog.cc
+++ b/qt/MakeDialog.cc
@@ -220,24 +220,14 @@ void MakeDialog::onSourceChanged()
builder_.emplace(filename.toStdString());
}
- QString text;
-
if (!builder_)
{
- text = tr("No source selected");
+ updatePiecesLabel();
}
else
{
- auto const files = tr("%Ln File(s)", nullptr, builder_->fileCount());
- auto const pieces = tr("%Ln Piece(s)", nullptr, builder_->pieceCount());
- text = tr("%1 in %2; %3 @ %4")
- .arg(Formatter::get().sizeToString(builder_->totalSize()))
- .arg(files)
- .arg(pieces)
- .arg(Formatter::get().sizeToString(static_cast(builder_->pieceSize())));
+ ui_.pieceSizeSlider->setValue(log2(builder_->pieceSize()));
}
-
- ui_.sourceSizeLabel->setText(text);
}
MakeDialog::MakeDialog(Session& session, QWidget* parent)
@@ -266,6 +256,7 @@ MakeDialog::MakeDialog(Session& session, QWidget* parent)
connect(ui_.dialogButtons, &QDialogButtonBox::accepted, this, &MakeDialog::makeTorrent);
connect(ui_.dialogButtons, &QDialogButtonBox::rejected, this, &MakeDialog::close);
+ connect(ui_.pieceSizeSlider, &QSlider::valueChanged, this, &MakeDialog::onPieceSizeUpdated);
onSourceChanged();
}
@@ -303,3 +294,34 @@ void MakeDialog::dropEvent(QDropEvent* event)
}
}
}
+
+void MakeDialog::updatePiecesLabel()
+{
+ QString text;
+
+ if (!builder_)
+ {
+ text = tr("No source selected");
+ ui_.pieceSizeSlider->setEnabled(false);
+ }
+ else
+ {
+ auto const files = tr("%Ln File(s)", nullptr, builder_->fileCount());
+ auto const pieces = tr("%Ln Piece(s)", nullptr, builder_->pieceCount());
+ text = tr("%1 in %2; %3 @ %4")
+ .arg(Formatter::get().sizeToString(builder_->totalSize()))
+ .arg(files)
+ .arg(pieces)
+ .arg(Formatter::get().memToString(static_cast(builder_->pieceSize())));
+ ui_.pieceSizeSlider->setEnabled(true);
+ }
+
+ ui_.sourceSizeLabel->setText(text);
+}
+
+void MakeDialog::onPieceSizeUpdated(int value)
+{
+ auto new_size = static_cast(pow(2, value));
+ builder_->setPieceSize(new_size);
+ updatePiecesLabel();
+}
diff --git a/qt/MakeDialog.h b/qt/MakeDialog.h
index 7414a2bd9..ff32f018b 100644
--- a/qt/MakeDialog.h
+++ b/qt/MakeDialog.h
@@ -32,10 +32,11 @@ protected:
private slots:
void onSourceChanged();
void makeTorrent();
+ void onPieceSizeUpdated(int);
private:
QString getSource() const;
-
+ void updatePiecesLabel();
Session& session_;
Ui::MakeDialog ui_ = {};
diff --git a/qt/MakeDialog.ui b/qt/MakeDialog.ui
index a5f233fe1..c7c5c1210 100644
--- a/qt/MakeDialog.ui
+++ b/qt/MakeDialog.ui
@@ -79,6 +79,32 @@
+ -
+
+
+ 10
+
+
+ 26
+
+
+ 1
+
+
+ Qt::Horizontal
+
+
+
+ -
+
+
+ Piece s&ize:
+
+
+ pieceSizeSlider
+
+
+
-