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:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user