Skip to content

Commit

Permalink
Single Click Navigation in File Dialogs (SpartanJ/ecode#256).
Browse files Browse the repository at this point in the history
  • Loading branch information
SpartanJ committed Apr 20, 2024
1 parent 657c977 commit 395a015
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 14 deletions.
2 changes: 2 additions & 0 deletions include/eepp/ui/uifiledialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class EE_API UIFileDialog : public UIWindow {

void setOpenShortut( const KeyBindings::Shortcut& newOpenShortut );

void setSingleClickNavigation( bool singleClickNavigation );

protected:
std::string mCurPath;
UIPushButton* mButtonOpen;
Expand Down
2 changes: 2 additions & 0 deletions include/eepp/ui/uimultimodelview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class EE_API UIMultiModelView : public UIStackWidget {

void setSelection( const ModelIndex& index, bool scrollToSelection = true );

void setSingleClickNavigation( bool singleClickNavigation );

protected:
UIMultiModelView( const std::string& tag );

Expand Down
4 changes: 4 additions & 0 deletions src/eepp/ui/uifiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,4 +776,8 @@ void UIFileDialog::setOpenShortut( const KeyBindings::Shortcut& newOpenShortut )
mOpenShortut = newOpenShortut;
}

void UIFileDialog::setSingleClickNavigation( bool singleClickNavigation ) {
mMultiView->setSingleClickNavigation( singleClickNavigation );
}

}} // namespace EE::UI
5 changes: 5 additions & 0 deletions src/eepp/ui/uimultimodelview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,9 @@ void UIMultiModelView::setSelection( const ModelIndex& index, bool scrollToSelec
mTable->setSelection( index, scrollToSelection );
}

void UIMultiModelView::setSingleClickNavigation( bool singleClickNavigation ) {
mList->setSingleClickNavigation( singleClickNavigation );
mTable->setSingleClickNavigation( singleClickNavigation );
}

}} // namespace EE::UI
4 changes: 2 additions & 2 deletions src/tools/ecode/appconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void AppConfig::load( const std::string& confPath, std::string& keybindingsPath,
editor.minimap = ini.getValueB( "editor", "minimap", true );
editor.showDocInfo = ini.getValueB( "editor", "show_doc_info", true );
editor.hideTabBarOnSingleTab = ini.getValueB( "editor", "hide_tab_bar_on_single_tab", false );
editor.singleClickTreeNavigation =
editor.singleClickNavigation =
ini.getValueB( "editor", "single_click_tree_navigation", false );
editor.syncProjectTreeWithEditor =
ini.getValueB( "editor", "sync_project_tree_with_editor", true );
Expand Down Expand Up @@ -257,7 +257,7 @@ void AppConfig::save( const std::vector<std::string>& recentFiles,
ini.setValueB( "editor", "minimap", editor.minimap );
ini.setValueB( "editor", "show_doc_info", editor.showDocInfo );
ini.setValueB( "editor", "hide_tab_bar_on_single_tab", editor.hideTabBarOnSingleTab );
ini.setValueB( "editor", "single_click_tree_navigation", editor.singleClickTreeNavigation );
ini.setValueB( "editor", "single_click_tree_navigation", editor.singleClickNavigation );
ini.setValueB( "editor", "sync_project_tree_with_editor", editor.syncProjectTreeWithEditor );
ini.setValueB( "editor", "auto_close_xml_tags", editor.autoCloseXMLTags );
ini.setValue( "editor", "line_spacing", editor.lineSpacing.toString() );
Expand Down
2 changes: 1 addition & 1 deletion src/tools/ecode/appconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct CodeEditorConfig {
bool minimap{ true };
bool showDocInfo{ true };
bool hideTabBarOnSingleTab{ true };
bool singleClickTreeNavigation{ false };
bool singleClickNavigation{ false };
bool syncProjectTreeWithEditor{ true };
bool autoCloseXMLTags{ true };
bool linesRelativePosition{ false };
Expand Down
6 changes: 5 additions & 1 deletion src/tools/ecode/ecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ void App::openFileDialog() {
dialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
dialog->setTitle( i18n( "open_file", "Open File" ) );
dialog->setCloseShortcut( KEY_ESCAPE );
dialog->setSingleClickNavigation( mConfig.editor.singleClickNavigation );
dialog->on( Event::OpenFile, [this]( const Event* event ) {
auto file = event->getNode()->asType<UIFileDialog>()->getFullPath();
mLastFileFolder = FileSystem::fileRemoveFileName( file );
Expand Down Expand Up @@ -252,6 +253,7 @@ void App::openFolderDialog() {
dialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
dialog->setTitle( i18n( "open_folder", "Open Folder" ) );
dialog->setCloseShortcut( KEY_ESCAPE );
dialog->setSingleClickNavigation( mConfig.editor.singleClickNavigation );
dialog->on( Event::OpenFile, [this]( const Event* event ) {
String path( event->getNode()->asType<UIFileDialog>()->getFullPath() );
if ( FileSystem::isDirectory( path ) )
Expand Down Expand Up @@ -280,6 +282,7 @@ void App::openFontDialog( std::string& fontPath, bool loadingMonoFont ) {
dialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
dialog->setTitle( i18n( "select_font_file", "Select Font File" ) );
dialog->setCloseShortcut( KEY_ESCAPE );
dialog->setSingleClickNavigation( mConfig.editor.singleClickNavigation );
dialog->on( Event::OnWindowClose, [this]( const Event* ) {
if ( mSplitter && mSplitter->getCurWidget() && !SceneManager::instance()->isShuttingDown() )
mSplitter->getCurWidget()->setFocus();
Expand Down Expand Up @@ -372,6 +375,7 @@ UIFileDialog* App::saveFileDialog( UICodeEditor* editor, bool focusOnClose ) {
dialog->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_MAXIMIZE_BUTTON | UI_WIN_MODAL );
dialog->setTitle( i18n( "save_file_as", "Save File As" ) );
dialog->setCloseShortcut( KEY_ESCAPE );
dialog->setSingleClickNavigation( mConfig.editor.singleClickNavigation );
dialog->setFileName( filename );
dialog->on( Event::SaveFile, [this, editor]( const Event* event ) {
if ( editor ) {
Expand Down Expand Up @@ -3033,7 +3037,7 @@ void App::initProjectTreeView( std::string path, bool openClean ) {
mProjectTreeView->setContractedIcon( "folder" );
mProjectTreeView->setHeadersVisible( false );
mProjectTreeView->setExpandersAsIcons( true );
mProjectTreeView->setSingleClickNavigation( mConfig.editor.singleClickTreeNavigation );
mProjectTreeView->setSingleClickNavigation( mConfig.editor.singleClickNavigation );
mProjectTreeView->setScrollViewType( UIScrollableWidget::Inclusive );
mProjectTreeView->on( Event::OnModelEvent, [this]( const Event* event ) {
const ModelEvent* modelEvent = static_cast<const ModelEvent*>( event );
Expand Down
19 changes: 9 additions & 10 deletions src/tools/ecode/settingsmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1283,13 +1283,12 @@ UIMenu* SettingsMenu::createViewMenu() {
i18n( "hide_tabbar_on_single_tab_tooltip",
"Hides the tabbar if there's only one element in the tab widget." ) )
->setId( "hide-tabbar-on-single-tab" );
mViewMenu
->addCheckBox( i18n( "treeview_single_click_nav", "Single Click Navigation in Tree View" ) )
->setActive( mApp->getConfig().editor.singleClickTreeNavigation )
->setTooltipText( i18n(
"treeview_single_click_nav_tooltip",
"Uses single click to open files and expand subfolders in\nthe directory tree." ) )
->setId( "treeview-single-click-nav" );
mViewMenu->addCheckBox( i18n( "treeview_single_click_nav", "Single Click Navigation" ) )
->setActive( mApp->getConfig().editor.singleClickNavigation )
->setTooltipText( i18n( "treeview_single_click_nav_tooltip",
"Uses single click to open files and expand subfolders in\nthe "
"directory tree and in file dialogs to open a folder or file." ) )
->setId( "single-click-nav" );
mViewMenu->addCheckBox( i18n( "sync_project_tree", "Synchronize project tree with editor" ) )
->setActive( mApp->getConfig().editor.syncProjectTreeWithEditor )
->setTooltipText(
Expand Down Expand Up @@ -1416,12 +1415,12 @@ UIMenu* SettingsMenu::createViewMenu() {
mApp->getConfig().editor.hideTabBarOnSingleTab =
item->asType<UIMenuCheckBox>()->isActive();
mSplitter->setHideTabBarOnSingleTab( mApp->getConfig().editor.hideTabBarOnSingleTab );
} else if ( item->getId() == "treeview-single-click-nav" ) {
mApp->getConfig().editor.singleClickTreeNavigation =
} else if ( item->getId() == "single-click-nav" ) {
mApp->getConfig().editor.singleClickNavigation =
item->asType<UIMenuCheckBox>()->isActive();
if ( mApp->getProjectTreeView() )
mApp->getProjectTreeView()->setSingleClickNavigation(
mApp->getConfig().editor.singleClickTreeNavigation );
mApp->getConfig().editor.singleClickNavigation );
} else if ( item->getId() == "sync-project-tree" ) {
mApp->getConfig().editor.syncProjectTreeWithEditor =
item->asType<UIMenuCheckBox>()->isActive();
Expand Down

0 comments on commit 395a015

Please sign in to comment.