aboutsummaryrefslogtreecommitdiff
path: root/launcher/ui/pages/instance
diff options
context:
space:
mode:
authorflow <flowlnlnln@gmail.com>2022-08-13 11:58:39 -0300
committerflow <flowlnlnln@gmail.com>2022-08-20 10:49:54 -0300
commite2ab2aea32b6d48ee0c9f90442ed53c47e2e7d96 (patch)
tree76c2c9cb6ea122f497aee22e844500ae1037c84d /launcher/ui/pages/instance
parentc3ceefbafbbeb3d31630ef329405ebaacdf9fce5 (diff)
downloadPrismLauncher-e2ab2aea32b6d48ee0c9f90442ed53c47e2e7d96.tar.gz
PrismLauncher-e2ab2aea32b6d48ee0c9f90442ed53c47e2e7d96.tar.bz2
PrismLauncher-e2ab2aea32b6d48ee0c9f90442ed53c47e2e7d96.zip
change: add enable/disable to resources
TIL that zip resource packs, when disabled, actually have the effect of not showing up in the game at all. Since this can be useful to someone, I moved the logic for it to the resources. Signed-off-by: flow <flowlnlnln@gmail.com>
Diffstat (limited to 'launcher/ui/pages/instance')
-rw-r--r--launcher/ui/pages/instance/ExternalResourcesPage.cpp28
-rw-r--r--launcher/ui/pages/instance/ExternalResourcesPage.h6
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.cpp29
-rw-r--r--launcher/ui/pages/instance/ModFolderPage.h5
4 files changed, 31 insertions, 37 deletions
diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp
index 0a3687e5..f31e8325 100644
--- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp
+++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp
@@ -40,6 +40,7 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared
connect(ui->actionViewFolder, &QAction::triggered, this, &ExternalResourcesPage::viewFolder);
connect(ui->treeView, &ModListView::customContextMenuRequested, this, &ExternalResourcesPage::ShowContextMenu);
+ connect(ui->treeView, &ModListView::activated, this, &ExternalResourcesPage::itemActivated);
auto selection_model = ui->treeView->selectionModel();
connect(selection_model, &QItemSelectionModel::currentChanged, this, &ExternalResourcesPage::current);
@@ -81,6 +82,15 @@ void ExternalResourcesPage::retranslate()
ui->retranslateUi(this);
}
+void ExternalResourcesPage::itemActivated(const QModelIndex&)
+{
+ if (!m_controlsEnabled)
+ return;
+
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
+ m_model->setResourceEnabled(selection.indexes(), EnableAction::TOGGLE);
+}
+
void ExternalResourcesPage::filterTextChanged(const QString& newContents)
{
m_viewFilter = newContents;
@@ -157,6 +167,24 @@ void ExternalResourcesPage::removeItem()
m_model->deleteResources(selection.indexes());
}
+void ExternalResourcesPage::enableItem()
+{
+ if (!m_controlsEnabled)
+ return;
+
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
+ m_model->setResourceEnabled(selection.indexes(), EnableAction::ENABLE);
+}
+
+void ExternalResourcesPage::disableItem()
+{
+ if (!m_controlsEnabled)
+ return;
+
+ auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
+ m_model->setResourceEnabled(selection.indexes(), EnableAction::DISABLE);
+}
+
void ExternalResourcesPage::viewConfigs()
{
DesktopServices::openDirectory(m_instance->instanceConfigFolder(), true);
diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.h b/launcher/ui/pages/instance/ExternalResourcesPage.h
index 280f1542..8e352cef 100644
--- a/launcher/ui/pages/instance/ExternalResourcesPage.h
+++ b/launcher/ui/pages/instance/ExternalResourcesPage.h
@@ -45,15 +45,15 @@ class ExternalResourcesPage : public QMainWindow, public BasePage {
virtual bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous);
protected slots:
- virtual void itemActivated(const QModelIndex& index) {};
+ void itemActivated(const QModelIndex& index);
void filterTextChanged(const QString& newContents);
virtual void runningStateChanged(bool running);
virtual void addItem();
virtual void removeItem();
- virtual void enableItem() {};
- virtual void disableItem() {};
+ virtual void enableItem();
+ virtual void disableItem();
virtual void viewFolder();
virtual void viewConfigs();
diff --git a/launcher/ui/pages/instance/ModFolderPage.cpp b/launcher/ui/pages/instance/ModFolderPage.cpp
index 63897fb0..75b40e77 100644
--- a/launcher/ui/pages/instance/ModFolderPage.cpp
+++ b/launcher/ui/pages/instance/ModFolderPage.cpp
@@ -110,8 +110,6 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
ModFolderPage::runningStateChanged(m_instance && m_instance->isRunning());
}
-
- connect(ui->treeView, &ModListView::activated, this, &ModFolderPage::itemActivated);
}
void ModFolderPage::runningStateChanged(bool running)
@@ -126,33 +124,6 @@ bool ModFolderPage::shouldDisplay() const
return true;
}
-void ModFolderPage::itemActivated(const QModelIndex&)
-{
- if (!m_controlsEnabled)
- return;
-
- auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
- m_model->setModStatus(selection.indexes(), ModFolderModel::Toggle);
-}
-
-void ModFolderPage::enableItem()
-{
- if (!m_controlsEnabled)
- return;
-
- auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
- m_model->setModStatus(selection.indexes(), ModFolderModel::Enable);
-}
-
-void ModFolderPage::disableItem()
-{
- if (!m_controlsEnabled)
- return;
-
- auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection());
- m_model->setModStatus(selection.indexes(), ModFolderModel::Disable);
-}
-
bool ModFolderPage::onSelectionChanged(const QModelIndex& current, const QModelIndex& previous)
{
auto sourceCurrent = m_filterModel->mapToSource(current);
diff --git a/launcher/ui/pages/instance/ModFolderPage.h b/launcher/ui/pages/instance/ModFolderPage.h
index 5da353f0..7fc9d9a1 100644
--- a/launcher/ui/pages/instance/ModFolderPage.h
+++ b/launcher/ui/pages/instance/ModFolderPage.h
@@ -58,11 +58,6 @@ class ModFolderPage : public ExternalResourcesPage {
public slots:
bool onSelectionChanged(const QModelIndex& current, const QModelIndex& previous) override;
- void itemActivated(const QModelIndex& index) override;
-
- void enableItem() override;
- void disableItem() override;
-
private slots:
void installMods();
void updateMods();