From 7bc3fd8c155fea4dda24f1c997001e02e27ecee6 Mon Sep 17 00:00:00 2001 From: Abhishek Raturi Date: Thu, 27 Jul 2023 21:12:40 -0400 Subject: [PATCH] HackStudio: Add option to open file in single click This feature is similar to Clion's "Open files with Single Click" which allows user to open file without double clicking it HackStudio: Update action name to remove "toggle" Action name does need to include "Toggle" word since its already implie d with checkable action --- Userland/DevTools/HackStudio/HackStudioWidget.cpp | 10 ++++++++++ Userland/DevTools/HackStudio/HackStudioWidget.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 9f62f95f4f..26aab65b63 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -1,6 +1,7 @@ /* * Copyright (c) 2018-2020, Andreas Kling * Copyright (c) 2020-2022, Itamar S. + * Copyright (c) 2023-2024, Abhishek R. * Copyright (c) 2020-2022, the SerenityOS developers. * * SPDX-License-Identifier: BSD-2-Clause @@ -866,6 +867,13 @@ ErrorOr> HackStudioWidget::create_remove_current_edit }); } +ErrorOr> HackStudioWidget::create_toggle_open_file_in_single_click_action() +{ + return GUI::Action::create_checkable("&Open File with Single Click", [this](auto&) { + m_project_tree_view->set_activates_on_selection(!m_project_tree_view->activates_on_selection()); + }); +} + ErrorOr> HackStudioWidget::create_open_action() { auto icon = TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"sv)); @@ -1498,6 +1506,8 @@ ErrorOr HackStudioWidget::create_view_menu(GUI::Window& window) view_menu.add_action(show_dotfiles_action); m_toggle_semantic_highlighting_action = TRY(create_toggle_syntax_highlighting_mode_action()); view_menu.add_action(*m_toggle_semantic_highlighting_action); + m_toggle_view_file_in_single_click_action = TRY(create_toggle_open_file_in_single_click_action()); + view_menu.add_action(*m_toggle_view_file_in_single_click_action); view_menu.add_separator(); m_wrapping_mode_actions.set_exclusive(true); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.h b/Userland/DevTools/HackStudio/HackStudioWidget.h index 04fcba54d8..42eb770f18 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.h +++ b/Userland/DevTools/HackStudio/HackStudioWidget.h @@ -113,6 +113,7 @@ private: NonnullRefPtr create_remove_current_editor_tab_widget_action(); ErrorOr> create_remove_current_editor_action(); ErrorOr> create_open_action(); + ErrorOr> create_toggle_open_file_in_single_click_action(); NonnullRefPtr create_save_action(); NonnullRefPtr create_save_as_action(); NonnullRefPtr create_show_in_file_manager_action(); @@ -247,6 +248,7 @@ private: RefPtr m_locations_history_back_action; RefPtr m_locations_history_forward_action; RefPtr m_toggle_semantic_highlighting_action; + RefPtr m_toggle_view_file_in_single_click_action; RefPtr m_open_project_configuration_action; RefPtr read_editor_font_from_config();