mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:52:26 +02:00
Code cleanup
This commit is contained in:
parent
f960b4fff3
commit
60f242118e
3 changed files with 35 additions and 33 deletions
|
@ -1120,18 +1120,18 @@ function handeMenuEvent(menuItem){
|
||||||
print(" Edit Properties.... about to edit properties...");
|
print(" Edit Properties.... about to edit properties...");
|
||||||
var array = new Array();
|
var array = new Array();
|
||||||
var decimals = 3;
|
var decimals = 3;
|
||||||
array.push({ label: "Model URL", value: selectedModelProperties.modelURL });
|
array.push({ label: "Model URL:", value: selectedModelProperties.modelURL });
|
||||||
array.push({ label: "Animation URL", value: selectedModelProperties.animationURL });
|
array.push({ label: "Animation URL:", value: selectedModelProperties.animationURL });
|
||||||
array.push({ label: "x", value: selectedModelProperties.position.x.toFixed(decimals) });
|
array.push({ label: "X:", value: selectedModelProperties.position.x.toFixed(decimals) });
|
||||||
array.push({ label: "y", value: selectedModelProperties.position.y.toFixed(decimals) });
|
array.push({ label: "Y:", value: selectedModelProperties.position.y.toFixed(decimals) });
|
||||||
array.push({ label: "z", value: selectedModelProperties.position.z.toFixed(decimals) });
|
array.push({ label: "Z:", value: selectedModelProperties.position.z.toFixed(decimals) });
|
||||||
var angles = Quat.safeEulerAngles(selectedModelProperties.modelRotation);
|
var angles = Quat.safeEulerAngles(selectedModelProperties.modelRotation);
|
||||||
array.push({ label: "pitch", value: angles.x.toFixed(decimals) });
|
array.push({ label: "Pitch:", value: angles.x.toFixed(decimals) });
|
||||||
array.push({ label: "yaw", value: angles.y.toFixed(decimals) });
|
array.push({ label: "Yaw:", value: angles.y.toFixed(decimals) });
|
||||||
array.push({ label: "roll", value: angles.z.toFixed(decimals) });
|
array.push({ label: "Roll:", value: angles.z.toFixed(decimals) });
|
||||||
array.push({ label: "Scale", value: 2 * selectedModelProperties.radius.toFixed(decimals) });
|
array.push({ label: "Scale:", value: 2 * selectedModelProperties.radius.toFixed(decimals) });
|
||||||
|
|
||||||
var propertyName = Window.arrayEdit("Edit Properties", array);
|
var propertyName = Window.form("Edit Properties", array);
|
||||||
modelSelected = false;
|
modelSelected = false;
|
||||||
|
|
||||||
selectedModelProperties.modelURL = array[0].value;
|
selectedModelProperties.modelURL = array[0].value;
|
||||||
|
|
|
@ -42,11 +42,11 @@ QScriptValue WindowScriptingInterface::confirm(const QString& message) {
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue WindowScriptingInterface::arrayEdit(const QString& title, QScriptValue array) {
|
QScriptValue WindowScriptingInterface::form(const QString& title, QScriptValue form) {
|
||||||
QScriptValue retVal;
|
QScriptValue retVal;
|
||||||
QMetaObject::invokeMethod(this, "showArrayEdit", Qt::BlockingQueuedConnection,
|
QMetaObject::invokeMethod(this, "showForm", Qt::BlockingQueuedConnection,
|
||||||
Q_RETURN_ARG(QScriptValue, retVal),
|
Q_RETURN_ARG(QScriptValue, retVal),
|
||||||
Q_ARG(const QString&, title), Q_ARG(QScriptValue, array));
|
Q_ARG(const QString&, title), Q_ARG(QScriptValue, form));
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,12 +82,12 @@ QScriptValue WindowScriptingInterface::showConfirm(const QString& message) {
|
||||||
return QScriptValue(response == QMessageBox::Yes);
|
return QScriptValue(response == QMessageBox::Yes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display a prompt with an edit box
|
/// Display a form layout with an edit box
|
||||||
/// \param const QString& title title to display
|
/// \param const QString& title title to display
|
||||||
/// \param const QString& defaultText default text in the text box
|
/// \param const QScriptValue form to display (array containing labels and values)
|
||||||
/// \return QScriptValue string text value in text box if the dialog was accepted, `null` otherwise.
|
/// \return QScriptValue result form (unchanged is dialog canceled)
|
||||||
QScriptValue WindowScriptingInterface::showArrayEdit(const QString& title, QScriptValue array) {
|
QScriptValue WindowScriptingInterface::showForm(const QString& title, QScriptValue form) {
|
||||||
if (array.isArray() && array.property("length").toInt32() > 0) {
|
if (form.isArray() && form.property("length").toInt32() > 0) {
|
||||||
QDialog* editDialog = new QDialog(Application::getInstance()->getWindow());
|
QDialog* editDialog = new QDialog(Application::getInstance()->getWindow());
|
||||||
editDialog->setWindowTitle(title);
|
editDialog->setWindowTitle(title);
|
||||||
|
|
||||||
|
@ -98,27 +98,29 @@ QScriptValue WindowScriptingInterface::showArrayEdit(const QString& title, QScri
|
||||||
layout->addWidget(area);
|
layout->addWidget(area);
|
||||||
area->setWidgetResizable(true);
|
area->setWidgetResizable(true);
|
||||||
QWidget* container = new QWidget();
|
QWidget* container = new QWidget();
|
||||||
QFormLayout* arrayLayout = new QFormLayout();
|
QFormLayout* formLayout = new QFormLayout();
|
||||||
container->setLayout(arrayLayout);
|
container->setLayout(formLayout);
|
||||||
container->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
|
container->sizePolicy().setHorizontalStretch(1);
|
||||||
|
formLayout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
||||||
|
formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
||||||
|
formLayout->setFormAlignment(Qt::AlignHCenter | Qt::AlignTop);
|
||||||
|
formLayout->setLabelAlignment(Qt::AlignLeft);
|
||||||
|
|
||||||
area->setWidget(container);
|
area->setWidget(container);
|
||||||
|
|
||||||
QVector<QLineEdit*> edits;
|
QVector<QLineEdit*> edits;
|
||||||
for (int i = 0; i < array.property("length").toInt32(); ++i) {
|
for (int i = 0; i < form.property("length").toInt32(); ++i) {
|
||||||
QScriptValue item = array.property(i);
|
QScriptValue item = form.property(i);
|
||||||
edits.push_back(new QLineEdit(item.property("value").toString()));
|
edits.push_back(new QLineEdit(item.property("value").toString()));
|
||||||
arrayLayout->addRow(item.property("label").toString(),
|
formLayout->addRow(item.property("label").toString(), edits.back());
|
||||||
edits.back());
|
|
||||||
}
|
}
|
||||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok);
|
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||||
connect(buttons, SIGNAL(accepted()), editDialog, SLOT(accept()));
|
connect(buttons, SIGNAL(accepted()), editDialog, SLOT(accept()));
|
||||||
layout->addWidget(buttons);
|
layout->addWidget(buttons);
|
||||||
|
|
||||||
editDialog->setMinimumSize(600, 600);
|
|
||||||
|
|
||||||
if (editDialog->exec() == QDialog::Accepted) {
|
if (editDialog->exec() == QDialog::Accepted) {
|
||||||
for (int i = 0; i < array.property("length").toInt32(); ++i) {
|
for (int i = 0; i < form.property("length").toInt32(); ++i) {
|
||||||
QScriptValue item = array.property(i);
|
QScriptValue item = form.property(i);
|
||||||
QScriptValue value = item.property("value");
|
QScriptValue value = item.property("value");
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
if (value.isNumber()) {
|
if (value.isNumber()) {
|
||||||
|
@ -136,7 +138,7 @@ QScriptValue WindowScriptingInterface::showArrayEdit(const QString& title, QScri
|
||||||
}
|
}
|
||||||
if (ok) {
|
if (ok) {
|
||||||
item.setProperty("value", value);
|
item.setProperty("value", value);
|
||||||
array.setProperty(i, item);
|
form.setProperty(i, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +146,7 @@ QScriptValue WindowScriptingInterface::showArrayEdit(const QString& title, QScri
|
||||||
delete editDialog;
|
delete editDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display a prompt with a text box
|
/// Display a prompt with a text box
|
||||||
|
|
|
@ -28,14 +28,14 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
QScriptValue alert(const QString& message = "");
|
QScriptValue alert(const QString& message = "");
|
||||||
QScriptValue confirm(const QString& message = "");
|
QScriptValue confirm(const QString& message = "");
|
||||||
QScriptValue arrayEdit(const QString& title, QScriptValue array);
|
QScriptValue form(const QString& title, QScriptValue array);
|
||||||
QScriptValue prompt(const QString& message = "", const QString& defaultText = "");
|
QScriptValue prompt(const QString& message = "", const QString& defaultText = "");
|
||||||
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
QScriptValue browse(const QString& title = "", const QString& directory = "", const QString& nameFilter = "");
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
QScriptValue showAlert(const QString& message);
|
QScriptValue showAlert(const QString& message);
|
||||||
QScriptValue showConfirm(const QString& message);
|
QScriptValue showConfirm(const QString& message);
|
||||||
QScriptValue showArrayEdit(const QString& title, QScriptValue array);
|
QScriptValue showForm(const QString& title, QScriptValue form);
|
||||||
QScriptValue showPrompt(const QString& message, const QString& defaultText);
|
QScriptValue showPrompt(const QString& message, const QString& defaultText);
|
||||||
QScriptValue showBrowse(const QString& title, const QString& directory, const QString& nameFilter);
|
QScriptValue showBrowse(const QString& title, const QString& directory, const QString& nameFilter);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue