mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into update_file2
This commit is contained in:
@ -42,6 +42,7 @@
|
||||
#include "minecraft/mod/ResourceFolderModel.h"
|
||||
#include "ui/GuiUtil.h"
|
||||
|
||||
#include <QHeaderView>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <algorithm>
|
||||
@ -95,7 +96,8 @@ ExternalResourcesPage::ExternalResourcesPage(BaseInstance* instance, std::shared
|
||||
|
||||
connect(viewHeader, &QHeaderView::customContextMenuRequested, this, &ExternalResourcesPage::ShowHeaderContextMenu);
|
||||
|
||||
m_model->loadHiddenColumns(ui->treeView);
|
||||
m_model->loadColumns(ui->treeView);
|
||||
connect(ui->treeView->header(), &QHeaderView::sectionResized, this, [this] { m_model->saveColumns(ui->treeView); });
|
||||
}
|
||||
|
||||
ExternalResourcesPage::~ExternalResourcesPage()
|
||||
|
@ -70,6 +70,9 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="WideBar" name="actionsToolbar">
|
||||
<property name="useDefaultAction" stdset="0">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Actions</string>
|
||||
</property>
|
||||
@ -146,17 +149,6 @@
|
||||
<string>Download a new resource</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUpdateItem">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check for &Updates</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Try to check or update all selected resources (all resources if none are selected)</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionVisitItemPage">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
@ -168,15 +160,15 @@
|
||||
<string>Go to mods home page</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRemoveItemMetadata">
|
||||
<action name="actionUpdateItem">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove metadata</string>
|
||||
<string>Check for &Updates</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Remove mod's metadata</string>
|
||||
<string>Try to check or update all selected resources (all resources if none are selected)</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
|
@ -90,6 +90,9 @@ void InstanceSettingsPage::globalSettingsButtonClicked(bool)
|
||||
case 2:
|
||||
APPLICATION->ShowGlobalSettings(this, "custom-commands");
|
||||
return;
|
||||
case 3:
|
||||
APPLICATION->ShowGlobalSettings(this, "environment-variables");
|
||||
return;
|
||||
default:
|
||||
APPLICATION->ShowGlobalSettings(this, "minecraft-settings");
|
||||
return;
|
||||
@ -199,6 +202,14 @@ void InstanceSettingsPage::applySettings()
|
||||
m_settings->reset("PostExitCommand");
|
||||
}
|
||||
|
||||
// Environment Variables
|
||||
auto env = ui->environmentVariables->override();
|
||||
m_settings->set("OverrideEnv", env);
|
||||
if (env)
|
||||
m_settings->set("Env", ui->environmentVariables->value());
|
||||
else
|
||||
m_settings->reset("Env");
|
||||
|
||||
// Workarounds
|
||||
bool workarounds = ui->nativeWorkaroundsGroupBox->isChecked();
|
||||
m_settings->set("OverrideNativeWorkarounds", workarounds);
|
||||
@ -318,6 +329,9 @@ void InstanceSettingsPage::loadSettings()
|
||||
ui->customCommands->initialize(true, m_settings->get("OverrideCommands").toBool(), m_settings->get("PreLaunchCommand").toString(),
|
||||
m_settings->get("WrapperCommand").toString(), m_settings->get("PostExitCommand").toString());
|
||||
|
||||
// Environment variables
|
||||
ui->environmentVariables->initialize(true, m_settings->get("OverrideEnv").toBool(), m_settings->get("Env").toMap());
|
||||
|
||||
// Workarounds
|
||||
ui->nativeWorkaroundsGroupBox->setChecked(m_settings->get("OverrideNativeWorkarounds").toBool());
|
||||
ui->useNativeGLFWCheck->setChecked(m_settings->get("UseNativeGLFW").toBool());
|
||||
@ -484,6 +498,7 @@ void InstanceSettingsPage::retranslate()
|
||||
{
|
||||
ui->retranslateUi(this);
|
||||
ui->customCommands->retranslate(); // TODO: why is this seperate from the others?
|
||||
ui->environmentVariables->retranslate();
|
||||
}
|
||||
|
||||
void InstanceSettingsPage::updateThresholds()
|
||||
|
@ -35,13 +35,10 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="settingsTabs">
|
||||
<property name="tabShape">
|
||||
<enum>QTabWidget::Rounded</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="minecraftTab">
|
||||
<widget class="QWidget" name="minecraftPage">
|
||||
<attribute name="title">
|
||||
<string notr="true">Java</string>
|
||||
</attribute>
|
||||
@ -158,7 +155,7 @@
|
||||
<string notr="true"> MiB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>128</number>
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
@ -180,7 +177,7 @@
|
||||
<string notr="true"> MiB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>128</number>
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1048576</number>
|
||||
@ -202,7 +199,7 @@
|
||||
<string notr="true"> MiB</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>64</number>
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999999999</number>
|
||||
@ -254,7 +251,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="javaTab">
|
||||
<widget class="QWidget" name="javaPage">
|
||||
<attribute name="title">
|
||||
<string>Game windows</string>
|
||||
</attribute>
|
||||
@ -414,7 +411,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab">
|
||||
<widget class="QWidget" name="customCommandsPage">
|
||||
<attribute name="title">
|
||||
<string>Custom commands</string>
|
||||
</attribute>
|
||||
@ -424,6 +421,16 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="environmentVariablesPage">
|
||||
<attribute name="title">
|
||||
<string>Environment variables</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||
<item>
|
||||
<widget class="EnvironmentVariables" name="environmentVariables" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="workaroundsPage">
|
||||
<attribute name="title">
|
||||
<string>Workarounds</string>
|
||||
@ -736,6 +743,12 @@
|
||||
<header>ui/widgets/CustomCommands.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>EnvironmentVariables</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ui/widgets/EnvironmentVariables.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>openGlobalJavaSettingsButton</tabstop>
|
||||
|
@ -84,50 +84,71 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
|
||||
|
||||
connect(ui->actionDownloadItem, &QAction::triggered, this, &ModFolderPage::installMods);
|
||||
|
||||
// update menu
|
||||
auto updateMenu = ui->actionUpdateItem->menu();
|
||||
if (updateMenu) {
|
||||
updateMenu->clear();
|
||||
} else {
|
||||
updateMenu = new QMenu(this);
|
||||
}
|
||||
|
||||
auto update = updateMenu->addAction(tr("Check for Updates"));
|
||||
update->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)"));
|
||||
connect(update, &QAction::triggered, this, &ModFolderPage::updateMods);
|
||||
|
||||
auto updateWithDeps = updateMenu->addAction(tr("Verify Dependencies"));
|
||||
updateWithDeps->setToolTip(
|
||||
tr("Try to update and check for missing dependencies all selected mods (all mods if none are selected)"));
|
||||
connect(updateWithDeps, &QAction::triggered, this, [this] { updateMods(true); });
|
||||
|
||||
auto depsDisabled = APPLICATION->settings()->getSetting("ModDependenciesDisabled");
|
||||
updateWithDeps->setVisible(!depsDisabled->get().toBool());
|
||||
connect(depsDisabled.get(), &Setting::SettingChanged, this,
|
||||
[updateWithDeps](const Setting& setting, QVariant value) { updateWithDeps->setVisible(!value.toBool()); });
|
||||
|
||||
auto actionRemoveItemMetadata = updateMenu->addAction(tr("Reset update metadata"));
|
||||
actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata"));
|
||||
connect(actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata);
|
||||
actionRemoveItemMetadata->setEnabled(false);
|
||||
|
||||
ui->actionUpdateItem->setMenu(updateMenu);
|
||||
|
||||
ui->actionUpdateItem->setToolTip(tr("Try to check or update all selected mods (all mods if none are selected)"));
|
||||
ui->actionsToolbar->insertActionAfter(ui->actionAddItem, ui->actionUpdateItem);
|
||||
connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods);
|
||||
ui->actionsToolbar->insertActionBefore(ui->actionAddItem, ui->actionUpdateItem);
|
||||
|
||||
ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
|
||||
ui->actionsToolbar->addAction(ui->actionVisitItemPage);
|
||||
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);
|
||||
|
||||
ui->actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata"));
|
||||
ui->actionsToolbar->insertActionAfter(ui->actionRemoveItem, ui->actionRemoveItemMetadata);
|
||||
connect(ui->actionRemoveItemMetadata, &QAction::triggered, this, &ModFolderPage::deleteModMetadata);
|
||||
|
||||
auto check_allow_update = [this] { return ui->treeView->selectionModel()->hasSelection() || !m_model->empty(); };
|
||||
|
||||
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, check_allow_update] {
|
||||
ui->actionUpdateItem->setEnabled(check_allow_update());
|
||||
connect(ui->treeView->selectionModel(), &QItemSelectionModel::selectionChanged, this,
|
||||
[this, check_allow_update, actionRemoveItemMetadata] {
|
||||
ui->actionUpdateItem->setEnabled(check_allow_update());
|
||||
|
||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||
auto mods_list = m_model->selectedMods(selection);
|
||||
auto selected = std::count_if(mods_list.cbegin(), mods_list.cend(),
|
||||
[](Mod* v) { return v->metadata() != nullptr || v->homeurl().size() != 0; });
|
||||
if (selected <= 1) {
|
||||
ui->actionVisitItemPage->setText(tr("Visit mod's page"));
|
||||
ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
|
||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||
auto mods_list = m_model->selectedMods(selection);
|
||||
auto selected = std::count_if(mods_list.cbegin(), mods_list.cend(),
|
||||
[](Mod* v) { return v->metadata() != nullptr || v->homeurl().size() != 0; });
|
||||
if (selected <= 1) {
|
||||
ui->actionVisitItemPage->setText(tr("Visit mod's page"));
|
||||
ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
|
||||
|
||||
ui->actionRemoveItemMetadata->setToolTip(tr("Remove mod's metadata"));
|
||||
} else {
|
||||
ui->actionVisitItemPage->setText(tr("Visit mods' pages"));
|
||||
ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods"));
|
||||
} else {
|
||||
ui->actionVisitItemPage->setText(tr("Visit mods' pages"));
|
||||
ui->actionVisitItemPage->setToolTip(tr("Go to the pages of the selected mods"));
|
||||
}
|
||||
ui->actionVisitItemPage->setEnabled(selected != 0);
|
||||
actionRemoveItemMetadata->setEnabled(selected != 0);
|
||||
});
|
||||
|
||||
ui->actionRemoveItemMetadata->setToolTip(tr("Remove mods' metadata"));
|
||||
}
|
||||
ui->actionVisitItemPage->setEnabled(selected != 0);
|
||||
ui->actionRemoveItemMetadata->setEnabled(selected != 0);
|
||||
});
|
||||
auto updateButtons = [this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); };
|
||||
connect(mods.get(), &ModFolderModel::rowsInserted, this, updateButtons);
|
||||
|
||||
connect(mods.get(), &ModFolderModel::rowsInserted, this,
|
||||
[this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
|
||||
connect(mods.get(), &ModFolderModel::rowsRemoved, this, updateButtons);
|
||||
|
||||
connect(mods.get(), &ModFolderModel::rowsRemoved, this,
|
||||
[this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
|
||||
|
||||
connect(mods.get(), &ModFolderModel::updateFinished, this,
|
||||
[this, check_allow_update] { ui->actionUpdateItem->setEnabled(check_allow_update()); });
|
||||
connect(mods.get(), &ModFolderModel::updateFinished, this, updateButtons);
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,7 +225,7 @@ void ModFolderPage::installMods()
|
||||
}
|
||||
}
|
||||
|
||||
void ModFolderPage::updateMods()
|
||||
void ModFolderPage::updateMods(bool includeDeps)
|
||||
{
|
||||
if (m_instance->typeName() != "Minecraft")
|
||||
return; // this is a null instance or a legacy instance
|
||||
@ -214,6 +235,10 @@ void ModFolderPage::updateMods()
|
||||
QMessageBox::critical(this, tr("Error"), tr("Please install a mod loader first!"));
|
||||
return;
|
||||
}
|
||||
if (APPLICATION->settings()->get("ModMetadataDisabled").toBool()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Mod updates are unavailable when metadata is disabled!"));
|
||||
return;
|
||||
}
|
||||
auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()).indexes();
|
||||
|
||||
auto mods_list = m_model->selectedMods(selection);
|
||||
@ -221,7 +246,7 @@ void ModFolderPage::updateMods()
|
||||
if (use_all)
|
||||
mods_list = m_model->allMods();
|
||||
|
||||
ModUpdateDialog update_dialog(this, m_instance, m_model, mods_list);
|
||||
ModUpdateDialog update_dialog(this, m_instance, m_model, mods_list, includeDeps);
|
||||
update_dialog.checkCandidates();
|
||||
|
||||
if (update_dialog.aborted()) {
|
||||
|
@ -64,7 +64,7 @@ class ModFolderPage : public ExternalResourcesPage {
|
||||
void deleteModMetadata();
|
||||
|
||||
void installMods();
|
||||
void updateMods();
|
||||
void updateMods(bool includeDeps = false);
|
||||
void visitModPages();
|
||||
|
||||
protected:
|
||||
|
@ -65,7 +65,7 @@ class OtherLogsPage : public QWidget, public BasePage {
|
||||
|
||||
private slots:
|
||||
void populateSelectLogBox();
|
||||
void on_selectLogBox_currentIndexChanged(const int index);
|
||||
void on_selectLogBox_currentIndexChanged(int index);
|
||||
void on_btnReload_clicked();
|
||||
void on_btnPaste_clicked();
|
||||
void on_btnCopy_clicked();
|
||||
@ -78,7 +78,7 @@ class OtherLogsPage : public QWidget, public BasePage {
|
||||
void findPreviousActivated();
|
||||
|
||||
private:
|
||||
void setControlsEnabled(const bool enabled);
|
||||
void setControlsEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
Ui::OtherLogsPage* ui;
|
||||
|
@ -68,8 +68,8 @@
|
||||
#include <FileSystem.h>
|
||||
#include "RWStorage.h"
|
||||
|
||||
typedef RWStorage<QString, QIcon> SharedIconCache;
|
||||
typedef std::shared_ptr<SharedIconCache> SharedIconCachePtr;
|
||||
using SharedIconCache = RWStorage<QString, QIcon>;
|
||||
using SharedIconCachePtr = std::shared_ptr<SharedIconCache>;
|
||||
|
||||
class ThumbnailingResult : public QObject {
|
||||
Q_OBJECT
|
||||
@ -383,20 +383,31 @@ void ScreenshotsPage::on_actionUpload_triggered()
|
||||
|
||||
QList<ScreenShot::Ptr> uploaded;
|
||||
auto job = NetJob::Ptr(new NetJob("Screenshot Upload", APPLICATION->network()));
|
||||
|
||||
ProgressDialog dialog(this);
|
||||
dialog.setSkipButton(true, tr("Abort"));
|
||||
|
||||
if (selection.size() < 2) {
|
||||
auto item = selection.at(0);
|
||||
auto info = m_model->fileInfo(item);
|
||||
auto screenshot = std::make_shared<ScreenShot>(info);
|
||||
job->addNetAction(ImgurUpload::make(screenshot));
|
||||
|
||||
m_uploadActive = true;
|
||||
ProgressDialog dialog(this);
|
||||
connect(job.get(), &Task::failed, [this](QString reason) {
|
||||
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), reason, QMessageBox::Critical)->show();
|
||||
});
|
||||
connect(job.get(), &Task::aborted, [this] {
|
||||
CustomMessageBox::selectable(this, tr("Screenshots upload aborted"), tr("The task has been aborted by the user."),
|
||||
QMessageBox::Information)
|
||||
->show();
|
||||
});
|
||||
|
||||
if (dialog.execWithTask(job.get()) != QDialog::Accepted) {
|
||||
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
|
||||
} else {
|
||||
m_uploadActive = true;
|
||||
|
||||
if (dialog.execWithTask(job.get()) == QDialog::Accepted) {
|
||||
auto link = screenshot->m_url;
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
qDebug() << "ImgurUpload link" << link;
|
||||
clipboard->setText(link);
|
||||
CustomMessageBox::selectable(
|
||||
this, tr("Upload finished"),
|
||||
@ -417,22 +428,36 @@ void ScreenshotsPage::on_actionUpload_triggered()
|
||||
}
|
||||
SequentialTask task;
|
||||
auto albumTask = NetJob::Ptr(new NetJob("Imgur Album Creation", APPLICATION->network()));
|
||||
auto imgurAlbum = ImgurAlbumCreation::make(uploaded);
|
||||
auto imgurResult = std::make_shared<ImgurAlbumCreation::Result>();
|
||||
auto imgurAlbum = ImgurAlbumCreation::make(imgurResult, uploaded);
|
||||
albumTask->addNetAction(imgurAlbum);
|
||||
task.addTask(job);
|
||||
task.addTask(albumTask);
|
||||
m_uploadActive = true;
|
||||
ProgressDialog prog(this);
|
||||
if (prog.execWithTask(&task) != QDialog::Accepted) {
|
||||
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
|
||||
} else {
|
||||
auto link = QString("https://imgur.com/a/%1").arg(imgurAlbum->id());
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
clipboard->setText(link);
|
||||
CustomMessageBox::selectable(this, tr("Upload finished"),
|
||||
tr("The <a href=\"%1\">link to the uploaded album</a> has been placed in your clipboard.").arg(link),
|
||||
|
||||
connect(&task, &Task::failed, [this](QString reason) {
|
||||
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), reason, QMessageBox::Critical)->show();
|
||||
});
|
||||
connect(&task, &Task::aborted, [this] {
|
||||
CustomMessageBox::selectable(this, tr("Screenshots upload aborted"), tr("The task has been aborted by the user."),
|
||||
QMessageBox::Information)
|
||||
->exec();
|
||||
->show();
|
||||
});
|
||||
|
||||
m_uploadActive = true;
|
||||
if (dialog.execWithTask(&task) == QDialog::Accepted) {
|
||||
if (imgurResult->id.isEmpty()) {
|
||||
CustomMessageBox::selectable(this, tr("Failed to upload screenshots!"), tr("Unknown error"), QMessageBox::Warning)->exec();
|
||||
} else {
|
||||
auto link = QString("https://imgur.com/a/%1").arg(imgurResult->id);
|
||||
qDebug() << "ImgurUpload link" << link;
|
||||
QClipboard* clipboard = QApplication::clipboard();
|
||||
clipboard->setText(link);
|
||||
CustomMessageBox::selectable(
|
||||
this, tr("Upload finished"),
|
||||
tr("The <a href=\"%1\">link to the uploaded album</a> has been placed in your clipboard.").arg(link),
|
||||
QMessageBox::Information)
|
||||
->exec();
|
||||
}
|
||||
}
|
||||
m_uploadActive = false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user