26 #if defined (HAVE_CONFIG_H)
31 #include <QMainWindow>
46 std::string s (up.get_accelerator ());
53 if (c >=
'A' && c <=
'Z')
55 if (c >=
'a' && c <=
'z')
57 if (c >=
'A' && c <=
'Z')
58 return QKeySequence (keyMod |
static_cast<int> (c));
61 return QKeySequence ();
65 Menu::create (octave::base_qobject& oct_qobj, octave::interpreter& interp,
66 const graphics_object& go)
75 return new Menu (oct_qobj, interp, go,
new QAction (qObj),
82 Menu::Menu (octave::base_qobject& oct_qobj, octave::interpreter& interp,
83 const graphics_object& go, QAction *action,
Object *xparent)
84 :
Object (oct_qobj, interp, go, action), m_parent (nullptr),
93 action->setCheckable (
true);
94 action->setChecked (up.is_checked ());
97 action->setEnabled (up.is_enable ());
99 action->setVisible (up.is_visible ());
101 if (up.is_separator ())
115 int pos =
static_cast<int> (up.get_position ());
121 m_parent->insertAction (
nullptr, action);
125 for (
auto *a :
m_parent->actions ())
126 if (! a->isSeparator ())
129 up.get_property (
"position").set
130 (
octave_value (
static_cast<double> (count)),
true,
false);
136 QAction *before =
nullptr;
138 for (
auto *a :
m_parent->actions ())
140 if (! a->isSeparator ())
153 m_parent->insertAction (before, action);
158 up.get_property (
"position").set
159 (
octave_value (
static_cast<double> (count+1)),
true,
false);
173 QAction *action = qWidget<QAction> ();
177 case uimenu::properties::ID_TEXT:
181 case uimenu::properties::ID_CHECKED:
182 if (up.is_checked ())
184 action->setCheckable (
true);
185 action->setChecked (up.is_checked ());
189 action->setChecked (
false);
190 action->setCheckable (
false);
194 case uimenu::properties::ID_ENABLE:
195 action->setEnabled (up.is_enable ());
198 case uimenu::properties::ID_ACCELERATOR:
199 if (! action->menu ())
203 case uimenu::properties::ID_SEPARATOR:
204 if (up.is_separator ())
223 case uimenu::properties::ID_VISIBLE:
224 action->setVisible (up.is_visible ());
229 case uimenu::properties::ID_POSITION:
236 int pos =
static_cast<int> (up.get_position ());
237 QAction *before =
nullptr;
243 for (
auto *a :
m_parent->actions ())
245 if (! a->isSeparator ())
260 m_parent->insertAction (before, action);
275 QAction *action = qWidget<QAction> ();
276 QMenu *action_menu = action->menu ();
280 action_menu =
new QMenu (action->parentWidget ());
281 action->setMenu (action_menu);
282 action->setShortcut (QKeySequence ());
292 QAction *action = qWidget<QAction> ();
294 if (action->isCheckable ())
295 action->setChecked (! action->isChecked ());
312 for (
auto *a :
m_parent->actions ())
314 if (! a->isSeparator ())
320 graphics_object go = aObj->
object ();
324 if (go.isa (
"uimenu"))
328 up.get_property (
"position").set
void gh_callback_event(const graphics_handle &h, const std::string &name)
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
static Object * fromQObject(QObject *obj)
graphics_object object(void) const
virtual QObject * qObject(void)
virtual void update(int pId)
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
const Qt::KeyboardModifier CTRL
QString fromStdString(const std::string &s)
T::properties & properties(graphics_object obj)