RFC: rename or kill KShortcut / add new triggers to KAction
ahartmetz at gmail.com
Sat Nov 4 08:01:10 GMT 2006
2006/11/3, David Faure <faure at kde.org>:
> On Fri Nov 3 2006, Andreas Hartmetz wrote:
> > Hi!
> > I never liked the mess of KAction, KShortcut and KAccel. Hamish Rodda
> > did a nice job cleaning it up and I still don't like the parts that
> > are left.
> > KShortcut is not much more than a QList<QKeySequence> now and I see no
> > good reason to keep it. Applications may need to adapt, but a quick
> > grep through kdebase didn't find any code that really needs KShortcut.
> I'm afraid your grep program is broken :-)
> Just one example from konqueror/konq_mainwindow.cc:
> KShortcut reloadShortcut = KStdAccel::shortcut(KStdAccel::Reload);
> reloadShortcut.append(Qt::CTRL + Qt::Key_R);
> m_paReload = new KAction(KIcon("reload"), i18n( "&Reload" ),
> actionCollection(), "reload" );
> > Additionally, QShortcut exists now (since Qt 4.0) and it is something
> > very different from KShortcut. This violates the principle of least
> > surprise.
> Well it's only "very different" because it supports multiple alternative
> shortcuts, no?
Actually, QShortcut can emit activated() and activatedAmbiguously()
which KShortcut can not. QShortcut also doesn't have KShortcut's badly
named init() methods that IMHO should be called "setKey" like in
And i think it's a bad idea to call a container for several shortcuts
> The above code with QList<QKeySequence> would look a bit uglier.
> Maybe KShortcut should be KShortcuts? ;)
> > What I propose is to:
> > either
> > -remove KShortcut
> > or
> > -rename KShortcut to KActionTriggerSet and make its API very similar
> > to KAction's shortcuts manipulation API. KActionTriggerSet should hold
> > exactly the triggers of one KAction including its default triggers,
> > not more and not less.
> Hmm. I guess this proposal alone wouldn't make much sense (more complicated
> but if that class also holds mouse gestures then I guess it does make sense.
_Generally_, a variable/class name should describe its owner first and
be as short/simple as possible second.
See the "activatedAmbiguously()" signal of QShortcut I mentioned
above. It's a long name but can you come up with a shorter descriptive
> David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
> Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
More information about the kde-core-devel