Files
hfut-bishe/client/gui/dialogs/EntityFinalizeDialog.cpp
2026-04-08 14:37:01 +08:00

57 lines
1.6 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "dialogs/EntityFinalizeDialog.h"
#include <QDialogButtonBox>
#include <QFormLayout>
#include <QLineEdit>
#include <QDoubleSpinBox>
#include <QVBoxLayout>
EntityFinalizeDialog::EntityFinalizeDialog(QWidget* parent)
: QDialog(parent) {
setWindowTitle(QStringLiteral("确认实体"));
setModal(true);
auto* root = new QVBoxLayout(this);
auto* form = new QFormLayout();
m_name = new QLineEdit(this);
m_name->setPlaceholderText(QStringLiteral("例如entity-1、人物、树、建筑…"));
form->addRow(QStringLiteral("名称"), m_name);
m_userScale = new QDoubleSpinBox(this);
m_userScale->setDecimals(3);
m_userScale->setRange(0.01, 50.0);
m_userScale->setSingleStep(0.05);
form->addRow(QStringLiteral("整体缩放"), m_userScale);
root->addLayout(form);
auto* btns = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
connect(btns, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(btns, &QDialogButtonBox::rejected, this, &QDialog::reject);
root->addWidget(btns);
}
void EntityFinalizeDialog::setDefaultName(const QString& name) {
if (m_name) {
m_name->setText(name);
m_name->selectAll();
m_name->setFocus();
}
}
QString EntityFinalizeDialog::name() const {
return m_name ? m_name->text().trimmed() : QString();
}
void EntityFinalizeDialog::setUserScale(double s) {
if (m_userScale) {
m_userScale->setValue(s);
}
}
double EntityFinalizeDialog::userScale() const {
return m_userScale ? m_userScale->value() : 1.0;
}