summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Feenstra <26406078+JonathanFeenstra@users.noreply.github.com>2024-10-12 13:37:58 +0200
committerGitHub <noreply@github.com>2024-10-12 13:37:58 +0200
commitb6de58f2d348e89f0d75f10b9c84312cd0d3a6e5 (patch)
tree8c90b6479ed2f5a05021cc6a10f7abc15d266cb4
parent75e24cd92652640241eb3e9a789950e5fa8fa99a (diff)
Highlight masters of selected plugins (#2140)
-rw-r--r--src/colortable.cpp9
-rw-r--r--src/pluginlist.cpp31
-rw-r--r--src/pluginlist.h3
-rw-r--r--src/pluginlistview.cpp2
-rw-r--r--src/settings.cpp10
-rw-r--r--src/settings.h3
6 files changed, 55 insertions, 3 deletions
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<unsigned int>& modIndices,
this->columnCount() - 1));
}
+void PluginList::highlightMasters(
+ const std::vector<unsigned int>& 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<int>(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 @@ public:
void highlightPlugins(const std::vector<unsigned int>& modIndices,
const MOShared::DirectoryEntry& directoryEntry);
+ void highlightMasters(const std::vector<unsigned int>& selectedPluginIndices);
+
void refreshLoadOrder();
void disconnectSlots();
@@ -342,6 +344,7 @@ private:
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<QColor>(m_Settings, "Settings", "masterColor", QColor(255, 255, 0, 64));
+}
+
+void ColorSettings::setPluginListMaster(const QColor& c)
+{
+ set(m_Settings, "Settings", "masterColor", c);
+}
+
std::optional<QColor> ColorSettings::previousSeparatorColor() const
{
const auto c = getOptional<QColor>(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 @@ public:
QColor pluginListContained() const;
void setPluginListContained(const QColor& c);
+ QColor pluginListMaster() const;
+ void setPluginListMaster(const QColor& c);
+
std::optional<QColor> previousSeparatorColor() const;
void setPreviousSeparatorColor(const QColor& c) const;
void removePreviousSeparatorColor();