mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-12-03 02:08:06 -05:00
Fix AltGr typing in settings boxes switching tabs, and add go-to shortcuts for the other tabs (#16918)
Remove the old Ctrl+1 to Ctrl+4 key handler on settings fields. wxWidgets reports AltGr as Ctrl+Alt, so on AZERTY and similar layouts, typing `{`, `~` or `#` in a multi-line settings box switched the main tab. The handler was also outside the shortcut registry and clashed with the Ctrl+1 to Ctrl+4 camera shortcuts.
Add unbound "Go to the ... tab" shortcuts for Home, Design, Multi-device and Calibration, next to the Prepare, Preview, Device and Project ones from #16301.
Fixes #9649
(cherry picked from commit 42608687e5)
This commit is contained in:
1 parent
0b2cb5ac48
commit
cb770802c4
7 files changed
+42
-37
No files matched your search
@@ -373,7 +373,7 @@ current `boost::any m_value`. Virtuals: `BUILD()`, `set_value(any, change_event)
|
||||
`toggle(en)` enables only when not `readonly`. Subclasses: `TextCtrl`, `CheckBox`, `SpinCtrl`, `Choice`,
|
||||
`ColourPicker`, `PointCtrl`, `StaticText`, `SliderCtrl`, `PrinterAgentChoice`, `PluginField`,
|
||||
`PluginConfigField`. `Field::Create<T>(parent, def, id)` constructs, runs `PostInitialize()` (em unit,
|
||||
`parent_is_custom_ctrl`, `BUILD()`, readonly → `disable()`, Ctrl+1..4 tab shortcuts on the window) and returns a
|
||||
`parent_is_custom_ctrl`, `BUILD()`, readonly → `disable()`) and returns a
|
||||
`std::unique_ptr<Field>` owned by `OptionsGroup::m_fields`. The subclass `CheckBox` shadows the global `::CheckBox`
|
||||
widget inside `Slic3r::GUI` wherever `Field.hpp` is visible, which is why widget code there writes `::CheckBox`
|
||||
(and qualifies `::TextInput` / `::ComboBox` the same way) (`references/orca-widgets.md`).
|
||||
|
||||
@@ -156,7 +156,8 @@ Control on the Global page, and from the `?` key on the page of the view that re
|
||||
the dialog should list it; the row's section heading is the `section_table` entry
|
||||
above it, so a new section needs an entry there too. Pick a default that does not
|
||||
collide inside its contexts; the `[Shortcuts]` tests check every default against the
|
||||
others.
|
||||
others. An empty chord `{}` leaves a shortcut unbound until the user picks a key,
|
||||
as the jump-to-tab shortcuts are.
|
||||
2. Handle it in the dispatcher of its context: `MainFrame::handle_global_shortcut`,
|
||||
`GLCanvas3D::handle_shortcut`, `ObjectList::dispatch_shortcut`, or a gizmo's
|
||||
`on_tool_shortcut`. A gizmo that opens on a key sets `m_shortcut` in its constructor.
|
||||
|
||||
@@ -356,44 +356,12 @@ void Field::PostInitialize()
|
||||
|
||||
BUILD();
|
||||
|
||||
// For the mode, when settings are in non-modal dialog, neither dialog nor tabpanel doesn't receive wxEVT_KEY_UP event, when some field is selected.
|
||||
// So, like a workaround check wxEVT_KEY_UP event for the Filed and switch between tabs if Ctrl+(1-4) was pressed
|
||||
if (getWindow()) {
|
||||
if (m_opt.readonly) {
|
||||
this->disable();
|
||||
} else {
|
||||
this->enable();
|
||||
}
|
||||
getWindow()->Bind(wxEVT_KEY_UP, [](wxKeyEvent& evt) {
|
||||
if ((evt.GetModifiers() & wxMOD_CONTROL) != 0) {
|
||||
int tab_id = -1;
|
||||
switch (evt.GetKeyCode()) {
|
||||
case '1': { tab_id = 0; break; }
|
||||
case '2': { tab_id = 1; break; }
|
||||
case '3': { tab_id = 2; break; }
|
||||
case '4': { tab_id = 3; break; }
|
||||
#ifdef __APPLE__
|
||||
case 'f':
|
||||
#else /* __APPLE__ */
|
||||
case WXK_CONTROL_F:
|
||||
#endif /* __APPLE__ */
|
||||
case 'F': {
|
||||
//wxGetApp().plater()->search(false, Preset::TYPE_MODEL, nullptr, nullptr);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
if (tab_id >= 0) {
|
||||
static constexpr const char* kShortcutTabIds[] = {TAB_ID_HOME, TAB_ID_PREPARE, TAB_ID_PREVIEW, TAB_ID_MONITOR};
|
||||
wxGetApp().mainframe->select_tab(kShortcutTabIds[tab_id]);
|
||||
}
|
||||
if (tab_id > 0)
|
||||
// tab panel should be focused for correct navigation between tabs
|
||||
wxGetApp().tab_panel()->SetFocus();
|
||||
}
|
||||
|
||||
evt.Skip();
|
||||
}, getWindow()->GetId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -851,13 +851,19 @@ bool MainFrame::handle_global_shortcut(const KeyChord& chord)
|
||||
return false;
|
||||
|
||||
switch (*shortcut) {
|
||||
case Shortcut::GoToHome: m_tabpanel->SelectPageByName(TAB_ID_HOME); break;
|
||||
#ifdef SLIC3R_CAD
|
||||
case Shortcut::GoToDesign: m_tabpanel->SelectPageByName(TAB_ID_DESIGN); break;
|
||||
#endif
|
||||
case Shortcut::GoToPrepare: m_tabpanel->SelectPageByName(TAB_ID_PREPARE); break;
|
||||
case Shortcut::GoToPreview: m_tabpanel->SelectPageByName(TAB_ID_PREVIEW); break;
|
||||
case Shortcut::GoToDevice:
|
||||
if (!m_tabpanel->SelectPageByName(TAB_ID_MONITOR))
|
||||
m_tabpanel->SelectPageByName(TAB_ID_MONITOR_WEB);
|
||||
break;
|
||||
case Shortcut::GoToProject: m_tabpanel->SelectPageByName(TAB_ID_PROJECT); break;
|
||||
case Shortcut::GoToMultiDevice: m_tabpanel->SelectPageByName(TAB_ID_MULTI_DEVICE); break;
|
||||
case Shortcut::GoToProject: m_tabpanel->SelectPageByName(TAB_ID_PROJECT); break;
|
||||
case Shortcut::GoToCalibration: m_tabpanel->SelectPageByName(TAB_ID_CALIBRATION); break;
|
||||
case Shortcut::TabNext:
|
||||
case Shortcut::TabPrevious: {
|
||||
// Cycle through the tab bar, wrapping around at either end
|
||||
|
||||
@@ -164,10 +164,16 @@ constexpr std::array<ShortcutInfo, size_t(Shortcut::Count)> shortcut_table = {{
|
||||
SHORTCUT(SwitchView, "switch_view", L("Switch between Prepare/Preview"), CANVAS, { WXK_TAB }),
|
||||
SHORTCUT(CollapseSidebar, "collapse_sidebar", L("Collapse/Expand the sidebar"), CANVAS, { WXK_TAB, SHIFT }),
|
||||
// The jump-to-tab shortcuts have no default key, so users can bind the ones they want.
|
||||
SHORTCUT(GoToHome, "go_to_home", L("Go to the Home tab"), GLOBAL, {}),
|
||||
#ifdef SLIC3R_CAD
|
||||
SHORTCUT(GoToDesign, "go_to_design", L("Go to the Design tab"), GLOBAL, {}),
|
||||
#endif
|
||||
SHORTCUT(GoToPrepare, "go_to_prepare", L("Go to the Prepare tab"), GLOBAL, {}),
|
||||
SHORTCUT(GoToPreview, "go_to_preview", L("Go to the Preview tab"), GLOBAL, {}),
|
||||
SHORTCUT(GoToDevice, "go_to_device", L("Go to the Device tab"), GLOBAL, {}),
|
||||
SHORTCUT(GoToMultiDevice, "go_to_multi_device", L("Go to the Multi-device tab"), GLOBAL, {}),
|
||||
SHORTCUT(GoToProject, "go_to_project", L("Go to the Project tab"), GLOBAL, {}),
|
||||
SHORTCUT(GoToCalibration, "go_to_calibration", L("Go to the Calibration tab"), GLOBAL, {}),
|
||||
SHORTCUT(TabNext, "tab_next", L("Switch to the next tab"), GLOBAL, TAB_NEXT_CHORD),
|
||||
SHORTCUT(TabPrevious, "tab_previous", L("Switch to the previous tab"), GLOBAL, TAB_PREVIOUS_CHORD),
|
||||
SHORTCUT(ReloadDevicePage, "reload_device_page", L("Reload the device page"), CANVAS, { WXK_F5 }),
|
||||
|
||||
@@ -48,7 +48,11 @@ enum class Shortcut : uint8_t {
|
||||
// Display
|
||||
ShowLabels, ShowCollisionVolumes, ShowWireframe, ToggleGcodeWindow, ToggleOneLayerMode, ToggleBeltRawGcode,
|
||||
// Application
|
||||
Preferences, Search, SwitchView, CollapseSidebar, GoToPrepare, GoToPreview, GoToDevice, GoToProject, TabNext, TabPrevious, ReloadDevicePage, KeyboardShortcuts, Quit,
|
||||
Preferences, Search, SwitchView, CollapseSidebar, GoToHome,
|
||||
#ifdef SLIC3R_CAD
|
||||
GoToDesign,
|
||||
#endif
|
||||
GoToPrepare, GoToPreview, GoToDevice, GoToMultiDevice, GoToProject, GoToCalibration, TabNext, TabPrevious, ReloadDevicePage, KeyboardShortcuts, Quit,
|
||||
// Speed Dial
|
||||
SpeedDial,
|
||||
Count
|
||||
|
||||
@@ -296,7 +296,8 @@ TEST_CASE("Tab shortcuts: jump-to-tab is unbound by default, Ctrl+Tab cycles", "
|
||||
ShortcutRegistry registry;
|
||||
|
||||
// The jump-to-tab shortcuts ship without a key, so F1-F4 stay free (F2 renames in the object list).
|
||||
for (Shortcut shortcut : { Shortcut::GoToPrepare, Shortcut::GoToPreview, Shortcut::GoToDevice, Shortcut::GoToProject })
|
||||
for (Shortcut shortcut : { Shortcut::GoToHome, Shortcut::GoToPrepare, Shortcut::GoToPreview, Shortcut::GoToDevice,
|
||||
Shortcut::GoToMultiDevice, Shortcut::GoToProject, Shortcut::GoToCalibration })
|
||||
CHECK_FALSE(registry.binding(shortcut).valid());
|
||||
CHECK_FALSE(registry.lookup(ShortcutContext::Global, KeyChord{ WXK_F2 }).has_value());
|
||||
|
||||
@@ -413,6 +414,25 @@ TEST_CASE("Custom bindings replace the default and survive a config round trip",
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("A shortcut with no default is saved only while the user has it bound", "[Shortcuts]")
|
||||
{
|
||||
ShortcutRegistry registry;
|
||||
CHECK(registry.accelerator(Shortcut::GoToPreview).empty());
|
||||
|
||||
const KeyChord alt_3{ '3', wxMOD_ALT };
|
||||
registry.bind(Shortcut::GoToPreview, alt_3);
|
||||
CHECK(registry.lookup(ShortcutContext::Global, alt_3) == Shortcut::GoToPreview);
|
||||
|
||||
AppConfig config;
|
||||
registry.save(config);
|
||||
CHECK(config.get("shortcuts", "go_to_preview") == alt_3.to_string());
|
||||
|
||||
registry.bind(Shortcut::GoToPreview, KeyChord{});
|
||||
CHECK_FALSE(registry.is_customized(Shortcut::GoToPreview));
|
||||
registry.save(config);
|
||||
CHECK_FALSE(config.has("shortcuts", "go_to_preview"));
|
||||
}
|
||||
|
||||
TEST_CASE("A Global shortcut refuses a config binding that would swallow typing", "[Shortcuts]")
|
||||
{
|
||||
AppConfig config;
|
||||
|
||||
Reference in new issue
Block a user