Added color variable type.

This commit is contained in:
Jim Evins
2019-08-03 17:16:14 -04:00
parent dd41aa3dd7
commit f41461ef26
13 changed files with 248 additions and 107 deletions
+20 -1
View File
@@ -31,7 +31,8 @@ namespace
const QVector<glabels::model::Variable::Type> allTypes = {
glabels::model::Variable::Type::STRING,
glabels::model::Variable::Type::INTEGER,
glabels::model::Variable::Type::FLOATING_POINT
glabels::model::Variable::Type::FLOATING_POINT,
glabels::model::Variable::Type::COLOR
};
// All variable increments. (must be in sorted order)
@@ -58,6 +59,11 @@ namespace glabels
QRegularExpression reIdentifier( "[a-zA-Z_][a-zA-Z_0-9]*" );
nameEdit->setValidator( new QRegularExpressionValidator( reIdentifier ) );
colorValueButton->init( tr("Default"),
QColor(0,0,0,255),
QColor(0,0,0,255),
false );
for ( auto type : allTypes )
{
typeCombo->addItem( model::Variable::typeToI18nString( type ) );
@@ -80,6 +86,7 @@ namespace glabels
typeCombo->setCurrentIndex( static_cast<int>(variable.type()) );
nameEdit->setText( variable.name() );
valueEdit->setText( variable.initialValue() );
colorValueButton->setColor( QColor( variable.initialValue() ) );
incrementCombo->setCurrentIndex( static_cast<int>(variable.increment()) );
stepSizeEdit->setText( variable.stepSize() );
@@ -127,6 +134,16 @@ namespace glabels
}
///
/// colorValueButton Changed
///
void EditVariableDialog::onColorValueButtonChanged()
{
valueEdit->setText( colorValueButton->colorNode().color().name() );
validateCurrentInputs();
}
///
/// incrementCombo Changed
///
@@ -173,6 +190,8 @@ namespace glabels
}
colorValueButton->setVisible( type == model::Variable::Type::COLOR );
bool isNumeric = ( type == model::Variable::Type::INTEGER ) ||
( type == model::Variable::Type::FLOATING_POINT );