39 |
40 |
40 // ============================================================================= |
41 // ============================================================================= |
41 // ----------------------------------------------------------------------------- |
42 // ----------------------------------------------------------------------------- |
42 void parseLDConfig() |
43 void parseLDConfig() |
43 { |
44 { |
44 File* f = openLDrawFile ("LDConfig.ldr", false); |
45 QFile* fp = openLDrawFile ("LDConfig.ldr", false); |
45 |
46 |
46 if (!f) |
47 if (!fp) |
47 { |
48 { |
48 critical (fmt (QObject::tr ("Unable to open LDConfig.ldr for parsing: %1"), |
49 critical (QObject::tr ("Unable to open LDConfig.ldr for parsing.")); |
49 strerror (errno))); |
|
50 return; |
50 return; |
51 } |
51 } |
52 |
52 |
53 // Read in the lines |
53 // Read in the lines |
54 for (QString line : *f) |
54 while (fp->atEnd() == false) |
55 { |
55 { |
56 if (line.length() == 0 || line[0] != '0') |
56 QString line = QString::fromUtf8 (fp->readLine()); |
|
57 |
|
58 if (line.isEmpty() || line[0] != '0') |
57 continue; // empty or illogical |
59 continue; // empty or illogical |
58 |
60 |
59 line.remove ('\r'); |
61 line.remove ('\r'); |
60 line.remove ('\n'); |
62 line.remove ('\n'); |
61 |
63 |
109 col->faceColor.setAlpha (alpha); |
111 col->faceColor.setAlpha (alpha); |
110 col->index = code; |
112 col->index = code; |
111 setColor (code, col); |
113 setColor (code, col); |
112 } |
114 } |
113 |
115 |
114 delete f; |
116 fp->close(); |
|
117 fp->deleteLater(); |
115 } |
118 } |
116 |
119 |
117 // ============================================================================= |
120 // ============================================================================= |
118 // ----------------------------------------------------------------------------- |
121 // ----------------------------------------------------------------------------- |
119 LDConfigParser::LDConfigParser (QString inText, char sep) |
122 LDConfigParser::LDConfigParser (QString inText, char sep) |