summaryrefslogtreecommitdiffstats
path: root/api/logic/minecraft/ComponentList.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2019-07-15 23:16:34 +0200
committerPetr Mrázek <peterix@gmail.com>2019-07-15 23:16:34 +0200
commit6fde775b9017401351425186deffd685827df3d3 (patch)
treecd8b37944c7dec955f9e21f32755596070f64308 /api/logic/minecraft/ComponentList.cpp
parent80b3efff11a34e2df7d1bc4cc3187e6aaf57e687 (diff)
downloadMultiMC-6fde775b9017401351425186deffd685827df3d3.tar
MultiMC-6fde775b9017401351425186deffd685827df3d3.tar.gz
MultiMC-6fde775b9017401351425186deffd685827df3d3.tar.lz
MultiMC-6fde775b9017401351425186deffd685827df3d3.tar.xz
MultiMC-6fde775b9017401351425186deffd685827df3d3.zip
NOISSUE Show Version page while the instancer is running.
All controls are disabled.
Diffstat (limited to 'api/logic/minecraft/ComponentList.cpp')
-rw-r--r--api/logic/minecraft/ComponentList.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/api/logic/minecraft/ComponentList.cpp b/api/logic/minecraft/ComponentList.cpp
index b2afdb17..51fe214d 100644
--- a/api/logic/minecraft/ComponentList.cpp
+++ b/api/logic/minecraft/ComponentList.cpp
@@ -43,6 +43,8 @@ ComponentList::ComponentList(MinecraftInstance * instance)
d->m_instance = instance;
d->m_saveTimer.setSingleShot(true);
d->m_saveTimer.setInterval(5000);
+ d->interactionDisabled = instance->isRunning();
+ connect(d->m_instance, &BaseInstance::runningStatusChanged, this, &ComponentList::disableInteraction);
connect(&d->m_saveTimer, &QTimer::timeout, this, &ComponentList::save_internal);
}
@@ -765,8 +767,9 @@ QVariant ComponentList::data(const QModelIndex &index, int role) const
{
switch (column)
{
- case NameColumn:
- return d->components.at(row)->isEnabled() ? Qt::Checked : Qt::Unchecked;
+ case NameColumn: {
+ return patch->isEnabled() ? Qt::Checked : Qt::Unchecked;
+ }
default:
return QVariant();
}
@@ -776,7 +779,7 @@ QVariant ComponentList::data(const QModelIndex &index, int role) const
switch (column)
{
case NameColumn:
- return d->components.at(row)->getName();
+ return patch->getName();
case VersionColumn:
{
if(patch->isCustom())
@@ -856,21 +859,25 @@ QVariant ComponentList::headerData(int section, Qt::Orientation orientation, int
}
return QVariant();
}
+
+// FIXME: zero precision mess
Qt::ItemFlags ComponentList::flags(const QModelIndex &index) const
{
- if (!index.isValid())
+ if (!index.isValid()) {
return Qt::NoItemFlags;
+ }
Qt::ItemFlags outFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
int row = index.row();
- if (row < 0 || row >= d->components.size())
+ if (row < 0 || row >= d->components.size()) {
return Qt::NoItemFlags;
+ }
auto patch = d->components.at(row);
// TODO: this will need fine-tuning later...
- if(patch->canBeDisabled())
+ if(patch->canBeDisabled() && !d->interactionDisabled)
{
outFlags |= Qt::ItemIsUserCheckable;
}
@@ -1205,3 +1212,14 @@ QString ComponentList::getComponentVersion(const QString& uid) const
}
return QString();
}
+
+void ComponentList::disableInteraction(bool disable)
+{
+ if(d->interactionDisabled != disable) {
+ d->interactionDisabled = disable;
+ auto size = d->components.size();
+ if(size) {
+ emit dataChanged(index(0), index(size - 1));
+ }
+ }
+}