diff --git a/src/colortable.cpp b/src/colortable.cpp index c4e21d3d..43a4dabd 100644 --- a/src/colortable.cpp +++ b/src/colortable.cpp @@ -249,6 +249,15 @@ void ColorTable::load(Settings& s) [this](auto&& v) { m_settings->colors().setPluginListContained(v); }); + + addColor( + QObject::tr("Plugin is master of selected plugin"), QColor(255, 255, 0, 64), + [this] { + return m_settings->colors().pluginListMaster(); + }, + [this](auto&& v) { + m_settings->colors().setPluginListMaster(v); + }); } void ColorTable::resetColors() diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index feb7afe1..04d4462a 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -161,6 +161,27 @@ void PluginList::highlightPlugins(const std::vector& modIndices, this->columnCount() - 1)); } +void PluginList::highlightMasters( + const std::vector& selectedPluginIndices) +{ + for (auto& esp : m_ESPs) { + esp.isMasterOfSelectedPlugin = false; + } + + for (const auto& pluginIndex : selectedPluginIndices) { + const ESPInfo& plugin = m_ESPs[pluginIndex]; + for (const auto& master : plugin.masters) { + const auto iter = m_ESPsByName.find(master); + if (iter != m_ESPsByName.end()) { + m_ESPs[iter->second].isMasterOfSelectedPlugin = true; + } + } + } + + emit dataChanged(this->index(0, 0), this->index(static_cast(m_ESPs.size()) - 1, + this->columnCount() - 1)); +} + void PluginList::refresh(const QString& profileName, const DirectoryEntry& baseDirectory, const QString& lockedOrderFile, bool force) @@ -1306,10 +1327,13 @@ QVariant PluginList::foregroundData(const QModelIndex& modelIndex) const QVariant PluginList::backgroundData(const QModelIndex& modelIndex) const { - const int index = modelIndex.row(); + const int index = modelIndex.row(); + const ESPInfo& plugin = m_ESPs[index]; - if (m_ESPs[index].modSelected) { + if (plugin.modSelected) { return Settings::instance().colors().pluginListContained(); + } else if (plugin.isMasterOfSelectedPlugin) { + return Settings::instance().colors().pluginListMaster(); } return {}; @@ -1921,7 +1945,8 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEn : name(name), fullPath(fullPath), enabled(forceLoaded), forceLoaded(forceLoaded), forceEnabled(forceEnabled), forceDisabled(forceDisabled), priority(0), loadOrder(-1), originName(originName), hasIni(hasIni), - archives(archives.begin(), archives.end()), modSelected(false) + archives(archives.begin(), archives.end()), modSelected(false), + isMasterOfSelectedPlugin(false) { try { ESP::File file(ToWString(fullPath)); diff --git a/src/pluginlist.h b/src/pluginlist.h index 41a7d634..9a741d41 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -222,6 +222,8 @@ class PluginList : public QAbstractItemModel void highlightPlugins(const std::vector& modIndices, const MOShared::DirectoryEntry& directoryEntry); + void highlightMasters(const std::vector& selectedPluginIndices); + void refreshLoadOrder(); void disconnectSlots(); @@ -342,6 +344,7 @@ public slots: bool isBlueprintFlagged; bool hasNoRecords; bool modSelected; + bool isMasterOfSelectedPlugin; QString author; QString description; bool hasIni; diff --git a/src/pluginlistview.cpp b/src/pluginlistview.cpp index 8b34f75d..49eb87dc 100644 --- a/src/pluginlistview.cpp +++ b/src/pluginlistview.cpp @@ -233,6 +233,8 @@ void PluginListView::setup(OrganizerCore& core, MainWindow* mw, Ui::MainWindow* pluginIndices.push_back(idx.row()); } mwui->modList->setHighlightedMods(pluginIndices); + m_core->pluginList()->highlightMasters(pluginIndices); + verticalScrollBar()->repaint(); }); // using a lambda here to avoid storing the mod list actions diff --git a/src/settings.cpp b/src/settings.cpp index 8b95a1d0..d88311eb 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1286,6 +1286,16 @@ void ColorSettings::setPluginListContained(const QColor& c) set(m_Settings, "Settings", "containedColor", c); } +QColor ColorSettings::pluginListMaster() const +{ + return get(m_Settings, "Settings", "masterColor", QColor(255, 255, 0, 64)); +} + +void ColorSettings::setPluginListMaster(const QColor& c) +{ + set(m_Settings, "Settings", "masterColor", c); +} + std::optional ColorSettings::previousSeparatorColor() const { const auto c = getOptional(m_Settings, "General", "previousSeparatorColor"); diff --git a/src/settings.h b/src/settings.h index 613a63bb..c4be0d7b 100644 --- a/src/settings.h +++ b/src/settings.h @@ -257,6 +257,9 @@ class ColorSettings QColor pluginListContained() const; void setPluginListContained(const QColor& c); + QColor pluginListMaster() const; + void setPluginListMaster(const QColor& c); + std::optional previousSeparatorColor() const; void setPreviousSeparatorColor(const QColor& c) const; void removePreviousSeparatorColor();