Skip to content

Commit

Permalink
Graph colour: added support for the alpha channel.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Sep 25, 2017
1 parent b2f6af6 commit 7e3090d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/plugins/miscellaneous/Core/src/propertyeditorwidget.cpp
Expand Up @@ -285,7 +285,7 @@ ColorEditorWidget::ColorEditorWidget(QWidget *pParent) :
{
// Set a validator that accepts any colour

static const QRegularExpression ColorRegEx = QRegularExpression("^#[[:xdigit:]]{6}$");
static const QRegularExpression ColorRegEx = QRegularExpression("^#([[:xdigit:]]{6}|[[:xdigit:]]{8})$");

setValidator(new QRegularExpressionValidator(ColorRegEx, this));
}
Expand Down Expand Up @@ -744,6 +744,7 @@ void Property::setValue(const QString &pValue, const bool &pForce,

color.setNamedColor(pValue);

colorPixmapPainter.fillRect(0, 0, colorPixmap.width()-1, colorPixmap.height()-1, Qt::white);
colorPixmapPainter.fillRect(0, 0, colorPixmap.width()-1, colorPixmap.height()-1, color);

mValue->setIcon(colorPixmap);
Expand Down Expand Up @@ -953,8 +954,14 @@ void Property::setColorValue(const QColor &pColorValue)
{
// Set our value, should it be of color type

if (mType == Color)
setValue(pColorValue.name());
if (mType == Color) {
QString colorValueName = pColorValue.name(QColor::HexArgb);

if (colorValueName.startsWith("#ff"))
setValue(pColorValue.name());
else
setValue(colorValueName);
}
}

//==============================================================================
Expand Down
Expand Up @@ -453,6 +453,7 @@ void SimulationExperimentViewInformationGraphsWidget::selectColor()

QColorDialog colorDialog(mPropertyEditor->currentProperty()->colorValue(), this);

colorDialog.setOption(QColorDialog::ShowAlphaChannel);
colorDialog.setWindowTitle(tr("Select Colour"));

if (colorDialog.exec()) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/support/SEDMLSupport/i18n/SEDMLSupport_fr.ts
Expand Up @@ -23,8 +23,8 @@
<translation>la propriété &apos;%1&apos; doit avoir une valeur de %2</translation>
</message>
<message>
<source>the &apos;%1&apos; property must have a value of &apos;#RRGGBB&apos;</source>
<translation>la propriété &apos;%1&apos; doit avoir une valeur de &apos;#RRGGBB&apos;</translation>
<source>the &apos;%1&apos; property must have a value of &apos;#RRGGBB&apos; or &apos;#AARRGGBB&apos;</source>
<translation>la propriété &apos;%1&apos; doit avoir une valeur de &apos;#RRGGBB&apos; ou &apos;#AARRGGBB&apos;</translation>
</message>
<message>
<source>only SED-ML files with one model are supported</source>
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/support/SEDMLSupport/src/sedmlfile.cpp
Expand Up @@ -314,13 +314,13 @@ bool SedmlFile::validColorPropertyValue(const libsbml::XMLNode &pPropertyNode,
{
// Check whether the given color property is valid

static const QRegularExpression ColorRegEx = QRegularExpression("^#[[:xdigit:]]{6}$");
static const QRegularExpression ColorRegEx = QRegularExpression("^#([[:xdigit:]]{6}|[[:xdigit:]]{8})$");

if (!ColorRegEx.match(pPropertyNodeValue).hasMatch()) {
mIssues << SedmlFileIssue(SedmlFileIssue::Error,
pPropertyNode.getLine(),
pPropertyNode.getColumn(),
tr("the '%1' property must have a value of '#RRGGBB'").arg(pPropertyName));
tr("the '%1' property must have a value of '#RRGGBB' or '#AARRGGBB'").arg(pPropertyName));

return false;
} else {
Expand Down

0 comments on commit 7e3090d

Please sign in to comment.