diff --git a/launcher/minecraft/mod/DataPackFolderModel.cpp b/launcher/minecraft/mod/DataPackFolderModel.cpp index a975b742e..b934e451e 100644 --- a/launcher/minecraft/mod/DataPackFolderModel.cpp +++ b/launcher/minecraft/mod/DataPackFolderModel.cpp @@ -64,6 +64,8 @@ QVariant DataPackFolderModel::data(const QModelIndex& index, int role) const int column = index.column(); switch (role) { + case Qt::BackgroundRole: + return rowBackground(row); case Qt::DisplayRole: switch (column) { case PackFormatColumn: { diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index cf3219918..50b8985c8 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -88,6 +88,8 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const int column = index.column(); switch (role) { + case Qt::BackgroundRole: + return rowBackground(row); case Qt::DisplayRole: switch (column) { case VersionColumn: { @@ -96,8 +98,9 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const return tr("Folder"); case ResourceType::SINGLEFILE: return tr("File"); + default: + return at(row).version(); } - return at(row).version(); } case SideColumn: { return at(row).side(); diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index 532eb8d66..11ef81dbc 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -499,6 +499,17 @@ bool ResourceFolderModel::validateIndex(const QModelIndex& index) const return true; } +// HACK: all subclasses need to call this to have the whole row painted +// and they only delegate to the superclass for compatible columns +QBrush ResourceFolderModel::rowBackground(int row) const +{ + if (!m_resources[row]->isCompatible()) { + return { QColor(255, 0, 0, 40) }; + } else { + return {}; + } +} + QVariant ResourceFolderModel::data(const QModelIndex& index, int role) const { if (!validateIndex(index)) @@ -508,6 +519,8 @@ QVariant ResourceFolderModel::data(const QModelIndex& index, int role) const int column = index.column(); switch (role) { + case Qt::BackgroundRole: + return rowBackground(row); case Qt::DisplayRole: switch (column) { case NameColumn: @@ -521,25 +534,37 @@ QVariant ResourceFolderModel::data(const QModelIndex& index, int role) const default: return {}; } - case Qt::ToolTipRole: + case Qt::ToolTipRole: { + QString tooltip = m_resources[row]->internal_id(); + if (column == NameColumn) { - if (at(row).isSymLinkUnder(instDirPath())) { - return m_resources[row]->internal_id() + - tr("\nWarning: This resource is symbolically linked from elsewhere. Editing it will also change the original." - "\nCanonical Path: %1") - .arg(at(row).fileinfo().canonicalFilePath()); - ; + if (!at(row).isCompatible()) { + tooltip += tr("\nResource is not marked as compatible with the instance."); } + + if (at(row).isSymLinkUnder(instDirPath())) { + tooltip += + m_resources[row]->internal_id() + + tr("\nWarning: This resource is symbolically linked from elsewhere. Editing it will also change the original." + "\nCanonical Path: %1") + .arg(at(row).fileinfo().canonicalFilePath()); + } + if (at(row).isMoreThanOneHardLink()) { - return m_resources[row]->internal_id() + - tr("\nWarning: This resource is hard linked elsewhere. Editing it will also change the original."); + tooltip += tr("\nWarning: This resource is hard linked elsewhere. Editing it will also change the original."); } } - return m_resources[row]->internal_id(); + return tooltip; + } case Qt::DecorationRole: { - if (column == NameColumn && (at(row).isSymLinkUnder(instDirPath()) || at(row).isMoreThanOneHardLink())) - return QIcon::fromTheme("status-yellow"); + if (column == NameColumn) { + if (!at(row).isCompatible()) { + return QIcon::fromTheme("status-bad"); + } else if (at(row).isSymLinkUnder(instDirPath()) || at(row).isMoreThanOneHardLink()) { + return QIcon::fromTheme("status-yellow"); + } + } return {}; } diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index b6343a807..81bc6f5fc 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -153,6 +153,7 @@ class ResourceFolderModel : public QAbstractListModel { [[nodiscard]] bool validateIndex(const QModelIndex& index) const; + QBrush rowBackground(int row) const; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; diff --git a/launcher/minecraft/mod/ResourcePackFolderModel.cpp b/launcher/minecraft/mod/ResourcePackFolderModel.cpp index c83f90e2a..fd59d5765 100644 --- a/launcher/minecraft/mod/ResourcePackFolderModel.cpp +++ b/launcher/minecraft/mod/ResourcePackFolderModel.cpp @@ -65,6 +65,8 @@ QVariant ResourcePackFolderModel::data(const QModelIndex& index, int role) const int column = index.column(); switch (role) { + case Qt::BackgroundRole: + return rowBackground(row); case Qt::DisplayRole: switch (column) { case PackFormatColumn: { diff --git a/launcher/minecraft/mod/TexturePackFolderModel.cpp b/launcher/minecraft/mod/TexturePackFolderModel.cpp index e5f3eef88..d96b768db 100644 --- a/launcher/minecraft/mod/TexturePackFolderModel.cpp +++ b/launcher/minecraft/mod/TexturePackFolderModel.cpp @@ -63,6 +63,8 @@ QVariant TexturePackFolderModel::data(const QModelIndex& index, int role) const int column = index.column(); switch (role) { + case Qt::BackgroundRole: + return rowBackground(row); case Qt::DecorationRole: { if (column == ImageColumn) { return at(row).image({ 32, 32 }, Qt::AspectRatioMode::KeepAspectRatioByExpanding);