Skip to content

Commit

Permalink
Merge pull request #1037 from ghutchis/fix-interface-translations
Browse files Browse the repository at this point in the history
Fix input generators (and other scripts) with translation
  • Loading branch information
ghutchis authored Jul 21, 2022
2 parents c789ef3 + a4d631f commit 4c1fb90
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
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

0 comments on commit 4c1fb90

Please sign in to comment.