changeset 27937:8dc5b36f1245

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
author Torsten Lilge <ttl-octave@mailbox.org>
date Tue, 14 Jan 2020 21:51:13 +0100
parents 106c8ba2f13c
children b4a76e7dac6b
files libgui/src/gui-preferences-sc.h libgui/src/octave-dock-widget.cc libgui/src/shortcut-manager.cc
diffstat 3 files changed, 26 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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 ())
--- 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;