Merge branch 'develop' into rename-groups
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -34,38 +34,37 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Application.h"
|
||||
#include "NewInstanceDialog.h"
|
||||
#include "Application.h"
|
||||
#include "ui/pages/modplatform/import_ftb/ImportFTBPage.h"
|
||||
#include "ui_NewInstanceDialog.h"
|
||||
|
||||
#include <BaseVersion.h>
|
||||
#include <InstanceList.h>
|
||||
#include <icons/IconList.h>
|
||||
#include <tasks/Task.h>
|
||||
#include <InstanceList.h>
|
||||
|
||||
#include "VersionSelectDialog.h"
|
||||
#include "ProgressDialog.h"
|
||||
#include "IconPickerDialog.h"
|
||||
#include "ProgressDialog.h"
|
||||
#include "VersionSelectDialog.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QFileDialog>
|
||||
#include <QLayout>
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
#include <QValidator>
|
||||
#include <QDialogButtonBox>
|
||||
#include <utility>
|
||||
|
||||
#include "ui/widgets/PageContainer.h"
|
||||
#include "ui/pages/modplatform/CustomPage.h"
|
||||
#include "ui/pages/modplatform/atlauncher/AtlPage.h"
|
||||
#include "ui/pages/modplatform/legacy_ftb/Page.h"
|
||||
#include "ui/pages/modplatform/flame/FlamePage.h"
|
||||
#include "ui/pages/modplatform/ImportPage.h"
|
||||
#include "ui/pages/modplatform/atlauncher/AtlPage.h"
|
||||
#include "ui/pages/modplatform/flame/FlamePage.h"
|
||||
#include "ui/pages/modplatform/legacy_ftb/Page.h"
|
||||
#include "ui/pages/modplatform/modrinth/ModrinthPage.h"
|
||||
#include "ui/pages/modplatform/technic/TechnicPage.h"
|
||||
#include "ui/widgets/PageContainer.h"
|
||||
|
||||
|
||||
|
||||
NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString & url, QWidget *parent)
|
||||
NewInstanceDialog::NewInstanceDialog(const QString& initialGroup, const QString& url, QWidget* parent)
|
||||
: QDialog(parent), ui(new Ui::NewInstanceDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -86,7 +85,8 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
|
||||
ui->groupBox->setCurrentIndex(index);
|
||||
ui->groupBox->lineEdit()->setPlaceholderText(tr("No group"));
|
||||
|
||||
// NOTE: m_buttons must be initialized before PageContainer, because it indirectly accesses m_buttons through setSuggestedPack! Do not move this below.
|
||||
// NOTE: m_buttons must be initialized before PageContainer, because it indirectly accesses m_buttons through setSuggestedPack! Do not
|
||||
// move this below.
|
||||
m_buttons = new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
|
||||
m_container = new PageContainer(this, {}, this);
|
||||
@ -113,8 +113,7 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
|
||||
HelpButton->setAutoDefault(false);
|
||||
connect(HelpButton, &QPushButton::clicked, m_container, &PageContainer::help);
|
||||
|
||||
if(!url.isEmpty())
|
||||
{
|
||||
if (!url.isEmpty()) {
|
||||
QUrl actualUrl(url);
|
||||
m_container->selectPage("import");
|
||||
importPage->setUrl(url);
|
||||
@ -146,9 +145,9 @@ void NewInstanceDialog::accept()
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
QList<BasePage *> NewInstanceDialog::getPages()
|
||||
QList<BasePage*> NewInstanceDialog::getPages()
|
||||
{
|
||||
QList<BasePage *> pages;
|
||||
QList<BasePage*> pages;
|
||||
|
||||
importPage = new ImportPage(this);
|
||||
|
||||
@ -158,6 +157,7 @@ QList<BasePage *> NewInstanceDialog::getPages()
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame)
|
||||
pages.append(new FlamePage(this));
|
||||
pages.append(new LegacyFTB::Page(this));
|
||||
pages.append(new FTBImportAPP::ImportFTBPage(this));
|
||||
pages.append(new ModrinthPage(this));
|
||||
pages.append(new TechnicPage(this));
|
||||
|
||||
@ -206,17 +206,17 @@ void NewInstanceDialog::setSuggestedPack(const QString& name, QString version, I
|
||||
m_buttons->button(QDialogButtonBox::Ok)->setEnabled(allowOK);
|
||||
}
|
||||
|
||||
void NewInstanceDialog::setSuggestedIconFromFile(const QString &path, const QString &name)
|
||||
void NewInstanceDialog::setSuggestedIconFromFile(const QString& path, const QString& name)
|
||||
{
|
||||
importIcon = true;
|
||||
importIconPath = path;
|
||||
importIconName = name;
|
||||
|
||||
//Hmm, for some reason they can be to small
|
||||
// Hmm, for some reason they can be to small
|
||||
ui->iconButton->setIcon(QIcon(path));
|
||||
}
|
||||
|
||||
void NewInstanceDialog::setSuggestedIcon(const QString &key)
|
||||
void NewInstanceDialog::setSuggestedIcon(const QString& key)
|
||||
{
|
||||
auto icon = APPLICATION->icons()->getIcon(key);
|
||||
importIcon = false;
|
||||
@ -224,9 +224,9 @@ void NewInstanceDialog::setSuggestedIcon(const QString &key)
|
||||
ui->iconButton->setIcon(icon);
|
||||
}
|
||||
|
||||
InstanceTask * NewInstanceDialog::extractTask()
|
||||
InstanceTask* NewInstanceDialog::extractTask()
|
||||
{
|
||||
InstanceTask * extracted = creationTask.get();
|
||||
InstanceTask* extracted = creationTask.get();
|
||||
creationTask.release();
|
||||
|
||||
InstanceName inst_name(ui->instNameTextBox->placeholderText().trimmed(), importVersion);
|
||||
@ -242,8 +242,7 @@ void NewInstanceDialog::updateDialogState()
|
||||
{
|
||||
auto allowOK = creationTask && !instName().isEmpty();
|
||||
auto OkButton = m_buttons->button(QDialogButtonBox::Ok);
|
||||
if(OkButton->isEnabled() != allowOK)
|
||||
{
|
||||
if (OkButton->isEnabled() != allowOK) {
|
||||
OkButton->setEnabled(allowOK);
|
||||
}
|
||||
}
|
||||
@ -251,13 +250,11 @@ void NewInstanceDialog::updateDialogState()
|
||||
QString NewInstanceDialog::instName() const
|
||||
{
|
||||
auto result = ui->instNameTextBox->text().trimmed();
|
||||
if(result.size())
|
||||
{
|
||||
if (result.size()) {
|
||||
return result;
|
||||
}
|
||||
result = ui->instNameTextBox->placeholderText().trimmed();
|
||||
if(result.size())
|
||||
{
|
||||
if (result.size()) {
|
||||
return result;
|
||||
}
|
||||
return QString();
|
||||
@ -274,28 +271,27 @@ QString NewInstanceDialog::iconKey() const
|
||||
|
||||
void NewInstanceDialog::on_iconButton_clicked()
|
||||
{
|
||||
importIconNow(); //so the user can switch back
|
||||
importIconNow(); // so the user can switch back
|
||||
IconPickerDialog dlg(this);
|
||||
dlg.execWithSelection(InstIconKey);
|
||||
|
||||
if (dlg.result() == QDialog::Accepted)
|
||||
{
|
||||
if (dlg.result() == QDialog::Accepted) {
|
||||
InstIconKey = dlg.selectedIconKey;
|
||||
ui->iconButton->setIcon(APPLICATION->icons()->getIcon(InstIconKey));
|
||||
importIcon = false;
|
||||
}
|
||||
}
|
||||
|
||||
void NewInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
|
||||
void NewInstanceDialog::on_instNameTextBox_textChanged([[maybe_unused]] const QString& arg1)
|
||||
{
|
||||
updateDialogState();
|
||||
}
|
||||
|
||||
void NewInstanceDialog::importIconNow()
|
||||
{
|
||||
if(importIcon) {
|
||||
if (importIcon) {
|
||||
APPLICATION->icons()->installIcon(importIconPath, importIconName);
|
||||
InstIconKey = importIconName;
|
||||
InstIconKey = importIconName.mid(0, importIconName.lastIndexOf('.'));
|
||||
importIcon = false;
|
||||
}
|
||||
APPLICATION->settings()->set("NewInstanceGeometry", saveGeometry().toBase64());
|
||||
|
Reference in New Issue
Block a user