From 48bfb68837b643fc346667d602868e6116e38201 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 3 Aug 2019 14:10:01 -0400 Subject: [PATCH] Make ColorHistory more robust to change in format. --- glabels/ColorHistory.cpp | 30 ++++++++++++++++++++++++++++-- translations/glabels_C.ts | 19 +++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/glabels/ColorHistory.cpp b/glabels/ColorHistory.cpp index 0175301..ba564de 100644 --- a/glabels/ColorHistory.cpp +++ b/glabels/ColorHistory.cpp @@ -77,7 +77,20 @@ namespace glabels for ( QString& nameColor : readNameColorList() ) { QStringList v = nameColor.split( ':' ); - colorList << QColor( v[1] ); + if ( v.size() == 2 ) + { + 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; @@ -91,7 +104,20 @@ namespace glabels for ( QString& nameColor : readNameColorList() ) { QStringList v = nameColor.split( ':' ); - nameList << v[0]; + if ( v.size() == 2 ) + { + 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; diff --git a/translations/glabels_C.ts b/translations/glabels_C.ts index 666ef04..10ece40 100644 --- a/translations/glabels_C.ts +++ b/translations/glabels_C.ts @@ -1127,6 +1127,13 @@ + + glabels::ColorHistory + + color %1 + + + glabels::ColorPaletteDialog @@ -1154,6 +1161,10 @@ %1 = color specification in hex. String must not contain a colon (:). + + Custom color #%1 + + glabels::FieldButton @@ -1912,6 +1923,14 @@ Shadow + + Insert Field + + + + Selected File... + + glabels::PrintView