Handling of default button in KDialog broken

Lubos Lunak l.lunak at suse.cz
Fri Jul 4 14:08:36 BST 2008


 Hello,

 could somebody please review the attached patch? It appears that KDialog has 
a bug with (not) setting the default button properly, which has been there 
since about forever.

 A demo of this bug is the timeout dialog after you enable compositing for 
KWin. If compositing setup fails for any reason and all you get is e.g. a 
black screen, it's quite possible that instead of waiting those 10 seconds 
for the dialog to revert (about which you may not know if you can't see the 
dialog) you will start hitting "random" keys on the keyboard, say Enter or 
Space, and will actually confirm the dialog. Even though the default button 
is the cancel one.

 The KDialog code has some function called setButtonFocus(), which however 
seems to be just a thin wrapper used for confusing things. Making a button 
default does not set focus to it, making it useless in many cases. It appears 
that e.g. KMessageBox works this around by explicitly later setting focus to 
the button (which however actually resets the button from being the default). 
I suggest the attached patch, which will normally make default buttons 
focused by default (and consistent with QMessageBox::setDefaultButton()).

 Does somebody see a problem with it?

-- 
Lubos Lunak
KDE developer
--------------------------------------------------------------
SUSE LINUX, s.r.o.   e-mail: l.lunak at suse.cz , l.lunak at kde.org
Lihovarska 1060/12   tel: +420 284 028 972
190 00 Prague 9      fax: +420 284 028 951
Czech Republic       http://www.suse.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdeui.patch
Type: text/x-diff
Size: 1874 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080704/760a689d/attachment.patch>


More information about the kde-core-devel mailing list