Skip to content

Commit

Permalink
Fix malformed color command #293
Browse files Browse the repository at this point in the history
In dd9895c the `printf` syntax using
`%02d` was replaced with `QString` and its `arg` function. The default
fill character of `arg` is a whitespace. This broke the formatting of
the color code if they had a leading zero in any component.

In 22c838b this was fixed for
`Timecode.cpp`. The same fix was now also applied in the other places.
  • Loading branch information
ServiusHack committed Jun 10, 2024
1 parent e0642dc commit 85720f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Core/Commands/SolidColorCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const QString SolidColorCommand::getPremultipliedColor() const
green = (green * alpha) / 255;
blue = (blue * alpha) / 255;

return QString("#%1%2%3%4").arg(alpha, 2, 16)
.arg(red, 2, 16)
.arg(green, 2, 16)
.arg(blue, 2, 16);
return QString("#%1%2%3%4").arg(alpha, 2, 16, QChar('0'))
.arg(red, 2, 16, QChar('0'))
.arg(green, 2, 16, QChar('0'))
.arg(blue, 2, 16, QChar('0'));
}

const QString& SolidColorCommand::getTransition() const
Expand Down
8 changes: 4 additions & 4 deletions src/Widgets/Inspector/InspectorSolidColorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ void InspectorSolidColorWidget::colorDialogClicked()

if (dialog.exec() == QDialog::Accepted)
{
QString color = QString("#%1%2%3%4").arg(dialog.selectedColor().alpha(), 2, 16)
.arg(dialog.selectedColor().red(), 2, 16)
.arg(dialog.selectedColor().green(), 2, 16)
.arg(dialog.selectedColor().blue(), 2, 16);
QString color = QString("#%1%2%3%4").arg(dialog.selectedColor().alpha(), 2, 16, QChar('0'))
.arg(dialog.selectedColor().red(), 2, 16, QChar('0'))
.arg(dialog.selectedColor().green(), 2, 16, QChar('0'))
.arg(dialog.selectedColor().blue(), 2, 16, QChar('0'));

this->lineEditColor->setText(color.toUpper());
}
Expand Down

0 comments on commit 85720f0

Please sign in to comment.