proposal for kaction api change

Jens Herden jens at kdewebdev.org
Fri May 5 03:45:34 BST 2006


Hi,

inspired by a discussion on kde-devel I was looking into kaction and I would 
like to propose to clean up the interface a little. There are many methods 
related to shortcuts and I think we should reduce them.

Basicly we have now two shortcut types, one custom and one global plus default 
values for both, makes four different shortcuts in total.

There is a enum which covers two of the four:

enum ShortcutType {
      /// The shortcut is a custom shortcut
      CustomShortcut = 0x1,
      /// The shortcut is a default shortcut
      DefaultShortcut = 0x2
    };

But the distinction between global/local is done by different method names. We 
could reduce the number of methods if we would change our enum like:

enum ShortcutType {
      /// normal shortcut
      Shortcut = 0x1,
      /// default shortcut
      DefaultShortcut = 0x2
      /// global shortcut
      GlobalShortcut = 0x4
      /// default global shortcut
      DefaultGlobalShortcut = 0x8
    };

and use only one setter and getter for our shortcuts, like:

setKShortcut(setShortcut(const KShortcut& shortcut, ShortcutTypes type = 
          static_cast<ShortcutType>(Shortcut | DefaultShortcut));

const KShortcut& kShortcut(ShortcutTypes types = Shortcut) const;

Please note that the names are intentional not setShortcut() and shortcut() 
because I do not want to hide the QAction methods. 

I would remove then:
	customShortcut()
	setCustomShortcut()
	defaultShortcut()
	setDefaultShortcut()
	globalShortcut()
	setGlobalShortcut()
	customGlobalShortcut()
	setCustomGlobalShortcut()
	defaultGlobalShortcut()
	setDefaultGlobalShortcut()
	setShortcut()
	shortcut()

This change would be more in line with how QAction is working, there you have 
also one enum to describe the way how the shortcuts works. I also believe 
that most users of the class would be happy with the default values for 
setting and getting a shortcut, so that they don't have to worry about which 
method would be the right one. 

I am looking forward to get comments.

Jens
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060505/f49f8aad/attachment.sig>


More information about the kde-core-devel mailing list