Avogadro::QtGui::JsonWidget#
-
class JsonWidget : public QWidget#
The JsonWidget class provides a user interface for running external scripts.
<avogadro/qtgui/jsonwidget.h>
The
JsonWidget creates a GUI to represent the options given by an script, turning JSON from the script into a form and passing the results back to the script via command-line.See also
It’s used by a range of different scripts, including:
Commands
InterfaceGenerators
Subclassed by InputGeneratorWidget, InterfaceWidget
Unnamed Group
-
virtual void updateOptions()#
Used to construct the script-specific GUI.
-
void buildOptionGui()#
Used to construct the script-specific GUI.
-
void combinedOptionRow(const QString &label1, const QString &label2, const QString &tr1, const QString &tr2, QJsonObject &options, bool bothLabels = false)#
Used to construct the script-specific GUI.
-
void addOptionRow(const QString &key, const QString &label, const QJsonValue &option)#
Used to construct the script-specific GUI.
-
QWidget *createOptionWidget(const QJsonValue &option)#
Used to construct the script-specific GUI.
-
QWidget *createStringListWidget(const QJsonObject &obj)#
Used to construct the script-specific GUI.
-
QWidget *createStringWidget(const QJsonObject &obj)#
Used to construct the script-specific GUI.
-
QWidget *createFilePathWidget(const QJsonObject &obj)#
Used to construct the script-specific GUI.
-
QWidget *createIntegerWidget(const QJsonObject &obj)#
Used to construct the script-specific GUI.
-
QWidget *createFloatWidget(const QJsonObject &obj)#
Used to construct the script-specific GUI.
-
QWidget *createBooleanWidget(const QJsonObject &obj)#
Used to construct the script-specific GUI.
-
QWidget *createTextWidget(const QJsonObject &obj)#
Used to construct the script-specific GUI.
-
QWidget *createTableWidget(const QJsonObject &obj)#
Used to construct the script-specific GUI.
Unnamed Group
-
void setOptionDefaults()#
Set the simulation settings to their default values.
-
void restoreOptionValues()#
Overlay the values saved by saveOptionValues() on top of the defaults.
-
bool optionIsSaveable(const QString &name) const#
Whether name is an option whose value may be written to QSettings.
-
void setOption(const QString &name, const QJsonValue &defaultValue)#
Set the simulation settings to their default values.
-
void setStringListOption(const QString &name, const QJsonValue &value)#
Set the simulation settings to their default values.
-
void setStringOption(const QString &name, const QJsonValue &value)#
Set the simulation settings to their default values.
-
void setFilePathOption(const QString &name, const QJsonValue &value)#
Set the simulation settings to their default values.
-
void setIntegerOption(const QString &name, const QJsonValue &value)#
Set the simulation settings to their default values.
-
void setFloatOption(const QString &name, const QJsonValue &value)#
Set the simulation settings to their default values.
-
void setBooleanOption(const QString &name, const QJsonValue &value)#
Set the simulation settings to their default values.
-
void setTextOption(const QString &name, const QJsonValue &value)#
Set the simulation settings to their default values.
-
void setTableOption(const QString &name, const QJsonValue &value)#
Set the simulation settings to their default values.
Public Functions
-
explicit JsonWidget(QWidget *parent_ = nullptr)#
Construct a widget that dynamically generates a GUI
-
~JsonWidget() override#
-
QJsonObject collectOptions() const#
Collect all of the user-specified options into a JSON object, to be sent to the generator script.
-
void applyOptions(const QJsonObject &opts)#
Apply the options in the passed QJsonObject to the GUI. Any widgets changed by this method will have their signals blocked while modifying their values.
-
inline bool isEmpty() const#
-
inline void setSettingsKey(const QString &key)#
Remember the user’s choices between sessions, filed under key.
saveOptionValues() writes the current values, and setOptionDefaults() restores them over the top of each option’s “default”, so a dialog comes back the way it was last left. Password fields are never written, nor are tables, and a script can opt an option out with “save”: false. An empty key, which is the default, switches the whole mechanism off.
-
void saveOptionValues() const#
Write every saveable option’s current value to QSettings. Does nothing unless a settings key has been set.
Public Slots
-
inline virtual void updatePreviewText()#
Update the preview text in the GUI. The base implementation does nothing; subclasses that have a preview area (e.g. InputGeneratorWidget) override this to regenerate their preview when options change.
Protected Functions
-
QString lookupOptionType(const QString &name) const#
Given the name of a user-option in m_options, return the type string. If an error occurs, an empty string will be returned.
-
bool optionString(const QString &option, QString &value) const#
Search for an option named option and convert its value to a string.
- Parameters:
option – The name of the option.
value – String to overwrite with option value.
- Returns:
True if value is overwritten, false if the option is not found or cannot be converted to a string.
-
QString generateJobTitle() const#
Update the autogenerated job title in the GUI.
Protected Attributes
-
bool m_isTabbed#
-
QJsonObject m_options#
-
QJsonObject m_optionCache#
-
QList<QTextEdit*> m_dirtyTextEdits#
-
bool m_empty#
-
bool m_batchMode#
-
QFormLayout *m_currentLayout#
-
QWidget *m_centralWidget#
-
QString m_settingsKey#
-
QMap<QString, QWidget*> m_widgets#
-
QMap<QString, QTextEdit*> m_textEdits#