annotate libgui/graphics/ToolBar.cc @ 29542:3d34b70b5a49

connect many Qt signals and slots without SIGNAL and SLOT macros This changes switches most code in the libgui/src and libgui/graphics directories to use the new Qt style of connecting signals and slots that uses pointers to member functions or function objects instead of strings to refer to the signal and slot functions. For an introduction, see https://wiki.qt.io/New_Signal_Slot_Syntax. There are many connections left to adapt. In some cases, there are overloaded functions (or default parameters) that need to be handled. Use of QOverload<> or an anonymous function should fix these. In others, we are connecting to parent objects where we only have a pointer to QWidget instead of a specific type of object. To fix those, we need to either move the code that makes th connection to a place where the actual types of both objects are known or pass more specific types as the parent object. In a few cases, there appear to real mismatches in the types of objects and the signal/slot functions. Files affected: ButtonControl.cc, ButtonGroup.cc, ContextMenu.cc, EditControl.cc, Figure.cc, ListBoxControl.cc, Menu.cc, Object.cc, ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushTool.cc, SliderControl.cc, Table.cc, ToggleTool.cc, ToolBar.cc, annotation-dialog.cc, qt-graphics-toolkit.cc, color-picker.cc, command-widget.cc, dialog.cc, documentation-bookmarks.cc, documentation.cc, files-dock-widget.cc, find-files-dialog.cc, history-dock-widget.cc, interpreter-qobject.cc, file-editor-tab.cc, file-editor-tab.h, file-editor.cc, find-dialog.cc, octave-qscintilla.cc, main-window.cc, octave-dock-widget.cc, octave-qobject.cc, qt-interpreter-events.cc, set-path-dialog.cc, set-path-model.cc, settings-dialog.cc, shortcut-manager.cc, tab-bar.cc, variable-editor-model.cc, variable-editor.cc, welcome-wizard.cc, welcome-wizard.h, workspace-view.cc, and workspace-view.h.
author John W. Eaton <jwe@octave.org>
date Fri, 16 Apr 2021 23:06:32 -0400
parents 0a5b15007766
children 6ea4a84df9c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 2011-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21203
diff changeset
27 # include "config.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
28 #endif
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
29
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
30 #include <QAction>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
31 #include <QActionEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QApplication>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <QEvent>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34 #include <QIcon>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include <QMainWindow>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include <QPixmap>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
37 #include <QTimer>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38 #include <QToolBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
39
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 #include "Figure.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41 #include "ToolBar.h"
18505
fb96b7f55242 rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
42 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
43
27645
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
44 #include "gui-preferences-global.h"
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
45 #include "octave-qobject.h"
028205a91a07 eliminate global access to Octave resources in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27560
diff changeset
46
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
47 namespace QtHandles
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
48 {
27557
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
49 static QIcon makeEmptyIcon (void)
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
50 {
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
51 QPixmap pix (16, 16);
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
52
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
53 pix.fill (Qt::transparent);
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
54
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
55 return QIcon (pix);
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
56 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
57
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
58 static QAction*
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
59 addEmptyAction (QToolBar *bar)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
60 {
27557
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
61 static const QIcon empty_icon = makeEmptyIcon ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
27557
f9f21bb2ea1c fix initialization so some function-local static vars may be declared const
John W. Eaton <jwe@octave.org>
parents: 27478
diff changeset
63 QAction *a = bar->addAction (empty_icon, "Empty Toolbar");
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
64
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
65 a->setEnabled (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
66 a->setToolTip ("");
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
67
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
68 return a;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
69 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
70
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
71 ToolBar*
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
72 ToolBar::create (octave::base_qobject& oct_qobj, octave::interpreter& interp,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
73 const graphics_object& go)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
74 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
75 Object *parent = parentObject (interp, go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
76
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
77 if (parent)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
78 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
79 QWidget *parentWidget = parent->qWidget<QWidget> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
81 if (parentWidget)
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
82 return new ToolBar (oct_qobj, interp, go,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
83 new QToolBar (parentWidget));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
84 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
85
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23449
diff changeset
86 return nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
87 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
88
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
89 ToolBar::ToolBar (octave::base_qobject& oct_qobj, octave::interpreter& interp,
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
90 const graphics_object& go, QToolBar *bar)
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
91 : Object (oct_qobj, interp, go, bar), m_empty (nullptr), m_figure (nullptr)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
92 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
93 uitoolbar::properties& tp = properties<uitoolbar> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
94
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
95 bar->setFloatable (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
96 bar->setMovable (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
97 bar->setVisible (tp.is_visible ());
27560
3fcc650de22f split gui-preferences.h into one file per widget
John W. Eaton <jwe@octave.org>
parents: 27557
diff changeset
98 bar->setStyleSheet (bar->styleSheet () + global_toolbar_style);
27478
9e526393d80a reduced vertical space in gui with responsive toolbar buttons (bug #53902)
Torsten Lilge <ttl-octave@mailbox.org>
parents: 27469
diff changeset
99
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
100
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
101 m_empty = addEmptyAction (bar);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
102
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
103 m_figure =
23447
db1fdf4384dd maint: Use convention "static_cast<void *>" for casting of pointers.
Rik <rik@octave.org>
parents: 23220
diff changeset
104 dynamic_cast<Figure *> (Object::fromQObject (bar->parentWidget ()));
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
105
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
106 if (m_figure)
26869
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
107 m_figure->addCustomToolBar (bar, tp.is_visible (),
992f55ef87f5 Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 26376
diff changeset
108 tp.get_tag () == "__default_toolbar__");
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
109
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
110 bar->installEventFilter (this);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
111 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
112
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
113 ToolBar::~ToolBar (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
114 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
115
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
116 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
117 ToolBar::update (int pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
118 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
119 uitoolbar::properties& tp = properties<uitoolbar> ();
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
120 QToolBar *bar = qWidget<QToolBar> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
121
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
122 switch (pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
123 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
124 case base_properties::ID_VISIBLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
125 if (m_figure)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
126 m_figure->showCustomToolBar (bar, tp.is_visible ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
127 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
128
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
129 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
130 Object::update (pId);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
131 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
132 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
133 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
134
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
135 bool
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
136 ToolBar::eventFilter (QObject *watched, QEvent *xevent)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
137 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
138 if (watched == qObject ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
139 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
140 switch (xevent->type ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
141 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
142 case QEvent::ActionAdded:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
143 case QEvent::ActionRemoved:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
144 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
145 QActionEvent *ae = dynamic_cast<QActionEvent *> (xevent);
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
146 QToolBar *bar = qWidget<QToolBar> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
147
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
148 if (ae->action () != m_empty)
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
149 {
19623
6b2d7a5dc62a use xevent instead of ev to avoid shadowed warnings
John W. Eaton <jwe@octave.org>
parents: 19621
diff changeset
150 if (xevent->type () == QEvent::ActionAdded)
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
151 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
152 if (bar->actions ().size () == 2)
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
153 QTimer::singleShot (0, this, &ToolBar::hideEmpty);
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
154 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
155 else
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
156 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
157 if (bar->actions ().size () == 1)
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
158 m_empty->setVisible (true);
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
159 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
160 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
161 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
162 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
163
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
164 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
165 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
166 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
167 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
168
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
169 return false;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
170 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
171
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
172 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
173 ToolBar::hideEmpty (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
174 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
175 m_empty->setVisible (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
176 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
177
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
178 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
179 ToolBar::beingDeleted (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
180 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
181 if (m_figure)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
182 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
183 QToolBar *bar = qWidget<QToolBar> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
184
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
185 if (bar)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
186 m_figure->showCustomToolBar (bar, false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
187 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
188 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
189
22413
8758addcf265 maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents: 22411
diff changeset
190 }