diff --git a/glabels/ColorHistory.cpp b/glabels/ColorHistory.cpp index 60ff08f..0175301 100644 --- a/glabels/ColorHistory.cpp +++ b/glabels/ColorHistory.cpp @@ -46,23 +46,25 @@ namespace glabels } - void ColorHistory::addColor( const QColor &color ) + void ColorHistory::addColor( const QColor &color, const QString& name ) { - QList colorList = readColorList(); + QString nameColor = name + ":" + color.name(); + + QStringList nameColorList = readNameColorList(); // Remove any occurrences of this color already in list - colorList.removeAll( color ); + nameColorList.removeAll( nameColor ); // Now add to list - colorList.append( color ); + nameColorList.append( nameColor ); // Remove oldest colors, if size exceeds current max - while ( colorList.size() > MAX_COLORS ) + while ( nameColorList.size() > MAX_COLORS ) { - colorList.removeFirst(); + nameColorList.removeFirst(); } - writeColorList( colorList ); + writeNameColorList( nameColorList ); emit changed(); } @@ -70,55 +72,57 @@ namespace glabels QList ColorHistory::getColors() { - return readColorList(); - } - - - QColor ColorHistory::getColor( int id ) - { - QList colors = readColorList(); - return colors[id]; - } - - - QList ColorHistory::readColorList() - { - QStringList defaultList; - QSettings settings; - - settings.beginGroup( "ColorHistory" ); - QStringList colorNameList = settings.value( "colors", defaultList ).toStringList(); - settings.endGroup(); - QList colorList; - foreach ( QString colorName, colorNameList ) + + for ( QString& nameColor : readNameColorList() ) { - colorList << QColor( colorName ); - } - - // Remove oldest colors, if size exceeds current max - while ( colorList.size() > MAX_COLORS ) - { - colorList.removeFirst(); + QStringList v = nameColor.split( ':' ); + colorList << QColor( v[1] ); } return colorList; } - void ColorHistory::writeColorList( const QList& colorList ) + QStringList ColorHistory::getNames() { - // Build name list - QStringList colorNameList; - foreach ( QColor color, colorList ) + QStringList nameList; + + for ( QString& nameColor : readNameColorList() ) { - colorNameList << color.name(); + QStringList v = nameColor.split( ':' ); + nameList << v[0]; } + return nameList; + } + + + QStringList ColorHistory::readNameColorList() + { + QStringList defaultList; + QSettings settings; + + settings.beginGroup( "ColorHistory" ); + QStringList nameColorList = settings.value( "colors", defaultList ).toStringList(); + settings.endGroup(); + + // Remove oldest colors, if size exceeds current max + while ( nameColorList.size() > MAX_COLORS ) + { + nameColorList.removeFirst(); + } + + return nameColorList; + } + + + void ColorHistory::writeNameColorList( const QStringList& nameColorList ) + { // Save QSettings settings; settings.beginGroup( "ColorHistory" ); - settings.setValue( "colors", colorNameList ); + settings.setValue( "colors", nameColorList ); settings.endGroup(); } diff --git a/glabels/ColorHistory.h b/glabels/ColorHistory.h index b74b3b4..eb14812 100644 --- a/glabels/ColorHistory.h +++ b/glabels/ColorHistory.h @@ -60,17 +60,17 @@ namespace glabels // Public Methods ///////////////////////////////// public: - void addColor( const QColor &color ); + void addColor( const QColor& color, const QString& name ); QList getColors(); - QColor getColor( int id ); + QStringList getNames(); ///////////////////////////////// // Private Methods ///////////////////////////////// private: - QList readColorList(); - void writeColorList( const QList& colorList ); + QStringList readNameColorList(); + void writeNameColorList( const QStringList& nameColorList ); ///////////////////////////////// diff --git a/glabels/ColorPaletteDialog.cpp b/glabels/ColorPaletteDialog.cpp index e11b4ad..3986fe4 100644 --- a/glabels/ColorPaletteDialog.cpp +++ b/glabels/ColorPaletteDialog.cpp @@ -206,7 +206,7 @@ namespace glabels { mColorNode = newColorNode; - mColorHistory->addColor( mColorNode.color() ); + mColorHistory->addColor( mColorNode.color(), mColorTable[id].trname ); emit colorChanged( mColorNode, false ); accept(); @@ -217,7 +217,7 @@ namespace glabels void ColorPaletteDialog::onHistoryItemActivated( int id ) { mColorNode.setField( false ); - mColorNode.setColor( mColorHistory->getColor(id) ); + mColorNode.setColor( mColorHistory->getColors()[id] ); mColorNode.setKey( "" ); emit colorChanged( mColorNode, false ); @@ -253,7 +253,10 @@ namespace glabels { mColorNode = newColorNode; - mColorHistory->addColor( mColorNode.color() ); + // TRANSLATORS + //: %1 = color specification in hex. String must not contain a colon (:). + mColorHistory->addColor( mColorNode.color(), + QString(tr("Custom Color %1")).arg(mColorNode.color().name()) ); emit colorChanged( mColorNode, false ); accept(); @@ -270,12 +273,13 @@ namespace glabels void ColorPaletteDialog::loadCustomColorHistory() { + QStringList nameList = mColorHistory->getNames(); QList colorList = mColorHistory->getColors(); int id = 0; foreach ( QColor color, colorList ) { - mHistoryItem[id]->setColor( id, color, QString(tr("Custom color #%1").arg(id+1) ) ); + mHistoryItem[id]->setColor( id, color, nameList[id] ); mHistoryItem[id]->setEnabled( true ); id++; } diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index add9668..666ef04 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -184,22 +184,22 @@ Dialog - - Name: - - - - Increment: - - Variable type: + + Name: + + Initial value: + + Increment: + + Step size: @@ -405,6 +405,10 @@ File + + Browse... + + Line/Fill @@ -481,10 +485,6 @@ Opacity: - - Browse... - - PreferencesDialog @@ -1056,18 +1056,6 @@ String - - Never - - - - Per copy - - - - Per page - - Integer @@ -1076,10 +1064,22 @@ Floating Point + + Never + + Per item + + Per copy + + + + Per page + + VariablesView @@ -1129,28 +1129,29 @@ glabels::ColorPaletteDialog + + Standard Colors + + + + Recent Colors + + Custom color... - - Custom Color - - - - Custom color #%1 - - Use key - Standard Colors + Custom Color - Recent Colors + Custom Color %1 + %1 = color specification in hex. String must not contain a colon (:). @@ -1768,7 +1769,11 @@ - Insert Field + Insert field + + + + Use field @@ -1907,18 +1912,6 @@ Shadow - - Selected File... - - - - Insert field - - - - Use field - - glabels::PrintView @@ -2148,14 +2141,6 @@ Variables - - Add Variable - - - - Edit Variable - - Name @@ -2164,6 +2149,10 @@ Type + + Initial Value + + Increment @@ -2173,7 +2162,11 @@ - Initial Value + Add Variable + + + + Edit Variable