# HG changeset patch # User Torsten Lilge # Date 1715361465 -7200 # Node ID 474f5a226fe0ddf6a30f0870811212edc9fbad72 # Parent 3485012a415aec0502ec45b39452127f1636aaf4 adding shortcut for setting focus to the find widget in the exp. console * command-widget.cc (command_widget): initialize new shortcut, connect slot for activating find widget to this shortcut; (notice_settings): set shortcut key sequence * command-widget.h: new shortcut * find-widget.cc (find_widget): initialize new flag for find widget being closeable or not, depending on close button; (activate_find): do not hide widget if visible but not closeable * find-widget.h: new class variable m_is_closeable diff -r 3485012a415a -r 474f5a226fe0 libgui/src/command-widget.cc --- a/libgui/src/command-widget.cc Fri May 10 13:42:19 2024 +0200 +++ b/libgui/src/command-widget.cc Fri May 10 19:17:45 2024 +0200 @@ -55,11 +55,9 @@ : QWidget (p), m_incomplete_parse (false), m_prompt (QString ()), m_console (new console (this)), - m_find_widget (new find_widget (false, this)) - + m_find_widget (new find_widget (false, this)), + m_find_shortcut (new QShortcut (this)) { - gui_settings settings; - QPushButton *pause_button = new QPushButton (tr("Pause"), this); QPushButton *stop_button = new QPushButton (tr("Stop"), this); QPushButton *resume_button = new QPushButton (tr("Continue"), this); @@ -111,6 +109,10 @@ connect (m_console, qOverload (&console::interpreter_event), this, qOverload (&command_widget::interpreter_event)); + m_find_shortcut->setContext (Qt::WidgetWithChildrenShortcut); + connect (m_find_shortcut, &QShortcut::activated, + m_find_widget, &find_widget::activate_find); + insert_interpreter_output ("\n\n Welcome to Octave\n\n"); } @@ -223,6 +225,8 @@ m_console->setStyleSheet (QString ("color: %1; background-color:%2;") .arg (fgc.name ()).arg (bgc.name ())); + settings.shortcut (m_find_shortcut, sc_edit_edit_find_replace); + m_find_widget->notice_settings (); } diff -r 3485012a415a -r 474f5a226fe0 libgui/src/command-widget.h --- a/libgui/src/command-widget.h Fri May 10 13:42:19 2024 +0200 +++ b/libgui/src/command-widget.h Fri May 10 19:17:45 2024 +0200 @@ -27,10 +27,11 @@ #define octave_command_widget_h 1 #include - #include +#include #include "find-widget.h" +#include "gui-preferences-sc.h" // FIXME: We need the following header for the fcn_callback and // meth_callback typedefs. Maybe it would be better to declare those in @@ -138,6 +139,7 @@ QString m_prompt; console *m_console; find_widget *m_find_widget; + QShortcut *m_find_shortcut; }; diff -r 3485012a415a -r 474f5a226fe0 libgui/src/find-widget.cc --- a/libgui/src/find-widget.cc Fri May 10 13:42:19 2024 +0200 +++ b/libgui/src/find-widget.cc Fri May 10 19:17:45 2024 +0200 @@ -38,6 +38,7 @@ // of the doc dock widget find_widget::find_widget (bool x_button, QWidget *p) : QWidget (p), + m_is_closeable (x_button), m_find_line_edit (new QLineEdit (this)), m_findnext_shortcut (new QShortcut (this)), m_findprev_shortcut (new QShortcut (this)) @@ -101,7 +102,7 @@ void find_widget::activate_find () { - if (isVisible ()) + if (m_is_closeable && isVisible ()) { hide (); } diff -r 3485012a415a -r 474f5a226fe0 libgui/src/find-widget.h --- a/libgui/src/find-widget.h Fri May 10 13:42:19 2024 +0200 +++ b/libgui/src/find-widget.h Fri May 10 19:17:45 2024 +0200 @@ -94,6 +94,8 @@ private: + bool m_is_closeable; + QLineEdit *m_find_line_edit; QShortcut *m_findnext_shortcut;