obsolete(?) code in KApplication::notify()

Andreas Hartmetz ahartmetz at gmail.com
Fri Nov 17 17:45:32 GMT 2006


2006/11/17, Reinhold Kainhofer <reinhold at kainhofer.com>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Am Freitag, 17. November 2006 17:45 schrieb Andreas Hartmetz:
> > Hi!
> >
> > While browsing kdelibs(4) to find use cases of KShortcut, I found some
> > really wrong looking and undocumented code in KApplication::notify().
> > To get you a quick impression, here is the beginning of the code in
> > question:
> >
> [...]
> >        static const KShortcut& _selectAll = KStdAccel::selectAll();
> [...]
> >           int key = kevent->key() | kevent->modifiers();
> >           if (_selectAll.contains(key))
> >           {
> >              if (t == QEvent::KeyPress)
> >              {
> >                 edit->selectAll();
> >                 return true;
> >              }
> >              else
> >              {
> >                 kevent->accept();
> >              }
> >           }
> > ## snip ##
> >
> > Strangely, other widgets seem to get their events just fine without
> > special hacks in KApplication.
>
> Without looking at the codepathes, the "special hacks" seem to be needed to
> let the Q* widget use the KDE shortcuts form kcontrol. E.g. you can change
> the shortcut for "Select all" from Ctrl+A to something else. That code from
> above makes this possible. But then, I might be wrong, too.
>
> Unfortunately, it seems that (at least in kde 3.5.5) changing the Shortcut
> for "Cut" does not seem to work in konqui's URL bar. Only Ctrl+X works, even
> though I changed that in kcontrol to something different.
>
> Cheers,
> Reinhold
> - --
> - ------------------------------------------------------------------
> Reinhold Kainhofer, Vienna University of Technology, Austria
> email: reinhold at kainhofer.com, http://reinhold.kainhofer.com/
>  * Financial and Actuarial Mathematics, TU Wien,
> http://www.fam.tuwien.ac.at/
>  * K Desktop Environment, http://www.kde.org, KOrganizer maintainer
>  * Chorvereinigung "Jung-Wien", http://www.jung-wien.at/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (GNU/Linux)
>
> iD8DBQFFXevcTqjEwhXvPN0RAmJHAJ9m84XCCuwgUcQtzlEfVBLFFzT0zACfSU0K
> CCiJvc23DKV7zDJFxXhWZW8=
> =89xC
> -----END PGP SIGNATURE-----
>
Actually, the code goes on like this:
## snip ##
          // Ctrl-U deletes from start of line.
          if (key == Qt::CTRL + Qt::Key_U)
          {
             if (t == QEvent::KeyPress)
             {
                if (!edit->isReadOnly())
                {
                   QString t(edit->text());
                   t = t.mid(edit->cursorPosition());
                   // TODO: how to port correctly?
                   // edit->validateAndSet(t, 0, 0, 0);
                   edit->setText( t );
                }
                return true;
             }
             else
             {
                kevent->accept();
             }

          }
       }
(more code follows)
## snip ##
As I said, it looks really, _really_ wrong, including hardcoded key shortcuts.




More information about the kde-core-devel mailing list