[Kde-games-devel] KZoomMainWindow and adjustSize() tale :)

Albert Astals Cid aacid at kde.org
Mon Jul 31 19:26:12 CEST 2006


A Dilluns 31 Juliol 2006 12:38, Dmitry Suzdalev va escriure:
> Hello, gamers!
>
> First some facts:
> KZoomMainWindow is used to introduce a common window with "zoomIn",
> "zoomOut" actions.
> Each child widget which supports this actions can call a static
> KZoomMainWindow::addWidget(this) to add itself to KZoomMainWindow pets list
> :). And then, after user activates zoomIn/Out actions, KZoomMainWindows
> walks through the list of its "pet" widgets and calls adjustSize() on each.
> Widgets were supposed to reimplement this adjustSize() method to make
> the zoomed resize.
>
> Well, now the problem:
> In Qt4 adjustSize() is non-virtual. So it can't be safely overridden.
>
> I see two solutions here:
> 1. Drop KZoomMainWindow. Its _separate_ copies are used in libksirtet,
> kreversi, kmines ONLY. And in kdegames only. I checked in lxr.kde.org.
> 2. Don't drop it, but implement something like this instead:
>
> class ZoomableWidget : public QWidget
> {
> ....
> protected:
>      /* This virtual is here instead of adjustSize */
>      virtual void zoomChanged() { }
> ....
> };
>
> class KZoomMainWindow : public KMainWindow
> {
> ....
> public:
>    // earlier had QWidget* param
>    static addWidget( ZoomedWidget*);
> };
>
> And later when KZoomMainWindow iterates over it's zoomable-widgets
> list it should call zoomChanged instead of adjustSize().
>
> Several things to note:
> - why is KZoomMainWindow _explicitly_ defined three times in three
> games, rather than being in libkdegames?
> - is the 2. worth it? That's not a lot funtionality to put it in
> common shared class, wont it be easier to add two slots
> (zoomIn/zoomOut)+three variables(minZoom,maxZoom,zoom) to games that
> need it and be done?

I vote for adding it to libkdegames.

Albert

>
> Thanks in advance for your fast replies,
> Dmitry :).
> _______________________________________________
> kde-games-devel mailing list
> kde-games-devel at kde.org
> https://mail.kde.org/mailman/listinfo/kde-games-devel


More information about the kde-games-devel mailing list