Source code for schrodinger.ui.qt.forcefield.ffsettingsbutton
from schrodinger.Qt.QtGui import QIcon
from schrodinger.Qt.QtWidgets import QToolButton
from schrodinger.ui.maestro_ui import MaestroHub
from schrodinger.ui.qt.standard.icons import icons
from .ffprojectsettingsdlg import show_ff_project_settings_dlg
from .forcefield import PROJECT_OPLS_DIR_CMD_OPTION
from .forcefield import get_custom_opls_dir
from .forcefield import has_valid_custom_OPLS_preference
maestro_hub = MaestroHub.instance()
[docs]class FFSettingsButton(QToolButton):
"""
Standard button for accessing the Force Field Settings Dialog.
"""
_CUSTOMIZE_TOOLTIP = (
'Change custom parameters location or add parameters via Customize... '
'button')
_CUSTOMIZATION_REQUIRED_TOOLTIP = (
'The specified customizations are either unavailable or '
'incompatible with the OPLS4 force field. New custom '
'parameters are needed to accurately model your structures.'
'<br><br>'
'This job may run without customizations, but we do not '
'recommend it. Click this button to choose a different set of '
'customizations (if available), or to create them using the '
'Force Field Builder, accessible via the Customize button.')
[docs] def __init__(self, parent=None):
super().__init__(parent=parent)
self.clicked.connect(
lambda: show_ff_project_settings_dlg(parent or self))
maestro_hub.projectPreferenceChanged.connect(self._onPreferenceChanged)
self._use_custom_opls = False
self._update()
[docs] def setUseCustomOPLS(self, use_custom: bool):
if self._use_custom_opls != use_custom:
self._use_custom_opls = use_custom
self._update()
def _onPreferenceChanged(self, pref_name):
if PROJECT_OPLS_DIR_CMD_OPTION in pref_name:
self._update()
def _update(self):
btn_tooltip = ''
btn_icon = icons.MORE_OPTIONS_LB
if self.getUseCustomOPLS():
if has_valid_custom_OPLS_preference():
btn_tooltip = self._CUSTOMIZE_TOOLTIP
else:
btn_tooltip = self._CUSTOMIZATION_REQUIRED_TOOLTIP
btn_icon = icons.VALIDATION_WARNING_LB
btn_tooltip += f'<br><br>Using: <i>{get_custom_opls_dir()}</i>'
self.setToolTip(btn_tooltip)
self.setIcon(QIcon(btn_icon))