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
+7 -3
View File
@@ -48,8 +48,9 @@ namespace glabels
void ColorButton::init( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color )
const QColor& defaultColor,
const QColor& color,
bool showUseFieldButton )
{
mDefaultColor = defaultColor;
mColorNode = model::ColorNode( color );
@@ -61,7 +62,10 @@ namespace glabels
setText( "" );
setCheckable( true );
mDialog = new ColorPaletteDialog( defaultLabel, defaultColor, color );
mDialog = new ColorPaletteDialog( defaultLabel,
defaultColor,
color,
showUseFieldButton );
connect( this, SIGNAL(toggled(bool)), this, SLOT(onButtonToggled(bool)) );
connect( mDialog, SIGNAL(colorChanged(model::ColorNode,bool)),
+5 -1
View File
@@ -58,7 +58,11 @@ namespace glabels
// Public Methods
/////////////////////////////////
public:
void init( const QString& defaultLabel, const QColor& defaultColor, const QColor& color );
void init( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color,
bool showUseFieldButton = true );
void setColorNode( model::ColorNode colorNode );
void setColor( QColor color );
void setToDefault();
+19 -8
View File
@@ -85,6 +85,7 @@ namespace glabels
ColorPaletteDialog::ColorPaletteDialog( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color,
bool showUseFieldButton,
QWidget* parent )
: QDialog( parent )
{
@@ -167,14 +168,21 @@ namespace glabels
vLayout->addWidget( customColorButton );
//
// Construct "Use key" Button
// Construct "Use field" Button
//
mFieldButton = new FieldButton();
mFieldButton->setText( tr("Use key") );
mFieldButton->setAutoDefault( false );
mFieldButton->setDefault( false );
connect( mFieldButton, SIGNAL(keySelected(QString)), this, SLOT(onKeySelected(QString)) );
vLayout->addWidget( mFieldButton );
if ( showUseFieldButton )
{
mFieldButton = new FieldButton();
mFieldButton->setText( tr("Use substitution field") );
mFieldButton->setAutoDefault( false );
mFieldButton->setDefault( false );
connect( mFieldButton, SIGNAL(keySelected(QString)), this, SLOT(onKeySelected(QString)) );
vLayout->addWidget( mFieldButton );
}
else
{
mFieldButton = nullptr;
}
setLayout( vLayout );
@@ -191,7 +199,10 @@ namespace glabels
void ColorPaletteDialog::setKeys( const merge::Merge* merge,
const model::Variables* variables )
{
mFieldButton->setKeys( merge, variables );
if (mFieldButton)
{
mFieldButton->setKeys( merge, variables );
}
}
+1
View File
@@ -49,6 +49,7 @@ namespace glabels
ColorPaletteDialog( const QString& defaultLabel,
const QColor& defaultColor,
const QColor& color,
bool showUseFieldButton = true,
QWidget* parent = nullptr );
+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 );
+1
View File
@@ -57,6 +57,7 @@ namespace glabels
void onNameEditChanged();
void onTypeComboChanged();
void onValueEditChanged();
void onColorValueButtonChanged();
void onIncrementComboChanged();
void onStepSizeEditChanged();
+3 -3
View File
@@ -67,9 +67,9 @@ namespace glabels
barcodeColorButton->init( tr("Default"), QColor(0,0,0,255), QColor(0,0,0,255) );
shadowColorButton->init( tr("Default"), QColor(0,0,0,255), QColor(0,0,0,255) );
textInsertFieldButton->setText( tr("Insert field") );
barcodeInsertFieldButton->setText( tr("Insert field") );
imageFieldButton->setText( tr("Use field") );
textInsertFieldButton->setText( tr("Insert substitution field") );
barcodeInsertFieldButton->setText( tr("Insert subsitution field") );
imageFieldButton->setText( tr("Use substitution field") );
setEnabled( false );
hidePages();
+1 -1
View File
@@ -63,7 +63,7 @@ namespace glabels
typeHeaderItem->setFlags( typeHeaderItem->flags() ^ Qt::ItemIsEditable );
table->setHorizontalHeaderItem( I_COL_TYPE, typeHeaderItem );
auto* valueHeaderItem = new QTableWidgetItem( tr("Initial Value") );
auto* valueHeaderItem = new QTableWidgetItem( tr("Value") );
valueHeaderItem->setFlags( valueHeaderItem->flags() ^ Qt::ItemIsEditable );
table->setHorizontalHeaderItem( I_COL_VALUE, valueHeaderItem );
+76 -38
View File
@@ -67,16 +67,6 @@
<item row="1" column="1">
<widget class="QLineEdit" name="nameEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="valueEdit"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
@@ -94,6 +84,27 @@
<item row="0" column="1">
<widget class="QComboBox" name="typeCombo"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLineEdit" name="valueEdit"/>
</item>
<item>
<widget class="glabels::ColorButton" name="colorValueButton">
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
@@ -111,6 +122,16 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>glabels::ColorButton</class>
<extends>QPushButton</extends>
<header>ColorButton.h</header>
<slots>
<signal>colorChanged()</signal>
</slots>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
@@ -120,8 +141,8 @@
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>227</x>
<y>214</y>
<x>236</x>
<y>287</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
@@ -136,8 +157,8 @@
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>295</x>
<y>220</y>
<x>304</x>
<y>287</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
@@ -152,8 +173,8 @@
<slot>onTypeComboChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>179</x>
<y>30</y>
<x>252</x>
<y>70</y>
</hint>
<hint type="destinationlabel">
<x>33</x>
@@ -161,22 +182,6 @@
</hint>
</hints>
</connection>
<connection>
<sender>valueEdit</sender>
<signal>textChanged(QString)</signal>
<receiver>EditVariableDialog</receiver>
<slot>onValueEditChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>212</x>
<y>86</y>
</hint>
<hint type="destinationlabel">
<x>63</x>
<y>166</y>
</hint>
</hints>
</connection>
<connection>
<sender>incrementCombo</sender>
<signal>currentIndexChanged(int)</signal>
@@ -184,8 +189,8 @@
<slot>onIncrementComboChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>170</x>
<y>123</y>
<x>100</x>
<y>223</y>
</hint>
<hint type="destinationlabel">
<x>97</x>
@@ -200,8 +205,8 @@
<slot>onStepSizeEditChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>344</x>
<y>125</y>
<x>440</x>
<y>223</y>
</hint>
<hint type="destinationlabel">
<x>333</x>
@@ -216,8 +221,8 @@
<slot>onNameEditChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>371</x>
<y>62</y>
<x>440</x>
<y>103</y>
</hint>
<hint type="destinationlabel">
<x>393</x>
@@ -225,6 +230,38 @@
</hint>
</hints>
</connection>
<connection>
<sender>valueEdit</sender>
<signal>textChanged(QString)</signal>
<receiver>EditVariableDialog</receiver>
<slot>onValueEditChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>318</x>
<y>129</y>
</hint>
<hint type="destinationlabel">
<x>459</x>
<y>157</y>
</hint>
</hints>
</connection>
<connection>
<sender>colorValueButton</sender>
<signal>colorChanged()</signal>
<receiver>EditVariableDialog</receiver>
<slot>onColorValueButtonChanged()</slot>
<hints>
<hint type="sourcelabel">
<x>406</x>
<y>114</y>
</hint>
<hint type="destinationlabel">
<x>458</x>
<y>122</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>onTypeComboChanged()</slot>
@@ -232,5 +269,6 @@
<slot>onIncrementComboChanged()</slot>
<slot>onStepSizeEditChanged()</slot>
<slot>onNameEditChanged()</slot>
<slot>onColorValueButtonChanged()</slot>
</slots>
</ui>
+60 -39
View File
@@ -786,46 +786,67 @@
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QLineEdit" name="imageFilenameLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>231</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>None</string>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLineEdit" name="imageFilenameLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>231</width>
<height>0</height>
</size>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>None</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="imageBrowseButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="imageBrowseButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="glabels::FieldButton" name="imageFieldButton">
<property name="text">
<string notr="true">Use field</string>
</property>
</widget>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_27">
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="glabels::FieldButton" name="imageFieldButton">
<property name="text">
<string notr="true">Use field</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>