Re: KConfig - setStandardButtons() breaks Help button?

2016-03-06 Thread Albert Astals Cid
El Sunday 06 March 2016, a les 13:03:26, Frederik Schwarzer va escriure:
> Am Sonntag, 6. März 2016, 12:20:38 schrieb Albert Astals Cid:
> > El Saturday 05 March 2016, a les 08:34:27, Frederik Schwarzer va
> 
> escriure:
> > > Hi,
> > > 
> > > I am struggling with using KConfigDialog. If I use it like this:
> > >  KConfigDialog* dialog = new KConfigDialog(this,
> > >  
> > >  "settings", Settings::self());
> > >  
> > >  connect(dialog, ::settingsChanged,
> > >  
> > >  this, ::loadSettings );
> > >  
> > >  dialog->show();
> > > 
> > > the Help button works.
> > > 
> > > Since in my use case, some of the values in the dialog are
> > > calculated and (to my understanding) cannot be handled correctly
> > > by Kcfg, I want>
> > > 
> > > to get rif of the "Restore Defaults" button. So I add this line:
> > >  dialog->setStandardButtons(QDialogButtonBox::Ok |
> > >  
> > >  QDialogButtonBox::Cancel | QDialogButtonBox::Help);
> > 
> > As a side note, there's ways in which you can make it so the
> > "restore default" button does execute some code for those "tricky"
> > settings (i.e. override updateWidgetsDefaults)
> 
> Hmm, updateWidgetsDefaults() is protected. Would I not have to make my
> own Dialog and inherit from KConfigDialog to overwrite that?

Yes.

> 
> > > but then the Help button does not open the Help browser anymore.
> > > Is that expected? Do I use KConfigDialog incorrectly? Is this just
> > > broken on my system?
> > > 
> > > In case someone wants to see what is happening, I created a semi-
> > > 
> > > minimal buildable example to play with. See:
> > > https://quickgit.kde.org/?p=scratch%2Fschwarzer%2Fkconfigexamp
> > > le.git
> > 
> > As Thomas says you have to recreate the connections, so basically
> > 
> > connect(buttonBox->button(QDialogButtonBox::Help),
> > 
> > SIGNAL(clicked()), q, SLOT(showHelp()));
> 
> This was done before during the KF5 porting but it did not open the
> correct halp page. 

That is very surprising giving how it's exactly what the KConfigDialog code 
does. Worth investigating if you have some time.

Cheers,
  Albert


Re: KConfig - setStandardButtons() breaks Help button?

2016-03-06 Thread Frederik Schwarzer
Am Sonntag, 6. März 2016, 12:20:38 schrieb Albert Astals Cid:
> El Saturday 05 March 2016, a les 08:34:27, Frederik Schwarzer va 
escriure:
> > Hi,
> > 
> > I am struggling with using KConfigDialog. If I use it like this:
> >  KConfigDialog* dialog = new KConfigDialog(this,
> >  
> >  "settings", Settings::self());
> >  
> >  connect(dialog, ::settingsChanged,
> >  
> >  this, ::loadSettings );
> >  
> >  dialog->show();
> > 
> > the Help button works.
> > 
> > Since in my use case, some of the values in the dialog are
> > calculated and (to my understanding) cannot be handled correctly
> > by Kcfg, I want> 
> > to get rif of the "Restore Defaults" button. So I add this line:
> >  dialog->setStandardButtons(QDialogButtonBox::Ok |
> >  
> >  QDialogButtonBox::Cancel | QDialogButtonBox::Help);
> 
> As a side note, there's ways in which you can make it so the
> "restore default" button does execute some code for those "tricky"
> settings (i.e. override updateWidgetsDefaults)

Hmm, updateWidgetsDefaults() is protected. Would I not have to make my 
own Dialog and inherit from KConfigDialog to overwrite that?


> > but then the Help button does not open the Help browser anymore.
> > Is that expected? Do I use KConfigDialog incorrectly? Is this just
> > broken on my system?
> > 
> > In case someone wants to see what is happening, I created a semi-
> > 
> > minimal buildable example to play with. See:
> > https://quickgit.kde.org/?p=scratch%2Fschwarzer%2Fkconfigexamp
> > le.git
> As Thomas says you have to recreate the connections, so basically
> 
> connect(buttonBox->button(QDialogButtonBox::Help),
> SIGNAL(clicked()), q, SLOT(showHelp()));

This was done before during the KF5 porting but it did not open the 
correct halp page. So I removed that part and used the StardardButtons 
to make the help work. ... Leading to other problems. :)

Kigo is q bit complicated in this regard. Even now Applying settings 
with an invalid Go command is breaking the whole game until the next 
restart.
My goal would be to get rid of the "tricky" part alltogether and just 
let the standard config dialog handle everything but it's a lot of 
fiddling to find out what can be done and what can't.

Thanks,
Frederik


Re: KConfig - setStandardButtons() breaks Help button?

2016-03-06 Thread Frederik Schwarzer
Am Sonntag, 6. März 2016, 12:19:14 schrieb Thomas Lübking:
> On Sonntag, 6. März 2016 12:10:36 CEST, Frederik Schwarzer wrote:
> >> The most straight forward solution is likely to hide or delete
> >> button(QDialogButtonBox::RestoreDefaults)
> > 
> > I would like to try this but cannot find info on how to hide a
> > standard button.
> > The KDE 4 version did not have that button either so it's at least
> > not worse than before.
> 
> if (QPushButton *restore =
> button(QDialogButtonBox::RestoreDefaults)) restore->hide();

Meh, KDevelop completed to "QDialogButtonBox::Reset" which then 
compiled but crashed without the if() condifion. :)

Thanks.
Frederik


Re: KConfig - setStandardButtons() breaks Help button?

2016-03-06 Thread Albert Astals Cid
El Saturday 05 March 2016, a les 08:34:27, Frederik Schwarzer va escriure:
> Hi,
> 
> I am struggling with using KConfigDialog. If I use it like this:
> 
>  KConfigDialog* dialog = new KConfigDialog(this,
>  "settings", Settings::self());
>  connect(dialog, ::settingsChanged,
>  this, ::loadSettings );
>  dialog->show();
> 
> the Help button works.
> 
> Since in my use case, some of the values in the dialog are calculated
> and (to my understanding) cannot be handled correctly by Kcfg, I want
> to get rif of the "Restore Defaults" button. So I add this line:
> 
>  dialog->setStandardButtons(QDialogButtonBox::Ok |
>  QDialogButtonBox::Cancel | QDialogButtonBox::Help);

As a side note, there's ways in which you can make it so the "restore default" 
button does execute some code for those "tricky" settings (i.e. override 
updateWidgetsDefaults)

> 
> but then the Help button does not open the Help browser anymore.
> Is that expected? Do I use KConfigDialog incorrectly? Is this just
> broken on my system?
> 
> In case someone wants to see what is happening, I created a semi-
> minimal buildable example to play with. See:
> https://quickgit.kde.org/?p=scratch%2Fschwarzer%2Fkconfigexample.git

As Thomas says you have to recreate the connections, so basically

connect(buttonBox->button(QDialogButtonBox::Help), SIGNAL(clicked()), 
q, SLOT(showHelp()));

Cheers,
  Albert

> 
> I am thankful for any hint. :)
> 
> Regards,
> Frederik



Re: KConfig - setStandardButtons() breaks Help button?

2016-03-06 Thread Frederik Schwarzer
Am Samstag, 5. März 2016, 10:53:18 schrieb Thomas Lübking:
> On Samstag, 5. März 2016 08:34:27 CEST, Frederik Schwarzer wrote:

Hi,

> > Since in my use case, some of the values in the dialog are
> > calculated and (to my understanding) cannot be handled correctly
> > by Kcfg, I want> 
> > to get rif of the "Restore Defaults" button. So I add this line:
> >  dialog->setStandardButtons(QDialogButtonBox::Ok |
> >  
> >  QDialogButtonBox::Cancel | QDialogButtonBox::Help);
> > 
> > but then the Help button does not open the Help browser anymore.
> > 
> ::setStandardButtons simply forwards the call to the internal button
> ::box which nukes all button objects (incl. their slot connections)
> ::and recreates them w/ the new item list.

Ok, reading it like this, the behaviour suddenly makes sense. :)


> The most straight forward solution is likely to hide or delete
> button(QDialogButtonBox::RestoreDefaults)

I would like to try this but cannot find info on how to hide a 
standard button.
The KDE 4 version did not have that button either so it's at least not 
worse than before.


> Rather replace the restore defaults button, resp. re-link it to your
> own calculation slot.

I will add a comment that this is better and should be considered in 
the future.

Thanks for the hints.

Regards,
Frederik


Re: KConfig - setStandardButtons() breaks Help button?

2016-03-05 Thread Thomas Lübking

On Samstag, 5. März 2016 08:34:27 CEST, Frederik Schwarzer wrote:

Since in my use case, some of the values in the dialog are calculated 
and (to my understanding) cannot be handled correctly by Kcfg, I want 
to get rif of the "Restore Defaults" button. So I add this line:


 dialog->setStandardButtons(QDialogButtonBox::Ok |
 QDialogButtonBox::Cancel | QDialogButtonBox::Help);

but then the Help button does not open the Help browser anymore.



::setStandardButtons simply forwards the call to the internal button box which 
nukes all button objects (incl. their slot connections) and recreates them w/ 
the new item list.
The most straight forward solution is likely to hide or delete 
button(QDialogButtonBox::RestoreDefaults)

Otherwise you'll have to grep through to the buttonbox and remove it 
"correctly" or rebind the help button to the showHelp() slot.
It though looks like you'd destroy more bindings by resetting the 
standardButtons (which you all need to restore)


I'm not sure the HIG team would like to remove the defaults button, though.
:-P

Rather replace the restore defaults button, resp. re-link it to your own 
calculation slot.


Cheers,
Thomas