More granularity in the busy cursors

This commit is contained in:
Kovid Goyal 2025-09-28 22:16:39 +05:30
parent d3ad93759e
commit bee185e874
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 15 additions and 12 deletions

View File

@ -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():

View File

@ -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(