Merge branch 'PrismLauncher:develop' into add-startmenu-shortcut
This commit is contained in:
commit
14a78d55b0
723 changed files with 20113 additions and 10156 deletions
|
@ -123,6 +123,7 @@
|
|||
#include "KonamiCode.h"
|
||||
|
||||
#include "InstanceCopyTask.h"
|
||||
#include "InstanceDirUpdate.h"
|
||||
|
||||
#include "Json.h"
|
||||
|
||||
|
@ -154,7 +155,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
// Qt doesn't like vertical moving toolbars, so we have to force them...
|
||||
// See https://github.com/PolyMC/PolyMC/issues/493
|
||||
connect(ui->instanceToolBar, &QToolBar::orientationChanged,
|
||||
[=](Qt::Orientation) { ui->instanceToolBar->setOrientation(Qt::Vertical); });
|
||||
[this](Qt::Orientation) { ui->instanceToolBar->setOrientation(Qt::Vertical); });
|
||||
|
||||
// if you try to add a widget to a toolbar in a .ui file
|
||||
// qt designer will delete it when you save the file >:(
|
||||
|
@ -175,10 +176,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
|
||||
// restore the instance toolbar settings
|
||||
auto const setting_name = QString("WideBarVisibility_%1").arg(ui->instanceToolBar->objectName());
|
||||
if (!APPLICATION->settings()->contains(setting_name))
|
||||
instanceToolbarSetting = APPLICATION->settings()->registerSetting(setting_name);
|
||||
else
|
||||
instanceToolbarSetting = APPLICATION->settings()->getSetting(setting_name);
|
||||
instanceToolbarSetting = APPLICATION->settings()->getOrRegisterSetting(setting_name);
|
||||
|
||||
ui->instanceToolBar->setVisibilityState(instanceToolbarSetting->get().toByteArray());
|
||||
|
||||
|
@ -308,10 +306,27 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||
|
||||
view->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
// FIXME: leaks ListViewDelegate
|
||||
view->setItemDelegate(new ListViewDelegate(this));
|
||||
auto delegate = new ListViewDelegate(this);
|
||||
view->setItemDelegate(delegate);
|
||||
view->setFrameShape(QFrame::NoFrame);
|
||||
// do not show ugly blue border on the mac
|
||||
view->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
connect(delegate, &ListViewDelegate::textChanged, this, [this](QString before, QString after) {
|
||||
if (auto newRoot = askToUpdateInstanceDirName(m_selectedInstance, before, after, this); !newRoot.isEmpty()) {
|
||||
auto oldID = m_selectedInstance->id();
|
||||
auto newID = QFileInfo(newRoot).fileName();
|
||||
QString origGroup(APPLICATION->instances()->getInstanceGroup(oldID));
|
||||
bool syncGroup = origGroup != GroupId() && oldID != newID;
|
||||
if (syncGroup)
|
||||
APPLICATION->instances()->setInstanceGroup(oldID, GroupId());
|
||||
|
||||
refreshInstances();
|
||||
setSelectedInstanceById(newID);
|
||||
|
||||
if (syncGroup)
|
||||
APPLICATION->instances()->setInstanceGroup(newID, origGroup);
|
||||
}
|
||||
});
|
||||
|
||||
view->installEventFilter(this);
|
||||
view->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
@ -726,7 +741,7 @@ void MainWindow::changeActiveAccount()
|
|||
QAction* sAction = (QAction*)sender();
|
||||
|
||||
// Profile's associated Mojang username
|
||||
if (sAction->data().type() != QVariant::Type::Int)
|
||||
if (sAction->data().typeId() != QMetaType::Int)
|
||||
return;
|
||||
|
||||
QVariant action_data = sAction->data();
|
||||
|
@ -816,11 +831,7 @@ void MainWindow::updateNewsLabel()
|
|||
|
||||
QList<int> stringToIntList(const QString& string)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QStringList split = string.split(',', Qt::SkipEmptyParts);
|
||||
#else
|
||||
QStringList split = string.split(',', QString::SkipEmptyParts);
|
||||
#endif
|
||||
QList<int> out;
|
||||
for (int i = 0; i < split.size(); ++i) {
|
||||
out.append(split.at(i).toInt());
|
||||
|
@ -1047,6 +1058,14 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (APPLICATION->instances()->count() <= 0) {
|
||||
CustomMessageBox::selectable(this, tr("No instance!"),
|
||||
tr("No instance available to add the resource to.\nPlease create a new instance before "
|
||||
"attempting to install this resource again."),
|
||||
QMessageBox::Critical)
|
||||
->show();
|
||||
continue;
|
||||
}
|
||||
ImportResourceDialog dlg(localFileName, type, this);
|
||||
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
|
@ -1059,19 +1078,19 @@ void MainWindow::processURLs(QList<QUrl> urls)
|
|||
|
||||
switch (type) {
|
||||
case PackedResourceType::ResourcePack:
|
||||
minecraftInst->resourcePackList()->installResource(localFileName);
|
||||
minecraftInst->resourcePackList()->installResourceWithFlameMetadata(localFileName, version);
|
||||
break;
|
||||
case PackedResourceType::TexturePack:
|
||||
minecraftInst->texturePackList()->installResource(localFileName);
|
||||
minecraftInst->texturePackList()->installResourceWithFlameMetadata(localFileName, version);
|
||||
break;
|
||||
case PackedResourceType::DataPack:
|
||||
qWarning() << "Importing of Data Packs not supported at this time. Ignoring" << localFileName;
|
||||
break;
|
||||
case PackedResourceType::Mod:
|
||||
minecraftInst->loaderModList()->installMod(localFileName, version);
|
||||
minecraftInst->loaderModList()->installResourceWithFlameMetadata(localFileName, version);
|
||||
break;
|
||||
case PackedResourceType::ShaderPack:
|
||||
minecraftInst->shaderPackList()->installResource(localFileName);
|
||||
minecraftInst->shaderPackList()->installResourceWithFlameMetadata(localFileName, version);
|
||||
break;
|
||||
case PackedResourceType::WorldSave:
|
||||
minecraftInst->worldList()->installWorld(localFileInfo);
|
||||
|
@ -1312,7 +1331,15 @@ void MainWindow::on_actionReportBug_triggered()
|
|||
|
||||
void MainWindow::on_actionClearMetadata_triggered()
|
||||
{
|
||||
APPLICATION->metacache()->evictAll();
|
||||
// This if contains side effects!
|
||||
if (!APPLICATION->metacache()->evictAll()) {
|
||||
CustomMessageBox::selectable(this, tr("Error"),
|
||||
tr("Metadata cache clear Failed!\nTo clear the metadata cache manually, press Folders -> View "
|
||||
"Launcher Root Folder, and after closing the launcher delete the folder named \"meta\"\n"),
|
||||
QMessageBox::Warning)
|
||||
->show();
|
||||
}
|
||||
|
||||
APPLICATION->metacache()->SaveNow();
|
||||
}
|
||||
|
||||
|
@ -1389,20 +1416,8 @@ void MainWindow::on_actionDeleteInstance_triggered()
|
|||
if (response != QMessageBox::Yes)
|
||||
return;
|
||||
|
||||
auto linkedInstances = APPLICATION->instances()->getLinkedInstancesById(id);
|
||||
if (!linkedInstances.empty()) {
|
||||
response = CustomMessageBox::selectable(this, tr("There are linked instances"),
|
||||
tr("The following instance(s) might reference files in this instance:\n\n"
|
||||
"%1\n\n"
|
||||
"Deleting it could break the other instance(s), \n\n"
|
||||
"Do you wish to proceed?",
|
||||
nullptr, linkedInstances.count())
|
||||
.arg(linkedInstances.join("\n")),
|
||||
QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No)
|
||||
->exec();
|
||||
if (response != QMessageBox::Yes)
|
||||
return;
|
||||
}
|
||||
if (!checkLinkedInstances(id, this, tr("Deleting")))
|
||||
return;
|
||||
|
||||
if (APPLICATION->instances()->trashInstance(id)) {
|
||||
ui->actionUndoTrashInstance->setEnabled(APPLICATION->instances()->trashedSomething());
|
||||
|
@ -1585,9 +1600,7 @@ void MainWindow::createInstanceShortcut(QString shortcutFilePath)
|
|||
|
||||
if (DesktopServices::isFlatpak()) {
|
||||
appPath = "flatpak";
|
||||
QString flatpakAppId = BuildConfig.LAUNCHER_DESKTOPFILENAME;
|
||||
flatpakAppId.remove(".desktop");
|
||||
args.append({ "run", flatpakAppId });
|
||||
args.append({ "run", BuildConfig.LAUNCHER_APPID });
|
||||
}
|
||||
|
||||
#elif defined(Q_OS_WIN)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue