summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-02-21 01:44:27 +0100
committerPetr Mrázek <peterix@gmail.com>2016-02-21 01:44:27 +0100
commit1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae (patch)
tree2c2fbc7a74ea5035fdfd8752272e011852eb1b85 /application
parent495d320ce267cf6d7c7e4468dbc36d3536bcb401 (diff)
downloadMultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.tar
MultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.tar.gz
MultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.tar.lz
MultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.tar.xz
MultiMC-1a0bbdd9acaf1c5edaad6d3f0790c1b02674c0ae.zip
GH-1453 report version file problems in the version page
Diffstat (limited to 'application')
-rw-r--r--application/pages/VersionPage.cpp96
-rw-r--r--application/pages/VersionPage.h2
-rw-r--r--application/pages/VersionPage.ui24
-rw-r--r--application/widgets/ModListView.cpp4
4 files changed, 121 insertions, 5 deletions
diff --git a/application/pages/VersionPage.cpp b/application/pages/VersionPage.cpp
index e1abcf0c..f01a2d62 100644
--- a/application/pages/VersionPage.cpp
+++ b/application/pages/VersionPage.cpp
@@ -47,6 +47,51 @@
#include "icons/IconList.h"
#include "Exception.h"
+#include "MultiMC.h"
+
+class IconProxy : public QIdentityProxyModel
+{
+ Q_OBJECT
+public:
+
+ IconProxy(QWidget *parentWidget) : QIdentityProxyModel(parentWidget)
+ {
+ connect(parentWidget, &QObject::destroyed, this, &IconProxy::widgetGone);
+ m_parentWidget = parentWidget;
+ }
+
+ virtual QVariant data(const QModelIndex &proxyIndex, int role = Qt::DisplayRole) const override
+ {
+ QVariant var = QIdentityProxyModel::data(mapToSource(proxyIndex), role);
+ int column = proxyIndex.column();
+ if(column == 0 && role == Qt::DecorationRole && m_parentWidget)
+ {
+ if(!var.isNull())
+ {
+ auto string = var.toString();
+ if(string == "warning")
+ {
+ return MMC->getThemedIcon("status-yellow");
+ }
+ else if(string == "error")
+ {
+ return MMC->getThemedIcon("status-bad");
+ }
+ }
+ return MMC->getThemedIcon("status-good");
+ }
+ return var;
+ }
+private slots:
+ void widgetGone()
+ {
+ m_parentWidget = nullptr;
+ }
+
+private:
+ QWidget *m_parentWidget = nullptr;
+};
+
QIcon VersionPage::icon() const
{
return ENV.icons()->getIcon(m_inst->iconKey());
@@ -72,11 +117,15 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent)
m_version = m_inst->getMinecraftProfile();
if (m_version)
{
- ui->packageView->setModel(m_version.get());
+ auto proxy = new IconProxy(ui->packageView);
+ proxy->setSourceModel(m_version.get());
+ ui->packageView->setModel(proxy);
ui->packageView->installEventFilter(this);
ui->packageView->setSelectionMode(QAbstractItemView::SingleSelection);
connect(ui->packageView->selectionModel(), &QItemSelectionModel::currentChanged,
this, &VersionPage::versionCurrent);
+ auto smodel = ui->packageView->selectionModel();
+ connect(smodel, SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(packageCurrent(QModelIndex, QModelIndex)));
updateVersionControls();
// select first item.
preselect(0);
@@ -94,6 +143,49 @@ VersionPage::~VersionPage()
delete ui;
}
+void VersionPage::packageCurrent(const QModelIndex &current, const QModelIndex &previous)
+{
+ if (!current.isValid())
+ {
+ ui->frame->clear();
+ return;
+ }
+ int row = current.row();
+ auto patch = m_version->versionPatch(row);
+ auto severity = patch->getProblemSeverity();
+ switch(severity)
+ {
+ case PROBLEM_WARNING:
+ ui->frame->setModText(tr("%1 possibly has issues.").arg(patch->getPatchName()));
+ break;
+ case PROBLEM_ERROR:
+ ui->frame->setModText(tr("%1 has issues!").arg(patch->getPatchName()));
+ break;
+ default:
+ case PROBLEM_NONE:
+ ui->frame->clear();
+ return;
+ }
+
+ auto &problems = patch->getProblems();
+ QString problemOut;
+ for (auto &problem: problems)
+ {
+ if(problem.getSeverity() == PROBLEM_ERROR)
+ {
+ problemOut += tr("Error: ");
+ }
+ else if(problem.getSeverity() == PROBLEM_WARNING)
+ {
+ problemOut += tr("Warning: ");
+ }
+ problemOut += problem.getDescription();
+ problemOut += "\n";
+ }
+ ui->frame->setModDescription(problemOut);
+}
+
+
void VersionPage::updateVersionControls()
{
ui->forgeBtn->setEnabled(true);
@@ -453,3 +545,5 @@ void VersionPage::on_revertBtn_clicked()
updateButtons();
preselect(currentIdx);
}
+
+#include "VersionPage.moc"
diff --git a/application/pages/VersionPage.h b/application/pages/VersionPage.h
index 8f2bf024..216bc30e 100644
--- a/application/pages/VersionPage.h
+++ b/application/pages/VersionPage.h
@@ -90,4 +90,6 @@ public slots:
private slots:
void onGameUpdateError(QString error);
+ void packageCurrent(const QModelIndex &current, const QModelIndex &previous);
+
};
diff --git a/application/pages/VersionPage.ui b/application/pages/VersionPage.ui
index e88888c8..c16208db 100644
--- a/application/pages/VersionPage.ui
+++ b/application/pages/VersionPage.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>693</width>
- <height>575</height>
+ <height>750</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -32,8 +32,8 @@
<attribute name="title">
<string notr="true">Tab 1</string>
</attribute>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
<widget class="ModListView" name="packageView">
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum>
@@ -49,7 +49,7 @@
</attribute>
</widget>
</item>
- <item>
+ <item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label">
@@ -245,6 +245,16 @@
</item>
</layout>
</item>
+ <item row="1" column="0" colspan="2">
+ <widget class="MCModInfoFrame" name="frame">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</widget>
@@ -263,6 +273,12 @@
<header>widgets/LineSeparator.h</header>
<container>1</container>
</customwidget>
+ <customwidget>
+ <class>MCModInfoFrame</class>
+ <extends>QFrame</extends>
+ <header>widgets/MCModInfoFrame.h</header>
+ <container>1</container>
+ </customwidget>
</customwidgets>
<tabstops>
<tabstop>tabWidget</tabstop>
diff --git a/application/widgets/ModListView.cpp b/application/widgets/ModListView.cpp
index aa16ad05..51b4a475 100644
--- a/application/widgets/ModListView.cpp
+++ b/application/widgets/ModListView.cpp
@@ -46,6 +46,10 @@ void ModListView::setModel ( QAbstractItemModel* model )
head->setStretchLastSection(false);
// HACK: this is true for the checkbox column of mod lists
auto string = model->headerData(0,head->orientation()).toString();
+ if(head->count() < 1)
+ {
+ return;
+ }
if(!string.size())
{
head->setSectionResizeMode(0, QHeaderView::ResizeToContents);