Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix input generators (and other scripts) with translation #1037

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions avogadro/qtgui/jsonwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,19 @@ void JsonWidget::buildOptionGui()

// Title first
if (userOptions.contains("Title"))
addOptionRow(tr("Title"), userOptions.take("Title"));
addOptionRow("Title", tr("Title"), userOptions.take("Title"));

// File basename next:
if (userOptions.contains("Filename Base"))
addOptionRow(tr("Filename Base"), userOptions.take("Filename Base"));
addOptionRow("Filename Base", tr("Filename Base"), userOptions.take("Filename Base"));

// Number of cores next:
if (userOptions.contains("Processor Cores"))
addOptionRow(tr("Processor Cores"), userOptions.take("Processor Cores"));
addOptionRow("Processor Cores", tr("Processor Cores"), userOptions.take("Processor Cores"));

// Calculation Type next:
if (userOptions.contains("Calculation Type"))
addOptionRow(tr("Calculation Type"),
addOptionRow("Calculation Type", tr("Calculation Type"),
userOptions.take("Calculation Type"));

// Theory/basis next. Combine into one row if both present.
Expand All @@ -192,16 +192,16 @@ void JsonWidget::buildOptionGui()

// Other special cases: Charge / Multiplicity
if (userOptions.contains("Charge"))
addOptionRow(tr("Charge"), userOptions.take("Charge"));
addOptionRow("Charge", tr("Charge"), userOptions.take("Charge"));

if (userOptions.contains("Multiplicity"))
addOptionRow(tr("Multiplicity"), userOptions.take("Multiplicity"));
addOptionRow("Multiplicity", tr("Multiplicity"), userOptions.take("Multiplicity"));

// Add remaining keys at bottom.
for (QJsonObject::const_iterator it = userOptions.constBegin(),
itEnd = userOptions.constEnd();
it != itEnd; ++it) {
addOptionRow(it.key(), it.value());
addOptionRow(it.key(), it.key(), it.value());
}

// Make connections for standard options:
Expand Down Expand Up @@ -258,13 +258,13 @@ void JsonWidget::combinedOptionRow(const QString& label1, const QString& label2,
m_currentLayout->addRow(tr1, hbox);
} else {
if (option1)
addOptionRow(tr1, options.take(label1));
addOptionRow(label1, tr1, options.take(label1));
if (option2)
addOptionRow(tr2, options.take(label2));
addOptionRow(label2, tr2, options.take(label2));
}
}

void JsonWidget::addOptionRow(const QString& name, const QJsonValue& option)
void JsonWidget::addOptionRow(const QString& key, const QString& name, const QJsonValue& option)
{
QWidget* widget = createOptionWidget(option);
if (!widget)
Expand All @@ -279,7 +279,7 @@ void JsonWidget::addOptionRow(const QString& name, const QJsonValue& option)
}

// For lookups during unit testing:
widget->setObjectName(name);
widget->setObjectName(key);
QString label(name);

QJsonObject obj = option.toObject();
Expand All @@ -290,7 +290,7 @@ void JsonWidget::addOptionRow(const QString& name, const QJsonValue& option)
}

form->addRow(label + ":", widget);
m_widgets.insert(name, widget);
m_widgets.insert(key, widget);

// optionally hide rows .. can be shown by the script later
bool hide = false;
Expand Down
2 changes: 1 addition & 1 deletion avogadro/qtgui/jsonwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class AVOGADROQTGUI_EXPORT JsonWidget : public QWidget
void combinedOptionRow(const QString& label1, const QString& label2,
const QString& tr1, const QString& tr2,
QJsonObject& options);
void addOptionRow(const QString& label, const QJsonValue& option);
void addOptionRow(const QString& key, const QString& label, const QJsonValue& option);

QWidget* createOptionWidget(const QJsonValue& option);
QWidget* createStringListWidget(const QJsonObject& obj);
Expand Down