NOISSUE Show Version page while the instancer is running.
All controls are disabled.
This commit is contained in:
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -134,6 +134,7 @@ private slots:
|
||||
void updateSucceeded();
|
||||
void updateFailed(const QString & error);
|
||||
void componentDataChanged();
|
||||
void disableInteraction(bool disable);
|
||||
|
||||
private:
|
||||
bool load();
|
||||
|
@ -38,5 +38,6 @@ struct ComponentListData
|
||||
QTimer m_saveTimer;
|
||||
shared_qobject_ptr<Task> m_updateTask;
|
||||
bool loaded = false;
|
||||
bool interactionDisabled = true;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user