This forum has been archived. All content is frozen. Please use KDE Discuss instead.

XML GUI system puts actions at the wrong place

Tags: solved solved solved
(comma "," separated)
User avatar
urwald
Registered Member
Posts
30
Karma
0
OS
Hello.

In my application, KRadioRipper, I have 2 problems the KDEs XMLGUI.

1.) The action for "paste" is created by KStandardAction.paste(). That's convenient (automatically you get an icon, appropriate shortcut...). However, "paste" shown now up in the toolbar - but in kradioripperui.rc I have inserted it only in the menu, not in the toolbar. Why does it also shows up in the toolbar and how can I avoid this?

2.) In the menu "Help", the entry "KRadioRipper Handbook F1" is created automatically - without that I have requested this in kradioripperui.rc. How can I avoid that this entry shows up? (Actually, there is no handbook, and I think for the user it's always frustrating to click on a "help" button and than get nothing).

I'm thankful for every hint.

Tim


urwald, proud to be a member of KDE forums since 2008-Oct.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
This is because they are provided by KXmlGui itself, as determined by the main Xml files from which yours inherits. You will need to use the following method, using your own custom name instead.

Change "custompaste" and "pasteSlot()" as needed.

Code: Select all
KStandardAction::paste(this, SLOT(pasteSlot()), actionCollection(), "custompaste");


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
urwald
Registered Member
Posts
30
Karma
0
OS
Hm, actually I use

Code: Select all
  pasteAction = KStandardAction::paste(m_streamlistwidget->stationlistmodel(),
                                       SLOT(paste()),
                                       actionCollection());


When I add a 4. argument, it doesn't compile anymore. And in the apidoc for KStandardAction namespace, there is also only a function with 3 arguments.

However, I can workaround by creating the paste action manually (by KAction itself, not by KStandardAction). That's not convenient, but works.

More important is my 2. question: How do I avoid that an entry for a handbook shows up in the menu? This action I haven't even created in the source code. How can I influence that?


urwald, proud to be a member of KDE forums since 2008-Oct.
User avatar
urwald
Registered Member
Posts
30
Karma
0
OS
I've made some experiments with kDebug() and found out how it works:

KXmlGuiWindow::setupGUI() creates a certain number of KAction objects, including an action for the handbook. It has the name "help_contents". With the following code, it is accessible and can be disabled or even removed:

Code: Select all
QAction *helpContentsAction = actionCollection()->action("help_contents");
if (!(helpContentsAction == 0)) {
  helpContentsAction->setEnabled(false);
  // delete helpContentsAction;
};


urwald, proud to be a member of KDE forums since 2008-Oct.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I actually meant this... oops.
http://api.kde.org/4.x-api/kdelibs-apid ... 8c2835d8f6

You can also use the appropriate remove() argument of KActionCollection which will hide it correctly.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
urwald
Registered Member
Posts
30
Karma
0
OS
This one is very good. Thanks.

Problem is SOLVED


urwald, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]