Merge pull request #1241 from Trial97/settings
Allow editing of running instances
This commit is contained in:
commit
f816e3cd3f
@ -1112,36 +1112,27 @@ JavaVersion MinecraftInstance::getJavaVersion()
|
|||||||
|
|
||||||
std::shared_ptr<ModFolderModel> MinecraftInstance::loaderModList()
|
std::shared_ptr<ModFolderModel> MinecraftInstance::loaderModList()
|
||||||
{
|
{
|
||||||
if (!m_loader_mod_list)
|
if (!m_loader_mod_list) {
|
||||||
{
|
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_loader_mod_list.reset(new ModFolderModel(modsRoot(), this, is_indexed));
|
m_loader_mod_list.reset(new ModFolderModel(modsRoot(), this, is_indexed));
|
||||||
m_loader_mod_list->disableInteraction(isRunning());
|
|
||||||
connect(this, &BaseInstance::runningStatusChanged, m_loader_mod_list.get(), &ModFolderModel::disableInteraction);
|
|
||||||
}
|
}
|
||||||
return m_loader_mod_list;
|
return m_loader_mod_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ModFolderModel> MinecraftInstance::coreModList()
|
std::shared_ptr<ModFolderModel> MinecraftInstance::coreModList()
|
||||||
{
|
{
|
||||||
if (!m_core_mod_list)
|
if (!m_core_mod_list) {
|
||||||
{
|
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_core_mod_list.reset(new ModFolderModel(coreModsDir(), this, is_indexed));
|
m_core_mod_list.reset(new ModFolderModel(coreModsDir(), this, is_indexed));
|
||||||
m_core_mod_list->disableInteraction(isRunning());
|
|
||||||
connect(this, &BaseInstance::runningStatusChanged, m_core_mod_list.get(), &ModFolderModel::disableInteraction);
|
|
||||||
}
|
}
|
||||||
return m_core_mod_list;
|
return m_core_mod_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ModFolderModel> MinecraftInstance::nilModList()
|
std::shared_ptr<ModFolderModel> MinecraftInstance::nilModList()
|
||||||
{
|
{
|
||||||
if (!m_nil_mod_list)
|
if (!m_nil_mod_list) {
|
||||||
{
|
|
||||||
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
bool is_indexed = !APPLICATION->settings()->get("ModMetadataDisabled").toBool();
|
||||||
m_nil_mod_list.reset(new ModFolderModel(nilModsDir(), this, is_indexed, false));
|
m_nil_mod_list.reset(new ModFolderModel(nilModsDir(), this, is_indexed, false));
|
||||||
m_nil_mod_list->disableInteraction(isRunning());
|
|
||||||
connect(this, &BaseInstance::runningStatusChanged, m_nil_mod_list.get(), &ModFolderModel::disableInteraction);
|
|
||||||
}
|
}
|
||||||
return m_nil_mod_list;
|
return m_nil_mod_list;
|
||||||
}
|
}
|
||||||
|
@ -215,16 +215,11 @@ bool ModFolderModel::uninstallMod(const QString& filename, bool preserve_metadat
|
|||||||
|
|
||||||
bool ModFolderModel::deleteMods(const QModelIndexList& indexes)
|
bool ModFolderModel::deleteMods(const QModelIndexList& indexes)
|
||||||
{
|
{
|
||||||
if(!m_can_interact) {
|
if (indexes.isEmpty())
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(indexes.isEmpty())
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (auto i: indexes)
|
for (auto i : indexes) {
|
||||||
{
|
if (i.column() != 0) {
|
||||||
if(i.column() != 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto m = at(i.row());
|
auto m = at(i.row());
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
#include "ResourceFolderModel.h"
|
#include "ResourceFolderModel.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
#include <QMenu>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QThreadPool>
|
#include <QThreadPool>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QMenu>
|
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
@ -18,6 +19,7 @@
|
|||||||
|
|
||||||
#include "settings/Setting.h"
|
#include "settings/Setting.h"
|
||||||
#include "tasks/Task.h"
|
#include "tasks/Task.h"
|
||||||
|
#include "ui/dialogs/CustomMessageBox.h"
|
||||||
|
|
||||||
ResourceFolderModel::ResourceFolderModel(QDir dir, BaseInstance* instance, QObject* parent, bool create_dir)
|
ResourceFolderModel::ResourceFolderModel(QDir dir, BaseInstance* instance, QObject* parent, bool create_dir)
|
||||||
: QAbstractListModel(parent), m_dir(dir), m_instance(instance), m_watcher(this)
|
: QAbstractListModel(parent), m_dir(dir), m_instance(instance), m_watcher(this)
|
||||||
@ -77,10 +79,6 @@ bool ResourceFolderModel::stopWatching(const QStringList paths)
|
|||||||
|
|
||||||
bool ResourceFolderModel::installResource(QString original_path)
|
bool ResourceFolderModel::installResource(QString original_path)
|
||||||
{
|
{
|
||||||
if (!m_can_interact) {
|
|
||||||
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
|
||||||
original_path = FS::NormalizePath(original_path);
|
original_path = FS::NormalizePath(original_path);
|
||||||
QFileInfo file_info(original_path);
|
QFileInfo file_info(original_path);
|
||||||
@ -171,9 +169,6 @@ bool ResourceFolderModel::uninstallResource(QString file_name)
|
|||||||
|
|
||||||
bool ResourceFolderModel::deleteResources(const QModelIndexList& indexes)
|
bool ResourceFolderModel::deleteResources(const QModelIndexList& indexes)
|
||||||
{
|
{
|
||||||
if (!m_can_interact)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (indexes.isEmpty())
|
if (indexes.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -192,11 +187,8 @@ bool ResourceFolderModel::deleteResources(const QModelIndexList& indexes)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResourceFolderModel::setResourceEnabled(const QModelIndexList &indexes, EnableAction action)
|
bool ResourceFolderModel::setResourceEnabled(const QModelIndexList& indexes, EnableAction action)
|
||||||
{
|
{
|
||||||
if (!m_can_interact)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (indexes.isEmpty())
|
if (indexes.isEmpty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@ -249,7 +241,9 @@ bool ResourceFolderModel::update()
|
|||||||
connect(m_current_update_task.get(), &Task::succeeded, this, &ResourceFolderModel::onUpdateSucceeded,
|
connect(m_current_update_task.get(), &Task::succeeded, this, &ResourceFolderModel::onUpdateSucceeded,
|
||||||
Qt::ConnectionType::QueuedConnection);
|
Qt::ConnectionType::QueuedConnection);
|
||||||
connect(m_current_update_task.get(), &Task::failed, this, &ResourceFolderModel::onUpdateFailed, Qt::ConnectionType::QueuedConnection);
|
connect(m_current_update_task.get(), &Task::failed, this, &ResourceFolderModel::onUpdateFailed, Qt::ConnectionType::QueuedConnection);
|
||||||
connect(m_current_update_task.get(), &Task::finished, this, [=] {
|
connect(
|
||||||
|
m_current_update_task.get(), &Task::finished, this,
|
||||||
|
[=] {
|
||||||
m_current_update_task.reset();
|
m_current_update_task.reset();
|
||||||
if (m_scheduled_update) {
|
if (m_scheduled_update) {
|
||||||
m_scheduled_update = false;
|
m_scheduled_update = false;
|
||||||
@ -257,7 +251,8 @@ bool ResourceFolderModel::update()
|
|||||||
} else {
|
} else {
|
||||||
emit updateFinished();
|
emit updateFinished();
|
||||||
}
|
}
|
||||||
}, Qt::ConnectionType::QueuedConnection);
|
},
|
||||||
|
Qt::ConnectionType::QueuedConnection);
|
||||||
|
|
||||||
QThreadPool::globalInstance()->start(m_current_update_task.get());
|
QThreadPool::globalInstance()->start(m_current_update_task.get());
|
||||||
|
|
||||||
@ -347,15 +342,9 @@ Qt::DropActions ResourceFolderModel::supportedDropActions() const
|
|||||||
Qt::ItemFlags ResourceFolderModel::flags(const QModelIndex& index) const
|
Qt::ItemFlags ResourceFolderModel::flags(const QModelIndex& index) const
|
||||||
{
|
{
|
||||||
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
Qt::ItemFlags defaultFlags = QAbstractListModel::flags(index);
|
||||||
auto flags = defaultFlags;
|
auto flags = defaultFlags | Qt::ItemIsDropEnabled;
|
||||||
if (!m_can_interact) {
|
if (index.isValid())
|
||||||
flags &= ~Qt::ItemIsDropEnabled;
|
|
||||||
} else {
|
|
||||||
flags |= Qt::ItemIsDropEnabled;
|
|
||||||
if (index.isValid()) {
|
|
||||||
flags |= Qt::ItemIsUserCheckable;
|
flags |= Qt::ItemIsUserCheckable;
|
||||||
}
|
|
||||||
}
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -430,7 +419,8 @@ QVariant ResourceFolderModel::data(const QModelIndex& index, int role) const
|
|||||||
return m_resources[row]->internal_id() +
|
return m_resources[row]->internal_id() +
|
||||||
tr("\nWarning: This resource is symbolically linked from elsewhere. Editing it will also change the original."
|
tr("\nWarning: This resource is symbolically linked from elsewhere. Editing it will also change the original."
|
||||||
"\nCanonical Path: %1")
|
"\nCanonical Path: %1")
|
||||||
.arg(at(row).fileinfo().canonicalFilePath());;
|
.arg(at(row).fileinfo().canonicalFilePath());
|
||||||
|
;
|
||||||
}
|
}
|
||||||
if (at(row).isMoreThanOneHardLink()) {
|
if (at(row).isMoreThanOneHardLink()) {
|
||||||
return m_resources[row]->internal_id() +
|
return m_resources[row]->internal_id() +
|
||||||
@ -463,8 +453,20 @@ bool ResourceFolderModel::setData(const QModelIndex& index, const QVariant& valu
|
|||||||
if (row < 0 || row >= rowCount(index.parent()) || !index.isValid())
|
if (row < 0 || row >= rowCount(index.parent()) || !index.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (role == Qt::CheckStateRole)
|
if (role == Qt::CheckStateRole) {
|
||||||
|
if (m_instance != nullptr && m_instance->isRunning()) {
|
||||||
|
auto response =
|
||||||
|
CustomMessageBox::selectable(nullptr, "Confirm toggle",
|
||||||
|
"If you enable/disable this resource while the game is running it may crash your game.\n"
|
||||||
|
"Are you sure you want to do this?",
|
||||||
|
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||||
|
->exec();
|
||||||
|
|
||||||
|
if (response != QMessageBox::Yes)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return setResourceEnabled({ index }, EnableAction::TOGGLE);
|
return setResourceEnabled({ index }, EnableAction::TOGGLE);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -583,16 +585,6 @@ SortType ResourceFolderModel::columnToSortKey(size_t column) const
|
|||||||
return m_column_sort_keys.at(column);
|
return m_column_sort_keys.at(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceFolderModel::enableInteraction(bool enabled)
|
|
||||||
{
|
|
||||||
if (m_can_interact == enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_can_interact = enabled;
|
|
||||||
if (size())
|
|
||||||
emit dataChanged(index(0), index(size() - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Standard Proxy Model for createFilterProxyModel */
|
/* Standard Proxy Model for createFilterProxyModel */
|
||||||
[[nodiscard]] bool ResourceFolderModel::ProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
[[nodiscard]] bool ResourceFolderModel::ProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
|
||||||
{
|
{
|
||||||
@ -628,6 +620,7 @@ void ResourceFolderModel::enableInteraction(bool enabled)
|
|||||||
return (compare_result.first > 0);
|
return (compare_result.first > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ResourceFolderModel::instDirPath() const {
|
QString ResourceFolderModel::instDirPath() const
|
||||||
|
{
|
||||||
return QFileInfo(m_instance->instanceRoot()).absoluteFilePath();
|
return QFileInfo(m_instance->instanceRoot()).absoluteFilePath();
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
#include "BaseInstance.h"
|
#include "BaseInstance.h"
|
||||||
|
|
||||||
#include "tasks/Task.h"
|
|
||||||
#include "tasks/ConcurrentTask.h"
|
#include "tasks/ConcurrentTask.h"
|
||||||
|
#include "tasks/Task.h"
|
||||||
|
|
||||||
class QSortFilterProxyModel;
|
class QSortFilterProxyModel;
|
||||||
|
|
||||||
@ -141,10 +141,6 @@ class ResourceFolderModel : public QAbstractListModel {
|
|||||||
|
|
||||||
QString instDirPath() const;
|
QString instDirPath() const;
|
||||||
|
|
||||||
public slots:
|
|
||||||
void enableInteraction(bool enabled);
|
|
||||||
void disableInteraction(bool disabled) { enableInteraction(!disabled); }
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateFinished();
|
void updateFinished();
|
||||||
|
|
||||||
@ -193,7 +189,11 @@ class ResourceFolderModel : public QAbstractListModel {
|
|||||||
* if the resource is complex and has more stuff to parse.
|
* if the resource is complex and has more stuff to parse.
|
||||||
*/
|
*/
|
||||||
virtual void onParseSucceeded(int ticket, QString resource_id);
|
virtual void onParseSucceeded(int ticket, QString resource_id);
|
||||||
virtual void onParseFailed(int ticket, QString resource_id) { Q_UNUSED(ticket); Q_UNUSED(resource_id); }
|
virtual void onParseFailed(int ticket, QString resource_id)
|
||||||
|
{
|
||||||
|
Q_UNUSED(ticket);
|
||||||
|
Q_UNUSED(resource_id);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Represents the relationship between a column's index (represented by the list index), and it's sorting key.
|
// Represents the relationship between a column's index (represented by the list index), and it's sorting key.
|
||||||
@ -203,8 +203,6 @@ class ResourceFolderModel : public QAbstractListModel {
|
|||||||
QStringList m_column_names_translated = {tr("Enable"), tr("Name"), tr("Last Modified")};
|
QStringList m_column_names_translated = {tr("Enable"), tr("Name"), tr("Last Modified")};
|
||||||
QList<QHeaderView::ResizeMode> m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Stretch, QHeaderView::ResizeToContents };
|
QList<QHeaderView::ResizeMode> m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Stretch, QHeaderView::ResizeToContents };
|
||||||
|
|
||||||
bool m_can_interact = true;
|
|
||||||
|
|
||||||
QDir m_dir;
|
QDir m_dir;
|
||||||
BaseInstance* m_instance;
|
BaseInstance* m_instance;
|
||||||
QFileSystemWatcher m_watcher;
|
QFileSystemWatcher m_watcher;
|
||||||
|
@ -151,9 +151,6 @@ void ExternalResourcesPage::retranslate()
|
|||||||
|
|
||||||
void ExternalResourcesPage::itemActivated(const QModelIndex&)
|
void ExternalResourcesPage::itemActivated(const QModelIndex&)
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
|
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,9 +194,6 @@ bool ExternalResourcesPage::eventFilter(QObject* obj, QEvent* ev)
|
|||||||
|
|
||||||
void ExternalResourcesPage::addItem()
|
void ExternalResourcesPage::addItem()
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto list = GuiUtil::BrowseForFiles(
|
auto list = GuiUtil::BrowseForFiles(
|
||||||
helpPage(), tr("Select %1", "Select whatever type of files the page contains. Example: 'Loader Mods'").arg(displayName()),
|
helpPage(), tr("Select %1", "Select whatever type of files the page contains. Example: 'Loader Mods'").arg(displayName()),
|
||||||
m_fileSelectionFilter.arg(displayName()), APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
m_fileSelectionFilter.arg(displayName()), APPLICATION->settings()->get("CentralModsDir").toString(), this->parentWidget());
|
||||||
@ -213,9 +207,6 @@ void ExternalResourcesPage::addItem()
|
|||||||
|
|
||||||
void ExternalResourcesPage::removeItem()
|
void ExternalResourcesPage::removeItem()
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
|
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@ -259,23 +250,37 @@ void ExternalResourcesPage::removeItem()
|
|||||||
|
|
||||||
void ExternalResourcesPage::removeItems(const QItemSelection& selection)
|
void ExternalResourcesPage::removeItems(const QItemSelection& selection)
|
||||||
{
|
{
|
||||||
|
if (m_instance != nullptr && m_instance->isRunning()) {
|
||||||
|
auto response = CustomMessageBox::selectable(this, "Confirm Delete",
|
||||||
|
"If you remove this resource while the game is running it may crash your game.\n"
|
||||||
|
"Are you sure you want to do this?",
|
||||||
|
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||||
|
->exec();
|
||||||
|
|
||||||
|
if (response != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_model->deleteResources(selection.indexes());
|
m_model->deleteResources(selection.indexes());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalResourcesPage::enableItem()
|
void ExternalResourcesPage::enableItem()
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
|
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
|
||||||
m_model->setResourceEnabled(selection.indexes(), EnableAction::ENABLE);
|
m_model->setResourceEnabled(selection.indexes(), EnableAction::ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalResourcesPage::disableItem()
|
void ExternalResourcesPage::disableItem()
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
if (m_instance != nullptr && m_instance->isRunning()) {
|
||||||
return;
|
auto response = CustomMessageBox::selectable(this, "Confirm disable",
|
||||||
|
"If you disable this resource while the game is running it may crash your game.\n"
|
||||||
|
"Are you sure you want to do this?",
|
||||||
|
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||||
|
->exec();
|
||||||
|
|
||||||
|
if (response != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
}
|
||||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
|
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
|
||||||
m_model->setResourceEnabled(selection.indexes(), EnableAction::DISABLE);
|
m_model->setResourceEnabled(selection.indexes(), EnableAction::DISABLE);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,5 @@ class ExternalResourcesPage : public QMainWindow, public BasePage {
|
|||||||
QString m_fileSelectionFilter;
|
QString m_fileSelectionFilter;
|
||||||
QString m_viewFilter;
|
QString m_viewFilter;
|
||||||
|
|
||||||
bool m_controlsEnabled = true;
|
|
||||||
|
|
||||||
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
std::shared_ptr<Setting> m_wide_bar_setting = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -60,17 +60,13 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
|
|||||||
m_settings = inst->settings();
|
m_settings = inst->settings();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// As the signal will (probably) not be triggered once we click edit, let's update it manually instead.
|
|
||||||
updateRunningStatus(m_instance->isRunning());
|
|
||||||
|
|
||||||
connect(m_instance, &BaseInstance::runningStatusChanged, this, &InstanceSettingsPage::updateRunningStatus);
|
|
||||||
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
|
connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked);
|
||||||
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
|
connect(APPLICATION, &Application::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings);
|
||||||
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);
|
connect(APPLICATION, &Application::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings);
|
||||||
connect(ui->instanceAccountSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &InstanceSettingsPage::changeInstanceAccount);
|
connect(ui->instanceAccountSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&InstanceSettingsPage::changeInstanceAccount);
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
|
|
||||||
updateThresholds();
|
updateThresholds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,8 +519,3 @@ void InstanceSettingsPage::updateThresholds()
|
|||||||
ui->labelMaxMemIcon->setPixmap(pix);
|
ui->labelMaxMemIcon->setPixmap(pix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceSettingsPage::updateRunningStatus(bool running)
|
|
||||||
{
|
|
||||||
setEnabled(!running);
|
|
||||||
}
|
|
||||||
|
@ -79,8 +79,7 @@ public:
|
|||||||
|
|
||||||
void updateThresholds();
|
void updateThresholds();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateRunningStatus(bool running);
|
|
||||||
void on_javaDetectBtn_clicked();
|
void on_javaDetectBtn_clicked();
|
||||||
void on_javaTestBtn_clicked();
|
void on_javaTestBtn_clicked();
|
||||||
void on_javaBrowseBtn_clicked();
|
void on_javaBrowseBtn_clicked();
|
||||||
|
@ -92,9 +92,7 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
|
|||||||
ui->actionsToolbar->addAction(ui->actionVisitItemPage);
|
ui->actionsToolbar->addAction(ui->actionVisitItemPage);
|
||||||
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
|
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
|
||||||
|
|
||||||
auto check_allow_update = [this] {
|
auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
|
||||||
return (!m_instance || !m_instance->isRunning()) && (ui->treeView->selectionModel()->hasSelection() || !m_model->empty());
|
|
||||||
};
|
|
||||||
|
|
||||||
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] {
|
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] {
|
||||||
ui->actionUpdateItem->setEnabled(check_allow_update());
|
ui->actionUpdateItem->setEnabled(check_allow_update());
|
||||||
@ -121,22 +119,9 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
|
|||||||
|
|
||||||
connect(mods.get(), &ModFolderModel::updateFinished, this,
|
connect(mods.get(), &ModFolderModel::updateFinished, this,
|
||||||
[this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
|
[this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
|
||||||
|
|
||||||
connect(m_instance, &BaseInstance::runningStatusChanged, this, &ModFolderPage::runningStateChanged);
|
|
||||||
ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModFolderPage::runningStateChanged(bool running)
|
|
||||||
{
|
|
||||||
ui->actionDownloadItem->setEnabled(!running);
|
|
||||||
ui->actionUpdateItem->setEnabled(!running);
|
|
||||||
ui->actionAddItem->setEnabled(!running);
|
|
||||||
ui->actionEnableItem->setEnabled(!running);
|
|
||||||
ui->actionDisableItem->setEnabled(!running);
|
|
||||||
ui->actionRemoveItem->setEnabled(!running);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ModFolderPage::shouldDisplay() const
|
bool ModFolderPage::shouldDisplay() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@ -155,13 +140,21 @@ bool ModFolderPage::onSelectionChanged(const QModelIndex& current, const QModelI
|
|||||||
|
|
||||||
void ModFolderPage::removeItems(const QItemSelection& selection)
|
void ModFolderPage::removeItems(const QItemSelection& selection)
|
||||||
{
|
{
|
||||||
|
if (m_instance != nullptr && m_instance->isRunning()) {
|
||||||
|
auto response = CustomMessageBox::selectable(this, "Confirm Delete",
|
||||||
|
"If you remove mods while the game is running it may crash your game.\n"
|
||||||
|
"Are you sure you want to do this?",
|
||||||
|
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||||
|
->exec();
|
||||||
|
|
||||||
|
if (response != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_model->deleteMods(selection.indexes());
|
m_model->deleteMods(selection.indexes());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModFolderPage::installMods()
|
void ModFolderPage::installMods()
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
|
||||||
return;
|
|
||||||
if (m_instance->typeName() != "Minecraft")
|
if (m_instance->typeName() != "Minecraft")
|
||||||
return; // this is a null instance or a legacy instance
|
return; // this is a null instance or a legacy instance
|
||||||
|
|
||||||
|
@ -60,7 +60,6 @@ class ModFolderPage : public ExternalResourcesPage {
|
|||||||
bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) override;
|
bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void runningStateChanged(bool running);
|
|
||||||
void removeItems(const QItemSelection& selection) override;
|
void removeItems(const QItemSelection& selection) override;
|
||||||
|
|
||||||
void installMods();
|
void installMods();
|
||||||
|
@ -67,8 +67,6 @@ bool ResourcePackPage::onSelectionChanged(const QModelIndex& current, const QMod
|
|||||||
|
|
||||||
void ResourcePackPage::downloadRPs()
|
void ResourcePackPage::downloadRPs()
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
|
||||||
return;
|
|
||||||
if (m_instance->typeName() != "Minecraft")
|
if (m_instance->typeName() != "Minecraft")
|
||||||
return; // this is a null instance or a legacy instance
|
return; // this is a null instance or a legacy instance
|
||||||
|
|
||||||
|
@ -46,7 +46,6 @@
|
|||||||
#include "ui/dialogs/ProgressDialog.h"
|
#include "ui/dialogs/ProgressDialog.h"
|
||||||
#include "ui/dialogs/ResourceDownloadDialog.h"
|
#include "ui/dialogs/ResourceDownloadDialog.h"
|
||||||
|
|
||||||
|
|
||||||
ShaderPackPage::ShaderPackPage(MinecraftInstance* instance, std::shared_ptr<ShaderPackFolderModel> model, QWidget* parent)
|
ShaderPackPage::ShaderPackPage(MinecraftInstance* instance, std::shared_ptr<ShaderPackFolderModel> model, QWidget* parent)
|
||||||
: ExternalResourcesPage(instance, model, parent)
|
: ExternalResourcesPage(instance, model, parent)
|
||||||
{
|
{
|
||||||
@ -61,8 +60,6 @@ ShaderPackPage::ShaderPackPage(MinecraftInstance* instance, std::shared_ptr<Shad
|
|||||||
|
|
||||||
void ShaderPackPage::downloadShaders()
|
void ShaderPackPage::downloadShaders()
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
|
||||||
return;
|
|
||||||
if (m_instance->typeName() != "Minecraft")
|
if (m_instance->typeName() != "Minecraft")
|
||||||
return; // this is a null instance or a legacy instance
|
return; // this is a null instance or a legacy instance
|
||||||
|
|
||||||
|
@ -69,8 +69,6 @@ bool TexturePackPage::onSelectionChanged(const QModelIndex& current, const QMode
|
|||||||
|
|
||||||
void TexturePackPage::downloadTPs()
|
void TexturePackPage::downloadTPs()
|
||||||
{
|
{
|
||||||
if (!m_controlsEnabled)
|
|
||||||
return;
|
|
||||||
if (m_instance->typeName() != "Minecraft")
|
if (m_instance->typeName() != "Minecraft")
|
||||||
return; // this is a null instance or a legacy instance
|
return; // this is a null instance or a legacy instance
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user