Loading...
Searching...
No Matches
MainWindow Class Reference

`#include <mainwindow.h>`

Inheritance diagram for MainWindow:

## Public Slots

void | setMolecule (Avogadro::QtGui::Molecule *molecule)
void | autosaveDocument ()
void | markMoleculeDirty ()
void | markMoleculeClean ()
void | updateWindowTitle ()
bool | openFile (const QString &fileName, Io::FileFormat *reader=nullptr)
void | setDefaultFileDialogPath (const QString &path)
void | exportGraphics (QString fileName)
bool | exportFile (const QString &fileName, bool async=true)
std::string | exportString (const std::string &format)

## Signals

void | moleculeChanged (QtGui::Molecule *molecue)

## Public Member Functions

| MainWindow (const QStringList &fileNames, bool disableSettings=false)
QtGui::Molecule * | molecule ()
void | writeSettings ()
void | readSettings ()
void | checkAutosaveRecovery ()
void | loadPackages ()
void | startAutosaveTimer ()
QString | autosaveFilePath () const
void | cleanupAutosaves (QString filename)
void | cleanupCurrentAutosave ()
void | setTranslationList (const QStringList &list, const QStringList &codes)
bool | handleCommand (const QString &command, const QVariantMap &options)

## Protected Slots

void | setLocale (const QString &locale)
void | moleculeReady (int number)
void | newMolecule ()
void | openFile ()
void | importFile ()
void | openRecentFile ()
void | updateRecentFiles ()
bool | saveFile (bool async=true)
bool | saveFileAs (bool async=true)
bool | exportFile (bool async=true)
bool | saveFileAs (const QString &fileName, Io::FileFormat *writer, bool async=true)
void | setActiveTool (QString toolName)
void | setActiveDisplayTypes (QStringList displayTypes)
void | setDisabledDisplayTypes (QStringList displayTypes)
void | undoEdit ()
void | redoEdit ()
void | activeMoleculeEdited ()
void | refreshDisplayTypes ()

## Protected Member Functions

void | closeEvent (QCloseEvent *event) override
void | dragEnterEvent (QDragEnterEvent *event) override
void | dropEvent (QDropEvent *event) override
void | changeEvent (QEvent *event) override

## Detailed Description

Author
  Marcus D. Hanwell

The MainWindow class for the Avogadro application. Takes care of initializing the application and overall layout.

## Member Function Documentation

## markMoleculeDirty

void markMoleculeDirty | ( |  | ) |

slot

Update internal state to reflect that the molecule has been modified.

## markMoleculeClean

void markMoleculeClean | ( |  | ) |

slot

Update internal state to reflect that the molecule is not modified.

## updateWindowTitle

void updateWindowTitle | ( |  | ) |

slot

Update the main window title.

## openFile [1/2]

bool openFile | ( | const QString & | fileName,
|  | Io::FileFormat * | reader = nullptr )

slot

Use the FileFormat reader to load fileName. This method takes ownership of reader and will delete it before returning.

## setDefaultFileDialogPath

void setDefaultFileDialogPath | ( | const QString & | path | ) |

slot

Set the default directory for open/save dialogs. Called when opening files from the command line to respect the current working directory.

## exportFile [1/2]

bool exportFile | ( | const QString & | fileName,
|  | bool | async = true )

slot

Export a file, using the full selection of formats capable of writing. The format will be guessed based on the filename extension. If async is true (default), the file is saved asynchronously.

Returns
  If async is true, this function returns true if a suitable writer was found (not if the write was successful). If async is false, the return value indicates whether or not the file was written successfully.

## exportString

std::string exportString | ( | const std::string & | format | ) |

slot

Export a file, using the full selection of formats capable of writing. Will use format to determine the file format to use.

Returns
  String-representation of the exported file, or an empty string if the export failed.

## writeSettings()

void writeSettings | ( |  | ) |

Write out all application settings, normally done as part of the application close event.

## readSettings()

void readSettings | ( |  | ) |

Read in all settings, and initialize our application based on the stored settings.

## checkAutosaveRecovery()

void checkAutosaveRecovery | ( |  | ) |

Attempt to recover autosave files from a crash

## loadPackages()

void loadPackages | ( |  | ) |

Scan standard directories for pyproject.toml-based plugin packages.

## setTranslationList()

void setTranslationList | ( | const QStringList & | list,
|  | const QStringList & | codes )

Set the list of possible translations

## handleCommand()

bool handleCommand | ( | const QString & | command,
|  | const QVariantMap & | options )

Handle script commands

Parameters

  command | The command to execute
  options | The options to the command

Returns
  True if the command was handled, false otherwise

## moleculeChanged

void moleculeChanged | ( | QtGui::Molecule * | molecue | ) |

signal

Emitted when the active molecule in the application has changed.

## setLocale

void setLocale | ( | const QString & | locale | ) |

protected slot

Set the preferred locale

## moleculeReady

void moleculeReady | ( | int | number | ) |

protected slot

Slot provided for extensions to indicate a molecule is ready to be read in. This slot will then pass a molecule to the extension for the data to be read in to.

## newMolecule

void newMolecule | ( |  | ) |

protected slot

Create a new molecule and make it the active molecule.

## openFile [2/2]

void openFile | ( |  | ) |

protected slot

Prompt for a file location, and attempt to open the specified file using our native readers.

## importFile

void importFile | ( |  | ) |

protected slot

Import a file, using the full selection of formats capable of reading.

## openRecentFile

void openRecentFile | ( |  | ) |

protected slot

Open file in the recent files list.

## updateRecentFiles

void updateRecentFiles | ( |  | ) |

protected slot

Update the list of recent files.

## saveFile

bool saveFile | ( | bool | async = true | ) |

protected slot

Save the current molecule to its current fileName. If it is not a standard format, offer to export and warn about possible data loss. If async is true (default), the file is saved asynchronously.

Returns
  If async is true, this function returns true if a suitable writer was found (not if the write was successful). If async is false, the return value indicates whether or not the file was written successfully.

## saveFileAs [1/2]

bool saveFileAs | ( | bool | async = true | ) |

protected slot

Prompt for a file location, and attempt to save the active molecule to the specified location. If async is true (default), the file is saved asynchronously.

Returns
  If async is true, this function returns true if a suitable writer was found (not if the write was successful). If async is false, the return value indicates whether or not the file was written successfully.

## exportFile [2/2]

bool exportFile | ( | bool | async = true | ) |

protected slot

Export a file, using the full selection of formats capable of writing. If async is true (default), the file is saved asynchronously.

Returns
  If async is true, this function returns true if a suitable writer was found (not if the write was successful). If async is false, the return value indicates whether or not the file was written successfully.

## saveFileAs [2/2]

bool saveFileAs | ( | const QString & | fileName,
|  | Io::FileFormat * | writer,
|  | bool | async = true )

protected slot

If specified, use the FileFormat writer to save the file. This method takes ownership of writer and will delete it before returning. If async is true (default), the file is saved asynchronously.

Returns
  If async is true, this function returns true if the write begins successfully (not if the writer completes). If async is false, the return value indicates whether or not the file was written successfully.

## setActiveTool

void setActiveTool | ( | QString | toolName | ) |

protected slot

Set the active tool for the currently active widget by name.

Parameters

  toolName | Name of the tool to select.

## setActiveDisplayTypes

void setActiveDisplayTypes | ( | QStringList | displayTypes | ) |

protected slot

Set the active display types, and cause the scene to be updated.

Parameters

  displayTypes | A list of