@@ -352,6 +352,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
352352 // used in toolbars
353353 restoreToolbars ();
354354
355+ QTimer::singleShot (isMaximized () || isFullScreen () ? 600 : 0 , this ,
356+ [this ]() { checkAiToolbarConfiguration (false ); });
357+
355358 // update the workspace menu and combobox entries again after
356359 // restoreToolbars() to fill the workspace combo box again
357360 _workspaceManager->updateWorkspaceLists ();
@@ -3912,6 +3915,7 @@ void MainWindow::openSettingsDialog(int page, bool openScriptRepository) {
39123915 // read all relevant settings, that can be set in the settings dialog,
39133916 // even if the dialog was canceled
39143917 readSettingsFromSettingsDialog ();
3918+ checkAiToolbarConfiguration ();
39153919
39163920 // update the panels sort and order
39173921 updatePanelsSortOrder ();
@@ -3941,6 +3945,33 @@ void MainWindow::openSettingsDialog(int page, bool openScriptRepository) {
39413945 forceRegenerateNotePreview ();
39423946}
39433947
3948+ void MainWindow::checkAiToolbarConfiguration (bool askToShowToolbar) {
3949+ QToolBar *aiToolbar = _aiToolbarManager->aiToolbar ();
3950+ const bool hasConfiguredAiBackend = OpenAiService::instance ()->hasConfiguredBackend ();
3951+ const bool aiToolbarWasHidden = aiToolbar->isHidden ();
3952+
3953+ if (!hasConfiguredAiBackend) {
3954+ aiToolbar->hide ();
3955+
3956+ if (!aiToolbarWasHidden) {
3957+ storeCurrentWorkspace ();
3958+ }
3959+
3960+ return ;
3961+ }
3962+
3963+ if (askToShowToolbar && aiToolbarWasHidden &&
3964+ Utils::Gui::question (this , tr (" AI toolbar disabled" ),
3965+ tr (" An AI backend is configured, but the AI toolbar is currently "
3966+ " disabled. Do you want to turn it on?" ),
3967+ QStringLiteral (" enable-ai-toolbar-question" ),
3968+ QMessageBox::Yes | QMessageBox::No,
3969+ QMessageBox::Yes) == QMessageBox::Yes) {
3970+ aiToolbar->show ();
3971+ storeCurrentWorkspace ();
3972+ }
3973+ }
3974+
39443975void MainWindow::forceRegenerateNotePreview () {
39453976 _notePreviewHash.clear ();
39463977 currentNote.resetNoteTextHtmlConversionHash ();
0 commit comments