# HG changeset patch # User Torsten Lilge # Date 1579035073 -3600 # Node ID 8dc5b36f124513cd67b0459c4962954d4ed4b3cc # Parent 106c8ba2f13c3e477511c35a670d8b232fc5568b include new undock/dock actions into the shortcut manager * gui-preferences-sc.h: add new symbolic constant for new action shortcuts * octave-dock-widget.cc: (octave_dock_widget): replace hard coded shortcuts by the ones configured by the user and use only one shortcut for undock and dock; (make_window, make_widget): do not reconfigure the dock action shortcut; * shortcut-manager.cc (init_data): initialize new shortcuts; (fill_treewidget): new category for dock widgets in the shortcut preferences dialog diff -r 106c8ba2f13c -r 8dc5b36f1245 libgui/src/gui-preferences-sc.h --- a/libgui/src/gui-preferences-sc.h Sun Jun 10 01:40:36 2018 -0500 +++ b/libgui/src/gui-preferences-sc.h Tue Jan 14 21:51:13 2020 +0100 @@ -55,6 +55,13 @@ const Qt::KeyboardModifiers CTRL_SHIFT = CTRL | Qt::ShiftModifier; const Qt::KeyboardModifiers CTRL_ALT = CTRL | Qt::AltModifier; +// Shortcuts not related to specific Menus + +// Dock widgets +const QString sc_dock_widget ("dock_widget"); +const sc_pref sc_dock_widget_dock (sc_dock_widget + ":dock", CTRL_ALT + Qt::Key_D); +const sc_pref sc_dock_widget_close (sc_dock_widget + ":close", CTRL_ALT + Qt::Key_C); + // Main window menu // file diff -r 106c8ba2f13c -r 8dc5b36f1245 libgui/src/octave-dock-widget.cc --- a/libgui/src/octave-dock-widget.cc Sun Jun 10 01:40:36 2018 -0500 +++ b/libgui/src/octave-dock-widget.cc Tue Jan 14 21:51:13 2020 +0100 @@ -39,6 +39,7 @@ #include "gui-preferences-dw.h" #include "gui-preferences-global.h" #include "gui-preferences-mw.h" +#include "gui-preferences-sc.h" #include "gui-settings.h" #include "octave-dock-widget.h" #include "octave-qobject.h" @@ -213,12 +214,14 @@ connect (this, SIGNAL (queue_make_widget ()), this, SLOT (make_widget ()), Qt::QueuedConnection); - m_dock_action->setShortcut (QKeySequence (Qt::CTRL + Qt::ALT + Qt::Key_U)); + shortcut_manager& scmgr = m_octave_qobj.get_shortcut_manager (); + scmgr.set_shortcut (m_dock_action, sc_dock_widget_dock); m_dock_action->setShortcutContext (Qt::WidgetWithChildrenShortcut); addAction (m_dock_action); connect (m_dock_action, SIGNAL (triggered (bool)), this, SLOT (make_window (bool))); - m_close_action->setShortcut (QKeySequence (Qt::CTRL + Qt::ALT + Qt::Key_C)); + + scmgr.set_shortcut (m_close_action, sc_dock_widget_close); m_close_action->setShortcutContext (Qt::WidgetWithChildrenShortcut); addAction (m_close_action); connect (m_close_action, SIGNAL (triggered (bool)), @@ -299,11 +302,12 @@ : m_recent_float_geom; setGeometry (geom); - // adjust the (un)dock icon - m_dock_action->setShortcut (QKeySequence (Qt::CTRL + Qt::ALT + Qt::Key_D)); + // adjust the (un)dock action disconnect (m_dock_action, 0, this, 0); connect (m_dock_action, SIGNAL (triggered (bool)), this, SLOT (make_widget (bool))); + + // adjust the (un)dock icon if (titleBarWidget ()) { m_dock_action->setIcon (QIcon (":/actions/icons/widget-dock" @@ -350,8 +354,6 @@ setFloating (false); // adjust the (un)dock icon - m_dock_action->setShortcut (QKeySequence (Qt::CTRL + Qt::ALT + Qt::Key_U)); - m_dock_action->setShortcutContext (Qt::WidgetWithChildrenShortcut); connect (m_dock_action, SIGNAL (triggered (bool)), this, SLOT (make_window (bool))); if (titleBarWidget ()) diff -r 106c8ba2f13c -r 8dc5b36f1245 libgui/src/shortcut-manager.cc --- a/libgui/src/shortcut-manager.cc Sun Jun 10 01:40:36 2018 -0500 +++ b/libgui/src/shortcut-manager.cc Tue Jan 14 21:51:13 2020 +0100 @@ -126,13 +126,19 @@ void shortcut_manager::init_data (void) { - // actions of the main window - resource_manager& rmgr = m_octave_qobj.get_resource_manager (); gui_settings *settings = rmgr.get_settings (); settings->setValue (sc_main_ctrld.key, false); // reset use fo ctrl-d + // actions not related to specific menus or widgets + + // dock widgets + init (tr ("Undock/Dock Widget"), sc_dock_widget_dock); + init (tr ("Close Widget"), sc_dock_widget_close); + + // actions of the main window + // file init (tr ("New File"), sc_main_file_new_file); init (tr ("New Function"), sc_main_file_new_function); @@ -387,6 +393,8 @@ main_help->setText (0, tr ("Help Menu")); QTreeWidgetItem *main_news = new QTreeWidgetItem (main); main_news->setText (0, tr ("News Menu")); + QTreeWidgetItem *main_dock_widgets = new QTreeWidgetItem (main); + main_dock_widgets->setText (0, tr ("Handling of Dock Widgets")); QTreeWidgetItem *main_tabs = new QTreeWidgetItem (main); main_tabs->setText (0, tr ("Tab Handling in Dock Widgets")); QTreeWidgetItem *main_find = new QTreeWidgetItem (main); @@ -400,6 +408,7 @@ m_level_hash[sc_main_window] = main_window; m_level_hash[sc_main_help] = main_help; m_level_hash[sc_main_news] = main_news; + m_level_hash[sc_dock_widget] = main_dock_widgets; m_level_hash[sc_edit_tabs] = main_tabs; m_level_hash[sc_edit_find] = main_find; m_level_hash[sc_edit_zoom] = main_zoom;