Added an option to reset panel layout (SpartanJ/ecode#675).

Added options to "Reset Global File Associations" and "Reset Project File Associations" (renamed the command names too).
This commit is contained in:
Martín Lucas Golini
2026-01-11 18:25:49 -03:00
parent ac91cedf9c
commit d198f36eca
4 changed files with 75 additions and 19 deletions

View File

@@ -562,6 +562,19 @@ void App::downloadFileWebDialog() {
} );
}
void App::resetPanelsPartitions() {
if ( mProjectSplitter ) {
mConfig.windowState.panelPartition = "15%";
mProjectSplitter->setSplitPartition(
StyleSheetLength( mConfig.windowState.panelPartition ) );
}
if ( mMainSplitter ) {
mConfig.windowState.statusBarPartition = "85%";
mMainSplitter->setSplitPartition(
StyleSheetLength( mConfig.windowState.statusBarPartition ) );
}
}
void App::downloadFileWeb( const std::string& url ) {
UIDownloadWindow::downloadFileWeb( url );
}

View File

@@ -419,21 +419,21 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider {
}
} );
t.setCommand( "reset-global-language-extensions-priorities", [this] {
t.setCommand( "reset-global-file-associations", [this] {
mConfig.languagesExtensions.priorities.clear();
saveConfig();
mNotificationCenter->addNotification(
i18n( "global_language_extensions_priorities_has_been_reset",
"Global language extensions priorities has been reset" ) );
i18n( "global_file_associations_has_been_reset",
"Global file associations has been reset" ) );
} );
t.setCommand( "reset-project-language-extensions-priorities", [this] {
t.setCommand( "reset-project-file-associations", [this] {
if ( !mCurrentProject.empty() && mCurrentProject != getPlaygroundPath() ) {
mProjectDocConfig.languagesExtensions.priorities.clear();
saveProject();
mNotificationCenter->addNotification(
i18n( "project_language_extensions_priorities_has_been_reset",
"Project language extensions priorities has been reset" ) );
i18n( "project_file_associations_has_been_reset",
"Project file associations has been reset" ) );
} else {
mNotificationCenter->addNotification(
i18n( "no_project_loaded", "No project loaded" ) );
@@ -443,8 +443,16 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider {
t.setCommand( "maximize-tab-widget", [this] { maximizeTabWidget(); } );
t.setCommand( "restore-maximized-tab-widget", [this] { restoreMaximizedTabWidget(); } );
t.setCommand( "reset-panel-layout", [this] {
resetPanelsPartitions();
mNotificationCenter->addNotification(
i18n( "panels_partitions_has_been_reset", "Panels partitions has been reset" ) );
} );
}
void resetPanelsPartitions();
void maximizeTabWidget();
void restoreMaximizedTabWidget();
@@ -616,6 +624,10 @@ class App : public UICodeEditorSplitter::Client, public PluginContextProvider {
bool isDestroyingApp() const { return mDestroyingApp; }
bool projectIsOpen() const {
return !mCurrentProject.empty() && mCurrentProject != getPlaygroundPath();
}
protected:
std::vector<std::string> mArgs;
EE::Window::Window* mWindow{ nullptr };

View File

@@ -150,6 +150,8 @@ class PluginContextProvider {
std::optional<std::string> pathFilters = {} ) = 0;
virtual const std::unordered_map<std::string, std::string>& getStatusBarKeybindings() const = 0;
virtual bool projectIsOpen() const = 0;
};
} // namespace ecode

View File

@@ -822,8 +822,7 @@ UIMenu* SettingsMenu::createDocumentMenu() {
UIPopUpMenu* indentWidthMenuProject = UIPopUpMenu::New();
for ( int w = 2; w <= 12; w++ )
indentWidthMenuProject
->addRadioButton( String::toString( w ),
mApp->getProjectConfig().doc.indentWidth == w )
->addRadioButton( String::toString( w ), mApp->getProjectConfig().doc.indentWidth == w )
->setId( String::format( "indent_width_%d", w ) )
->setData( w );
mProjectDocMenu
@@ -851,16 +850,16 @@ UIMenu* SettingsMenu::createDocumentMenu() {
UIPopUpMenu* lineEndingsProjectMenu = UIPopUpMenu::New();
lineEndingsProjectMenu
->addRadioButton( "Windows (CR/LF)", mApp->getProjectConfig().doc.lineEndings ==
TextFormat::LineEnding::CRLF )
->addRadioButton( "Windows (CR/LF)",
mApp->getProjectConfig().doc.lineEndings == TextFormat::LineEnding::CRLF )
->setId( "CRLF" );
lineEndingsProjectMenu
->addRadioButton( "Unix (LF)", mApp->getProjectConfig().doc.lineEndings ==
TextFormat::LineEnding::LF )
->addRadioButton( "Unix (LF)",
mApp->getProjectConfig().doc.lineEndings == TextFormat::LineEnding::LF )
->setId( "LF" );
lineEndingsProjectMenu
->addRadioButton( "Macintosh (CR)", mApp->getProjectConfig().doc.lineEndings ==
TextFormat::LineEnding::CR )
->addRadioButton( "Macintosh (CR)",
mApp->getProjectConfig().doc.lineEndings == TextFormat::LineEnding::CR )
->setId( "CR" );
mProjectDocMenu
->addSubMenu( i18n( "line_endings", "Line Endings" ), nullptr, lineEndingsProjectMenu )
@@ -1474,6 +1473,22 @@ UIMenu* SettingsMenu::createWindowMenu() {
mWindowMenu->addSeparator();
mWindowMenu->add( i18n( "reset_panel_layout", "Reset Panel Layout" ) )
->setTooltipText( i18n( "reset_panel_layout_tooltip",
"Restores all panels to their default sizes "
"(e.g. sidebar, statusbar)." ) )
->setId( "reset-panel-layout" );
mWindowMenu->add( i18n( "reset_global_file_associations", "Reset Global File Associations" ) )
->setTooltipText( i18n( "reset_global_file_associations_tooltip",
"Clears your saved language choices for ambiguous file extensions\n"
"(e.g. choosing C++ for .h files). This only affects files opened\n"
"outside of project folders. After resetting, you'll be prompted\n"
"to choose a language again when opening these files." ) )
->setId( "reset-global-file-associations" );
mWindowMenu->addSeparator();
mWindowMenu
->addCheckBox( i18n( "welcome_screen_enable", "Enable Welcome Screen" ),
mApp->getConfig().ui.welcomeScreen )
@@ -2300,11 +2315,11 @@ void SettingsMenu::updateProjectSettingsMenu() {
->asType<UIMenuCheckBox>()
->setActive( mApp->getProjectConfig().doc.autoDetectIndentType );
auto* curIndent = mProjectDocMenu->find( "indent_width" )
->asType<UIMenuSubMenu>()
->getSubMenu()
->find( String::format( "indent_width_%d",
mApp->getProjectConfig().doc.indentWidth ) );
auto* curIndent =
mProjectDocMenu->find( "indent_width" )
->asType<UIMenuSubMenu>()
->getSubMenu()
->find( String::format( "indent_width_%d", mApp->getProjectConfig().doc.indentWidth ) );
if ( curIndent )
curIndent->asType<UIMenuRadioButton>()->setActive( true );
@@ -2334,6 +2349,9 @@ void SettingsMenu::updateProjectSettingsMenu() {
->setEnabled( true )
->asType<UIMenuCheckBox>()
->setActive( mApp->getProjectConfig().useGlobalSettings );
mProjectMenu->getItemId( "reset-project-file-associations" )
->setEnabled( mApp->projectIsOpen() );
}
void SettingsMenu::updateTerminalMenu() {
@@ -2839,6 +2857,17 @@ void SettingsMenu::createProjectMenu() {
mProjectMenu->addSubMenu( i18n( "treat_h_files_as_ellipsis", "Treat .h files as..." ), nullptr,
mHExtLanguageTypeMenu );
mProjectMenu->addSeparator();
mProjectMenu
->add( i18n( "reset_project_file_associations", "Reset Project File Associations" ) )
->setTooltipText( i18n( "reset_project_file_associations_tooltip",
"Clears your saved language choices for ambiguous file extensions\n"
"(e.g. choosing C++ for .h files) in the current project.\n"
"After resetting, you'll be prompted to choose a language again\n"
"when opening these files within this project." ) )
->setId( "reset-project-file-associations" );
mHExtLanguageTypeMenu->on( Event::OnItemClicked, [this]( const Event* event ) {
if ( event->getNode()->isType( UI_TYPE_MENU_SEPARATOR ) ||
event->getNode()->isType( UI_TYPE_MENUSUBMENU ) )