KPopupMenu patch

Aaron J. Seigo aseigo at olympusproject.org
Tue Dec 31 00:00:06 GMT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi...

While working on another project I needed to modify KPopupMenu a bit, 
including nicer titles and context menus. I implemented the needed changes 
via a subclass of KPopupMenu. The attatched patch merges these changes into 
KPopupMenu.

The context menu handling allows the application developer to define a context 
menu for a given menu by calling the QPopupMenu* contextMenu() method and 
filling that menu with the appropriate items. By connecting to the void 
aboutToShowContextMenu(KPopupMenu* menu, int menuItem, QPopupMenu* ctxMenu) 
signal, the application can fill the context menu on demand. By connecting to 
the context menu's activated signal and using the static KPopupMenu* 
contextMenuFocus() and int contextMenuFocusItem() methods to retrieve the 
menu and menu item the context menu was operating on, the application can 
take the appropriate actions. This approach also allows using a single slot 
to provide a common contextual functionality to many menus in the same 
application while keeping memory usage down. 

The cost in terms of processing is virtually nill, especially when a context 
menu has not been defined. The cost in terms of memory for an application is 
(9 + (4 * KPopupMenu Instances)) bytes plus whatever context menus are 
defined at run time, if any.

The second enhancement is in the handling of popup menu titles. Currently, 
they are drawn by a static bit of drawing code in the KPopupMenuTitle class. 
They do not follow the style settings and so look out of place. They do allow 
theming, although there is no GUI (that I know of?) to control those options 
and none of the applications in KDE's CVS takes advantage of these theming 
capability according to lxr.kde.org. In this above patch, titles are now 
drawn in the style of a toolbar. Three snapshots showing the old and the new 
titles can be seen at the bottom of the page at:

	http://urbanlizard.com/~aseigo/kpopup/

The gains are quicker processing, a more consistent look, and the ability to 
remove 4 QColor, one KPixmap, one boolean and one KPixmapEffect::GradientType 
member in KDE4. There are also some code clean ups, such as using KMAX and 
kdWarning instead of their Qt equivalents.

I'd like to commit this for 3.2 if people are cool with the changes.

Hrm... speaking of which, I just realized I didn't mark the new methods as 
being new in 3.2. I'll do that before committing, of course...

- -- 
Aaron J. Seigo
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

"Everything should be made as simple as possible, but not simpler"
    - Albert Einstein
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+EN4G1rcusafx20MRAtDiAJ0VNsBJ14h0V5pTG2QDlSK7ckwUpACfaje7
EvKe9qEoUPXhxWmnSnjepDE=
=25Of
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kpopupmenu_with_rmb.diff
Type: text/x-diff
Size: 14230 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20021230/48e169c2/attachment.diff>


More information about the kde-core-devel mailing list