diff --git a/src/moapplication.cpp b/src/moapplication.cpp
index e131d3d96..bf6a40747 100644
--- a/src/moapplication.cpp
+++ b/src/moapplication.cpp
@@ -44,6 +44,7 @@ along with Mod Organizer. If not, see .
#include
#include
#include
+#include
#include
// see addDllsToPath() below
@@ -154,8 +155,8 @@ MOApplication::MOApplication(int& argc, char** argv) : QApplication(argc, argv)
updateStyle(file);
});
- m_defaultStyle = style()->objectName();
- setStyle(new ProxyStyle(style()));
+ m_defaultStyle = "windowsvista";
+ updateStyle(m_defaultStyle);
addDllsToPath();
}
@@ -558,14 +559,94 @@ bool MOApplication::notify(QObject* receiver, QEvent* event)
}
}
+namespace
+{
+QStringList extractTopStyleSheetComments(QFile& stylesheet)
+{
+ if (!stylesheet.open(QFile::ReadOnly)) {
+ log::error("failed to open stylesheet file {}", stylesheet.fileName());
+ return {};
+ }
+ ON_BLOCK_EXIT([&stylesheet]() {
+ stylesheet.close();
+ });
+
+ QStringList topComments;
+
+ while (true) {
+ const auto byteLine = stylesheet.readLine();
+ if (byteLine.isNull()) {
+ break;
+ }
+
+ const auto line = QString(byteLine).trimmed();
+
+ // skip empty lines
+ if (line.isEmpty()) {
+ continue;
+ }
+
+ // only handle single line comments
+ if (!line.startsWith("/*")) {
+ break;
+ }
+
+ topComments.push_back(line.mid(2, line.size() - 4).trimmed());
+ }
+
+ return topComments;
+}
+
+QString extractBaseStyleFromStyleSheet(QFile& stylesheet, const QString& defaultStyle)
+{
+ // read the first line of the files that are either empty or comments
+ //
+ const auto topLines = extractTopStyleSheetComments(stylesheet);
+
+ const auto factoryStyles = QStyleFactory::keys();
+
+ QString style = defaultStyle;
+
+ for (const auto& line : topLines) {
+ if (!line.startsWith("mo2-base-style")) {
+ continue;
+ }
+
+ const auto parts = line.split(":");
+ if (parts.size() != 2) {
+ log::warn("found invalid top-comment for mo2 in {}: {}", stylesheet.fileName(),
+ line);
+ continue;
+ }
+
+ const auto tmpStyle = parts[1].trimmed();
+ const auto index = factoryStyles.indexOf(tmpStyle, 0, Qt::CaseInsensitive);
+ if (index == -1) {
+ log::warn("base style '{}' from style '{}' not found", tmpStyle,
+ stylesheet.fileName(), line);
+ continue;
+ }
+
+ style = factoryStyles[index];
+ log::info("found base style '{}' for style '{}'", style, stylesheet.fileName());
+ break;
+ }
+
+ return style;
+}
+
+} // namespace
+
void MOApplication::updateStyle(const QString& fileName)
{
if (QStyleFactory::keys().contains(fileName)) {
setStyleSheet("");
setStyle(new ProxyStyle(QStyleFactory::create(fileName)));
} else {
- setStyle(new ProxyStyle(QStyleFactory::create(m_defaultStyle)));
- if (QFile::exists(fileName)) {
+ QFile stylesheet(fileName);
+ if (stylesheet.exists()) {
+ setStyle(new ProxyStyle(QStyleFactory::create(
+ extractBaseStyleFromStyleSheet(stylesheet, m_defaultStyle))));
setStyleSheet(QString("file:///%1").arg(fileName));
} else {
log::warn("invalid stylesheet: {}", fileName);
diff --git a/src/organizer_en.ts b/src/organizer_en.ts
index 362ccd892..dc4bc55e2 100644
--- a/src/organizer_en.ts
+++ b/src/organizer_en.ts
@@ -1799,194 +1799,194 @@ Right now the only case I know of where this needs to be overwritten is for the
FileTree
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -2398,11 +2398,17 @@ Right now the only case I know of where this needs to be overwritten is for the
+
+
+
+
+
+
@@ -2895,37 +2901,37 @@ This is likely due to a corrupted or incompatible download or unrecognized archi
MOApplication
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -4662,22 +4668,22 @@ p, li { white-space: pre-wrap; }
ModInfoForeign
-
+
-
+
-
+
-
+
@@ -5884,207 +5890,208 @@ Please enter a name:
OrganizerCore
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
+
@@ -6310,107 +6317,117 @@ Continue?
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -6516,7 +6533,8 @@ Continue?
PluginListView
-
+
+ <table cellspacing="6"><tr><th>Type</th><th>Active </th><th>Total</th></tr><tr><td>All plugins:</td><td align=right>%1 </td><td align=right>%2</td></tr><tr><td>ESMs:</td><td align=right>%3 </td><td align=right>%4</td></tr><tr><td>ESPs:</td><td align=right>%7 </td><td align=right>%8</td></tr><tr><td>ESMs+ESPs:</td><td align=right>%9 </td><td align=right>%10</td></tr><tr><td>ESLs:</td><td align=right>%5 </td><td align=right>%6</td></tr><tr><td>Overlay:</td><td align=right>%11 </td><td align=right>%12</td></tr></table>
@@ -7230,7 +7248,7 @@ p, li { white-space: pre-wrap; }
-
+
@@ -7449,22 +7467,22 @@ Destination:
-
+
-
+
-
+
-
+
@@ -7481,7 +7499,7 @@ Destination:
-
+
@@ -7493,7 +7511,7 @@ Destination:
-
+
@@ -7621,12 +7639,12 @@ Destination:
-
+
-
+
@@ -7754,7 +7772,7 @@ Destination:
-
+
@@ -7764,12 +7782,12 @@ Destination:
-
+
-
+
@@ -7822,19 +7840,19 @@ This program is known to cause issues with Mod Organizer, such as freezing or bl
-
-
-
+
+
+
-
+
-
+
@@ -7989,12 +8007,12 @@ This program is known to cause issues with Mod Organizer, such as freezing or bl
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
@@ -8297,17 +8344,17 @@ You can restart Mod Organizer as administrator and try launching the program aga
-
+
-
+
-
+
@@ -8408,11 +8455,6 @@ You can restart Mod Organizer as administrator and try launching the program aga
-
-
-
-
-
@@ -8452,55 +8494,60 @@ You can restart Mod Organizer as administrator and try launching the program aga
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
+
+
+
QueryOverwriteDialog
@@ -9465,6 +9512,15 @@ p, li { white-space: pre-wrap; }
+
+
+
+
+
+
-
+
-
+
-
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
uibase
-
+
h
Time remaining hours
-
+
m
Time remaining minutes
-
+
s
Time remaining seconds