MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / extractBaseStyleFromStyleSheet

Function extractBaseStyleFromStyleSheet

src/moapplication.cpp:600–636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

598}
599
600QString 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

Callers 1

updateStyleMethod · 0.85

Calls 3

indexOfMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected