| 598 | } |
| 599 | |
| 600 | QString extractBaseStyleFromStyleSheet(QFile& stylesheet, const QString& defaultStyle) |
| 601 | { |
| 602 | // read the first line of the files that are either empty or comments |
| 603 | // |
| 604 | const auto topLines = extractTopStyleSheetComments(stylesheet); |
| 605 | |
| 606 | const auto factoryStyles = QStyleFactory::keys(); |
| 607 | |
| 608 | QString style = defaultStyle; |
| 609 | |
| 610 | for (const auto& line : topLines) { |
| 611 | if (!line.startsWith("mo2-base-style")) { |
| 612 | continue; |
| 613 | } |
| 614 | |
| 615 | const auto parts = line.split(":"); |
| 616 | if (parts.size() != 2) { |
| 617 | log::warn("found invalid top-comment for mo2 in {}: {}", stylesheet.fileName(), |
| 618 | line); |
| 619 | continue; |
| 620 | } |
| 621 | |
| 622 | const auto tmpStyle = parts[1].trimmed(); |
| 623 | const auto index = factoryStyles.indexOf(tmpStyle, 0, Qt::CaseInsensitive); |
| 624 | if (index == -1) { |
| 625 | log::warn("base style '{}' from style '{}' not found", tmpStyle, |
| 626 | stylesheet.fileName(), line); |
| 627 | continue; |
| 628 | } |
| 629 | |
| 630 | style = factoryStyles[index]; |
| 631 | log::info("found base style '{}' for style '{}'", style, stylesheet.fileName()); |
| 632 | break; |
| 633 | } |
| 634 | |
| 635 | return style; |
| 636 | } |
| 637 | |
| 638 | } // namespace |
| 639 |
no test coverage detected