GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
octave-dock-widget.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-2018 Richard Crozier
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_octave_dock_widget_h)
24 #define octave_octave_dock_widget_h 1
25 
26 #include <QDockWidget>
27 #include <QSettings>
28 #include <QIcon>
29 #include <QMainWindow>
30 #include <QToolButton>
31 #include <QMouseEvent>
32 
33 namespace octave
34 {
35 
36  // The few decoration items common to both main window and variable editor.
37 
39  {
40  Q_OBJECT
41 
42  public:
43 
44  label_dock_widget (QWidget *p = nullptr);
45 
46  void set_title (const QString&);
47 
48  protected slots:
49 
50  //! Slots to handle copy & paste.
51  //!@{
52  virtual void copyClipboard (void) { }
53  virtual void pasteClipboard (void) { }
54  virtual void selectAll (void) { }
55  //!@}
56 
57  //! Slot to handle undo.
58 
59  virtual void do_undo (void) { }
60 
61  protected:
62 
67  QAction *m_dock_action;
68  QAction *m_close_action;
69  };
70 
72  {
73  Q_OBJECT
74 
75  public:
76 
77  octave_dock_widget (QWidget *p = nullptr);
78 
79  virtual ~octave_dock_widget (void) = default;
80 
81  virtual void connect_visibility_changed (void);
82 
83  void make_window (void);
84  void make_widget (bool dock=true);
85  void set_predecessor_widget (octave_dock_widget *prev_widget);
86 
87  signals:
88 
89  //! Custom signal that tells whether a user has clicked away that dock
90  //! widget, i.e the active dock widget has changed.
91 
92  void active_changed (bool active);
93 
94  protected:
95 
96  virtual void closeEvent (QCloseEvent *e);
97 
98  QWidget * focusWidget (void);
99 
100  public slots:
101 
102  virtual void focus (void)
103  {
104  if (! isVisible ())
105  setVisible (true);
106 
107  setFocus ();
108  activateWindow ();
109  raise ();
110  }
111 
112  virtual void handle_visibility (bool visible)
113  {
114  if (visible && ! isFloating ())
115  focus ();
116  }
117 
118  virtual void notice_settings (const QSettings*) { }
119 
120  void handle_settings (const QSettings*);
121 
123 
124  QMainWindow * main_win (void) { return m_parent; }
125 
126  void save_settings (void);
127 
128  protected slots:
129 
130  //! Slot to steer changing visibility from outside.
131 
132  virtual void handle_visibility_changed (bool visible)
133  {
134  if (visible)
135  emit active_changed (true);
136  }
137 
138  //! Event filter for double clicks into the window decoration elements.
139 
140  bool eventFilter (QObject *obj, QEvent *e);
141 
142  private slots:
143 
144  void change_floating (bool);
145  void change_visibility (bool);
146 
147  private:
148 
149  void set_style (bool active);
150  void set_focus_predecessor (void);
151 
152  //! Stores the parent, since we are reparenting to 0.
153 
155 
159  QColor m_bg_color;
161  QColor m_fg_color;
163  QString m_icon_color;
166 
167  };
168 }
169 
170 #endif
virtual void notice_settings(const QSettings *)
void set_predecessor_widget(octave_dock_widget *prev_widget)
virtual void handle_visibility_changed(bool visible)
Slot to steer changing visibility from outside.
virtual void selectAll(void)
Slots to handle copy & paste.
void active_changed(bool active)
Custom signal that tells whether a user has clicked away that dock widget, i.e the active dock widget...
virtual void copyClipboard(void)
Slots to handle copy & paste.
label_dock_widget(QWidget *p=nullptr)
QMainWindow * m_parent
Stores the parent, since we are reparenting to 0.
i e
Definition: data.cc:2591
virtual void handle_visibility(bool visible)
octave_dock_widget(QWidget *p=nullptr)
virtual void pasteClipboard(void)
Slots to handle copy & paste.
QMainWindow * main_win(void)
void handle_settings(const QSettings *)
void set_title(const QString &)
void handle_active_dock_changed(octave_dock_widget *, octave_dock_widget *)
octave_dock_widget * m_predecessor_widget
virtual void do_undo(void)
Slot to handle undo.
virtual void connect_visibility_changed(void)
void make_widget(bool dock=true)
virtual void closeEvent(QCloseEvent *e)
virtual ~octave_dock_widget(void)=default
bool eventFilter(QObject *obj, QEvent *e)
Event filter for double clicks into the window decoration elements.
p
Definition: lu.cc:138