Slider: add label substitution for certain values

Allows "Threads" option in advanced export setting to show "Auto" when set to 0
This commit is contained in:
itsmattkc
2022-02-01 15:36:26 -08:00
parent 60aa76794a
commit 217973e069
4 changed files with 20 additions and 2 deletions
@@ -48,6 +48,7 @@ ExportAdvancedVideoDialog::ExportAdvancedVideoDialog(const QList<QString> &pix_f
thread_slider_ = new IntegerSlider();
thread_slider_->SetMinimum(0);
thread_slider_->SetDefaultValue(0);
thread_slider_->InsertLabelSubstitution(0, tr("Auto"));
performance_layout->addWidget(thread_slider_, row, 1);
row++;
-1
View File
@@ -251,7 +251,6 @@ void ExportVideoTab::VideoCodecChanged()
} else {
pix_fmt_.clear();
}
qDebug() << "Set default pix fmt" << pix_fmt_;
}
void ExportVideoTab::SetTime(const rational &time)
+11 -1
View File
@@ -104,7 +104,17 @@ void SliderBase::changeEvent(QEvent *e)
void SliderBase::UpdateLabel()
{
label_->setText(tristate_ ? tr("---") : GetFormattedValueToString());
QString s;
if (tristate_) {
s = tr("---");
} else if (label_substitutions_.contains(GetValueInternal())) {
s = label_substitutions_.value(GetValueInternal());
} else {
s = GetFormattedValueToString();
}
label_->setText(s);
}
QVariant SliderBase::AdjustValue(const QVariant &value) const
+8
View File
@@ -49,6 +49,12 @@ public:
QString GetFormattedValueToString(const QVariant& v) const;
void InsertLabelSubstitution(const QVariant &value, const QString &label)
{
label_substitutions_.insert(value, label);
UpdateLabel();
}
public slots:
void ShowEditor();
@@ -92,6 +98,8 @@ private:
bool format_plural_;
QMap<QVariant, QString> label_substitutions_;
private slots:
void LineEditConfirmed();