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