Skip to content

Commit

Permalink
Initial checkbox dismiss implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Dec 3, 2024
1 parent cb7e0dc commit 3260704
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
29 changes: 22 additions & 7 deletions napari_plugin_manager/base_qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

CONDA = 'Conda'
PYPI = 'PyPI'
DISMISS_WARN_PYPI_INSTALL_DLG = False


class PackageMetadataProtocol(Protocol):
Expand Down Expand Up @@ -621,6 +622,7 @@ def _cancel_requested(self):
)

def _action_requested(self):
global DISMISS_WARN_PYPI_INSTALL_DLG
version = self.version_choice_dropdown.currentText()
tool = self.get_installer_tool()
action = (
Expand All @@ -632,20 +634,33 @@ def _action_requested(self):
tool == InstallerTools.PIP
and action == InstallerActions.INSTALL
and self._warn_pypi_install()
and not DISMISS_WARN_PYPI_INSTALL_DLG
):
button_clicked = QMessageBox.warning(
self,
self._trans('PyPI installation on bundle'),
warn_msgbox = QMessageBox(self)
warn_msgbox.setWindowTitle(
self._trans('PyPI installation on bundle')
)
warn_msgbox.setText(
self._trans(
'Installing from PyPI does not take into account existing installed packages, '
'so it can break existing installations. '
'If this happens the only solution is to reinstall the bundle.\n\n'
'Are you sure you want to install from PyPI?'
),
buttons=QMessageBox.StandardButton.Ok
| QMessageBox.StandardButton.Cancel,
defaultButton=QMessageBox.StandardButton.Cancel,
)
)
warn_checkbox = QCheckBox(
self._trans(
"Don't show this message again in the current session"
)
)
warn_msgbox.setCheckBox(warn_checkbox)
warn_msgbox.setIcon(QMessageBox.Icon.Warning)
warn_msgbox.setStandardButtons(
QMessageBox.StandardButton.Ok
| QMessageBox.StandardButton.Cancel
)
button_clicked = warn_msgbox.exec_()
DISMISS_WARN_PYPI_INSTALL_DLG = warn_checkbox.isChecked()
if button_clicked != QMessageBox.StandardButton.Ok:
return
self.actionRequested.emit(self.item, self.name, action, version, tool)
Expand Down
4 changes: 3 additions & 1 deletion napari_plugin_manager/qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ def _on_enabled_checkbox(self, state: int):
return

def _warn_pypi_install(self):
return running_as_constructor_app() or is_conda_package('napari')
return running_as_constructor_app() or is_conda_package(
'napari'
) # or True


class QPluginList(BaseQPluginList):
Expand Down

0 comments on commit 3260704

Please sign in to comment.