| 562 | namespace |
| 563 | { |
| 564 | QStringList extractTopStyleSheetComments(QFile& stylesheet) |
| 565 | { |
| 566 | if (!stylesheet.open(QFile::ReadOnly)) { |
| 567 | log::error("failed to open stylesheet file {}", stylesheet.fileName()); |
| 568 | return {}; |
| 569 | } |
| 570 | ON_BLOCK_EXIT([&stylesheet]() { |
| 571 | stylesheet.close(); |
| 572 | }); |
| 573 | |
| 574 | QStringList topComments; |
| 575 | |
| 576 | while (true) { |
| 577 | const auto byteLine = stylesheet.readLine(); |
| 578 | if (byteLine.isNull()) { |
| 579 | break; |
| 580 | } |
| 581 | |
| 582 | const auto line = QString(byteLine).trimmed(); |
| 583 | |
| 584 | // skip empty lines |
| 585 | if (line.isEmpty()) { |
| 586 | continue; |
| 587 | } |
| 588 | |
| 589 | // only handle single line comments |
| 590 | if (!line.startsWith("/*")) { |
| 591 | break; |
| 592 | } |
| 593 | |
| 594 | topComments.push_back(line.mid(2, line.size() - 4).trimmed()); |
| 595 | } |
| 596 | |
| 597 | return topComments; |
| 598 | } |
| 599 | |
| 600 | QString extractBaseStyleFromStyleSheet(QFile& stylesheet, const QString& defaultStyle) |
| 601 | { |