use anchorlayout, quite a good quantity of code wiped out,
workaround to an annoying anchorlayout crasher tough svn path=/trunk/KDE/kdelibs/; revision=1038665
This commit is contained in:
parent
637a50e17c
commit
7e80fdd8f1
@ -21,6 +21,7 @@
|
||||
//Qt
|
||||
#include <QGraphicsSceneResizeEvent>
|
||||
#include <QGraphicsGridLayout>
|
||||
#include <QGraphicsAnchorLayout>
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
@ -94,14 +95,15 @@ public:
|
||||
topBorder->setSvg(borderSvg);
|
||||
topBorder->setElementID("border-top");
|
||||
topBorder->setZValue(900);
|
||||
topBorder->resize(topBorder->effectiveSizeHint(Qt::PreferredSize));
|
||||
topBorder->show();
|
||||
bordersLayout->addAnchors(bordersLayout, topBorder, Qt::Horizontal);
|
||||
bordersLayout->addAnchor(bordersLayout, Qt::AnchorTop, topBorder, Qt::AnchorTop);
|
||||
|
||||
bottomBorder = new Plasma::SvgWidget(q);
|
||||
bottomBorder->setSvg(borderSvg);
|
||||
bottomBorder->setElementID("border-bottom");
|
||||
bottomBorder->setZValue(900);
|
||||
bottomBorder->resize(bottomBorder->effectiveSizeHint(Qt::PreferredSize));
|
||||
bottomBorder->show();
|
||||
bordersLayout->addAnchors(bordersLayout, bottomBorder, Qt::Horizontal);
|
||||
bordersLayout->addAnchor(bordersLayout, Qt::AnchorBottom, bottomBorder, Qt::AnchorBottom);
|
||||
} else if (topBorder && widget && widget->size().height() <= q->size().height()) {
|
||||
//FIXME: in some cases topBorder->deleteLater() is deleteNever(), why?
|
||||
topBorder->hide();
|
||||
@ -118,14 +120,16 @@ public:
|
||||
leftBorder->setSvg(borderSvg);
|
||||
leftBorder->setElementID("border-left");
|
||||
leftBorder->setZValue(900);
|
||||
leftBorder->resize(leftBorder->effectiveSizeHint(Qt::PreferredSize));
|
||||
leftBorder->show();
|
||||
bordersLayout->addAnchors(bordersLayout, leftBorder, Qt::Vertical);
|
||||
bordersLayout->addAnchor(bordersLayout, Qt::AnchorLeft, leftBorder, Qt::AnchorLeft);
|
||||
|
||||
rightBorder = new Plasma::SvgWidget(q);
|
||||
rightBorder->setSvg(borderSvg);
|
||||
rightBorder->setElementID("border-right");
|
||||
rightBorder->setZValue(900);
|
||||
rightBorder->resize(rightBorder->effectiveSizeHint(Qt::PreferredSize));
|
||||
rightBorder->show();
|
||||
bordersLayout->addAnchors(bordersLayout, rightBorder, Qt::Vertical);
|
||||
bordersLayout->addAnchor(bordersLayout, Qt::AnchorRight, rightBorder, Qt::AnchorRight);
|
||||
|
||||
} else if (leftBorder && widget && widget->size().width() <= q->size().width()) {
|
||||
leftBorder->hide();
|
||||
rightBorder->hide();
|
||||
@ -137,17 +141,6 @@ public:
|
||||
|
||||
layout->activate();
|
||||
|
||||
if (topBorder) {
|
||||
topBorder->resize(q->size().width(), topBorder->size().height());
|
||||
bottomBorder->resize(q->size().width(), bottomBorder->size().height());
|
||||
bottomBorder->setPos(0, q->size().height() - topBorder->size().height());
|
||||
}
|
||||
if (leftBorder) {
|
||||
leftBorder->resize(leftBorder->size().width(), q->size().height());
|
||||
rightBorder->resize(rightBorder->size().width(), q->size().height());
|
||||
rightBorder->setPos(q->size().width() - rightBorder->size().width(), 0);
|
||||
}
|
||||
|
||||
QSizeF widgetSize = widget->size();
|
||||
if (widget->sizePolicy().expandingDirections() & Qt::Horizontal) {
|
||||
//keep a 1 pixel border
|
||||
@ -214,6 +207,7 @@ public:
|
||||
|
||||
ScrollWidget *q;
|
||||
QGraphicsWidget *scrollingWidget;
|
||||
QGraphicsAnchorLayout *bordersLayout;
|
||||
QGraphicsWidget *widget;
|
||||
Plasma::Svg *borderSvg;
|
||||
Plasma::SvgWidget *topBorder;
|
||||
@ -238,8 +232,11 @@ ScrollWidget::ScrollWidget(QGraphicsWidget *parent)
|
||||
{
|
||||
d->layout = new QGraphicsGridLayout(this);
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
d->layout->setContentsMargins(1, 1, 1, 1);
|
||||
d->layout->setContentsMargins(0, 0, 0, 0);
|
||||
d->scrollingWidget = new QGraphicsWidget(this);
|
||||
d->bordersLayout = new QGraphicsAnchorLayout(d->scrollingWidget);
|
||||
//FIXME:setContentsMargins(0) crashes AnchorLayout
|
||||
d->bordersLayout->setContentsMargins(0.01, 0.01, 0.01, 0.01);
|
||||
d->layout->addItem(d->scrollingWidget, 0, 0);
|
||||
d->borderSvg = new Plasma::Svg(this);
|
||||
d->borderSvg->setImagePath("widgets/scrollwidget");
|
||||
@ -404,18 +401,6 @@ void ScrollWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
|
||||
|
||||
d->adjustClipping();
|
||||
|
||||
//if topBorder exists bottomBorder too
|
||||
if (d->topBorder) {
|
||||
d->topBorder->resize(event->newSize().width(), d->topBorder->size().height());
|
||||
d->bottomBorder->resize(event->newSize().width(), d->bottomBorder->size().height());
|
||||
d->bottomBorder->setPos(0, event->newSize().height() - d->bottomBorder->size().height());
|
||||
}
|
||||
if (d->leftBorder) {
|
||||
d->leftBorder->resize(d->leftBorder->size().width(), event->newSize().height());
|
||||
d->rightBorder->resize(d->rightBorder->size().width(), event->newSize().height());
|
||||
d->rightBorder->setPos(event->newSize().width() - d->rightBorder->size().width(), 0);
|
||||
}
|
||||
|
||||
QGraphicsWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user