GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
octave-dock-widget.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2012-2023 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 (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <QAction>
31 #include <QApplication>
32 #include <QHBoxLayout>
33 #include <QLabel>
34 #include <QScreen>
35 #include <QStyle>
36 #include <QToolBar>
37 #include <QMenuBar>
38 #include <QWindow>
39 
40 #include "gui-preferences-dw.h"
41 #include "gui-preferences-global.h"
42 #include "gui-preferences-mw.h"
43 #include "gui-preferences-sc.h"
44 #include "gui-settings.h"
45 #include "gui-utils.h"
46 #include "main-window.h"
47 #include "octave-dock-widget.h"
48 #include "octave-qobject.h"
49 
51 
53 : QDockWidget (p), m_octave_qobj (oct_qobj),
54  m_default_float_button (nullptr), m_default_close_button (nullptr)
55 {
56  QStyle *st = style ();
57  m_icon_size = 0.75*st->pixelMetric (QStyle::PM_SmallIconSize);
58 
59  // keep track of the original buttons on the default title bar,
60  // the button further left is considered "float"
61  QList<QAbstractButton *> buttonlist = findChildren<QAbstractButton *> ();
62  if (buttonlist.size () == 2)
63  {
64  if (buttonlist.at (0)->x () < buttonlist.at (1)->x ())
65  {
66  m_default_float_button = buttonlist.at (0);
67  m_default_close_button = buttonlist.at (1);
68  }
69  else
70  {
71  m_default_float_button = buttonlist.at (1);
72  m_default_close_button = buttonlist.at (0);
73  }
74  }
75 
76  resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
77 
78  // the custom (extra) title bar of the widget
79  m_title_widget = new QWidget ();
80 
81  m_dock_action = new QAction
82  (rmgr.icon ("widget-undock", true), "", this);
83  m_dock_action->setToolTip (tr ("Undock widget"));
84  m_dock_button = new QToolButton (m_title_widget);
85  m_dock_button->setDefaultAction (m_dock_action);
86  m_dock_button->setFocusPolicy (Qt::NoFocus);
87  m_dock_button->setIconSize (QSize (m_icon_size, m_icon_size));
88 
89  m_close_action = new QAction
90  (rmgr.icon ("widget-close", true), "", this);
91  m_close_action->setToolTip (tr ("Close widget"));
92  m_close_button = new QToolButton (m_title_widget);
93  m_close_button->setDefaultAction (m_close_action);
94  m_close_button->setFocusPolicy (Qt::NoFocus);
95  m_close_button->setIconSize (QSize (m_icon_size, m_icon_size));
96 
97  QString css_button = QString ("QToolButton {background: transparent; border: 0px;}");
98  m_dock_button->setStyleSheet (css_button);
99  m_close_button->setStyleSheet (css_button);
100 
101  QHBoxLayout *h_layout = new QHBoxLayout ();
102  h_layout->addStretch (100);
103  h_layout->addWidget (m_dock_button);
104  h_layout->addWidget (m_close_button);
105  h_layout->setSpacing (10);
106  h_layout->setContentsMargins (5, 2, 2, 2);
107 
108  m_title_widget->setLayout (h_layout);
109 
110  if (p && (p->objectName () == gui_obj_name_main_window))
111  {
112  // Only connect the when a parent (main window) is given
113  // copy & paste handling
114  connect (p, SIGNAL (copyClipboard_signal ()),
115  this, SLOT (copyClipboard ()));
116  connect (p, SIGNAL (pasteClipboard_signal ()),
117  this, SLOT (pasteClipboard ()));
118  connect (p, SIGNAL (selectAll_signal ()),
119  this, SLOT (selectAll ()));
120 
121  // undo handling
122  connect (p, SIGNAL (undo_signal ()), this, SLOT (do_undo ()));
123  }
124 }
125 
126 // set the title in the dockwidgets title bar
127 void
128 label_dock_widget::set_title (const QString& title)
129 {
130  QHBoxLayout *h_layout
131  = static_cast<QHBoxLayout *> (m_title_widget->layout ());
132  QLabel *label = new QLabel (title, m_title_widget);
133  label->setStyleSheet ("background-color: transparent;");
134  h_layout->insertWidget (0, label);
135  setTitleBarWidget (m_title_widget);
136  setWindowTitle (title);
137 }
138 
139 static QString
140 qdockwidget_css (const QString& close_icon, const QString& close_tooltip,
141  const QString& float_icon, const QString& float_tooltip,
142  int icon_size, const QString& titlebar_foreground,
143  const QString& titlebar_background)
144 {
145  return QString ("QDockWidget\n"
146  "{\n"
147  "%6"
148  " border: none;\n"
149  " titlebar-close-icon: url(%1);\n"
150  " titlebar-normal-icon: url(%2);\n"
151  "}\n"
152  "\n"
153  "QDockWidget::close-button, QDockWidget::float-button\n"
154  "{\n"
155  " border: none;\n"
156  " icon-size: %3px;\n"
157  "}\n"
158  "\n"
159  "QAbstractButton#qt_dockwidget_closebutton\n"
160  "{\n"
161  " qproperty-toolTip: \"%4\";\n"
162  "}\n"
163  "\n"
164  "QAbstractButton#qt_dockwidget_floatbutton\n"
165  "{\n"
166  " qproperty-toolTip: \"%5\";\n"
167  "}\n"
168  "\n"
169  "QDockWidget::title {\n"
170  " text-align: left;\n"
171  "%7"
172  " padding-left: 1px;\n"
173  "}\n"
174  "\n"
175  "QDockWidget::close-button\n"
176  "{\n"
177  " right: %8px;\n"
178  " top: 3px;\n"
179  "}\n"
180  "\n"
181  "QDockWidget::float-button\n"
182  "{\n"
183  " right: %9px;\n"
184  " top: 3px;\n"
185  "}\n"
186  ).arg (close_icon).arg (float_icon).arg (icon_size)
187  .arg (close_tooltip).arg (float_tooltip)
188  .arg (titlebar_foreground).arg (titlebar_background)
189  .arg ((icon_size*2)/3).arg((icon_size*7)/3);
190 }
191 
192 octave_dock_widget::octave_dock_widget (const QString& obj_name, QWidget *p,
193  base_qobject& oct_qobj)
194  : label_dock_widget (p, oct_qobj), m_adopted (false),
195  m_custom_style (false), m_focus_follows_mouse (false),
196  m_recent_float_geom (), m_recent_dock_geom (),
197  m_waiting_for_mouse_button_release (false)
198 {
199  setObjectName (obj_name);
200 
201  // FIXME: Can we avoid the cast here?
202  m_main_window = dynamic_cast<main_window *> (p);
203 
204  m_predecessor_widget = nullptr;
205 
206  connect (this, &octave_dock_widget::topLevelChanged,
208  connect (this, &octave_dock_widget::visibilityChanged,
210 
211  if (m_default_float_button != nullptr)
212  {
213  disconnect (m_default_float_button, 0, 0, 0);
214  connect (m_default_float_button, &QAbstractButton::clicked,
216  }
218  this, &octave_dock_widget::make_window, Qt::QueuedConnection);
220  this, [=] () { make_widget (); }, Qt::QueuedConnection);
221 
224  m_dock_action->setShortcutContext (Qt::WidgetWithChildrenShortcut);
225  addAction (m_dock_action);
226  connect (m_dock_action, &QAction::triggered,
228 
229  scmgr.set_shortcut (m_close_action, sc_dock_widget_close);
230  m_close_action->setShortcutContext (Qt::WidgetWithChildrenShortcut);
231  addAction (m_close_action);
232  connect (m_close_action, &QAction::triggered,
234 
235  m_close_action->setToolTip (tr ("Hide widget"));
236 
237  setStyleSheet (qdockwidget_css (
238  global_icon_paths.at (ICON_THEME_OCTAVE) + "widget-close.png",
239  QString ("Close widget"),
240  global_icon_paths.at (ICON_THEME_OCTAVE) + "widget-undock.png",
241  QString ("Undock widget"),
242  m_icon_size,
243  QString (""),
244  QString ("")));
245 
246  if (widget ())
247  widget ()->setToolTip (QString (""));
248 
249  m_icon_color = "";
250  m_title_3d = 50;
251 
252  installEventFilter (this);
253 
254  setFocusPolicy (Qt::StrongFocus);
255 
256  setFeatures (QDockWidget::DockWidgetClosable
257  | QDockWidget::DockWidgetMovable
258  | QDockWidget::DockWidgetFloatable);
259 
261  handle_settings (rmgr.get_settings ());
262 }
263 
264 void
266 {
267  emit active_changed (isVisible ()); // emit once for init of window menu
268 }
269 
270 // make the widget floating
271 void
272 octave_dock_widget::make_window (bool widget_was_dragged)
273 {
274  bool vis = isVisible ();
275 
276  // prevent follow-up calls by clearing state variable
278 
279  set_focus_predecessor (); // set focus previously active widget if tabbed
280 
281  // Before unparenting, get current geometry for restoring if dragged
282  QRect geom = geometry ();
283 
284  // the widget has to be reparented (parent = 0), preferably
285  // from a non-toplevel widget otherwise may not have full
286  // decorations, e.g., no taskbar icon and always in front
287  if (isFloating ())
288  setFloating (false);
289 
290  if (m_main_window)
291  {
292  // Before making it a separate (no more parent) floating widget,
293  // remove the dock widget from the main window. This ensures
294  // that tabbed widgets keep their focus when it is re-docked
295  // later
296  m_main_window->removeDockWidget (this);
297  }
298 
299  setParent (0, Qt::CustomizeWindowHint | Qt::WindowTitleHint |
300  Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::Window);
301 
302  // restore the last geometry when floating only if we have not dragged
303  // the window outside the main window
304  if (! widget_was_dragged)
305  geom = m_recent_float_geom.isNull () ? QRect (50,100,480,480)
307  setGeometry (geom);
308 
309  // adjust the (un)dock action
310  disconnect (m_dock_action, 0, this, 0);
311  connect (m_dock_action, &QAction::triggered,
313 
314  // adjust the (un)dock icon
315  if (titleBarWidget ())
316  {
318  m_dock_action->setIcon (rmgr.icon ("widget-dock" + m_icon_color, true));
319  m_dock_action->setToolTip (tr ("Dock widget"));
320  }
321  else
322  {
323  disconnect (m_default_float_button, 0, this, 0);
324  connect (m_default_float_button, &QAbstractButton::clicked,
326  }
327 
328  raise ();
329  activateWindow ();
330 
331  if (vis)
332  {
333  show ();
334  setFocus ();
335  set_style (true);
336  }
337 
338  emit topLevelChanged (true); // Be sure signal is emitted
339 }
340 
341 // dock the widget
342 void
344 {
345  bool vis = isVisible ();
346 
347  // Since floating widget has no parent, we have to read it
350 
351  if (m_main_window)
352  {
353  settings->setValue (mw_state.key, m_main_window->saveState ());
354 
355  // Stay window, otherwise will bounce back to window by default
356  // because there is no layout information for this widget in the
357  // saved settings.
358  setParent (m_main_window, Qt::Window);
359  m_main_window->addDockWidget (Qt::BottomDockWidgetArea, this);
360  m_adopted = false;
361  // recover old window states, hide and re-show new added widget
362  m_main_window->restoreState (settings->value (mw_state.key).toByteArray ());
363  setFloating (false);
364  // restore size using setGeometry instead of restoreGeometry
365  // following this post:
366  // https://forum.qt.io/topic/79326/qdockwidget-restoregeometry-not-working-correctly-when-qmainwindow-is-maximized/5
367  setGeometry (m_recent_dock_geom);
368  }
369 
370  // adjust the (un)dock icon
371  disconnect (m_dock_action, 0, this, 0);
372  connect (m_dock_action, &QAction::triggered,
374  if (titleBarWidget ())
375  {
376  m_dock_action->setIcon (rmgr.icon ("widget-undock" + m_icon_color, true));
377  m_dock_action->setToolTip (tr ("Undock widget"));
378  }
379  else
380  {
381  disconnect (m_default_float_button, 0, this, 0);
382  connect (m_default_float_button, &QAbstractButton::clicked,
384  }
385 
386  raise ();
387  QApplication::setActiveWindow (this);
388 
389  if (vis)
390  {
391  show ();
392  setFocus ();
393  set_style (true);
394  }
395 }
396 
397 // dock the widget
398 void
400 {
401  setFloating (false);
402 }
403 
404 // set the widget which previously had focus when tabified
405 void
407 {
408  m_predecessor_widget = prev_widget;
409 }
410 
411 void
413 {
414  m_main_window = mw;
415 
416  if (m_main_window)
417  {
420 
423 
426 
429  }
430 }
431 
432 // close event
433 void
435 {
436  emit active_changed (false);
438  save_settings ();
439 
440  QDockWidget::closeEvent (e);
441 }
442 
443 // get focus widget
444 QWidget *
446 {
447  QWidget *w = QApplication::focusWidget ();
448  if (w && w->focusProxy ()) w = w->focusProxy ();
449  return w;
450 }
451 
452 bool
454 {
455  // low-level check of whether docked-widget became a window via
456  // double-click or via drag-and-drop
457  if ( (event->type () == QEvent::MouseButtonDblClick && ! isFloating ())
458  || (event->type () == QEvent::ActivationChange
460  {
461  bool retval = QDockWidget::event (event);
462  if (isFloating () && parent () != 0)
463  {
465  emit queue_make_window (event->type () != QEvent::MouseButtonDblClick);
466  }
467  return retval;
468  }
469 
470  return QDockWidget::event (event);
471 }
472 
473 void
475 {
476  if (! settings)
477  return;
478 
480 
482  = settings->value (dw_title_custom_style).toBool ();
483 
484  m_title_3d = settings->value (dw_title_3d.key, dw_title_3d.def).toInt ();
485 
486  m_fg_color
487  = settings->value (dw_title_fg_color).value<QColor> ();
488 
490  = settings->value (dw_title_fg_color_active).value<QColor> ();
491 
492  m_bg_color = settings->value (dw_title_bg_color).value<QColor> ();
493 
495  = settings->value (dw_title_bg_color_active).value<QColor> ();
496 
497  QColor bcol (m_bg_color);
498  QColor bcola (m_bg_color_active);
499 
500  if (! m_custom_style)
501  {
502  bcol = QWidget::palette ().color (m_title_widget->backgroundRole ());
503  bcola = bcol;
504  }
505 
506  int r, g, b;
507  bcol.getRgb (&r, &g, &b);
508  if (r+g+b < 400)
509  m_icon_color = "-light";
510  else
511  m_icon_color = "";
512 
513  bcola.getRgb (&r, &g, &b);
514  if (r+g+b < 400)
515  m_icon_color_active = "-light";
516  else
517  m_icon_color_active = "";
518 
519  int x, y, w, h;
520  QGuiApplication::primaryScreen ()->availableGeometry ().getRect (&x, &y, &w, &h);
521  QRect default_floating_size = QRect (x+16, y+32, w/3, h/2);
522 
523  QRect default_dock_size;
524  if (m_main_window)
525  {
526  // We have a main window, dock size depends on size of main window
527  m_main_window->geometry ().getRect (&x, &y, &w, &h);
528  default_dock_size = QRect (x+16, y+32, w/3, h/3);
529  }
530  else
531  {
532  // No main window, default dock size should never be used
533  default_dock_size = QRect (0, 0, w/10, h/10);
534  }
535 
537  = settings->value (dw_float_geometry.key.arg (objectName ()),
538  default_floating_size).toRect ();
539 
540  adjust_to_screen (m_recent_float_geom, default_floating_size);
541 
542  // The following is required for ensure smooth transition from old
543  // saveGeomety to new QRect setting (see comment for restoring size
544  // of docked widgets)
545  QVariant dock_geom
546  = settings->value (dw_dock_geometry.key.arg (objectName ()),
547  default_dock_size);
548  if (dock_geom.canConvert (QMetaType::QRect))
549  m_recent_dock_geom = dock_geom.toRect ();
550  else
552 
553  notice_settings (settings); // call individual handler
554 
555  set_style (false);
556 
557  // Compacter design
558  QToolBar *toolbar = findChild <QToolBar *> ();
559  if (toolbar)
560  toolbar->setStyleSheet (toolbar->styleSheet () + global_toolbar_style);
561 
562  QMenuBar *menubar = findChild <QMenuBar *> ();
563  if (menubar)
564  menubar->setStyleSheet (menubar->styleSheet () + global_menubar_style);
565 
566 }
567 
568 void
570  octave_dock_widget *w_new)
571 {
572  if (m_custom_style && this == w_old)
573  {
574  set_style (false);
575  update ();
576  }
577 
578  if (m_custom_style && this == w_new)
579  {
580  set_style (true);
581  update ();
582  }
583 }
584 
585 void
587 {
588  // save state of this dock-widget
589  QString name = objectName ();
592 
593  if (! settings)
594  return;
595 
596  store_geometry ();
597 
598  // conditional needed?
599  if (! m_recent_float_geom.isNull ())
600  settings->setValue (dw_float_geometry.key.arg (name), m_recent_float_geom);
601 
602  if (! m_recent_dock_geom.isEmpty ())
603  settings->setValue (dw_dock_geometry.key.arg (name), m_recent_dock_geom);
604  settings->setValue (dw_is_visible.key.arg (name), isVisible ()); // store visibility
605  settings->setValue (dw_is_floating.key.arg (name), isFloating ()); // store floating
606  settings->setValue (dw_is_minimized.key.arg (name), isMinimized ()); // store minimized
607 
608  settings->sync ();
609 }
610 
612 {
613  // Ignore double clicks into window decoration elements
614  if (e->type () == QEvent::NonClientAreaMouseButtonDblClick)
615  {
616  e->ignore ();
617  return true;
618  }
619 
620  // Detect mouse enter events if "focus follows mouse" is desired
621  // for widgets docked to the main window (non floating) and activate
622  // the widget currently under the mouse
623  if (m_focus_follows_mouse && ! isFloating () && (e->type () == QEvent::Enter))
624  setFocus ();
625 
626  return QDockWidget::eventFilter (obj, e);
627 }
628 
629 void
631 {
632  if (isFloating ())
633  {
634  if (! parent ())
635  m_recent_float_geom = geometry ();
636  }
637  else
638  {
639  m_recent_dock_geom = geometry ();
640  }
641 }
642 
643 void
644 octave_dock_widget::moveEvent (QMoveEvent *event)
645 {
646  store_geometry ();
647 
648  QDockWidget::moveEvent (event);
649 }
650 
651 void
652 octave_dock_widget::resizeEvent (QResizeEvent *event)
653 {
654  store_geometry ();
655 
656  QDockWidget::resizeEvent (event);
657 }
658 
659 // slot for hiding the widget
660 void
662 {
663  setVisible (false);
664  emit active_changed (false);
665 }
666 
668 {
669  if (! isVisible ())
670  setVisible (true);
671 
672  setFocus ();
673  activateWindow ();
674  raise ();
675 }
676 
678 {
679  if (visible)
680  {
681  emit active_changed (true);
682  if (! isFloating ())
683  setFocus ();
684  }
685 }
686 
687 void
689 {
690  QObject *dockobj;
691  const char *docksig;
692 
693  if (titleBarWidget ())
694  {
695  dockobj = m_dock_action;
696  docksig = SIGNAL (triggered (bool));
697  }
698  else
699  {
700  dockobj = m_default_float_button;
701  docksig = SIGNAL (clicked (bool));
702  }
703 
704  if (toplevel)
705  {
706  // This is a fallback in case the attempt to create a floated
707  // top-level window fails and the QDockWidget remains a child
708  // of the QMainWindow.
709  connect (dockobj, docksig, this, SLOT (default_dock (bool)));
710 
711  // Could be dragging window, so must wait until there is a
712  // change in focus.
713  if (parent () != 0)
715  }
716  else
717  {
718  // If a drag-and-drop within the QMainWindow occurred, want to remain a widget.
720 
721  // Making into a widget immediately will mangle the double-click
722  // status and cause problems on followup button clicks.
723  if (parent () == 0)
724  emit queue_make_widget ();
725  }
726 }
727 
728 void
730 {
731  QString css_foreground;
732  QString css_background;
733  QString css_button;
734  QString dock_icon;
735 
736  QString icon_col = m_icon_color;
737 
738  QString close_tooltip = "Close widget";
739  QString dock_tooltip;
740 
741  if (isFloating ())
742  {
743  dock_icon = "widget-dock";
744  dock_tooltip = "Dock widget";
745  }
746  else
747  {
748  dock_icon = "widget-undock";
749  dock_tooltip = "Undock widget";
750  }
751 
752 #if defined (Q_OS_MAC)
753  QString alignment = "center";
754 #else
755  QString alignment = "center left";
756 #endif
757  if (m_custom_style)
758  {
759 
760  QColor bg_col, fg_col;
761 
762  if (active)
763  {
764  bg_col = m_bg_color_active;
765  fg_col = m_fg_color_active;
766  icon_col = m_icon_color_active;
767  }
768  else
769  {
770  bg_col = m_bg_color;
771  fg_col = m_fg_color;
772  icon_col = m_icon_color;
773  }
774 
775  QColor bg_col_top, bg_col_bottom;
776  if (m_title_3d > 0)
777  {
778  bg_col_top = bg_col.lighter (100 + m_title_3d);
779  bg_col_bottom = bg_col.darker (100 + m_title_3d);
780  }
781  else
782  {
783  bg_col_top = bg_col.darker (100 - m_title_3d);
784  bg_col_bottom = bg_col.lighter (100 - m_title_3d);
785  }
786 
787  css_foreground = QString (" color: %1;\n").arg (fg_col.name ());
788 
789  css_background =
790  QString (" background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
791  " stop: 0 %1, stop: 0.60 %2, stop: 0.95 %2 stop: 1.0 %3);\n").
792  arg (bg_col_top.name ()).
793  arg (bg_col.name ()).
794  arg (bg_col_bottom.name ());
795  }
796  else
797  {
798  css_foreground = QString ("");
799  css_background = QString ("");
800  }
801 
802  QString full_dock_icon = dock_icon + icon_col;
803  QString full_close_icon = "widget-close" + icon_col;
804  if (titleBarWidget ())
805  {
807  titleBarWidget ()->setStyleSheet (css_foreground + css_background);
808  css_button = QString ("QToolButton {background: transparent; border: 0px;}");
809  m_dock_button->setStyleSheet (css_button);
810  m_close_button->setStyleSheet (css_button);
811  m_dock_action->setIcon (rmgr.icon (full_dock_icon, true));
812  m_close_action->setIcon (rmgr.icon (full_close_icon, true));
813  }
814  else
815  {
816  setStyleSheet (qdockwidget_css (global_icon_paths.at (ICON_THEME_OCTAVE) + full_close_icon + ".png",
817  close_tooltip,
818  global_icon_paths.at (ICON_THEME_OCTAVE) + full_dock_icon + ".png",
819  dock_tooltip,
820  m_icon_size,
821  css_foreground,
822  css_background));
823  }
824 }
825 
826 // set focus to previously active widget in tabbed widget stack
827 void
829 {
830  // only != 0 if widget was tabbed
831  if (m_predecessor_widget && m_predecessor_widget->isVisible ())
832  m_predecessor_widget->setFocus ();
833 
834  m_predecessor_widget = nullptr;
835 
836  // FIXME: Until cset bda0c5b38bda, the wrong keys "Dockwidget/..." were used
837  // here. This had no effect in Qt4, but does in Qt5. In the following, the
838  // four incorrect keys are updated if still present in the settings files.
839  // The keys are also used in the settings dialog, but
840  // octave_dock_widget::handle_settings is already called at program start.
841  // These tests can be removed in a future version of Octave (version 6).
842 
844 
845  rmgr.update_settings_key ("Dockwidgets/title_bg_color",
847 
848  rmgr.update_settings_key ("Dockwidgets/title_bg_color_active",
850 
851  rmgr.update_settings_key ("Dockwidgets/title_fg_color",
853 
854  rmgr.update_settings_key ("Dockwidgets/title_fg_color_active",
856 }
857 
OCTAVE_END_NAMESPACE(octave)
Base class for Octave interfaces that use Qt.
resource_manager & get_resource_manager(void)
shortcut_manager & get_shortcut_manager(void)
base_qobject & m_octave_qobj
virtual void pasteClipboard(void)
Slots to handle copy & paste.
void set_title(const QString &)
virtual void copyClipboard(void)
Slots to handle copy & paste.
QAbstractButton * m_default_float_button
QToolButton * m_dock_button
virtual void do_undo(void)
Slot to handle undo.
virtual void selectAll(void)
Slots to handle copy & paste.
QToolButton * m_close_button
Represents the main window.
Definition: main-window.h:73
void pasteClipboard_signal(void)
void copyClipboard_signal(void)
void undo_signal(void)
void selectAll_signal(void)
void queue_make_window(bool widget_was_dragged)
virtual void notice_settings(const gui_settings *)
bool eventFilter(QObject *obj, QEvent *e)
Event filter for double clicks into the window decoration elements.
void handle_settings(const gui_settings *)
bool event(QEvent *event)
void init_window_menu_entry(void)
virtual void handle_visibility(bool visible)
octave_dock_widget * m_predecessor_widget
virtual void save_settings(void)
void queue_make_widget(void)
void default_dock(bool not_used=false)
void handle_active_dock_changed(octave_dock_widget *, octave_dock_widget *)
void set_predecessor_widget(octave_dock_widget *prev_widget)
virtual void toplevel_change(bool)
main_window * m_main_window
Stores the parent, since we are reparenting to 0.
QWidget * focusWidget(void)
void set_focus_predecessor(void)
void moveEvent(QMoveEvent *event)
octave_dock_widget(const QString &obj_name, QWidget *p, base_qobject &oct_qobj)
void set_style(bool active)
void resizeEvent(QResizeEvent *event)
void set_main_window(main_window *mw)
virtual void closeEvent(QCloseEvent *e)
void make_window(bool widget_was_dragged=false)
void make_widget(bool not_used=false)
void active_changed(bool active)
Custom signal that tells whether a user has clicked away that dock widget, i.e.
virtual void activate(void)
bool update_settings_key(const QString &new_key, const QString &old_key)
gui_settings * get_settings(void) const
QIcon icon(const QString &icon_name, bool octave_only=false, const QString &icon_alt_name=QString())
void set_shortcut(QAction *action, const sc_pref &scpref, bool enable=true)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
const gui_pref dw_title_3d("DockWidgets/widget_title_3d", QVariant(20))
const gui_pref dw_title_fg_color("DockWidgets/title_fg_color", QVariant(QColor(0, 0, 0)))
const gui_pref dw_is_floating("DockWidgets/%1Floating", QVariant(false))
const gui_pref dw_title_fg_color_active("DockWidgets/title_fg_color_active", QVariant(QColor(255, 255, 255)))
const gui_pref dw_title_custom_style("DockWidgets/widget_title_custom_style", QVariant(true))
const gui_pref dw_focus_follows_mouse("DockWidgets/focus_follows_mouse", QVariant(false))
const gui_pref dw_title_bg_color_active("DockWidgets/title_bg_color_active", QVariant(QColor(128, 128, 128)))
const gui_pref dw_dock_geometry("DockWidgets/%1", QVariant(QRect(10, 10, 240, 320)))
const gui_pref dw_title_bg_color("DockWidgets/title_bg_color", QVariant(QColor(192, 192, 192)))
const gui_pref dw_is_visible("DockWidgets/%1Visible", QVariant(true))
const gui_pref dw_is_minimized("DockWidgets/%1_minimized", QVariant(false))
const gui_pref dw_float_geometry("DockWidgets/%1_floating_geometry", QVariant(QRect(50, 50, 480, 640)))
const QString global_menubar_style("QMenuBar {" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "}")
const QString gui_obj_name_main_window
const QStringList global_icon_paths
const QString global_toolbar_style("QToolBar {" "margin-top: 0px;" "margin-bottom: 0px;" "padding-top: 0px;" "padding-bottom: 0px;" "border-top: 0px;" "border-bottom: 0px;" "}")
@ ICON_THEME_OCTAVE
const gui_pref mw_state("MainWindow/windowState", QVariant(QByteArray()))
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)
OCTGUI_API void adjust_to_screen(QRect &actual_geometry, const QRect &default_geometry)
Definition: gui-utils.cc:60
F77_RET_T const F77_DBLE * x
T * r
Definition: mx-inlines.cc:773
std::complex< double > w(std::complex< double > z, double relerr=0)
static QString qdockwidget_css(const QString &close_icon, const QString &close_tooltip, const QString &float_icon, const QString &float_tooltip, int icon_size, const QString &titlebar_foreground, const QString &titlebar_background)
const QString key
const QVariant def