diff --git a/declarativeimports/plasmacomponents/qmenu.cpp b/declarativeimports/plasmacomponents/qmenu.cpp index db613ee7b..b513c4f8e 100644 --- a/declarativeimports/plasmacomponents/qmenu.cpp +++ b/declarativeimports/plasmacomponents/qmenu.cpp @@ -73,6 +73,19 @@ void QMenuProxy::setVisualParent(QDeclarativeItem *parent) emit visualParentChanged(); } +void QMenuProxy::clearMenuItems() +{ + qDeleteAll(m_items); + m_items.clear(); +} + +void QMenuProxy::addMenuItem(const QString &text) +{ + QMenuItem *item = new QMenuItem(this); + item->setText(text); + m_items << item; +} + void QMenuProxy::showMenu(int x, int y) { m_menu->clear(); diff --git a/declarativeimports/plasmacomponents/qmenu.h b/declarativeimports/plasmacomponents/qmenu.h index 0f503efaf..5332a35ef 100644 --- a/declarativeimports/plasmacomponents/qmenu.h +++ b/declarativeimports/plasmacomponents/qmenu.h @@ -52,6 +52,8 @@ public: void showMenu(int x, int y); Q_INVOKABLE void open(); Q_INVOKABLE void close(); + Q_INVOKABLE void clearMenuItems(); + Q_INVOKABLE void addMenuItem(const QString &text); Q_SIGNALS: void statusChanged();