From 857896dc6b3fdfbf5cebc5057bde5a179a29b1ba Mon Sep 17 00:00:00 2001 From: Lam Wei Lun Date: Wed, 21 Oct 2026 14:44:00 +0800 Subject: [PATCH] Make Ctrl+Q quit the application on Linux and Windows Quit was only bound to Cmd+Q on macOS. Add a Quit entry to the shortcut registry bound to Ctrl+Q and handle it in the global key handler, so the shortcut reaches the app regardless of focus. The File menu shows it as display text. The macOS-only key check is removed; Cmd+Q now goes through the registry. --- src/slic3r/GUI/MainFrame.cpp | 6 ++++-- src/slic3r/GUI/Shortcuts.cpp | 1 + src/slic3r/GUI/Shortcuts.hpp | 2 +- tests/slic3rutils/test_shortcuts.cpp | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index b1ae832abc..c36a895a17 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -801,7 +801,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, BORDERLESS_FRAME_ this->Iconize(); return; } - if (evt.CmdDown() && evt.GetKeyCode() == 'Q') { wxPostEvent(this, wxCloseEvent(wxEVT_CLOSE_WINDOW)); return;} if (evt.CmdDown() && evt.RawControlDown() && evt.GetKeyCode() == 'F') { EnableFullScreenView(true); if (IsFullScreen()) { @@ -901,6 +900,9 @@ bool MainFrame::handle_global_shortcut(const KeyChord& chord) if (can_export_model()) publish_project(); break; + case Shortcut::Quit: + Close(false); + break; case Shortcut::ShowLabels: if (m_plater && m_plater->is_view3D_shown()) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); @@ -3116,7 +3118,7 @@ void MainFrame::init_menubar_as_editor() fileMenu->AppendSeparator(); #ifndef __APPLE__ - append_menu_item(fileMenu, wxID_EXIT, _L("Quit"), wxString::Format(_L("Quit")), + append_shortcut_item(fileMenu, Shortcut::Quit, false, _L("Quit"), wxString::Format(_L("Quit")), [this](wxCommandEvent&) { Close(false); }, "menu_exit", nullptr); #else append_menu_item(fileMenu, wxID_EXIT, _L("Quit"), wxString::Format(_L("Quit")), diff --git a/src/slic3r/GUI/Shortcuts.cpp b/src/slic3r/GUI/Shortcuts.cpp index df8d7c00ca..b3809ade38 100644 --- a/src/slic3r/GUI/Shortcuts.cpp +++ b/src/slic3r/GUI/Shortcuts.cpp @@ -159,6 +159,7 @@ constexpr std::array shortcut_table = {{ SHORTCUT(CollapseSidebar, "collapse_sidebar", L("Collapse/Expand the sidebar"), CANVAS, { WXK_TAB, SHIFT }), SHORTCUT(ReloadDevicePage, "reload_device_page", L("Reload the device page"), CANVAS, { WXK_F5 }), SHORTCUT(KeyboardShortcuts, "keyboard_shortcuts", L("Show keyboard shortcuts list"), CANVAS, { '?' }), + SHORTCUT(Quit, "quit", L("Quit"), GLOBAL, { 'Q', CTRL }), // Speed Dial SHORTCUT(SpeedDial, "speed_dial", L("Open the Speed Dial"), GLOBAL, { WXK_SPACE }), diff --git a/src/slic3r/GUI/Shortcuts.hpp b/src/slic3r/GUI/Shortcuts.hpp index aba315d521..50652af000 100644 --- a/src/slic3r/GUI/Shortcuts.hpp +++ b/src/slic3r/GUI/Shortcuts.hpp @@ -48,7 +48,7 @@ enum class Shortcut : uint8_t { // Display ShowLabels, ShowWireframe, ToggleGcodeWindow, ToggleOneLayerMode, ToggleBeltRawGcode, // Application - Preferences, Search, SwitchView, CollapseSidebar, ReloadDevicePage, KeyboardShortcuts, + Preferences, Search, SwitchView, CollapseSidebar, ReloadDevicePage, KeyboardShortcuts, Quit, // Speed Dial SpeedDial, Count diff --git a/tests/slic3rutils/test_shortcuts.cpp b/tests/slic3rutils/test_shortcuts.cpp index d36c1d3b39..171d3257b0 100644 --- a/tests/slic3rutils/test_shortcuts.cpp +++ b/tests/slic3rutils/test_shortcuts.cpp @@ -222,6 +222,7 @@ TEST_CASE("Every shortcut is listed under the section of its table row", "[Short CHECK(shortcut_section(Shortcut::MovesSliderEnd) == ShortcutSection::Sliders); CHECK(shortcut_section(Shortcut::ViewDefault) == ShortcutSection::Camera); CHECK(shortcut_section(Shortcut::KeyboardShortcuts) == ShortcutSection::Application); + CHECK(shortcut_section(Shortcut::Quit) == ShortcutSection::Application); CHECK(std::string(section_name(ShortcutSection::SlicingAndPrinting)) == "Slicing and printing"); }