26 #if defined (HAVE_CONFIG_H)
31 #include <QMainWindow>
47 std::string s (up.get_accelerator ());
54 if (c >=
'A' && c <=
'Z')
56 if (c >=
'a' && c <=
'z')
58 if (c >=
'A' && c <=
'Z')
59 return QKeySequence (keyMod |
static_cast<int> (c));
62 return QKeySequence ();
76 return new Menu (oct_qobj, interp, go,
new QAction (qObj),
85 :
Object (oct_qobj, interp, go, action), m_parent (nullptr),
94 action->setCheckable (
true);
95 action->setChecked (up.is_checked ());
98 action->setEnabled (up.is_enable ());
100 action->setVisible (up.is_visible ());
102 if (up.is_separator ())
116 int pos =
static_cast<int> (up.get_position ());
122 m_parent->insertAction (
nullptr, action);
126 for (
auto *a :
m_parent->actions ())
127 if (! a->isSeparator ())
131 (
octave_value (
static_cast<double> (count)),
true,
false);
137 QAction *before =
nullptr;
139 for (
auto *a :
m_parent->actions ())
141 if (! a->isSeparator ())
154 m_parent->insertAction (before, action);
160 (
octave_value (
static_cast<double> (count+1)),
true,
false);
164 connect (action, SIGNAL (triggered (
bool)), SLOT (
actionTriggered (
void)));
174 QAction *action = qWidget<QAction> ();
178 case uimenu::properties::ID_LABEL:
182 case uimenu::properties::ID_CHECKED:
183 if (up.is_checked ())
185 action->setCheckable (
true);
186 action->setChecked (up.is_checked ());
190 action->setChecked (
false);
191 action->setCheckable (
false);
195 case uimenu::properties::ID_ENABLE:
196 action->setEnabled (up.is_enable ());
199 case uimenu::properties::ID_ACCELERATOR:
200 if (! action->menu ())
204 case uimenu::properties::ID_SEPARATOR:
205 if (up.is_separator ())
224 case uimenu::properties::ID_VISIBLE:
225 action->setVisible (up.is_visible ());
230 case uimenu::properties::ID_POSITION:
237 int pos =
static_cast<int> (up.get_position ());
238 QAction *before =
nullptr;
244 for (
auto *a :
m_parent->actions ())
246 if (! a->isSeparator ())
261 m_parent->insertAction (before, action);
276 QAction *action = qWidget<QAction> ();
277 QMenu *_menu = action->menu ();
281 _menu =
new QMenu (action->parentWidget ());
282 action->setMenu (_menu);
283 action->setShortcut (QKeySequence ());
284 connect (_menu, SIGNAL (aboutToShow (
void)),
294 QAction *action = qWidget<QAction> ();
296 if (action->isCheckable ())
297 action->setChecked (! action->isChecked ());
314 for (
auto *a :
m_parent->actions ())
316 if (! a->isSeparator ())
326 if (go.
isa (
"uimenu"))
virtual QWidget * menu(void)=0
void updateSiblingPositions(void)
Menu(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go, QAction *action, Object *parent)
static Menu * create(octave::base_qobject &oct_qobj, octave::interpreter &interp, const graphics_object &go)
void actionTriggered(void)
graphics_object object(void) const
static Object * parentObject(octave::interpreter &interp, const graphics_object &go)
void gh_callback_event(const graphics_handle &h, const std::string &name)
static Object * fromQObject(QObject *obj)
virtual void update(int pId)
virtual QObject * qObject(void)
virtual property get_property(const caseless_str &pname)
bool isa(const std::string &go_name) const
Base class for Octave interfaces that use Qt.
bool set(const octave_value &val, bool do_run=true, bool do_notify_toolkit=true)
const Qt::KeyboardModifier CTRL
QString fromStdString(const std::string &s)
static QKeySequence accelSequence(const uimenu::properties &up)