diff --git a/avogadro/qtplugins/forcefield/CMakeLists.txt b/avogadro/qtplugins/forcefield/CMakeLists.txt index cbd6fb14a6..484689aede 100644 --- a/avogadro/qtplugins/forcefield/CMakeLists.txt +++ b/avogadro/qtplugins/forcefield/CMakeLists.txt @@ -61,5 +61,6 @@ if (NOT BUILD_GPL_PLUGINS) ) endif() -install(PROGRAMS ${forcefields} -DESTINATION "${INSTALL_LIBRARY_DIR}/avogadro2/scripts/energy/") +# Don't install the scripts - we'll use these as plugins +# install(PROGRAMS ${forcefields} +# DESTINATION "${INSTALL_LIBRARY_DIR}/avogadro2/scripts/energy/") diff --git a/avogadro/qtplugins/forcefield/forcefield.cpp b/avogadro/qtplugins/forcefield/forcefield.cpp index e78095fbe2..70bf78172f 100644 --- a/avogadro/qtplugins/forcefield/forcefield.cpp +++ b/avogadro/qtplugins/forcefield/forcefield.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -65,24 +66,6 @@ Forcefield::Forcefield(QObject* parent_) m_gradientTolerance = settings.value("gradientTolerance", 1.0e-4).toDouble(); settings.endGroup(); - // prefer to use Python interface scripts if available - refreshScripts(); - - // add the openbabel calculators in case they don't exist -#ifdef BUILD_GPL_PLUGINS - // These directly use Open Babel and are fast - qDebug() << " registering GPL plugins"; - Calc::EnergyManager::registerModel(new OBEnergy("MMFF94")); - Calc::EnergyManager::registerModel(new OBEnergy("UFF")); - Calc::EnergyManager::registerModel(new OBEnergy("GAFF")); -#else - // These call obmm and can be slower - qDebug() << " registering obmm plugins"; - Calc::EnergyManager::registerModel(new OBMMEnergy("MMFF94")); - Calc::EnergyManager::registerModel(new OBMMEnergy("UFF")); - Calc::EnergyManager::registerModel(new OBMMEnergy("GAFF")); -#endif - QAction* action = new QAction(this); action->setEnabled(true); action->setText(tr("Optimize Geometry")); @@ -133,6 +116,9 @@ Forcefield::Forcefield(QObject* parent_) action->setData(unfreezeAction); connect(action, SIGNAL(triggered()), SLOT(unfreezeSelected())); m_actions.push_back(action); + + // single-shot timer to allow the GUI to start up + QTimer::singleShot(500, this, SLOT(deferredStart())); } Forcefield::~Forcefield() {} @@ -142,6 +128,28 @@ QList Forcefield::actions() const return m_actions; } +void Forcefield::deferredStart() +{ + + // prefer to use Python interface scripts if available + refreshScripts(); + + // add the openbabel calculators in case they don't exist +#ifdef BUILD_GPL_PLUGINS + // These directly use Open Babel and are fast + qDebug() << " registering GPL plugins"; + Calc::EnergyManager::registerModel(new OBEnergy("MMFF94")); + Calc::EnergyManager::registerModel(new OBEnergy("UFF")); + Calc::EnergyManager::registerModel(new OBEnergy("GAFF")); +#else + // These call obmm and can be slower + qDebug() << " registering obmm plugins"; + Calc::EnergyManager::registerModel(new OBMMEnergy("MMFF94")); + Calc::EnergyManager::registerModel(new OBMMEnergy("UFF")); + Calc::EnergyManager::registerModel(new OBMMEnergy("GAFF")); +#endif +} + QStringList Forcefield::menuPath(QAction* action) const { QStringList path; diff --git a/avogadro/qtplugins/forcefield/forcefield.h b/avogadro/qtplugins/forcefield/forcefield.h index a08e75675c..7b8bcc98f9 100644 --- a/avogadro/qtplugins/forcefield/forcefield.h +++ b/avogadro/qtplugins/forcefield/forcefield.h @@ -76,6 +76,8 @@ private slots: void freezeSelected(); void unfreezeSelected(); + void deferredStart(); + private: QList m_actions; QtGui::Molecule* m_molecule = nullptr;