mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2025-04-03 07:20:26 +00:00
Merge pull request #4828 from arthomnix/feature-prefill-suggested-name
GH-4812 Prefill instance name to allow making adjustments
This commit is contained in:
commit
cf49f171b3
@ -103,6 +103,8 @@ NewInstanceDialog::NewInstanceDialog(const QString & initialGroup, const QString
|
|||||||
importPage->setUrl(url);
|
importPage->setUrl(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect(APPLICATION, &QApplication::focusChanged, this, &NewInstanceDialog::onFocusChanged);
|
||||||
|
|
||||||
updateDialogState();
|
updateDialogState();
|
||||||
|
|
||||||
restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toByteArray()));
|
restoreGeometry(QByteArray::fromBase64(APPLICATION->settings()->get("NewInstanceGeometry").toByteArray()));
|
||||||
@ -150,8 +152,15 @@ NewInstanceDialog::~NewInstanceDialog()
|
|||||||
void NewInstanceDialog::setSuggestedPack(const QString& name, InstanceTask* task)
|
void NewInstanceDialog::setSuggestedPack(const QString& name, InstanceTask* task)
|
||||||
{
|
{
|
||||||
creationTask.reset(task);
|
creationTask.reset(task);
|
||||||
|
|
||||||
|
defaultInstName = name;
|
||||||
ui->instNameTextBox->setPlaceholderText(name);
|
ui->instNameTextBox->setPlaceholderText(name);
|
||||||
|
|
||||||
|
if (!instNameChanged)
|
||||||
|
{
|
||||||
|
ui->instNameTextBox->setText(name);
|
||||||
|
}
|
||||||
|
|
||||||
if(!task)
|
if(!task)
|
||||||
{
|
{
|
||||||
ui->iconButton->setIcon(APPLICATION->icons()->getIcon("default"));
|
ui->iconButton->setIcon(APPLICATION->icons()->getIcon("default"));
|
||||||
@ -238,11 +247,29 @@ void NewInstanceDialog::on_iconButton_clicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewInstanceDialog::on_resetNameButton_clicked()
|
||||||
|
{
|
||||||
|
ui->instNameTextBox->setText(defaultInstName);
|
||||||
|
instNameChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
void NewInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
|
void NewInstanceDialog::on_instNameTextBox_textChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
updateDialogState();
|
updateDialogState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewInstanceDialog::on_instNameTextBox_textEdited(const QString &text)
|
||||||
|
{
|
||||||
|
instNameChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewInstanceDialog::onFocusChanged(QWidget *, QWidget *newWidget)
|
||||||
|
{
|
||||||
|
if (newWidget == ui->instNameTextBox && !instNameChanged) {
|
||||||
|
QTimer::singleShot(0, ui->instNameTextBox, &QLineEdit::selectAll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NewInstanceDialog::importIconNow()
|
void NewInstanceDialog::importIconNow()
|
||||||
{
|
{
|
||||||
if(importIcon) {
|
if(importIcon) {
|
||||||
|
@ -56,10 +56,13 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void accept() override;
|
void accept() override;
|
||||||
void reject() override;
|
void reject() override;
|
||||||
|
void onFocusChanged(QWidget *, QWidget *newWidget);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_iconButton_clicked();
|
void on_iconButton_clicked();
|
||||||
|
void on_resetNameButton_clicked();
|
||||||
void on_instNameTextBox_textChanged(const QString &arg1);
|
void on_instNameTextBox_textChanged(const QString &arg1);
|
||||||
|
void on_instNameTextBox_textEdited(const QString &text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NewInstanceDialog *ui = nullptr;
|
Ui::NewInstanceDialog *ui = nullptr;
|
||||||
@ -75,4 +78,7 @@ private:
|
|||||||
QString importIconName;
|
QString importIconName;
|
||||||
|
|
||||||
void importIconNow();
|
void importIconNow();
|
||||||
|
|
||||||
|
QString defaultInstName;
|
||||||
|
bool instNameChanged = false;
|
||||||
};
|
};
|
||||||
|
@ -26,6 +26,9 @@
|
|||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QLineEdit" name="instNameTextBox"/>
|
||||||
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="QComboBox" name="groupBox">
|
<widget class="QComboBox" name="groupBox">
|
||||||
<property name="editable">
|
<property name="editable">
|
||||||
@ -33,6 +36,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="nameLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Name:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>instNameTextBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="groupLabel">
|
<widget class="QLabel" name="groupLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -43,19 +56,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QLineEdit" name="instNameTextBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QLabel" name="nameLabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>&Name:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>instNameTextBox</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0" rowspan="2">
|
<item row="0" column="0" rowspan="2">
|
||||||
<widget class="QToolButton" name="iconButton">
|
<widget class="QToolButton" name="iconButton">
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
@ -66,6 +66,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QPushButton" name="resetNameButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user