FEATURE: new property: overflowBordersVisible

it can enable/disable the painting of the borders when the inner widget is bigger then the viewport

svn path=/trunk/KDE/kdelibs/; revision=1184911
This commit is contained in:
Marco Martin 2010-10-11 19:59:47 +00:00
parent 7306716038
commit 395cd8e146
2 changed files with 40 additions and 4 deletions

View File

@ -98,6 +98,7 @@ public:
leftBorder(0),
rightBorder(0),
dragging(false),
overflowBordersVisible(true),
multitouchGesture(GestureNone)
{
}
@ -212,13 +213,14 @@ public:
topBorder->setElementID("border-top");
topBorder->setZValue(900);
topBorder->resize(topBorder->effectiveSizeHint(Qt::PreferredSize));
topBorder->show();
topBorder->setVisible(overflowBordersVisible);
bottomBorder = new Plasma::SvgWidget(q);
bottomBorder->setSvg(borderSvg);
bottomBorder->setElementID("border-bottom");
bottomBorder->setZValue(900);
bottomBorder->resize(bottomBorder->effectiveSizeHint(Qt::PreferredSize));
bottomBorder->show();
bottomBorder->setVisible(overflowBordersVisible);
} else if (topBorder && widget && widget.data()->size().height() <= q->size().height()) {
//FIXME: in some cases topBorder->deleteLater() is deleteNever(), why?
topBorder->hide();
@ -236,13 +238,14 @@ public:
leftBorder->setElementID("border-left");
leftBorder->setZValue(900);
leftBorder->resize(leftBorder->effectiveSizeHint(Qt::PreferredSize));
leftBorder->show();
leftBorder->setVisible(overflowBordersVisible);
rightBorder = new Plasma::SvgWidget(q);
rightBorder->setSvg(borderSvg);
rightBorder->setElementID("border-right");
rightBorder->setZValue(900);
rightBorder->resize(rightBorder->effectiveSizeHint(Qt::PreferredSize));
rightBorder->show();
rightBorder->setVisible(overflowBordersVisible);
} else if (leftBorder && widget && widget.data()->size().width() <= q->size().width()) {
leftBorder->hide();
rightBorder->hide();
@ -1070,6 +1073,7 @@ public:
QSizeF snapSize;
bool stealEvent;
bool hasOvershoot;
bool overflowBordersVisible;
Qt::Alignment alignment;
@ -1156,6 +1160,21 @@ Qt::ScrollBarPolicy ScrollWidget::verticalScrollBarPolicy() const
return d->verticalScrollBarPolicy;
}
bool ScrollWidget::overflowBordersVisible() const
{
return d->overflowBordersVisible;
}
void ScrollWidget::setOverflowBordersVisible(const bool visible)
{
if (d->overflowBordersVisible == visible) {
return;
}
d->overflowBordersVisible = visible;
d->adjustScrollbars();
}
void ScrollWidget::ensureRectVisible(const QRectF &rect)
{
if (!d->widget) {

View File

@ -46,6 +46,7 @@ class PLASMA_EXPORT ScrollWidget : public QGraphicsWidget
Q_PROPERTY(QGraphicsWidget *widget READ widget WRITE setWidget)
Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy)
Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy)
Q_PROPERTY(bool overflowBordersVisible READ overflowBordersVisible WRITE setOverflowBordersVisible)
Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition)
Q_PROPERTY(QSizeF contentsSize READ contentsSize)
Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry)
@ -134,6 +135,22 @@ public:
*/
Qt::ScrollBarPolicy verticalScrollBarPolicy() const;
/**
* @return true if the widget shows borders when the inner widget
* is bigger than the viewport
* @since 4.6
*/
bool overflowBordersVisible() const;
/**
* Sets whether borders should be shown when the inner widget
* is bigger than the viewport
* @param visible true if the border should be visible when
* the inner widget overflows
* @since 4.6
*/
void setOverflowBordersVisible(const bool visible);
/**
* Scroll the view until the given rectangle is visible
*