| 1698 | } |
| 1699 | |
| 1700 | void App::onTabCreated( UITab* tab, UIWidget* ) { |
| 1701 | tab->on( Event::OnCreateContextMenu, [this]( const Event* event ) { |
| 1702 | if ( !event->getNode()->isType( UI_TYPE_TAB ) ) |
| 1703 | return; |
| 1704 | const ContextMenuEvent* menuEvent = static_cast<const ContextMenuEvent*>( event ); |
| 1705 | UIPopUpMenu* menu = menuEvent->getMenu(); |
| 1706 | if ( nullptr == menu ) |
| 1707 | return; |
| 1708 | UITab* tab = event->getNode()->asType<UITab>(); |
| 1709 | if ( !tab->getTabWidget() ) |
| 1710 | return; |
| 1711 | const auto menuAdd = [menu, this]( const std::string& translateKey, |
| 1712 | const String& translateString, const std::string& icon, |
| 1713 | const std::string& cmd ) { |
| 1714 | UIMenuItem* menuItem = menu->add( i18n( translateKey, translateString ), |
| 1715 | findIcon( icon ), getKeybind( cmd ) ); |
| 1716 | menuItem->setId( cmd ); |
| 1717 | return menuItem; |
| 1718 | }; |
| 1719 | |
| 1720 | menuAdd( "editor_tab_menu_close_tab", "Close Tab", "document-close", "close-tab" ); |
| 1721 | menuAdd( "editor_tab_menu_close_other_tabs", "Close Other Tabs", "", "close-other-tabs" ); |
| 1722 | menuAdd( "editor_tab_menu_close_clean_tabs", "Close Clean Tabs", "", "close-clean-tabs" ); |
| 1723 | menuAdd( "editor_tab_menu_close_all_tabs", "Close All Tabs", "", "close-all-tabs" ); |
| 1724 | menuAdd( "editor_tab_menu_close_tabs_to_the_left", "Close Tabs To The Left", "", |
| 1725 | "close-tabs-to-the-left" ); |
| 1726 | menuAdd( "editor_tab_menu_close_tabs_to_the_right", "Close Tabs To The Right", "", |
| 1727 | "close-tabs-to-the-right" ); |
| 1728 | |
| 1729 | if ( tab->getOwnedWidget()->isType( UI_TYPE_CODEEDITOR ) ) { |
| 1730 | menu->addSeparator(); |
| 1731 | |
| 1732 | menuAdd( "split_left", "Split Left", "split-horizontal", "split-left" ); |
| 1733 | menuAdd( "split_right", "Split Right", "split-horizontal", "split-right" ); |
| 1734 | menuAdd( "split_top", "Split Top", "split-vertical", "split-top" ); |
| 1735 | menuAdd( "split_bottom", "Split Bottom", "split-vertical", "split-bottom" ); |
| 1736 | |
| 1737 | menu->addSeparator(); |
| 1738 | |
| 1739 | menuAdd( "open_containing_folder_in_fm", "Open Containing Folder in File Manager", |
| 1740 | "folder-open", "open-containing-folder" ); |
| 1741 | |
| 1742 | menuAdd( "copy_containing_folder_path_ellipsis", "Copy Containing Folder Path...", |
| 1743 | "copy", "copy-containing-folder-path" ); |
| 1744 | |
| 1745 | menuAdd( "copy_file_path", "Copy File Path", "copy", "copy-file-path" ); |
| 1746 | |
| 1747 | menuAdd( "copy_file_path_and_position", "Copy File Path and Position", "copy", |
| 1748 | "copy-file-path-and-position" ); |
| 1749 | |
| 1750 | menu->addSeparator(); |
| 1751 | |
| 1752 | menuAdd( "open_in_new_window", "Open in New Window", "window", "open-in-new-window" ); |
| 1753 | |
| 1754 | menuAdd( "move_to_new_window", "Move to New Window", "window", "move-to-new-window" ); |
| 1755 | |
| 1756 | if ( !tab->isSelected() ) { |
| 1757 | menu->addSeparator(); |
no test coverage detected