KConfigXT Flaws
Frerich Raabe
raabe at kde.org
Mon Jan 26 09:57:04 GMT 2004
On Sun, Jan 25, 2004 at 06:23:31PM +0100, Frerich Raabe wrote:
> On Sun, Jan 25, 2004 at 03:47:27PM +0100, Waldo Bastian wrote:
> > On Sun January 25 2004 15:44, Frerich Raabe wrote:
> > > - It is not possible to dictate KConfigDialog not to use any default button
> > > at all. This is annoying when you have e.g. a KLineEdit in the dialog:
> > > entering a text there and then pressing return immediately triggers the
> > > default button (which is often "Ok", which in turn closes the dialog). A
> > > workaround is to use cfgDlg.actionButton( Foo )->setDefault( false ), but
> > > that looks clumsy. This flaw is also inherited from KDialogBase.
> > > I suggest adding a new value to the KDialogBase::ButtonCode enumeration
> > > called "None". This value would get ignored in situations other than
> > > specifying a default value. I attached a patch which demonstrates this.
> >
> > Don't see a patch
>
> That's because there was none even though I claimed otherwise. I noticed
> a weird problem which I did not yet find the cause of: the attached patch
> implements this (the "NoDefault" enumeration value) but apparently it does
> not work yet. If I pass "NoDefault" the Ok button does indeed not become
> the default - but instead, always the leftmost button does (for instance,
> if the Help button is in the button mask, then it appears at the very left and
> thus gets marked. If the Help button misses but a Default button is in the mask,
> then it appears at the very left - and gets marked). Maybe you or somebody
> who is more familiar with KDialogBase internals can have a look.
FWIW, I figured this out last night. The cause of this behaviour is
QPushButton's "auto-default" property, which I didn't know before. It's
set to default - except when the parent widget is a QDialog. In that case,
the first button inserted into the dialog will be marked by default.
Since my test application used a horizontal button box, insertion started
at the left side. Consequently, the button at the very left edge was always
selected.
I attached an additional one-liner which deactivates the auto-default feature
of all buttons in the button box. This means that the question of which (if
any) button is the default one solely depends on the defaultButton parameter,
as intended.
- Frerich
-------------- next part --------------
Index: kdialogbase.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kdialogbase.cpp,v
retrieving revision 1.90
diff -u -3 -p -r1.90 kdialogbase.cpp
--- kdialogbase.cpp 30 Nov 2003 21:55:27 -0000 1.90
+++ kdialogbase.cpp 26 Jan 2004 09:13:14 -0000
@@ -219,6 +219,7 @@ KDialogBase::~KDialogBase()
KPushButton *SButton::append( int key, const KGuiItem &item )
{
KDialogBaseButton *p = new KDialogBaseButton( item, key, box );
+ p->setAutoDefault( false );
list.append( p );
return( p );
}
More information about the kde-core-devel
mailing list