feat(gui): assignable keyboard shortcuts (#15706)

This commit is contained in:
Kris Austin
2026-09-21 17:36:04 -03:00
committed by GitHub
parent bfe458507b
commit 824b216f18
52 changed files with 2685 additions and 1299 deletions
+29 -6
View File
@@ -18,6 +18,7 @@
#include "NetworkTestDialog.hpp"
#include "Widgets/StaticLine.hpp"
#include "Widgets/RadioGroup.hpp"
#include "Shortcuts.hpp"
#include "slic3r/Utils/bambu_networking.hpp"
#include "slic3r/Utils/NetworkAgent.hpp"
#include "NetworkPluginDialog.hpp"
@@ -285,6 +286,7 @@ std::tuple<wxBoxSizer*, ComboBox*> PreferencesDialog::create_item_combobox_base(
auto combobox = new ::ComboBox(m_parent, wxID_ANY, wxEmptyString, wxDefaultPosition, DESIGN_LARGE_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY);
combobox->GetDropDown().SetUseContentWidth(true);
combobox->SetToolTip(tip);
combobox->SetName(param); // select_tab() finds the row by this name
std::vector<wxString>::iterator iter;
for (iter = vlist.begin(); iter != vlist.end(); iter++) {
@@ -1522,6 +1524,19 @@ PreferencesDialog::~PreferencesDialog()
{
}
void PreferencesDialog::select_tab(PreferencesTab tab, const std::string& option)
{
if (const auto index = m_tab_index.find(tab); index != m_tab_index.end())
m_pref_tabs->SelectItem(index->second);
wxWindow* control = option.empty() ? nullptr : m_parent->FindWindow(wxString(option));
if (control == nullptr)
return;
int unit = 1;
m_parent->GetScrollPixelsPerUnit(nullptr, &unit);
m_parent->Scroll(wxDefaultCoord, (m_parent->CalcUnscrolledPosition(control->GetPosition()).y - FromDIP(10)) / unit);
control->SetFocus(); // the focused tint marks the row
}
void PreferencesDialog::on_dpi_changed(const wxRect &suggested_rect) {
m_pref_tabs->Rescale();
@@ -1599,7 +1614,7 @@ void PreferencesDialog::create_items()
//////////////////////////
//// GENERAL TAB
/////////////////////////////////////
m_pref_tabs->AppendItem(_L("General"));
m_tab_index[PreferencesTab::General] = m_pref_tabs->AppendItem(_L("General"));
f_sizers.push_back(new wxFlexGridSizer(1, 1, v_gap, 0));
g_sizer = f_sizers.back();
g_sizer->AddGrowableCol(0, 1);
@@ -1730,8 +1745,8 @@ void PreferencesDialog::create_items()
auto item_multi_machine = create_item_checkbox(_L("Multi device management"), _L("With this option enabled, you can send a task to multiple devices at the same time and manage multiple devices."), "enable_multi_machine", _L("(Requires restart)"));
g_sizer->Add(item_multi_machine);
auto item_speed_dial = create_item_checkbox(_L("Open the Speed Dial with the Space key"),
_L("When enabled, pressing Space (with no other key held) opens the Speed Dial action search from any page."),
auto item_speed_dial = create_item_checkbox(_L("Open the Speed Dial from the keyboard"),
_L("When enabled, the Speed Dial keyboard shortcut (Space by default) opens the action search from any page."),
"enable_speed_dial");
g_sizer->Add(item_speed_dial);
@@ -1789,7 +1804,7 @@ void PreferencesDialog::create_items()
//////////////////////////
//// CONTROL TAB
/////////////////////////////////////
m_pref_tabs->AppendItem(_L("Control"));
m_tab_index[PreferencesTab::Control] = m_pref_tabs->AppendItem(_L("Control"));
f_sizers.push_back(new wxFlexGridSizer(1, 1, v_gap, 0));
g_sizer = f_sizers.back();
g_sizer->AddGrowableCol(0, 1);
@@ -1859,6 +1874,14 @@ void PreferencesDialog::create_items()
auto item_right_mouse_drag = create_item_combobox(_L("Right Mouse Drag"), _L("Set the action that dragging the right mouse button should perform."), "right_mouse_drag_action", ButtonDragActions);
g_sizer->Add(item_right_mouse_drag);
//// CONTROL > Keyboard
g_sizer->Add(create_item_title(_L("Keyboard")), 1, wxEXPAND);
auto item_shortcuts = create_item_button(_L("Keyboard shortcuts"), _L("Edit") + dots, "", _L("Choose the key for each action."), [this]() {
wxGetApp().keyboard_shortcuts(ShortcutContext::Global, this);
});
g_sizer->Add(item_shortcuts);
//// CONTROL > Clear my choice on ...
g_sizer->Add(create_item_title(_L("Clear my choice on...")), 1, wxEXPAND);
@@ -1883,7 +1906,7 @@ void PreferencesDialog::create_items()
//////////////////////////
//// GRAPHICS TAB
/////////////////////////////////////
m_pref_tabs->AppendItem(_L("Graphics"));
m_tab_index[PreferencesTab::Graphics] = m_pref_tabs->AppendItem(_L("Graphics"));
f_sizers.push_back(new wxFlexGridSizer(1, 1, v_gap, 0));
g_sizer = f_sizers.back();
g_sizer->AddGrowableCol(0, 1);
@@ -2031,7 +2054,7 @@ void PreferencesDialog::create_items()
//////////////////////////
//// ONLINE TAB
/////////////////////////////////////
m_pref_tabs->AppendItem(_L("Online"));
m_tab_index[PreferencesTab::Online] = m_pref_tabs->AppendItem(_L("Online"));
f_sizers.push_back(new wxFlexGridSizer(1, 1, v_gap, 0));
g_sizer = f_sizers.back();
g_sizer->AddGrowableCol(0, 1);