From 9a77c33a7e9639d7f5f01e309e7e62b18c38bf04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 2 Jun 2024 23:36:14 -0300 Subject: [PATCH] AutoCompletePlugin::updateDocCache is now aware of document closing Set the tooltip on tab editor split When changing folder update/save the last folder Allow disabling welcome screen (SpartanJ/ecode#279). --- src/eepp/ui/tools/uicodeeditorsplitter.cpp | 3 +++ src/tools/ecode/appconfig.cpp | 2 ++ src/tools/ecode/appconfig.hpp | 1 + src/tools/ecode/ecode.cpp | 14 ++++++++++---- .../plugins/autocomplete/autocompleteplugin.cpp | 11 +++++++++++ src/tools/ecode/settingsmenu.cpp | 10 ++++++++++ src/tools/ecode/uiwelcomescreen.cpp | 6 ++++++ 7 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/eepp/ui/tools/uicodeeditorsplitter.cpp b/src/eepp/ui/tools/uicodeeditorsplitter.cpp index 4d996f423..27077746a 100644 --- a/src/eepp/ui/tools/uicodeeditorsplitter.cpp +++ b/src/eepp/ui/tools/uicodeeditorsplitter.cpp @@ -674,6 +674,9 @@ UITabWidget* UICodeEditorSplitter::createEditorWithTabWidget( Node* parent, bool !prevCurEditor->getDocument().isEmpty() ) { editorData.second->setDocument( prevCurEditor->getDocumentRef() ); editorData.second->goToLine( prevCurEditor->getDocument().getSelection().start() ); + auto path( editorData.second->getDocument().getFilePath() ); + if ( !path.empty() ) + editorData.first->setTooltipText( path ); } mAboutToAddEditor = nullptr; Lock l( mTabWidgetMutex ); diff --git a/src/tools/ecode/appconfig.cpp b/src/tools/ecode/appconfig.cpp index 9a0ec4e2a..4b96830b0 100644 --- a/src/tools/ecode/appconfig.cpp +++ b/src/tools/ecode/appconfig.cpp @@ -93,6 +93,7 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath, ui.showSidePanel = ini.getValueB( "ui", "show_side_panel", true ); ui.showStatusBar = ini.getValueB( "ui", "show_status_bar", true ); ui.showMenuBar = ini.getValueB( "ui", "show_menu_bar", false ); + ui.welcomeScreen = ini.getValueB( "ui", "welcome_screen", true ); ui.panelPosition = panelPositionFromString( ini.getValue( "ui", "panel_position", "left" ) ); ui.serifFont = ini.getValue( "ui", "serif_font", "fonts/NotoSans-Regular.ttf" ); ui.monospaceFont = ini.getValue( "ui", "monospace_font", "fonts/DejaVuSansMono.ttf" ); @@ -242,6 +243,7 @@ void AppConfig::save( const std::vector& recentFiles, ini.setValueB( "ui", "show_side_panel", ui.showSidePanel ); ini.setValueB( "ui", "show_status_bar", ui.showStatusBar ); ini.setValueB( "ui", "show_menu_bar", ui.showMenuBar ); + ini.setValueB( "ui", "welcome_screen", ui.welcomeScreen ); ini.setValue( "ui", "panel_position", panelPositionToString( ui.panelPosition ) ); ini.setValue( "ui", "serif_font", ui.serifFont ); ini.setValue( "ui", "monospace_font", ui.monospaceFont ); diff --git a/src/tools/ecode/appconfig.hpp b/src/tools/ecode/appconfig.hpp index d190c449f..ea25ba170 100644 --- a/src/tools/ecode/appconfig.hpp +++ b/src/tools/ecode/appconfig.hpp @@ -31,6 +31,7 @@ struct UIConfig { bool showSidePanel{ true }; bool showStatusBar{ true }; bool showMenuBar{ false }; + bool welcomeScreen{ true }; PanelPosition panelPosition{ PanelPosition::Left }; std::string serifFont; std::string monospaceFont; diff --git a/src/tools/ecode/ecode.cpp b/src/tools/ecode/ecode.cpp index 78e85931c..28c2398fb 100644 --- a/src/tools/ecode/ecode.cpp +++ b/src/tools/ecode/ecode.cpp @@ -2266,8 +2266,10 @@ void App::closeFolder() { mFileSystemModel->setRootPath( "" ); mPluginManager->setWorkspaceFolder( "" ); updateOpenRecentFolderBtn(); - UIWelcomeScreen::createWelcomeScreen( this ); - mStatusBar->setVisible( false ); + if ( getConfig().ui.welcomeScreen ) { + UIWelcomeScreen::createWelcomeScreen( this ); + mStatusBar->setVisible( false ); + } } void App::createDocDirtyAlert( UICodeEditor* editor ) { @@ -3208,8 +3210,10 @@ void App::initProjectTreeView( std::string path, bool openClean ) { } else { updateOpenRecentFolderBtn(); - UIWelcomeScreen::createWelcomeScreen( this ); - mStatusBar->setVisible( false ); + if ( getConfig().ui.welcomeScreen ) { + UIWelcomeScreen::createWelcomeScreen( this ); + mStatusBar->setVisible( false ); + } } mProjectTreeView->setAutoExpandOnSingleColumn( true ); @@ -3361,6 +3365,8 @@ void App::loadFolder( const std::string& path ) { setAppTitle( titleFromEditor( mSplitter->getCurEditor() ) ); mPluginManager->setWorkspaceFolder( rpath ); + + saveProject(); } #if EE_PLATFORM == EE_PLATFORM_MACOS diff --git a/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp b/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp index 849ce40df..d740ffd7c 100644 --- a/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp +++ b/src/tools/ecode/plugins/autocomplete/autocompleteplugin.cpp @@ -117,6 +117,17 @@ AutoCompletePlugin::~AutoCompletePlugin() { editor.first->removeEventListener( listener ); editor.first->unregisterPlugin( this ); } + + bool isUpdating = false; + do { + { + Lock lu( mDocsUpdatingMutex ); + isUpdating = std::any_of( mDocsUpdating.begin(), mDocsUpdating.end(), + []( const auto& du ) { return du.second == true; } ); + } + if ( isUpdating ) + Sys::sleep( Milliseconds( 1 ) ); + } while ( isUpdating ); } void AutoCompletePlugin::load( PluginManager* pluginManager ) { diff --git a/src/tools/ecode/settingsmenu.cpp b/src/tools/ecode/settingsmenu.cpp index 6bfd47aa4..ad8cd5ef5 100644 --- a/src/tools/ecode/settingsmenu.cpp +++ b/src/tools/ecode/settingsmenu.cpp @@ -1124,6 +1124,13 @@ UIMenu* SettingsMenu::createWindowMenu() { ->add( i18n( "zoom_reset", "Zoom Reset" ), findIcon( "zoom-reset" ), getKeybind( "font-size-reset" ) ) ->setId( "zoom-reset" ); + + mWindowMenu->addSeparator(); + mWindowMenu + ->addCheckBox( i18n( "welcome_screen_enable", "Enable Welcome Screen" ), + mApp->getConfig().ui.welcomeScreen ) + ->setId( "welcome-screen-enable" ); + mWindowMenu->on( Event::OnItemClicked, [this]( const Event* event ) { if ( !event->getNode()->isType( UI_TYPE_MENUITEM ) ) return; @@ -1134,6 +1141,9 @@ UIMenu* SettingsMenu::createWindowMenu() { mSplitter->zoomOut(); } else if ( "zoom-reset" == item->getId() ) { mSplitter->zoomReset(); + } else if ( "welcome-screen-enable" == item->getId() ) { + bool active = item->asType()->isActive(); + mApp->getConfig().ui.welcomeScreen = active; } else { String text = String( event->getNode()->asType()->getId() ).toLower(); String::replaceAll( text, " ", "-" ); diff --git a/src/tools/ecode/uiwelcomescreen.cpp b/src/tools/ecode/uiwelcomescreen.cpp index 0c988744f..7473c39cc 100644 --- a/src/tools/ecode/uiwelcomescreen.cpp +++ b/src/tools/ecode/uiwelcomescreen.cpp @@ -141,6 +141,7 @@ static const auto LAYOUT = R"xml( + )xml"; @@ -238,6 +239,11 @@ UIWelcomeScreen::UIWelcomeScreen( App* app ) : find( "open_folder_shortcut" )->setText( mApp->getKeybind( "open-folder" ) ); find( "open_file_shortcut" )->setText( mApp->getKeybind( "open-file" ) ); + + auto welcomeDisabledChk = find( "disable_welcome_screen" ); + welcomeDisabledChk->on( Event::OnValueChange, [welcomeDisabledChk, this]( auto ) { + mApp->getConfig().ui.welcomeScreen = !welcomeDisabledChk->isChecked(); + } ); } } // namespace ecode