GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
shortcut-manager.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2014-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_shortcut_manager_h)
27 #define octave_shortcut_manager_h 1
28 
29 #include <QKeyEvent>
30 #include <QLabel>
31 #include <QLineEdit>
32 #include <QShortcut>
33 #include <QTreeWidget>
34 #include <QWidget>
35 
36 #include "gui-settings.h"
37 
38 namespace octave
39 {
40  class enter_shortcut : public QLineEdit
41  {
42  Q_OBJECT
43 
44  public:
45 
46  enter_shortcut (QWidget *p = nullptr);
47 
48  ~enter_shortcut (void) = default;
49 
50  virtual void keyPressEvent (QKeyEvent *e);
51 
52  public slots:
53 
54  void handle_direct_shortcut (int);
55  void handle_shift_modifier (int);
56 
57  private:
58 
61 
62  };
63 
64  class base_qobject;
65 
66  class shortcut_manager : public QWidget
67  {
68  Q_OBJECT
69 
70  public:
71 
72  enum
73  {
76  OSC_DEFAULT = 2
77  };
78 
79  shortcut_manager (base_qobject& oct_qobj);
80 
81  // No copying!
82 
84 
86 
87  ~shortcut_manager (void) = default;
88 
89  void init_data (void);
90 
91  void write_shortcuts (gui_settings *settings, bool closing);
92 
93  void set_shortcut (QAction *action, const sc_pref& scpref);
94 
95  void shortcut (QShortcut *sc, const sc_pref& scpref);
96 
97  void fill_treewidget (QTreeWidget *tree_view);
98 
99  bool import_export (int action);
100 
101  protected slots:
102 
103  void handle_double_clicked (QTreeWidgetItem*, int);
104  void shortcut_dialog_finished (int);
106 
107  private:
108 
109  void init (const QString&, const sc_pref& scpref);
110  void shortcut_dialog (int);
112  bool overwrite_all_shortcuts (void);
113 
115  {
116  public:
117 
118  shortcut_t (void)
119  : m_tree_item (nullptr), m_description (), m_settings_key (),
120  m_actual_sc (QKeySequence ()), m_default_sc (QKeySequence ())
121  { }
122 
126  {
127  m_actual_sc = x.m_actual_sc;
128  m_default_sc = x.m_default_sc;
129  }
130 
132  {
133  if (&x != this)
134  {
135  m_tree_item = x.m_tree_item;
136  m_description = x.m_description;
137  m_settings_key = x.m_settings_key;
138 
139  m_actual_sc = QKeySequence ();
140  m_default_sc = QKeySequence ();
141 
142  m_actual_sc = x.m_actual_sc;
143  m_default_sc = x.m_default_sc;
144  }
145 
146  return *this;
147  }
148 
149  ~shortcut_t (void) = default;
150 
151  QTreeWidgetItem *m_tree_item;
152  QString m_description;
153  QString m_settings_key;
154  QKeySequence m_actual_sc;
155  QKeySequence m_default_sc;
156  };
157 
159 
161  QHash<QString, int> m_shortcut_hash;
162  QHash<QString, int> m_action_hash;
163  QHash <QString, QTreeWidgetItem*> m_level_hash;
164  QHash<int, QTreeWidgetItem*> m_index_item_hash;
165  QHash<QTreeWidgetItem*, int> m_item_index_hash;
166 
171  };
172 }
173 
174 #endif
Base class for Octave interfaces that use Qt.
virtual void keyPressEvent(QKeyEvent *e)
enter_shortcut(QWidget *p=nullptr)
~enter_shortcut(void)=default
shortcut_t & operator=(const shortcut_t &x)
QList< shortcut_t > m_sc
void init(const QString &, const sc_pref &scpref)
bool import_export(int action)
void fill_treewidget(QTreeWidget *tree_view)
~shortcut_manager(void)=default
enter_shortcut * m_edit_actual
void write_shortcuts(gui_settings *settings, bool closing)
void shortcut(QShortcut *sc, const sc_pref &scpref)
shortcut_manager & operator=(const shortcut_manager &)=delete
QHash< QString, int > m_shortcut_hash
QHash< int, QTreeWidgetItem * > m_index_item_hash
void set_shortcut(QAction *action, const sc_pref &scpref)
QHash< QString, int > m_action_hash
QHash< QString, QTreeWidgetItem * > m_level_hash
QHash< QTreeWidgetItem *, int > m_item_index_hash
void handle_double_clicked(QTreeWidgetItem *, int)
shortcut_manager(base_qobject &oct_qobj)
void import_shortcuts(gui_settings *settings)
shortcut_manager(const shortcut_manager &)=delete
F77_RET_T const F77_DBLE * x