Skip to content

Commit 21c97e9

Browse files
committed
config: add option to use CTRL+C to copy selections
1 parent 155914a commit 21c97e9

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

include/config.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Config
5151
bool show_text_tools = true;
5252
bool enable_vsync = true;
5353
bool render_anns = true;
54+
bool ctrl_c_copy_img = true;
5455
std::vector<std::string> fonts;
5556

5657
// C++20: Automatic generation of ==, !=, <, <=, >, >=
@@ -293,6 +294,11 @@ show-text-tools = {}
293294
# or only when saving the selection (false).
294295
annotations-in-text-tools = {}
295296
297+
# Copy image shortcut to use.
298+
# true: CTRL+C
299+
# false: CTRL+SHIFT+C
300+
ctrl-c-copy-img = {}
301+
296302
# Fonts to use for the application. Can be an absolute path, or just a name.
297303
# You can combine multiple fonts for multiple language support.
298304
# for example, using "Roboto-Regular.ttf" and "RobotoCJK-Regular.ttc" for Chinese, Japanese, and Korean support alongside English support.

src/config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void Config::LoadConfigFile(const std::string& filename)
7070
File.enable_vsync = GetValue<bool>("default.vsync", true);
7171
File.real_full_screen = GetValue<bool>("default.real-full-screen", false);
7272
File.render_anns = GetValue<bool>("default.annotations-in-text-tools", true);
73+
File.ctrl_c_copy_img = GetValue<bool>("default.ctrl-c-copy-img", false);
7374

7475
File.fonts = GetValueArrayStr("default.fonts", { GetValue<std::string>("default.font", "") });
7576

@@ -182,6 +183,7 @@ void Config::GenerateConfig(const std::string& filename, const bool force)
182183
File.allow_out_edit,
183184
File.show_text_tools,
184185
File.render_anns,
186+
File.ctrl_c_copy_img,
185187
fonts_str,
186188
File.image_out_fmt,
187189
File.theme_style,

src/screenshot_tool.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ void ScreenshotTool::HandleShortcutsInput()
455455
if (m_on_complete)
456456
m_on_complete(SavingOp::File, Ok(GetFinalImage()));
457457

458-
if (ImGui::Shortcut(ImGuiKey_C | ImGuiMod_Ctrl | ImGuiMod_Shift, ImGuiInputFlags_RouteGlobal))
458+
if (ImGui::Shortcut(ImGuiKey_C | ImGuiMod_Ctrl | (g_config->File.ctrl_c_copy_img ? 0 : ImGuiMod_Shift),
459+
ImGuiInputFlags_RouteGlobal) && !ui_blocks_selection())
459460
if (m_on_complete)
460461
m_on_complete(SavingOp::Clipboard, Ok(GetFinalImage()));
461462
}
@@ -1084,7 +1085,7 @@ void ScreenshotTool::DrawMenuItems()
10841085
if (m_on_complete)
10851086
m_on_complete(SavingOp::File, Ok(GetFinalImage()));
10861087

1087-
if (ImGui::MenuItem("Copy Image", "CTRL+SHIFT+C"))
1088+
if (ImGui::MenuItem("Copy Image", g_config->File.ctrl_c_copy_img ? "CTRL+C" : "CTRL+SHIFT+C"))
10881089
if (m_on_complete)
10891090
m_on_complete(SavingOp::Clipboard, Ok(GetFinalImage()));
10901091

@@ -1506,7 +1507,7 @@ void ScreenshotTool::DrawAnnotationToolbar()
15061507

15071508
static void draw_preference_edit_config(const std::function<void()>& refresh_models_func, bool window_just_opened)
15081509
{
1509-
static std::string new_font;
1510+
static std::string new_font;
15101511
static Result<std::string> r = get_config_image_out_fmt();
15111512

15121513
ImGui::SeparatorText("Edit default config");
@@ -1588,6 +1589,10 @@ static void draw_preference_edit_config(const std::function<void()>& refresh_mod
15881589
ImGui::SameLine();
15891590
HelpMarker("When enabled, annotations are included in the region passed to the text extractor.");
15901591

1592+
ImGui::Checkbox("Use CTRL+C to copy image##config_ctrl_c_copy_img", &g_config->File.ctrl_c_copy_img);
1593+
ImGui::SameLine();
1594+
HelpMarker("Shortcut to use when copying the image selection.\nIf disabled, the shortcut will be CTRL+SHIFT+C.");
1595+
15911596
// --- Image output format section ---
15921597
ImGui::Dummy(ImVec2(0, 8));
15931598
ImGui::Separator();

0 commit comments

Comments
 (0)