|
This document describes how I converted an existing KDE application to
use the new XML based user interface framework. I chose to use
'kedit' as the example application since it has a combination of
standard and non-standard items and definitely needs to be standards
compliant.
I modified only three files to do this: Makefile.am,
kedit.cpp, and kedit.h. I also added one file:
kdeui.rc
The concepts in this document are quite general and could be applied
to nearly any KDE application.
In some ways, the conversion felt like a search and destroy mission.
I would search for remnents of the old UI code, delete a few lines,
and add one line to replace it.
In general, the procedure is like so:
- Search for any menubar or toolbar code
- When you find the code, determine if the item created is a
"standard" item or is app-specific. You can use either the
KStdAction class or go straight to the source and check the KDE UI
Standards Guide.
- If the item is standard, delete the item and replace it with a
KStdAction action (usually one line of code.. sometimes more). Go
back to step 1 and repeat.
- If the item is app specific, delete the item and replace it with a
new KAction object. The internal name you give the KAction is
important as that will be needed in the next step
- Create (or add to) your app specific XML file. Insert your new
action into the XML using the internal name. Which menu you insert
it into is a judgement call.
- Repeat until all old code is gone
Typically, you'll see a decrease in UI code by a factor of about four.
The files you are looking for are the interface and implementation of
the KMainWindow derived class. Note that if your app does not use
KMainWindow, it cannot (easily) use the XML UI code, either. In
almost all cases with sane naming conventions, this will be something
like 'kmyapp.h' and 'kmyapp.cpp'
If you have local actions (and you probably will), then you will also
need to modify the Makefile.am to add two lines and modify two more.
You will also add a new file to the distribution if you have local
actions.
|