57 PrimitiveCategory::loadCategories(); |
57 PrimitiveCategory::loadCategories(); |
58 |
58 |
59 // Try to load prims.cfg |
59 // Try to load prims.cfg |
60 QFile conf (Config::filepath ("prims.cfg")); |
60 QFile conf (Config::filepath ("prims.cfg")); |
61 |
61 |
62 if (conf.open (QIODevice::ReadOnly) == false) |
62 if (not conf.open (QIODevice::ReadOnly)) |
63 { |
63 { |
64 // No prims.cfg, build it |
64 // No prims.cfg, build it |
65 PrimitiveScanner::start(); |
65 PrimitiveScanner::start(); |
66 } |
66 } |
67 else |
67 else |
68 { |
68 { |
69 while (conf.atEnd() == false) |
69 while (not conf.atEnd()) |
70 { |
70 { |
71 QString line = conf.readLine(); |
71 QString line = conf.readLine(); |
72 |
72 |
73 if (line.endsWith ("\n")) |
73 if (line.endsWith ("\n")) |
74 line.chop (1); |
74 line.chop (1); |
135 for (; m_i < j; ++m_i) |
135 for (; m_i < j; ++m_i) |
136 { |
136 { |
137 QString fname = m_files[m_i]; |
137 QString fname = m_files[m_i]; |
138 QFile f (fname); |
138 QFile f (fname); |
139 |
139 |
140 if (!f.open (QIODevice::ReadOnly)) |
140 if (not f.open (QIODevice::ReadOnly)) |
141 continue; |
141 continue; |
142 |
142 |
143 Primitive info; |
143 Primitive info; |
144 info.name = fname.mid (m_baselen + 1); // make full path relative |
144 info.name = fname.mid (m_baselen + 1); // make full path relative |
145 info.name.replace ('/', '\\'); // use DOS backslashes, they're expected |
145 info.name.replace ('/', '\\'); // use DOS backslashes, they're expected |
164 { |
164 { |
165 // Done with primitives, now save to a config file |
165 // Done with primitives, now save to a config file |
166 QString path = Config::filepath ("prims.cfg"); |
166 QString path = Config::filepath ("prims.cfg"); |
167 QFile conf (path); |
167 QFile conf (path); |
168 |
168 |
169 if (!conf.open (QIODevice::WriteOnly | QIODevice::Text)) |
169 if (not conf.open (QIODevice::WriteOnly | QIODevice::Text)) |
170 critical (format ("Couldn't write primitive list %1: %2", |
170 critical (format ("Couldn't write primitive list %1: %2", |
171 path, conf.errorString())); |
171 path, conf.errorString())); |
172 else |
172 else |
173 { |
173 { |
174 for (Primitive& info : m_prims) |
174 for (Primitive& info : m_prims) |
272 delete cat; |
272 delete cat; |
273 |
273 |
274 g_PrimitiveCategories.clear(); |
274 g_PrimitiveCategories.clear(); |
275 QString path = Config::dirpath() + "primregexps.cfg"; |
275 QString path = Config::dirpath() + "primregexps.cfg"; |
276 |
276 |
277 if (!QFile::exists (path)) |
277 if (not QFile::exists (path)) |
278 path = ":/data/primitive-categories.cfg"; |
278 path = ":/data/primitive-categories.cfg"; |
279 |
279 |
280 QFile f (path); |
280 QFile f (path); |
281 |
281 |
282 if (!f.open (QIODevice::ReadOnly)) |
282 if (not f.open (QIODevice::ReadOnly)) |
283 { |
283 { |
284 critical (format (QObject::tr ("Failed to open primitive categories: %1"), f.errorString())); |
284 critical (format (QObject::tr ("Failed to open primitive categories: %1"), f.errorString())); |
285 return; |
285 return; |
286 } |
286 } |
287 |
287 |
288 PrimitiveCategory* cat = null; |
288 PrimitiveCategory* cat = null; |
289 |
289 |
290 while (f.atEnd() == false) |
290 while (not f.atEnd()) |
291 { |
291 { |
292 QString line = f.readLine(); |
292 QString line = f.readLine(); |
293 int colon; |
293 int colon; |
294 |
294 |
295 if (line.endsWith ("\n")) |
295 if (line.endsWith ("\n")) |
611 f->setDefaultName (name); |
611 f->setDefaultName (name); |
612 |
612 |
613 QString author = APPNAME; |
613 QString author = APPNAME; |
614 QString license = ""; |
614 QString license = ""; |
615 |
615 |
616 if (ld_defaultname.isEmpty() == false) |
616 if (not ld_defaultname.isEmpty()) |
617 { |
617 { |
618 license = getLicenseText (ld_defaultlicense); |
618 license = getLicenseText (ld_defaultlicense); |
619 author = format ("%1 [%2]", ld_defaultname, ld_defaultuser); |
619 author = format ("%1 [%2]", ld_defaultname, ld_defaultuser); |
620 } |
620 } |
621 |
621 |
681 // |
681 // |
682 DEFINE_ACTION (MakePrimitive, 0) |
682 DEFINE_ACTION (MakePrimitive, 0) |
683 { |
683 { |
684 PrimitivePrompt* dlg = new PrimitivePrompt (g_win); |
684 PrimitivePrompt* dlg = new PrimitivePrompt (g_win); |
685 |
685 |
686 if (!dlg->exec()) |
686 if (not dlg->exec()) |
687 return; |
687 return; |
688 |
688 |
689 int segs = dlg->ui->sb_segs->value(); |
689 int segs = dlg->ui->sb_segs->value(); |
690 int divs = dlg->ui->cb_hires->isChecked() ? g_hires : g_lores; |
690 int divs = dlg->ui->cb_hires->isChecked() ? g_hires : g_lores; |
691 int num = dlg->ui->sb_ringnum->value(); |
691 int num = dlg->ui->sb_ringnum->value(); |