mirror of
https://github.com/ModOrganizer2/modorganizer.git
synced 2025-12-28 06:34:38 +00:00
Highlight masters of selected plugins (#2140)
This commit is contained in:
parent
75e24cd926
commit
b6de58f2d3
@ -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()
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user