Request restart after changing the fallback font.

This commit is contained in:
Martín Lucas Golini
2025-03-28 16:03:44 -03:00
parent bce702bf9f
commit a8ee9e8c31
2 changed files with 17 additions and 6 deletions

View File

@@ -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<void()> 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<UIFileDialog>()->getFullPath();
if ( String::startsWith( newPath, mResPath ) )
newPath = newPath.substr( mResPath.size() );
if ( fontPath != newPath ) {
if ( !loadingMonoFont ) {
fontPath = newPath;
if ( onFinish )
onFinish();
return;
}
auto fontName =

View File

@@ -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<void()> 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(); } );