[Kde-games-devel] The status bar and the Difficulty Level widget

Ian Wadham iandw.au at gmail.com
Sun Jan 8 01:19:56 UTC 2012


On 07/01/2012, at 1:45 PM, Parker Coates wrote:

> On Fri, Jan 6, 2012 at 19:01, Ian Wadham wrote:
>> Libkdegames' standard Difficulty Level widget always appears in the
>> status bar, so if you use it you must have a status bar.
>> 
>> Would anyone have any objections if I modified libkdegames to provide
>> an option to return a Difficulty Level widget that can be placed anywhere,
>> leaving the status bar as the default position?
> 
> I'm not sure returning a widget is the cleanest API. I'm guessing
> you're talking about some sort of "KComboBox *
> KGameDifficulty::comboBox()" method, but that raises a couple issues.
> Who owns the widget returned? If the method is called second time, is
> a pointer to the same widget returned or a pointer to a new widget?
> 
> Personally, I'd recommend to instead create a new
> KGameDifficultyComboBox class the inherits KComboBox and automatically
> hooks itself up KGameDifficulty. It would probably just be a matter of
> make the existing widget public.

Thanks, Parker.  ATM I would like to establish that there is no earth-shattering
reason why the KGameDifficulty combo box has to be in the status bar.

Maybe the simplest way to change KGameDifficulty is to add a KComboBox *
parameter to KGameDifficulty::init(), with default value zero.  If the parameter
is supplied, the KGameDifficulty::init() code could simply not execute the lines
        m_comboBox = new KComboBox(window);
and
        window->statusBar()->addPermanentWidget(m_comboBox);
and instead do
        m_comboBox = comboBoxParameter;
All the other references to m_comboBox appear to work the same, no
matter where the combo box comes from.

IOW the application would create the combo box, owned by whatever widget
contains it, and would then use KGameDifficulty to operate it.

An alternative would be to overload KGameDifficulty::init() or add a method
KGameDifficulty::initComboBox() that provides the extra parameter.  I am not
sure which way would be best.  I think the last would be BC and the others SC.

Cheers, Ian W.





More information about the kde-games-devel mailing list