[Panel-devel] [Patch] LineEdit::setGeometry

Matt Broadstone mbroadst at gmail.com
Sun Aug 5 23:41:41 CEST 2007


On 8/5/07, Aaron J. Seigo <aseigo at kde.org> wrote:
> On Sunday 05 August 2007, Matt Broadstone wrote:
> > On 8/5/07, Aaron J. Seigo <aseigo at kde.org> wrote:
> > > so .... are layouts working right now or not? what changes are/were
> > > needed in layouts / widgets to fix it?
> >
> > Depending on your definition of the word "fixed".
>
> "widgets get layed out with proper geometry"
Yeah however, I think we should expand fixed to include, this piece of
code runs:

int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QGraphicsView view;
    QGraphicsScene scene;
    view.setScene(&scene);

    Plasma::Widget *widget = new Plasma::Widget;
    Plasma::VBoxLayout *widgetLayout = new Plasma::VBoxLayout(widget);

    Plasma::PushButton *pushOne = new Plasma::PushButton("pushbutton one");
    Plasma::PushButton *pushTwo = new Plasma::PushButton("pushbutton two");
    widgetLayout->addItem(pushOne);
    widgetLayout->addItem(pushTwo);

    scene.addItem(widget);
    view.show();

    return app.exec();
}

Just like you would expect it to given work with Qt in the past.
Currently the way layouts work looks something more like this:
int main(int argc, char **argv)
{
    QApplication app(argc, argv);

    QGraphicsView view;
    QGraphicsScene scene;
    view.setScene(&scene);

    Plasma::VBoxLayout *widgetLayout = new Plasma::VBoxLayout(0);
    widgetLayout->setGeometry( QRectF(0.0, 0.0, 100.0, 100.0) );

    Plasma::PushButton *pushOne = new Plasma::PushButton("pushbutton one");
    Plasma::PushButton *pushTwo = new Plasma::PushButton("pushbutton two");
    widgetLayout->addItem(pushOne);
    widgetLayout->addItem(pushTwo);

    scene.addItem(pushOne);
    scene.addItem(pushTwo);
    view.show();

    return app.exec();
}
Which I think is just crazy, and not intuitive :)

> > Yes layout are back
> > to where they were. What needed to be fixed was the fact that all
> > widgets were implementing their own form of size hint information
>
> which makes sense, really...
Yep

>
> > (minimumSize maximumSize sizeHint etc) and I deleted that, stupidly
> > assuming that Plasma::Widget was smart enough to handle this stuff ;)
>
> hm... would it make sense to put those methods back then?
>
Yes I did do that. Read below for what I meant..

> > Anyway, we need to make Plasma::Widget a WHOLE lot more comprehensive,
>
> what did you discover is missing?
What I mean by more comprehensive (aside from my code example
earlier), is that the minimumSize, maximumSize and sizeHint and
friends should be much smarter with sensible defaults (why they
currently do not have). Further, Plasma::Widget subclasses should
probably be using sizeHint to define their size instead of
boundingRects, and Widget's boundingRect should just return a smart
sized based on some clamping sizeHint between min and max size. Had we
had this type of sensible default code, me just making PushButton a
Widget subclass and chopping out all those reimplemented methods
probably would have just worked and not broken anything.

_Lastly_ I've begun making some test programs in
workspace/libs/plasma/widgets/tests, which are not unit tests, but
just executables that are built during build time and not installed
just testing some of the functionality of our widgets that we can
verify visually. For instance, the code above is in an executable
called testLayouts right now. I'll commit it later on today, but I
would LOVE it if we sort of made it a rule to add a test or two before
anyone adds new widgets because we currently have no way of testing
whether changes are breaking anything until we get people screaming on
irc or on the dev lists ;)

Having said all this, I'm working on it, and code is on its way. It's
taken me a day or two to finish off some of the Widget classes and
digest the code to see a path, but I'm on the way now.

I'm in touch with Matias on irc, anyone else involved in Widgets
currently (not sure if Siraj's around or not?) and Layouts that's
interested knows where to find me.

Cheers,
   Matt

>
> --
> Aaron J. Seigo
> humru othro a kohnu se
> GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43
>
> KDE core developer sponsored by Trolltech
>
> _______________________________________________
> Panel-devel mailing list
> Panel-devel at kde.org
> https://mail.kde.org/mailman/listinfo/panel-devel
>
>
>


More information about the Panel-devel mailing list