From a8ee9e8c3171fe97a36923f9f66566f44113ca59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Fri, 28 Mar 2025 16:03:44 -0300 Subject: [PATCH] Request restart after changing the fallback font. --- src/tools/ecode/ecode.cpp | 9 ++++++--- src/tools/ecode/ecode.hpp | 14 +++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index d5eefb863..9ad983bfe 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -387,7 +387,8 @@ void App::openFolderDialog() { dialog->show(); } -void App::openFontDialog( std::string& fontPath, bool loadingMonoFont, bool terminalFont ) { +void App::openFontDialog( std::string& fontPath, bool loadingMonoFont, bool terminalFont, + std::function onFinish ) { std::string absoluteFontPath( fontPath ); if ( FileSystem::isRelativePath( absoluteFontPath ) ) absoluteFontPath = mResPath + fontPath; @@ -407,14 +408,16 @@ void App::openFontDialog( std::string& fontPath, bool loadingMonoFont, bool term if ( mSplitter && mSplitter->getCurWidget() && !SceneManager::instance()->isShuttingDown() ) mSplitter->getCurWidget()->setFocus(); } ); - dialog->on( Event::OpenFile, [this, &fontPath, loadingMonoFont, - terminalFont]( const Event* event ) { + dialog->on( Event::OpenFile, [this, &fontPath, loadingMonoFont, terminalFont, + onFinish]( const Event* event ) { auto newPath = event->getNode()->asType()->getFullPath(); if ( String::startsWith( newPath, mResPath ) ) newPath = newPath.substr( mResPath.size() ); if ( fontPath != newPath ) { if ( !loadingMonoFont ) { fontPath = newPath; + if ( onFinish ) + onFinish(); return; } auto fontName = diff --git a/src/tools/ecode/ecode.hpp b/src/tools/ecode/ecode.hpp index a7f1674c7..1b9ac81c3 100644 --- a/src/tools/ecode/ecode.hpp +++ b/src/tools/ecode/ecode.hpp @@ -59,7 +59,8 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider { void openFolderDialog(); - void openFontDialog( std::string& fontPath, bool loadingMonoFont, bool terminalFont = false ); + void openFontDialog( std::string& fontPath, bool loadingMonoFont, bool terminalFont = false, + std::function onFinish = {} ); void downloadFileWeb( const std::string& url ); @@ -312,8 +313,15 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider { [this] { openFontDialog( mConfig.ui.monospaceFont, true ); } ); t.setCommand( "terminal-font", [this] { openFontDialog( mConfig.ui.terminalFont, true, true ); } ); - t.setCommand( "fallback-font", - [this] { openFontDialog( mConfig.ui.fallbackFont, false ); } ); + t.setCommand( "fallback-font", [this] { + openFontDialog( mConfig.ui.fallbackFont, false, false, [this] { + UIMessageBox::New( UIMessageBox::OK, + i18n( "new_fallback_font_requires_restart", + "New fallback font has been set. Application must be " + "restarted in order to see the changes." ) ) + ->showWhenReady(); + } ); + } ); t.setCommand( "tree-view-configure-ignore-files", [this] { treeViewConfigureIgnoreFiles(); } ); t.setCommand( "check-languages-health", [this] { checkLanguagesHealth(); } );