aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/objects
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/objects')
-rw-r--r--src/modules/objects/class_popupmenu.cpp45
-rw-r--r--src/modules/objects/class_popupmenu.h2
2 files changed, 46 insertions, 1 deletions
diff --git a/src/modules/objects/class_popupmenu.cpp b/src/modules/objects/class_popupmenu.cpp
index aa3d50b17..f90674758 100644
--- a/src/modules/objects/class_popupmenu.cpp
+++ b/src/modules/objects/class_popupmenu.cpp
@@ -57,6 +57,9 @@
@functions:
!fn: $insertItem(<text:string>,[icon_id:string])
Inserts menu items into a popup menu with optional icon and return the popup identifier.
+ !fn: $addMenu(<popupmenu:hobject,[idx:uinteger])
+ Add a popupmenu.
+ With the optional parameter idx the popup will be inserted.
!fn: $setTitle(<text:string>)
Sets the popupmenu title to text.
!fn: $exec([<widget:objects>,<x:uinteger>,<y:integer>])
@@ -169,6 +172,7 @@ KVSO_BEGIN_REGISTERCLASS(KviKvsObject_popupmenu,"popupmenu","widget")
KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_popupmenu,exec)
KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_popupmenu,insertSeparator)
KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_popupmenu,removeItem)
+ KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_popupmenu,addMenu)
// events
KVSO_REGISTER_HANDLER_BY_NAME(KviKvsObject_popupmenu,highlightedEvent)
@@ -255,6 +259,47 @@ KVSO_CLASS_FUNCTION(popupmenu,exec)
return true;
}
+
+
+KVSO_CLASS_FUNCTION(popupmenu,addMenu)
+{
+ CHECK_INTERNAL_POINTER(widget())
+ KviKvsObject *pObject;
+ kvs_uint_t iIdx;
+ kvs_hobject_t hObject;
+ KVSO_PARAMETERS_BEGIN(c)
+ KVSO_PARAMETER("popupmenu",KVS_PT_HOBJECT,0,hObject)
+ KVSO_PARAMETER("index",KVS_PT_UNSIGNEDINTEGER,KVS_PF_OPTIONAL,iIdx)
+ KVSO_PARAMETERS_END(c)
+ pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
+ if (!pObject)\
+ {
+ c->warning(__tr2qs_ctx("Popup menu parameter is not an object","objects"));\
+ return true;
+ }
+ if (!pObject->object())\
+ {
+ c->warning(__tr2qs_ctx("Popup menu parameter is not a valid object","objects"));\
+ return true;\
+ }
+ if(!pObject->inheritsClass("popupmenu"))\
+ {\
+ c->warning(__tr2qs_ctx("Popupmenu object required","objects"));\
+ return true;\
+ }
+ QAction *pAction;
+ if(iIdx)
+ {
+ QAction *pActionBefore=actionsDict[iIdx];
+ pAction=((QMenu *)widget())->insertMenu(pActionBefore,(QMenu*)pObject->object());
+ }
+ else pAction=((QMenu *)widget())->addMenu((QMenu*)pObject->object());
+ actionsDict[identifier]=pAction;
+ c->returnValue()->setInteger(identifier);
+ identifier++;
+ return true;
+}
+
KVSO_CLASS_FUNCTION(popupmenu,removeItem)
{
CHECK_INTERNAL_POINTER(widget())
diff --git a/src/modules/objects/class_popupmenu.h b/src/modules/objects/class_popupmenu.h
index ed4dad066..287cfaaef 100644
--- a/src/modules/objects/class_popupmenu.h
+++ b/src/modules/objects/class_popupmenu.h
@@ -43,7 +43,7 @@ protected:
int identifier;
bool insertItem(KviKvsObjectFunctionCall *c);
bool setTitle(KviKvsObjectFunctionCall *c);
- //bool insertWidget(KviKvsObjectFunctionCall *c);
+ bool addMenu(KviKvsObjectFunctionCall *c);
//bool insertHandle(KviKvsObjectFunctionCall *c);
bool exec(KviKvsObjectFunctionCall *c);
bool removeItem(KviKvsObjectFunctionCall *c);