From kde-devel Mon Feb 25 16:16:49 2002 From: Jason Harris Date: Mon, 25 Feb 2002 16:16:49 +0000 To: kde-devel Subject: problem with ActionList (long) X-MARC-Message: https://marc.info/?l=kde-devel&m=101465392909963 Hello, I'm trying to add dynamic menu items to my app (KStars) using XMLGUI, but I can't get it to work. I was hoping someone here might be able to see what I am doing wrong. I've followed the example at: http://developer.kde.org/documentation/kde2arch/xmlgui.html and I've also looked at the konqueror source code. I have the following in my kstarsui.rc: &Settings ... and the following in my source code: //in class definition (header file): QPtrList colorActions; //in source code file: //these actions don't take actionCollection() as a parent //(use (QObject*)0 instead) KAction *actCSDefault = new KAction( i18n( "&Default" ), 0, this, SLOT( ks->mDefaultScheme(int) ), (QObject*)0, "cs_def" ); KAction *actCSChart = new KAction( i18n( "&Star Chart" ), 0, this, SLOT( ks->mChartScheme(int) ), (QObject*)0, "cs_chart" ); KAction *actCSNight = new KAction( i18n( "&Night Vision" ), 0, this, SLOT( ks->mNightScheme(int) ), (QObject*)0, "cs_night" ); colorActions.setAutoDelete( true ); colorActions.clear(); colorActions.append( actCSDefault ); colorActions.append( actCSChart ); colorActions.append( actCSNight ); plugActionList( "colorschemes", colorActions ); When I run the program, the menu items don't appear in the menu. I tried moving the above code to both before and after createGUI("kstarsui.rc") is called, but it doesn't seem to make a difference (which location is correct?) I also dug around in kdelibs, trying to track down the problem. I found that in KXMLGUIFactory::plugActionList(), in the following statement: d->clientName = client->domDocument().documentElement().attribute( d->attrName ); "d->clientName" is assigned an empty string. and so, in ContainerNode::plugActionList(), it returns prematurely when it gets to the statement: if ( mergingIdx.clientName != state.clientName ) return; because mergingIdx.clientName is "colorschemes" but state.clientName is empty. If I comment these two lines out, then my menu items appear in the menu. I'm afraid I don't know enough about KDE's XMLGUI functions to really understand what's happening here. Can anyone see something obvious that I've done wrong? Or perhaps point me to some more documentation/examples on using XMLGUI to create dynamic menu items? Thanks in advance, and please cc me on any replies. sincerely, Jason Harris -- KStars: A K Desktop Planetarium http://kstars.sourceforge.net >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<