Make ColorHistory more robust to change in format.

This commit is contained in:
Jim Evins
2019-08-03 14:10:01 -04:00
parent 2c1c865f53
commit 48bfb68837
2 changed files with 47 additions and 2 deletions
+26
View File
@@ -77,8 +77,21 @@ namespace glabels
for ( QString& nameColor : readNameColorList() ) for ( QString& nameColor : readNameColorList() )
{ {
QStringList v = nameColor.split( ':' ); QStringList v = nameColor.split( ':' );
if ( v.size() == 2 )
{
colorList << QColor( v[1] ); colorList << QColor( v[1] );
} }
else if ( v.size() == 1 )
{
// Old-style, no name
colorList << QColor( v[0] );
}
else
{
// Should not happen
qWarning() << "Invalid color history.";
}
}
return colorList; return colorList;
} }
@@ -91,8 +104,21 @@ namespace glabels
for ( QString& nameColor : readNameColorList() ) for ( QString& nameColor : readNameColorList() )
{ {
QStringList v = nameColor.split( ':' ); QStringList v = nameColor.split( ':' );
if ( v.size() == 2 )
{
nameList << v[0]; nameList << v[0];
} }
else if ( v.size() == 1 )
{
// Old-style, no name
nameList << QString(tr("color %1")).arg( v[0] );
}
else
{
// Should not happen
qWarning() << "Invalid color history.";
}
}
return nameList; return nameList;
} }
+19
View File
@@ -1127,6 +1127,13 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context>
<name>glabels::ColorHistory</name>
<message>
<source>color %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>glabels::ColorPaletteDialog</name> <name>glabels::ColorPaletteDialog</name>
<message> <message>
@@ -1154,6 +1161,10 @@
<extracomment>%1 = color specification in hex. String must not contain a colon (:).</extracomment> <extracomment>%1 = color specification in hex. String must not contain a colon (:).</extracomment>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Custom color #%1</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>glabels::FieldButton</name> <name>glabels::FieldButton</name>
@@ -1912,6 +1923,14 @@
<source>Shadow</source> <source>Shadow</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Insert Field</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Selected File...</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>glabels::PrintView</name> <name>glabels::PrintView</name>