NOISSUE Do not hide mods list pages when the instance is running.
Instead, disable (most of) the controls.
This commit is contained in:
parent
e4273d6a17
commit
80b3efff11
@ -897,8 +897,9 @@ std::shared_ptr<SimpleModList> MinecraftInstance::loaderModList() const
|
|||||||
if (!m_loader_mod_list)
|
if (!m_loader_mod_list)
|
||||||
{
|
{
|
||||||
m_loader_mod_list.reset(new SimpleModList(loaderModsDir()));
|
m_loader_mod_list.reset(new SimpleModList(loaderModsDir()));
|
||||||
|
m_loader_mod_list->disableInteraction(isRunning());
|
||||||
|
connect(this, &BaseInstance::runningStatusChanged, m_loader_mod_list.get(), &SimpleModList::disableInteraction);
|
||||||
}
|
}
|
||||||
m_loader_mod_list->update();
|
|
||||||
return m_loader_mod_list;
|
return m_loader_mod_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -907,8 +908,9 @@ std::shared_ptr<SimpleModList> MinecraftInstance::coreModList() const
|
|||||||
if (!m_core_mod_list)
|
if (!m_core_mod_list)
|
||||||
{
|
{
|
||||||
m_core_mod_list.reset(new SimpleModList(coreModsDir()));
|
m_core_mod_list.reset(new SimpleModList(coreModsDir()));
|
||||||
|
m_core_mod_list->disableInteraction(isRunning());
|
||||||
|
connect(this, &BaseInstance::runningStatusChanged, m_core_mod_list.get(), &SimpleModList::disableInteraction);
|
||||||
}
|
}
|
||||||
m_core_mod_list->update();
|
|
||||||
return m_core_mod_list;
|
return m_core_mod_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -917,8 +919,9 @@ std::shared_ptr<SimpleModList> MinecraftInstance::resourcePackList() const
|
|||||||
if (!m_resource_pack_list)
|
if (!m_resource_pack_list)
|
||||||
{
|
{
|
||||||
m_resource_pack_list.reset(new SimpleModList(resourcePacksDir()));
|
m_resource_pack_list.reset(new SimpleModList(resourcePacksDir()));
|
||||||
|
m_resource_pack_list->disableInteraction(isRunning());
|
||||||
|
connect(this, &BaseInstance::runningStatusChanged, m_resource_pack_list.get(), &SimpleModList::disableInteraction);
|
||||||
}
|
}
|
||||||
m_resource_pack_list->update();
|
|
||||||
return m_resource_pack_list;
|
return m_resource_pack_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,8 +930,9 @@ std::shared_ptr<SimpleModList> MinecraftInstance::texturePackList() const
|
|||||||
if (!m_texture_pack_list)
|
if (!m_texture_pack_list)
|
||||||
{
|
{
|
||||||
m_texture_pack_list.reset(new SimpleModList(texturePacksDir()));
|
m_texture_pack_list.reset(new SimpleModList(texturePacksDir()));
|
||||||
|
m_texture_pack_list->disableInteraction(isRunning());
|
||||||
|
connect(this, &BaseInstance::runningStatusChanged, m_texture_pack_list.get(), &SimpleModList::disableInteraction);
|
||||||
}
|
}
|
||||||
m_texture_pack_list->update();
|
|
||||||
return m_texture_pack_list;
|
return m_texture_pack_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,6 +86,17 @@ bool SimpleModList::update()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimpleModList::disableInteraction(bool disabled)
|
||||||
|
{
|
||||||
|
if (interaction_disabled == disabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
interaction_disabled = disabled;
|
||||||
|
if(size()) {
|
||||||
|
emit dataChanged(index(0), index(size() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SimpleModList::directoryChanged(QString path)
|
void SimpleModList::directoryChanged(QString path)
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
@ -99,6 +110,10 @@ bool SimpleModList::isValid()
|
|||||||
// FIXME: this does not take disabled mod (with extra .disable extension) into account...
|
// FIXME: this does not take disabled mod (with extra .disable extension) into account...
|
||||||
bool SimpleModList::installMod(const QString &filename)
|
bool SimpleModList::installMod(const QString &filename)
|
||||||
{
|
{
|
||||||
|
if(interaction_disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE: fix for GH-1178: remove trailing slash to avoid issues with using the empty result of QFileInfo::fileName
|
// NOTE: fix for GH-1178: remove trailing slash to avoid issues with using the empty result of QFileInfo::fileName
|
||||||
auto originalPath = FS::NormalizePath(filename);
|
auto originalPath = FS::NormalizePath(filename);
|
||||||
QFileInfo fileinfo(originalPath);
|
QFileInfo fileinfo(originalPath);
|
||||||
@ -177,6 +192,10 @@ bool SimpleModList::installMod(const QString &filename)
|
|||||||
|
|
||||||
bool SimpleModList::enableMods(const QModelIndexList& indexes, bool enable)
|
bool SimpleModList::enableMods(const QModelIndexList& indexes, bool enable)
|
||||||
{
|
{
|
||||||
|
if(interaction_disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(indexes.isEmpty())
|
if(indexes.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -192,6 +211,10 @@ bool SimpleModList::enableMods(const QModelIndexList& indexes, bool enable)
|
|||||||
|
|
||||||
bool SimpleModList::deleteMods(const QModelIndexList& indexes)
|
bool SimpleModList::deleteMods(const QModelIndexList& indexes)
|
||||||
{
|
{
|
||||||
|
if(interaction_disabled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if(indexes.isEmpty())
|
if(indexes.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -313,11 +336,17 @@ QVariant SimpleModList::headerData(int section, Qt::Orientation orientation, int
|
|||||||
Qt::ItemFlags SimpleModList::flags(const QModelIndex &index) const
|
Qt::ItemFlags SimpleModList::flags(const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
||||||
if (index.isValid())
|
auto flags = defaultFlags;
|
||||||
return Qt::ItemIsUserCheckable | Qt::ItemIsDropEnabled |
|
if(index.isValid()) {
|
||||||
defaultFlags;
|
if(interaction_disabled) {
|
||||||
else
|
flags &= ~Qt::ItemIsDropEnabled;
|
||||||
return Qt::ItemIsDropEnabled | defaultFlags;
|
flags &= ~Qt::ItemIsUserCheckable;
|
||||||
|
} else {
|
||||||
|
flags |= Qt::ItemIsUserCheckable;
|
||||||
|
flags |= Qt::ItemIsDropEnabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::DropActions SimpleModList::supportedDropActions() const
|
Qt::DropActions SimpleModList::supportedDropActions() const
|
||||||
|
@ -106,6 +106,9 @@ public:
|
|||||||
return mods;
|
return mods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void disableInteraction(bool disabled);
|
||||||
|
|
||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void directoryChanged(QString path);
|
void directoryChanged(QString path);
|
||||||
@ -116,6 +119,7 @@ signals:
|
|||||||
protected:
|
protected:
|
||||||
QFileSystemWatcher *m_watcher;
|
QFileSystemWatcher *m_watcher;
|
||||||
bool is_watching = false;
|
bool is_watching = false;
|
||||||
|
bool interaction_disabled = false;
|
||||||
QDir m_dir;
|
QDir m_dir;
|
||||||
QList<Mod> mods;
|
QList<Mod> mods;
|
||||||
};
|
};
|
||||||
|
@ -39,6 +39,7 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList>
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->tabWidget->tabBar()->hide();
|
ui->tabWidget->tabBar()->hide();
|
||||||
m_inst = inst;
|
m_inst = inst;
|
||||||
|
on_RunningState_changed(m_inst && m_inst->isRunning());
|
||||||
m_mods = mods;
|
m_mods = mods;
|
||||||
m_id = id;
|
m_id = id;
|
||||||
m_displayName = displayName;
|
m_displayName = displayName;
|
||||||
@ -57,6 +58,7 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList>
|
|||||||
auto smodel = ui->modTreeView->selectionModel();
|
auto smodel = ui->modTreeView->selectionModel();
|
||||||
connect(smodel, &QItemSelectionModel::currentChanged, this, &ModFolderPage::modCurrent);
|
connect(smodel, &QItemSelectionModel::currentChanged, this, &ModFolderPage::modCurrent);
|
||||||
connect(ui->filterEdit, &QLineEdit::textChanged, this, &ModFolderPage::on_filterTextChanged );
|
connect(ui->filterEdit, &QLineEdit::textChanged, this, &ModFolderPage::on_filterTextChanged );
|
||||||
|
connect(m_inst, &BaseInstance::runningStatusChanged, this, &ModFolderPage::on_RunningState_changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModFolderPage::openedImpl()
|
void ModFolderPage::openedImpl()
|
||||||
@ -89,10 +91,20 @@ ModFolderPage::~ModFolderPage()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ModFolderPage::on_RunningState_changed(bool running)
|
||||||
|
{
|
||||||
|
if(m_controlsEnabled == !running) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
m_controlsEnabled = !running;
|
||||||
|
ui->addModBtn->setEnabled(m_controlsEnabled);
|
||||||
|
ui->disableModBtn->setEnabled(m_controlsEnabled);
|
||||||
|
ui->enableModBtn->setEnabled(m_controlsEnabled);
|
||||||
|
ui->rmModBtn->setEnabled(m_controlsEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
bool ModFolderPage::shouldDisplay() const
|
bool ModFolderPage::shouldDisplay() const
|
||||||
{
|
{
|
||||||
if (m_inst)
|
|
||||||
return !m_inst->isRunning();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,6 +164,9 @@ bool ModFolderPage::eventFilter(QObject *obj, QEvent *ev)
|
|||||||
|
|
||||||
void ModFolderPage::on_addModBtn_clicked()
|
void ModFolderPage::on_addModBtn_clicked()
|
||||||
{
|
{
|
||||||
|
if(!m_controlsEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto list = GuiUtil::BrowseForFiles(
|
auto list = GuiUtil::BrowseForFiles(
|
||||||
m_helpName,
|
m_helpName,
|
||||||
tr("Select %1",
|
tr("Select %1",
|
||||||
@ -170,18 +185,27 @@ void ModFolderPage::on_addModBtn_clicked()
|
|||||||
|
|
||||||
void ModFolderPage::on_enableModBtn_clicked()
|
void ModFolderPage::on_enableModBtn_clicked()
|
||||||
{
|
{
|
||||||
|
if(!m_controlsEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection());
|
auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection());
|
||||||
m_mods->enableMods(selection.indexes(), true);
|
m_mods->enableMods(selection.indexes(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModFolderPage::on_disableModBtn_clicked()
|
void ModFolderPage::on_disableModBtn_clicked()
|
||||||
{
|
{
|
||||||
|
if(!m_controlsEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection());
|
auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection());
|
||||||
m_mods->enableMods(selection.indexes(), false);
|
m_mods->enableMods(selection.indexes(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModFolderPage::on_rmModBtn_clicked()
|
void ModFolderPage::on_rmModBtn_clicked()
|
||||||
{
|
{
|
||||||
|
if(!m_controlsEnabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection());
|
auto selection = m_filterModel->mapSelectionToSource(ui->modTreeView->selectionModel()->selection());
|
||||||
m_mods->deleteMods(selection.indexes());
|
m_mods->deleteMods(selection.indexes());
|
||||||
}
|
}
|
||||||
|
@ -67,18 +67,19 @@ protected:
|
|||||||
bool modListFilter(QKeyEvent *ev);
|
bool modListFilter(QKeyEvent *ev);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BaseInstance *m_inst;
|
BaseInstance *m_inst = nullptr;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Ui::ModFolderPage *ui;
|
Ui::ModFolderPage *ui = nullptr;
|
||||||
std::shared_ptr<SimpleModList> m_mods;
|
std::shared_ptr<SimpleModList> m_mods;
|
||||||
QSortFilterProxyModel *m_filterModel;
|
QSortFilterProxyModel *m_filterModel = nullptr;
|
||||||
QString m_iconName;
|
QString m_iconName;
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
QString m_helpName;
|
QString m_helpName;
|
||||||
QString m_fileSelectionFilter;
|
QString m_fileSelectionFilter;
|
||||||
QString m_viewFilter;
|
QString m_viewFilter;
|
||||||
|
bool m_controlsEnabled = true;
|
||||||
|
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
@ -87,6 +88,7 @@ slots:
|
|||||||
private
|
private
|
||||||
slots:
|
slots:
|
||||||
void on_filterTextChanged(const QString & newContents);
|
void on_filterTextChanged(const QString & newContents);
|
||||||
|
void on_RunningState_changed(bool running);
|
||||||
void on_addModBtn_clicked();
|
void on_addModBtn_clicked();
|
||||||
void on_rmModBtn_clicked();
|
void on_rmModBtn_clicked();
|
||||||
void on_viewModBtn_clicked();
|
void on_viewModBtn_clicked();
|
||||||
|
Loading…
Reference in New Issue
Block a user