@@ -490,48 +490,58 @@ bool PsiIconset::loadClients()
490
490
iconsId.insert (it.next ()->name ().section (' /' , 1 , 1 ));
491
491
}
492
492
493
- QStringList dirs = ApplicationInfo::dataDirs ();
494
493
ClientIconMap cm; // start part, spec[spec2[spec3]]
495
- foreach (const QString &dataDir, dirs) {
496
- QFile capsConv (dataDir + QLatin1String (" /client_icons.txt" ));
494
+
495
+ auto readClientsDesc = [&](const QString &filePath) {
496
+ QFile capsConv (filePath);
497
497
/* file format: <icon res name> <left_part_of_cap1#inside1#inside2>,<left_part_of_cap2>
498
498
next line the same.
499
499
*/
500
- if (capsConv.open (QIODevice::ReadOnly)) {
501
- QTextStream stream (&capsConv);
502
-
503
- QString line;
504
- while (!(line = stream.readLine ()).isNull ()) {
505
- line = line.trimmed ();
506
- QString iconName = line.section (QLatin1Char (' ' ), 0 , 0 );
507
- if (!iconName.length () || !iconsId.contains (iconName)) {
508
- continue ;
509
- }
510
- ClientIconCheck ic = { iconName, QStringList () };
511
- QString caps = line.mid (iconName.length ());
512
- foreach (const QString &c, caps.split (QLatin1Char (' ,' ), QString::SkipEmptyParts)) {
513
- QString ct = c.trimmed ();
514
- if (ct.length ()) {
515
- QStringList spec = ct.split (' #' );
516
- if (spec.size () > 1 ) {
517
- ic.inside = spec.mid (1 );
518
- } else {
519
- ic.inside .clear ();
520
- }
521
- ClientIconMap::Iterator it = cm.find (spec[0 ]);
522
- if (it == cm.end ()) {
523
- cm.insert (spec[0 ], QList<ClientIconCheck>() << ic);
524
- } else {
525
- it.value ().append (ic);
526
- }
500
+ if (!capsConv.open (QIODevice::ReadOnly))
501
+ return false ;
502
+
503
+ QTextStream stream (&capsConv);
504
+
505
+ QString line;
506
+ while (!(line = stream.readLine ()).isNull ()) {
507
+ line = line.trimmed ();
508
+ QString iconName = line.section (QLatin1Char (' ' ), 0 , 0 );
509
+ if (!iconName.length () || !iconsId.contains (iconName)) {
510
+ continue ;
511
+ }
512
+ ClientIconCheck ic = { iconName, QStringList () };
513
+ QString caps = line.mid (iconName.length ());
514
+ for (const QString &c : caps.split (QLatin1Char (' ,' ), QString::SkipEmptyParts)) {
515
+ QString ct = c.trimmed ();
516
+ if (ct.length ()) {
517
+ QStringList spec = ct.split (' #' );
518
+ if (spec.size () > 1 ) {
519
+ ic.inside = spec.mid (1 );
520
+ } else {
521
+ ic.inside .clear ();
522
+ }
523
+ ClientIconMap::Iterator it = cm.find (spec[0 ]);
524
+ if (it == cm.end ()) {
525
+ cm.insert (spec[0 ], QList<ClientIconCheck>() << ic);
526
+ } else {
527
+ it.value ().append (ic);
527
528
}
528
529
}
529
530
}
530
- /* insert end boundry element to make search implementation simple */
531
- cm.insert (QLatin1String (" ~" ), QList<ClientIconCheck>());
532
- break ;
533
531
}
532
+ /* insert end boundry element to make search implementation simple */
533
+ cm.insert (QLatin1String (" ~" ), QList<ClientIconCheck>());
534
+ return true ;
535
+ };
536
+
537
+ auto customPath = PsiOptions::instance ()->getOption (" options.iconsets.clients-capsfile" ).toString ();
538
+ if (customPath.isEmpty () || !readClientsDesc (customPath)) {
539
+ QStringList dirs = ApplicationInfo::dataDirs ();
540
+ for (const auto &dataDir : dirs)
541
+ if (readClientsDesc (dataDir + QLatin1String (" /client_icons.txt" )))
542
+ break ;
534
543
}
544
+
535
545
if (cm.isEmpty ()) {
536
546
qWarning (" Failed to read client_icons.txt. Clients detection won't work" );
537
547
}
0 commit comments