annotate libgui/graphics/Menu.cc @ 31639:ca7d58406f82

eliminate unnecessary uses of octave_qobject in GUI classes * BaseControl.cc, BaseControl.h, ButtonControl.cc, ButtonControl.h, ButtonGroup.cc, ButtonGroup.h, Canvas.cc, Canvas.h, CheckBoxControl.cc, CheckBoxControl.h, Container.cc, Container.h, ContextMenu.cc, ContextMenu.h, EditControl.cc, EditControl.h, Figure.cc, Figure.h, GLCanvas.cc, GLCanvas.h, ListBoxControl.cc, ListBoxControl.h, Menu.cc, Menu.h, Object.cc, Object.h, Panel.cc, Panel.h, PopupMenuControl.cc, PopupMenuControl.h, PushButtonControl.cc, PushButtonControl.h, PushTool.cc, PushTool.h, RadioButtonControl.cc, RadioButtonControl.h, SliderControl.cc, SliderControl.h, Table.cc, Table.h, TextControl.cc, TextControl.h, ToggleButtonControl.cc, ToggleButtonControl.h, ToggleTool.cc, ToggleTool.h, ToolBar.cc, ToolBar.h, ToolBarButton.cc, ToolBarButton.h, annotation-dialog.cc, annotation-dialog.h, qt-graphics-toolkit.cc, qt-graphics-toolkit.h, command-widget.h, community-news.cc, community-news.h, documentation-bookmarks.cc, documentation-bookmarks.h, documentation.cc, external-editor-interface.cc, external-editor-interface.h, find-files-dialog.cc, find-files-dialog.h, graphics-init.cc, graphics-init.h, interpreter-qobject.cc, file-editor.cc, find-dialog.cc, find-dialog.h, main-window.cc, main-window.h, news-reader.cc, news-reader.h, octave-qobject.cc, release-notes.cc, resource-manager.cc, set-path-dialog.cc, set-path-dialog.h, shortcut-manager.cc, shortcut-manager.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc: Don't store references to octave_qobject in GUI classes where it is no longer needed. Eliminate unnecessary octave_qobject constructor arguments. Change all uses.
author John W. Eaton <jwe@octave.org>
date Sun, 04 Dec 2022 22:57:02 -0500
parents fef2957c38ec
children 431f80aba37a
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30398
diff changeset
3 // Copyright (C) 2011-2022 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 <QMainWindow>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
32 #include <QMenu>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
33 #include <QMenuBar>
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
34
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
35 #include "Figure.h"
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
36 #include "Menu.h"
18505
fb96b7f55242 rename file to avoid clash on case-insenstive filesystems (bug #41658)
John W. Eaton <jwe@octave.org>
parents: 18501
diff changeset
37 #include "QtHandlesUtils.h"
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
38
29992
6ea4a84df9c7 rename QtHandles namespace to octave
John W. Eaton <jwe@octave.org>
parents: 29913
diff changeset
39 namespace octave
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
40 {
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
41
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
42 static QKeySequence
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
43 accelSequence (const uimenu::properties& up)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
44 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
45 std::string s (up.get_accelerator ());
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
46
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
47 if (! s.empty ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
48 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
49 char c = s[0];
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
50 int keyMod = Qt::CTRL;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
51
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
52 if (c >= 'A' && c <= 'Z')
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
53 keyMod |= Qt::SHIFT;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
54 if (c >= 'a' && c <= 'z')
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
55 c -= ('a' - 'A');
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
56 if (c >= 'A' && c <= 'Z')
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
57 return QKeySequence (keyMod | static_cast<int> (c));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
58 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
59
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
60 return QKeySequence ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
61 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
62
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30100
diff changeset
63 Menu *
31639
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 30999
diff changeset
64 Menu::create (octave::interpreter& interp,
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
65 const graphics_object& go)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
66 {
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
67 Object *parent_obj = parentObject (interp, go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
68
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
69 if (parent_obj)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
70 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
71 QObject *qObj = parent_obj->qObject ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
72
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
73 if (qObj)
31639
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 30999
diff changeset
74 return new Menu (interp, go, new QAction (qObj),
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
75 parent_obj);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
76 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
77
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23457
diff changeset
78 return nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
79 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
80
31639
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 30999
diff changeset
81 Menu::Menu (octave::interpreter& interp,
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
82 const graphics_object& go, QAction *action, Object *xparent)
31639
ca7d58406f82 eliminate unnecessary uses of octave_qobject in GUI classes
John W. Eaton <jwe@octave.org>
parents: 30999
diff changeset
83 : Object (interp, go, action), m_parent (nullptr),
27647
2a506bc4a7af eliminate global access to Octave interpreter in qt graphics classes
John W. Eaton <jwe@octave.org>
parents: 27645
diff changeset
84 m_separator (nullptr)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
85 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
86 uimenu::properties& up = properties<uimenu> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
87
29913
3eca54836f97 Allow 'Label' to be used as a synonym for 'Text' on uimenus (bug #60870)
Rik <rik@octave.org>
parents: 29542
diff changeset
88 action->setText (Utils::fromStdString (up.get_text ()));
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
89
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
90 if (up.is_checked ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
91 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
92 action->setCheckable (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
93 action->setChecked (up.is_checked ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
94 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
95
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
96 action->setEnabled (up.is_enable ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
97 action->setShortcut (accelSequence (up));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
98 action->setVisible (up.is_visible ());
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
99
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
100 if (up.is_separator ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
101 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
102 m_separator = new QAction (action);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
103 m_separator->setSeparator (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
104 m_separator->setVisible (up.is_visible ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
105 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
106
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
107 MenuContainer *menuContainer = dynamic_cast<MenuContainer *> (xparent);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
108
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
109 if (menuContainer)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
110 m_parent = menuContainer->menu ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
111
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
112 if (m_parent)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
113 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
114 int pos = static_cast<int> (up.get_position ());
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 if (pos <= 0)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
117 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
118 if (m_separator)
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23457
diff changeset
119 m_parent->insertAction (nullptr, m_separator);
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23457
diff changeset
120 m_parent->insertAction (nullptr, action);
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 int count = 0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
123
27677
92fea2cd024f use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents: 27647
diff changeset
124 for (auto *a : m_parent->actions ())
23224
73f7ef7169ac Make uimenu "Position" property Matlab-compatible (bug #50369).
Rik <rik@octave.org>
parents: 23223
diff changeset
125 if (! a->isSeparator ())
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
126 count++;
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
127
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
128 up.get_property ("position").set
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
129 (octave_value (static_cast<double> (count)), true, false);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
130 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
131 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
132 {
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
133
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
134 int count = 0;
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23449
diff changeset
135 QAction *before = nullptr;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
136
27677
92fea2cd024f use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents: 27647
diff changeset
137 for (auto *a : m_parent->actions ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
138 {
23224
73f7ef7169ac Make uimenu "Position" property Matlab-compatible (bug #50369).
Rik <rik@octave.org>
parents: 23223
diff changeset
139 if (! a->isSeparator ())
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
140 {
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
141 count++;
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
142 if (pos <= count)
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
143 {
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
144 before = a;
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
145 break;
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
146 }
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
147 }
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
148 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
149
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
150 if (m_separator)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
151 m_parent->insertAction (before, m_separator);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
152 m_parent->insertAction (before, action);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
153
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
154 if (before)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
155 updateSiblingPositions ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
156 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
157 up.get_property ("position").set
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
158 (octave_value (static_cast<double> (count+1)), true, false);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
159 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
160 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
161
29542
3d34b70b5a49 connect many Qt signals and slots without SIGNAL and SLOT macros
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
162 connect (action, &QAction::triggered, this, &Menu::actionTriggered);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
163 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
164
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
165 Menu::~Menu (void)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22413
diff changeset
166 { }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
167
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
168 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
169 Menu::update (int pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
170 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
171 uimenu::properties& up = properties<uimenu> ();
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
172 QAction *action = qWidget<QAction> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
173
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
174 switch (pId)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
175 {
29913
3eca54836f97 Allow 'Label' to be used as a synonym for 'Text' on uimenus (bug #60870)
Rik <rik@octave.org>
parents: 29542
diff changeset
176 case uimenu::properties::ID_TEXT:
3eca54836f97 Allow 'Label' to be used as a synonym for 'Text' on uimenus (bug #60870)
Rik <rik@octave.org>
parents: 29542
diff changeset
177 action->setText (Utils::fromStdString (up.get_text ()));
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
178 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
179
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
180 case uimenu::properties::ID_CHECKED:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
181 if (up.is_checked ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
182 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
183 action->setCheckable (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
184 action->setChecked (up.is_checked ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
185 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
186 else
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 action->setChecked (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
189 action->setCheckable (false);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
190 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
191 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
192
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
193 case uimenu::properties::ID_ENABLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
194 action->setEnabled (up.is_enable ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
195 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
196
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
197 case uimenu::properties::ID_ACCELERATOR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
198 if (! action->menu ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
199 action->setShortcut (accelSequence (up));
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
200 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
201
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
202 case uimenu::properties::ID_SEPARATOR:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
203 if (up.is_separator ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
204 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
205 if (! m_separator)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
206 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
207 m_separator = new QAction (action);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
208 m_separator->setSeparator (true);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
209 m_separator->setVisible (up.is_visible ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
210 if (m_parent)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
211 m_parent->insertAction (action, m_separator);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
212 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
213 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
214 else
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
215 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
216 if (m_separator)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
217 delete m_separator;
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23457
diff changeset
218 m_separator = nullptr;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
219 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
220 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
221
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
222 case uimenu::properties::ID_VISIBLE:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
223 action->setVisible (up.is_visible ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
224 if (m_separator)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
225 m_separator->setVisible (up.is_visible ());
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
226 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
227
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
228 case uimenu::properties::ID_POSITION:
19621
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
229 {
af0399a5aae0 untabify QtHandles source files
John W. Eaton <jwe@octave.org>
parents: 19616
diff changeset
230 if (m_separator)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
231 m_parent->removeAction (m_separator);
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
232
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
233 m_parent->removeAction (action);
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
234
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
235 int pos = static_cast<int> (up.get_position ());
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23449
diff changeset
236 QAction *before = nullptr;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
237
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
238 if (pos > 0)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
239 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
240 int count = 0;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
241
27677
92fea2cd024f use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents: 27647
diff changeset
242 for (auto *a : m_parent->actions ())
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
243 {
23224
73f7ef7169ac Make uimenu "Position" property Matlab-compatible (bug #50369).
Rik <rik@octave.org>
parents: 23223
diff changeset
244 if (! a->isSeparator ())
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
245 {
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
246 count++;
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
247 if (pos <= count)
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
248 {
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
249 before = a;
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
250 break;
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
251 }
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
252 }
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
253 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
254 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
255
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
256 if (m_separator)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
257 m_parent->insertAction (before, m_separator);
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
258
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
259 m_parent->insertAction (before, action);
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
260
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
261 updateSiblingPositions ();
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
262 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
263 break;
19967
3cc0734283dc style fixes in Qt graphics code
John W. Eaton <jwe@octave.org>
parents: 19625
diff changeset
264
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
265 default:
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
266 Object::update (pId);
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
267 break;
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
268 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
269 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
270
30398
d4d83344d653 maint: style check C++ files in src/ and libgui/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30100
diff changeset
271 QWidget *
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
272 Menu::menu (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
273 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
274 QAction *action = qWidget<QAction> ();
30100
112e70370b71 *Menu.cc: do not use "_" prefix for local variables
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29992
diff changeset
275 QMenu *action_menu = action->menu ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
276
30100
112e70370b71 *Menu.cc: do not use "_" prefix for local variables
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29992
diff changeset
277 if (! action_menu)
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
278 {
30100
112e70370b71 *Menu.cc: do not use "_" prefix for local variables
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29992
diff changeset
279 action_menu = new QMenu (action->parentWidget ());
112e70370b71 *Menu.cc: do not use "_" prefix for local variables
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29992
diff changeset
280 action->setMenu (action_menu);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
281 action->setShortcut (QKeySequence ());
30100
112e70370b71 *Menu.cc: do not use "_" prefix for local variables
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29992
diff changeset
282 connect (action_menu, &QMenu::aboutToShow, this, &Menu::actionHovered);
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
283 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
284
30100
112e70370b71 *Menu.cc: do not use "_" prefix for local variables
Torsten Lilge <ttl-octave@mailbox.org>
parents: 29992
diff changeset
285 return action_menu;
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
286 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
287
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
288 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
289 Menu::actionTriggered (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
290 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
291 QAction *action = qWidget<QAction> ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
292
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
293 if (action->isCheckable ())
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
294 action->setChecked (! action->isChecked ());
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
295 emit gh_callback_event (m_handle, "menuselectedfcn");
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
296 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
297
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
298 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
299 Menu::actionHovered (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
300 {
30999
fef2957c38ec Deprecate uimenu properties "label" and "callback" (bug #62443)
Rik <rik@octave.org>
parents: 30564
diff changeset
301 emit gh_callback_event (m_handle, "menuselectedfcn");
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
302 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
303
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
304 void
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
305 Menu::updateSiblingPositions (void)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
306 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
307 if (m_parent)
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
308 {
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
309 double count = 1.0;
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
310
27677
92fea2cd024f use standard C++ range-based for loops instead of Qt foreach macro
John W. Eaton <jwe@octave.org>
parents: 27647
diff changeset
311 for (auto *a : m_parent->actions ())
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
312 {
23224
73f7ef7169ac Make uimenu "Position" property Matlab-compatible (bug #50369).
Rik <rik@octave.org>
parents: 23223
diff changeset
313 if (! a->isSeparator ())
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
314 {
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23447
diff changeset
315 Object *aObj = Object::fromQObject (a);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
316
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
317 if (aObj)
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
318 {
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
319 graphics_object go = aObj->object ();
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
320
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
321 // Probably overkill as a uimenu child can only be another
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
322 // uimenu object.
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
323 if (go.isa ("uimenu"))
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
324 {
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
325 uimenu::properties& up = Utils::properties<uimenu> (go);
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
326
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
327 up.get_property ("position").set
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
328 (octave_value (count), true, false);
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
329 }
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
330 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
331
23223
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
332 count++;
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
333 }
4b642b593ec2 maint: Indent foreach blocks in Qt GUI code for readability.
Rik <rik@octave.org>
parents: 23220
diff changeset
334 }
22411
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
335 }
c69805d1fa64 maint: Style check C++ code in libgui/
Rik <rik@octave.org>
parents: 22323
diff changeset
336 }
18498
2e7cad6f180c Initial integration of QtHandles.
John W. Eaton <jwe@octave.org>
parents:
diff changeset
337
22413
8758addcf265 maint: Remove ';' at end of namespace declaration.
Rik <rik@octave.org>
parents: 22411
diff changeset
338 }