From bee185e874a32bf63826e0e6b9ae34b8989e8792 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 28 Sep 2025 22:16:39 +0530 Subject: [PATCH] More granularity in the busy cursors --- src/calibre/ai/config.py | 6 ++---- src/calibre/ai/ollama/config.py | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/calibre/ai/config.py b/src/calibre/ai/config.py index 0c103dd006..e87bb61fbc 100644 --- a/src/calibre/ai/config.py +++ b/src/calibre/ai/config.py @@ -6,7 +6,6 @@ from qt.core import QComboBox, QDialog, QGroupBox, QHBoxLayout, QLabel, QStacked from calibre.ai import AICapabilities from calibre.ai.prefs import plugin_for_purpose, plugins_for_purpose, prefs from calibre.gui2 import Application, error_dialog -from calibre.gui2.widgets import BusyCursor class ConfigureAI(QWidget): @@ -61,9 +60,8 @@ class ConfigureAI(QWidget): return self.plugin_config_widgets[self.current_idx].validate() def commit(self) -> bool: - with BusyCursor(): - if not self.validate(): - return False + if not self.validate(): + return False idx = self.current_idx p, w = self.available_plugins[idx], self.plugin_config_widgets[idx] if not w.validate(): diff --git a/src/calibre/ai/ollama/config.py b/src/calibre/ai/ollama/config.py index e12bb26108..28d6bfc631 100644 --- a/src/calibre/ai/ollama/config.py +++ b/src/calibre/ai/ollama/config.py @@ -9,6 +9,7 @@ from calibre.ai.ollama import OllamaAI from calibre.ai.prefs import pref_for_provider, set_prefs_for_provider from calibre.ai.utils import configure, plugin_for_name from calibre.gui2 import error_dialog +from calibre.gui2.widgets import BusyCursor pref = partial(pref_for_provider, OllamaAI.name) @@ -86,14 +87,18 @@ class ConfigWidget(QWidget): if not self.text_model: error_dialog(self, _('No model specified'), _('You specify a model to use for text based tasks.'), show=True) return False - if not self.does_model_exist_locally(self.text_model): - try: - avail = self.available_models() - except Exception: - import traceback - det_msg = _('Failed to get list of available models with error:') + '\n' + traceback.format_exc() - else: - det_msg = _('Available models:') + '\n' + '\n'.join(avail) + with BusyCursor(): + exists = self.does_model_exist_locally(self.text_model) + + if not exists: + with BusyCursor(): + try: + avail = self.available_models() + except Exception: + import traceback + det_msg = _('Failed to get list of available models with error:') + '\n' + traceback.format_exc() + else: + det_msg = _('Available models:') + '\n' + '\n'.join(avail) error_dialog(self, _('No matching model'), _( 'No model named {} found in Ollama. Click "Show details" to see a list of available models.').format(