Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into scale_cat
This commit is contained in:
commit
1ff8136f98
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -86,11 +86,11 @@ jobs:
|
|||||||
|
|
||||||
- os: macos-12
|
- os: macos-12
|
||||||
name: macOS
|
name: macOS
|
||||||
macosx_deployment_target: 10.15
|
macosx_deployment_target: 11.0
|
||||||
qt_ver: 6
|
qt_ver: 6
|
||||||
qt_host: mac
|
qt_host: mac
|
||||||
qt_arch: ''
|
qt_arch: ''
|
||||||
qt_version: '6.5.1'
|
qt_version: '6.5.0'
|
||||||
qt_modules: 'qt5compat qtimageformats'
|
qt_modules: 'qt5compat qtimageformats'
|
||||||
qt_tools: ''
|
qt_tools: ''
|
||||||
|
|
||||||
|
2
.github/workflows/trigger_release.yml
vendored
2
.github/workflows/trigger_release.yml
vendored
@ -47,7 +47,7 @@ jobs:
|
|||||||
mv PrismLauncher-macOS-Legacy*/PrismLauncher.tar.gz PrismLauncher-macOS-Legacy-${{ env.VERSION }}.tar.gz
|
mv PrismLauncher-macOS-Legacy*/PrismLauncher.tar.gz PrismLauncher-macOS-Legacy-${{ env.VERSION }}.tar.gz
|
||||||
mv PrismLauncher-macOS*/PrismLauncher.tar.gz PrismLauncher-macOS-${{ env.VERSION }}.tar.gz
|
mv PrismLauncher-macOS*/PrismLauncher.tar.gz PrismLauncher-macOS-${{ env.VERSION }}.tar.gz
|
||||||
|
|
||||||
tar -czf PrismLauncher-${{ env.VERSION }}.tar.gz PrismLauncher-${{ env.VERSION }}
|
tar --exclude='.git' -czf PrismLauncher-${{ env.VERSION }}.tar.gz PrismLauncher-${{ env.VERSION }}
|
||||||
|
|
||||||
for d in PrismLauncher-Windows-MSVC*; do
|
for d in PrismLauncher-Windows-MSVC*; do
|
||||||
cd "${d}" || continue
|
cd "${d}" || continue
|
||||||
|
@ -376,33 +376,33 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
|
|
||||||
// init the logger
|
// init the logger
|
||||||
{
|
{
|
||||||
static const QString logBase = BuildConfig.LAUNCHER_NAME + "-%0.log";
|
static const QString baseLogFile = BuildConfig.LAUNCHER_NAME + "-%0.log";
|
||||||
auto moveFile = [](const QString &oldName, const QString &newName)
|
static const QString logBase = FS::PathCombine("logs", baseLogFile);
|
||||||
{
|
auto moveFile = [](const QString& oldName, const QString& newName) {
|
||||||
QFile::remove(newName);
|
QFile::remove(newName);
|
||||||
QFile::copy(oldName, newName);
|
QFile::copy(oldName, newName);
|
||||||
QFile::remove(oldName);
|
QFile::remove(oldName);
|
||||||
};
|
};
|
||||||
|
if (FS::ensureFolderPathExists("logs")) { // if this did not fail
|
||||||
|
for (auto i = 0; i <= 4; i++)
|
||||||
|
if (auto oldName = baseLogFile.arg(i);
|
||||||
|
QFile::exists(oldName)) // do not pointlessly delete new files if the old ones are not there
|
||||||
|
moveFile(oldName, logBase.arg(i));
|
||||||
|
}
|
||||||
|
|
||||||
moveFile(logBase.arg(3), logBase.arg(4));
|
for (auto i = 4; i > 0; i--)
|
||||||
moveFile(logBase.arg(2), logBase.arg(3));
|
moveFile(logBase.arg(i - 1), logBase.arg(i));
|
||||||
moveFile(logBase.arg(1), logBase.arg(2));
|
|
||||||
moveFile(logBase.arg(0), logBase.arg(1));
|
|
||||||
|
|
||||||
logFile = std::unique_ptr<QFile>(new QFile(logBase.arg(0)));
|
logFile = std::unique_ptr<QFile>(new QFile(logBase.arg(0)));
|
||||||
if(!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
|
if (!logFile->open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
|
||||||
{
|
showFatalErrorMessage("The launcher data folder is not writable!",
|
||||||
showFatalErrorMessage(
|
QString("The launcher couldn't create a log file - the data folder is not writable.\n"
|
||||||
"The launcher data folder is not writable!",
|
"\n"
|
||||||
QString(
|
"Make sure you have write permissions to the data folder.\n"
|
||||||
"The launcher couldn't create a log file - the data folder is not writable.\n"
|
"(%1)\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Make sure you have write permissions to the data folder.\n"
|
"The launcher cannot continue until you fix this problem.")
|
||||||
"(%1)\n"
|
.arg(dataPath));
|
||||||
"\n"
|
|
||||||
"The launcher cannot continue until you fix this problem."
|
|
||||||
).arg(dataPath)
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qInstallMessageHandler(appDebugOutput);
|
qInstallMessageHandler(appDebugOutput);
|
||||||
@ -1699,6 +1699,7 @@ bool Application::handleDataMigration(const QString& currentData,
|
|||||||
matcher->add(std::make_shared<SimplePrefixMatcher>(configFile));
|
matcher->add(std::make_shared<SimplePrefixMatcher>(configFile));
|
||||||
matcher->add(std::make_shared<SimplePrefixMatcher>(
|
matcher->add(std::make_shared<SimplePrefixMatcher>(
|
||||||
BuildConfig.LAUNCHER_CONFIGFILE)); // it's possible that we already used that directory before
|
BuildConfig.LAUNCHER_CONFIGFILE)); // it's possible that we already used that directory before
|
||||||
|
matcher->add(std::make_shared<SimplePrefixMatcher>("logs/"));
|
||||||
matcher->add(std::make_shared<SimplePrefixMatcher>("accounts.json"));
|
matcher->add(std::make_shared<SimplePrefixMatcher>("accounts.json"));
|
||||||
matcher->add(std::make_shared<SimplePrefixMatcher>("accounts/"));
|
matcher->add(std::make_shared<SimplePrefixMatcher>("accounts/"));
|
||||||
matcher->add(std::make_shared<SimplePrefixMatcher>("assets/"));
|
matcher->add(std::make_shared<SimplePrefixMatcher>("assets/"));
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "minecraft/PackProfile.h"
|
#include "minecraft/PackProfile.h"
|
||||||
#include "minecraft/mod/ModFolderModel.h"
|
#include "minecraft/mod/ModFolderModel.h"
|
||||||
|
|
||||||
const QStringList ModrinthPackExportTask::PREFIXES({ "mods", "coremods", "resourcepacks", "texturepacks", "shaderpacks" });
|
const QStringList ModrinthPackExportTask::PREFIXES({ "mods/", "coremods/", "resourcepacks/", "texturepacks/", "shaderpacks/" });
|
||||||
const QStringList ModrinthPackExportTask::FILE_EXTENSIONS({ "jar", "litemod", "zip" });
|
const QStringList ModrinthPackExportTask::FILE_EXTENSIONS({ "jar", "litemod", "zip" });
|
||||||
|
|
||||||
ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
ModrinthPackExportTask::ModrinthPackExportTask(const QString& name,
|
||||||
@ -99,14 +99,12 @@ void ModrinthPackExportTask::collectHashes()
|
|||||||
|
|
||||||
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
const QString relative = gameRoot.relativeFilePath(file.absoluteFilePath());
|
||||||
// require sensible file types
|
// require sensible file types
|
||||||
if (!std::any_of(PREFIXES.begin(), PREFIXES.end(),
|
if (!std::any_of(PREFIXES.begin(), PREFIXES.end(), [&relative](const QString& prefix) { return relative.startsWith(prefix); }))
|
||||||
[&relative](const QString& prefix) { return relative.startsWith(prefix + QDir::separator()); }))
|
|
||||||
continue;
|
continue;
|
||||||
if (!std::any_of(FILE_EXTENSIONS.begin(), FILE_EXTENSIONS.end(), [&relative](const QString& extension) {
|
if (!std::any_of(FILE_EXTENSIONS.begin(), FILE_EXTENSIONS.end(), [&relative](const QString& extension) {
|
||||||
return relative.endsWith('.' + extension) || relative.endsWith('.' + extension + ".disabled");
|
return relative.endsWith('.' + extension) || relative.endsWith('.' + extension + ".disabled");
|
||||||
})) {
|
}))
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
QCryptographicHash sha512(QCryptographicHash::Algorithm::Sha512);
|
QCryptographicHash sha512(QCryptographicHash::Algorithm::Sha512);
|
||||||
|
|
||||||
@ -303,9 +301,7 @@ QByteArray ModrinthPackExportTask::generateIndex()
|
|||||||
const ResolvedFile& value = iterator.value();
|
const ResolvedFile& value = iterator.value();
|
||||||
|
|
||||||
QJsonObject file;
|
QJsonObject file;
|
||||||
QString path = iterator.key();
|
file["path"] = iterator.key();
|
||||||
path.replace(QDir::separator(), "/");
|
|
||||||
file["path"] = path;
|
|
||||||
file["downloads"] = QJsonArray({ iterator.value().url });
|
file["downloads"] = QJsonArray({ iterator.value().url });
|
||||||
|
|
||||||
QJsonObject hashes;
|
QJsonObject hashes;
|
||||||
|
@ -53,7 +53,10 @@ class ByteArraySink : public Sink {
|
|||||||
public:
|
public:
|
||||||
auto init(QNetworkRequest& request) -> Task::State override
|
auto init(QNetworkRequest& request) -> Task::State override
|
||||||
{
|
{
|
||||||
m_output->clear();
|
if (m_output)
|
||||||
|
m_output->clear();
|
||||||
|
else
|
||||||
|
qWarning() << "ByteArraySink did not initialize the buffer because it's not addressable";
|
||||||
if (initAllValidators(request))
|
if (initAllValidators(request))
|
||||||
return Task::State::Running;
|
return Task::State::Running;
|
||||||
return Task::State::Failed;
|
return Task::State::Failed;
|
||||||
@ -61,7 +64,10 @@ class ByteArraySink : public Sink {
|
|||||||
|
|
||||||
auto write(QByteArray& data) -> Task::State override
|
auto write(QByteArray& data) -> Task::State override
|
||||||
{
|
{
|
||||||
m_output->append(data);
|
if (m_output)
|
||||||
|
m_output->append(data);
|
||||||
|
else
|
||||||
|
qWarning() << "ByteArraySink did not write the buffer because it's not addressable";
|
||||||
if (writeAllValidators(data))
|
if (writeAllValidators(data))
|
||||||
return Task::State::Running;
|
return Task::State::Running;
|
||||||
return Task::State::Failed;
|
return Task::State::Failed;
|
||||||
@ -69,7 +75,10 @@ class ByteArraySink : public Sink {
|
|||||||
|
|
||||||
auto abort() -> Task::State override
|
auto abort() -> Task::State override
|
||||||
{
|
{
|
||||||
m_output->clear();
|
if (m_output)
|
||||||
|
m_output->clear();
|
||||||
|
else
|
||||||
|
qWarning() << "ByteArraySink did not clear the buffer because it's not addressable";
|
||||||
failAllValidators();
|
failAllValidators();
|
||||||
return Task::State::Failed;
|
return Task::State::Failed;
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,12 @@
|
|||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
INIFile::INIFile()
|
INIFile::INIFile() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool INIFile::saveFile(QString fileName)
|
bool INIFile::saveFile(QString fileName)
|
||||||
{
|
{
|
||||||
|
if (!contains("ConfigVersion"))
|
||||||
|
insert("ConfigVersion", "1.1");
|
||||||
QSettings _settings_obj{ fileName, QSettings::Format::IniFormat };
|
QSettings _settings_obj{ fileName, QSettings::Format::IniFormat };
|
||||||
_settings_obj.setFallbacksEnabled(false);
|
_settings_obj.setFallbacksEnabled(false);
|
||||||
|
|
||||||
@ -71,6 +71,67 @@ bool INIFile::saveFile(QString fileName)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
QString unescape(QString orig)
|
||||||
|
{
|
||||||
|
QString out;
|
||||||
|
QChar prev = QChar::Null;
|
||||||
|
for (auto c : orig) {
|
||||||
|
if (prev == '\\') {
|
||||||
|
if (c == 'n')
|
||||||
|
out += '\n';
|
||||||
|
else if (c == 't')
|
||||||
|
out += '\t';
|
||||||
|
else if (c == '#')
|
||||||
|
out += '#';
|
||||||
|
else
|
||||||
|
out += c;
|
||||||
|
prev = QChar::Null;
|
||||||
|
} else {
|
||||||
|
if (c == '\\') {
|
||||||
|
prev = c;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out += c;
|
||||||
|
prev = QChar::Null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
bool parseOldFileFormat(QIODevice& device, QSettings::SettingsMap& map)
|
||||||
|
{
|
||||||
|
QTextStream in(device.readAll());
|
||||||
|
#if QT_VERSION <= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
in.setCodec("UTF-8");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QStringList lines = in.readAll().split('\n');
|
||||||
|
for (int i = 0; i < lines.count(); i++) {
|
||||||
|
QString& lineRaw = lines[i];
|
||||||
|
// Ignore comments.
|
||||||
|
int commentIndex = 0;
|
||||||
|
QString line = lineRaw;
|
||||||
|
// Search for comments until no more escaped # are available
|
||||||
|
while ((commentIndex = line.indexOf('#', commentIndex + 1)) != -1) {
|
||||||
|
if (commentIndex > 0 && line.at(commentIndex - 1) == '\\') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
line = line.left(lineRaw.indexOf('#')).trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
int eqPos = line.indexOf('=');
|
||||||
|
if (eqPos == -1)
|
||||||
|
continue;
|
||||||
|
QString key = line.left(eqPos).trimmed();
|
||||||
|
QString valueStr = line.right(line.length() - eqPos - 1).trimmed();
|
||||||
|
|
||||||
|
valueStr = unescape(valueStr);
|
||||||
|
|
||||||
|
QVariant value(valueStr);
|
||||||
|
map.insert(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool INIFile::loadFile(QString fileName)
|
bool INIFile::loadFile(QString fileName)
|
||||||
{
|
{
|
||||||
@ -84,10 +145,19 @@ bool INIFile::loadFile(QString fileName)
|
|||||||
qCritical() << "A format error occurred (e.g. loading a malformed INI file).";
|
qCritical() << "A format error occurred (e.g. loading a malformed INI file).";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (!_settings_obj.value("ConfigVersion").isValid()) {
|
||||||
for (auto&& key : _settings_obj.allKeys())
|
QFile file(fileName);
|
||||||
insert(key, _settings_obj.value(key));
|
if (!file.open(QIODevice::ReadOnly))
|
||||||
|
return false;
|
||||||
|
QSettings::SettingsMap map;
|
||||||
|
parseOldFileFormat(file, map);
|
||||||
|
file.close();
|
||||||
|
for (auto&& key : map.keys())
|
||||||
|
insert(key, map.value(key));
|
||||||
|
insert("ConfigVersion", "1.1");
|
||||||
|
} else
|
||||||
|
for (auto&& key : _settings_obj.allKeys())
|
||||||
|
insert(key, _settings_obj.value(key));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,4 +173,3 @@ void INIFile::set(QString key, QVariant val)
|
|||||||
{
|
{
|
||||||
this->operator[](key) = val;
|
this->operator[](key) = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,19 +138,18 @@ void ConcurrentTask::startNext()
|
|||||||
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total) { subTaskProgress(next, current, total); });
|
connect(next.get(), &Task::progress, this, [this, next](qint64 current, qint64 total) { subTaskProgress(next, current, total); });
|
||||||
|
|
||||||
m_doing.insert(next.get(), next);
|
m_doing.insert(next.get(), next);
|
||||||
|
qsizetype num_starts = qMin(m_queue.size(), m_total_max_size - m_doing.size());
|
||||||
auto task_progress = std::make_shared<TaskStepProgress>(next->getUid());
|
auto task_progress = std::make_shared<TaskStepProgress>(next->getUid());
|
||||||
m_task_progress.insert(next->getUid(), task_progress);
|
m_task_progress.insert(next->getUid(), task_progress);
|
||||||
|
|
||||||
updateState();
|
updateState();
|
||||||
updateStepProgress(*task_progress.get(), Operation::ADDED);
|
updateStepProgress(*task_progress.get(), Operation::ADDED);
|
||||||
|
|
||||||
|
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
|
|
||||||
QMetaObject::invokeMethod(next.get(), &Task::start, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(next.get(), &Task::start, Qt::QueuedConnection);
|
||||||
|
|
||||||
// Allow going up the number of concurrent tasks in case of tasks being added in the middle of a running task.
|
// Allow going up the number of concurrent tasks in case of tasks being added in the middle of a running task.
|
||||||
int num_starts = qMin(m_queue.size(), m_total_max_size - m_doing.size());
|
|
||||||
for (int i = 0; i < num_starts; i++)
|
for (int i = 0; i < num_starts; i++)
|
||||||
QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, &ConcurrentTask::startNext, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the menu for the folders help, and accounts tool buttons
|
// set the menu for the folders help, accounts, and export tool buttons
|
||||||
{
|
{
|
||||||
auto foldersMenuButton = dynamic_cast<QToolButton*>(ui->mainToolBar->widgetForAction(ui->actionFoldersButton));
|
auto foldersMenuButton = dynamic_cast<QToolButton*>(ui->mainToolBar->widgetForAction(ui->actionFoldersButton));
|
||||||
ui->actionFoldersButton->setMenu(ui->foldersMenu);
|
ui->actionFoldersButton->setMenu(ui->foldersMenu);
|
||||||
@ -201,6 +201,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
|
|
||||||
auto accountMenuButton = dynamic_cast<QToolButton*>(ui->mainToolBar->widgetForAction(ui->actionAccountsButton));
|
auto accountMenuButton = dynamic_cast<QToolButton*>(ui->mainToolBar->widgetForAction(ui->actionAccountsButton));
|
||||||
accountMenuButton->setPopupMode(QToolButton::InstantPopup);
|
accountMenuButton->setPopupMode(QToolButton::InstantPopup);
|
||||||
|
|
||||||
|
auto exportInstanceMenu = new QMenu(this);
|
||||||
|
exportInstanceMenu->addAction(ui->actionExportInstanceZip);
|
||||||
|
exportInstanceMenu->addAction(ui->actionExportInstanceMrPack);
|
||||||
|
ui->actionExportInstance->setMenu(exportInstanceMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
// hide, disable and show stuff
|
// hide, disable and show stuff
|
||||||
@ -397,8 +402,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
// removing this looks stupid
|
// removing this looks stupid
|
||||||
view->setFocus();
|
view->setFocus();
|
||||||
|
|
||||||
ui->actionExportInstance->setMenu(ui->exportInstanceMenu);
|
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,7 +473,23 @@ void MainWindow::lockToolbars(bool state)
|
|||||||
|
|
||||||
void MainWindow::konamiTriggered()
|
void MainWindow::konamiTriggered()
|
||||||
{
|
{
|
||||||
qDebug() << "Super Secret Mode ACTIVATED!";
|
QString gradient = " stop:0 rgba(125, 0, 0, 255), stop:0.166 rgba(125, 125, 0, 255), stop:0.333 rgba(0, 125, 0, 255), stop:0.5 rgba(0, 125, 125, 255), stop:0.666 rgba(0, 0, 125, 255), stop:0.833 rgba(125, 0, 125, 255), stop:1 rgba(125, 0, 0, 255));";
|
||||||
|
QString stylesheet = "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0," + gradient;
|
||||||
|
if (ui->mainToolBar->styleSheet() == stylesheet) {
|
||||||
|
ui->mainToolBar->setStyleSheet("");
|
||||||
|
ui->instanceToolBar->setStyleSheet("");
|
||||||
|
ui->centralWidget->setStyleSheet("");
|
||||||
|
ui->newsToolBar->setStyleSheet("");
|
||||||
|
ui->statusBar->setStyleSheet("");
|
||||||
|
qDebug() << "Super Secret Mode DEACTIVATED!";
|
||||||
|
} else {
|
||||||
|
ui->mainToolBar->setStyleSheet(stylesheet);
|
||||||
|
ui->instanceToolBar->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1," + gradient);
|
||||||
|
ui->centralWidget->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:1," + gradient);
|
||||||
|
ui->newsToolBar->setStyleSheet(stylesheet);
|
||||||
|
ui->statusBar->setStyleSheet(stylesheet);
|
||||||
|
qDebug() << "Super Secret Mode ACTIVATED!";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
||||||
|
@ -150,10 +150,6 @@
|
|||||||
<addaction name="actionChangeInstGroup"/>
|
<addaction name="actionChangeInstGroup"/>
|
||||||
<addaction name="actionViewSelectedInstFolder"/>
|
<addaction name="actionViewSelectedInstFolder"/>
|
||||||
<addaction name="actionExportInstance"/>
|
<addaction name="actionExportInstance"/>
|
||||||
<widget class="QMenu" name="exportInstanceMenu">
|
|
||||||
<addaction name="actionExportInstanceZip"/>
|
|
||||||
<addaction name="actionExportInstanceMrPack"/>
|
|
||||||
</widget>
|
|
||||||
<addaction name="actionCopyInstance"/>
|
<addaction name="actionCopyInstance"/>
|
||||||
<addaction name="actionDeleteInstance"/>
|
<addaction name="actionDeleteInstance"/>
|
||||||
<addaction name="actionCreateInstanceShortcut"/>
|
<addaction name="actionCreateInstanceShortcut"/>
|
||||||
@ -467,11 +463,17 @@
|
|||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionExportInstanceZip">
|
<action name="actionExportInstanceZip">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="launcher"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Prism Launcher (zip)</string>
|
<string>Prism Launcher (zip)</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionExportInstanceMrPack">
|
<action name="actionExportInstanceMrPack">
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="modrinth"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Modrinth (mrpack)</string>
|
<string>Modrinth (mrpack)</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -60,6 +60,10 @@ 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);
|
||||||
@ -70,11 +74,6 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
|
|||||||
updateThresholds();
|
updateThresholds();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InstanceSettingsPage::shouldDisplay() const
|
|
||||||
{
|
|
||||||
return !m_instance->isRunning();
|
|
||||||
}
|
|
||||||
|
|
||||||
InstanceSettingsPage::~InstanceSettingsPage()
|
InstanceSettingsPage::~InstanceSettingsPage()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
@ -524,3 +523,8 @@ void InstanceSettingsPage::updateThresholds()
|
|||||||
ui->labelMaxMemIcon->setPixmap(pix);
|
ui->labelMaxMemIcon->setPixmap(pix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstanceSettingsPage::updateRunningStatus(bool running)
|
||||||
|
{
|
||||||
|
setEnabled(!running);
|
||||||
|
}
|
||||||
|
@ -75,12 +75,12 @@ public:
|
|||||||
{
|
{
|
||||||
return "Instance-settings";
|
return "Instance-settings";
|
||||||
}
|
}
|
||||||
virtual bool shouldDisplay() const override;
|
|
||||||
void retranslate() override;
|
void retranslate() override;
|
||||||
|
|
||||||
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();
|
||||||
|
@ -240,10 +240,13 @@ void ResourcePage::updateSelectionButton()
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_ui->resourceSelectionButton->setEnabled(true);
|
m_ui->resourceSelectionButton->setEnabled(true);
|
||||||
if (!getCurrentPack()->isVersionSelected(m_selected_version_index)) {
|
if (getCurrentPack()) {
|
||||||
m_ui->resourceSelectionButton->setText(tr("Select %1 for download").arg(resourceString()));
|
if (!getCurrentPack()->isVersionSelected(m_selected_version_index))
|
||||||
|
m_ui->resourceSelectionButton->setText(tr("Select %1 for download").arg(resourceString()));
|
||||||
|
else
|
||||||
|
m_ui->resourceSelectionButton->setText(tr("Deselect %1 for download").arg(resourceString()));
|
||||||
} else {
|
} else {
|
||||||
m_ui->resourceSelectionButton->setText(tr("Deselect %1 for download").arg(resourceString()));
|
qWarning() << "Tried to update the selected button but there is not a pack selected";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,24 +1,16 @@
|
|||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
|
||||||
|
#include <settings/INIFile.h>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <settings/INIFile.h>
|
|
||||||
|
|
||||||
#include <QVariantUtils.h>
|
#include <QVariantUtils.h>
|
||||||
|
|
||||||
class IniFileTest : public QObject
|
class IniFileTest : public QObject {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private
|
private slots:
|
||||||
slots:
|
void initTestCase() {}
|
||||||
void initTestCase()
|
void cleanupTestCase() {}
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void cleanupTestCase()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void test_Escape_data()
|
void test_Escape_data()
|
||||||
{
|
{
|
||||||
@ -47,17 +39,17 @@ slots:
|
|||||||
// load
|
// load
|
||||||
INIFile f2;
|
INIFile f2;
|
||||||
f2.loadFile(filename);
|
f2.loadFile(filename);
|
||||||
QCOMPARE(f2.get("a","NOT SET").toString(), a);
|
QCOMPARE(f2.get("a", "NOT SET").toString(), a);
|
||||||
QCOMPARE(f2.get("b","NOT SET").toString(), b);
|
QCOMPARE(f2.get("b", "NOT SET").toString(), b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_SaveLoadLists()
|
void test_SaveLoadLists()
|
||||||
{
|
{
|
||||||
QString slist_strings = "(\"a\",\"b\",\"c\")";
|
QString slist_strings = "(\"a\",\"b\",\"c\")";
|
||||||
QStringList list_strings = {"a", "b", "c"};
|
QStringList list_strings = { "a", "b", "c" };
|
||||||
|
|
||||||
QString slist_numbers = "(1,2,3,10)";
|
QString slist_numbers = "(1,2,3,10)";
|
||||||
QList<int> list_numbers = {1, 2, 3, 10};
|
QList<int> list_numbers = { 1, 2, 3, 10 };
|
||||||
|
|
||||||
QString filename = "test_SaveLoadLists.ini";
|
QString filename = "test_SaveLoadLists.ini";
|
||||||
|
|
||||||
@ -72,13 +64,41 @@ slots:
|
|||||||
|
|
||||||
QStringList out_list_strings = f2.get("list_strings", QStringList()).toStringList();
|
QStringList out_list_strings = f2.get("list_strings", QStringList()).toStringList();
|
||||||
qDebug() << "OutStringList" << out_list_strings;
|
qDebug() << "OutStringList" << out_list_strings;
|
||||||
|
|
||||||
QList<int> out_list_numbers = QVariantUtils::toList<int>(f2.get("list_numbers", QVariantUtils::fromList(QList<int>())));
|
QList<int> out_list_numbers = QVariantUtils::toList<int>(f2.get("list_numbers", QVariantUtils::fromList(QList<int>())));
|
||||||
qDebug() << "OutNumbersList" << out_list_numbers;
|
qDebug() << "OutNumbersList" << out_list_numbers;
|
||||||
|
|
||||||
QCOMPARE(out_list_strings, list_strings);
|
QCOMPARE(out_list_strings, list_strings);
|
||||||
QCOMPARE(out_list_numbers, list_numbers);
|
QCOMPARE(out_list_numbers, list_numbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void test_SaveAleardyExistingFile()
|
||||||
|
{
|
||||||
|
QString fileName = "test_SaveAleardyExistingFile.ini";
|
||||||
|
QString fileContent = R"(InstanceType=OneSix
|
||||||
|
iconKey=vanillia_icon
|
||||||
|
name=Minecraft Vanillia
|
||||||
|
OverrideCommands=true
|
||||||
|
PreLaunchCommand="$INST_JAVA" -jar packwiz-installer-bootstrap.jar link
|
||||||
|
)";
|
||||||
|
QFile file(fileName);
|
||||||
|
|
||||||
|
if (file.open(QFile::WriteOnly | QFile::Text)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
stream << fileContent;
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// load
|
||||||
|
INIFile f1;
|
||||||
|
f1.loadFile(fileName);
|
||||||
|
QCOMPARE(f1.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link");
|
||||||
|
f1.saveFile(fileName);
|
||||||
|
INIFile f2;
|
||||||
|
f2.loadFile(fileName);
|
||||||
|
QCOMPARE(f2.get("PreLaunchCommand", "NOT SET").toString(), "\"$INST_JAVA\" -jar packwiz-installer-bootstrap.jar link");
|
||||||
|
QCOMPARE(f2.get("ConfigVersion", "NOT SET").toString(), "1.1");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(IniFileTest)
|
QTEST_GUILESS_MAIN(IniFileTest)
|
||||||
|
Loading…
Reference in New Issue
Block a user