Merge remote-tracking branch 'origin/KDE/4.10'

This commit is contained in:
David Faure 2012-10-13 18:31:40 +02:00
commit 445ccb0bc7
9 changed files with 103 additions and 31 deletions

View File

@ -145,10 +145,10 @@ Containment::Containment(const QString &packagePath, uint appletId, const QVaria
Containment::~Containment() Containment::~Containment()
{ {
delete d;
// Applet touches our dptr if we are a containment and is the superclass (think of dtors) // Applet touches our dptr if we are a containment and is the superclass (think of dtors)
// so we reset this as we exit the building // so we reset this as we exit the building
Applet::d->isContainment = false; Applet::d->isContainment = false;
delete d;
} }
void Containment::init() void Containment::init()

View File

@ -171,9 +171,8 @@ void DataContainer::setNeedsToBeStored(bool store)
DataEngine* DataContainer::getDataEngine() DataEngine* DataContainer::getDataEngine()
{ {
QObject *o = NULL; QObject *o = this;
DataEngine *de = NULL; DataEngine *de = NULL;
o = this;
while (de == NULL) while (de == NULL)
{ {
o = dynamic_cast<QObject *> (o->parent()); o = dynamic_cast<QObject *> (o->parent());

View File

@ -43,7 +43,7 @@ class PluginLoaderPrivate;
* default PluginLoader implementation will be used. The reimplemented version should * default PluginLoader implementation will be used. The reimplemented version should
* not do more than simply returning a loaded plugin. It should not init() it, and it should not * not do more than simply returning a loaded plugin. It should not init() it, and it should not
* hang on to it. The associated methods will be called only when a component of Plasma * hang on to it. The associated methods will be called only when a component of Plasma
* needs to load a _new_ plugin. (e.g. DataEngine does it's own caching). * needs to load a _new_ plugin. (e.g. DataEngine does its own caching).
* *
* @author Ryan Rix <ry@n.rix.si> * @author Ryan Rix <ry@n.rix.si>
* @since 4.6 * @since 4.6

View File

@ -237,21 +237,22 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
QLinearGradient g(QPoint(0, 0), QPoint(m_decorationRect.width(), 0)); QLinearGradient g(QPoint(0, 0), QPoint(m_decorationRect.width(), 0));
//fading out panel //fading out panel
if (m_rect.height() > qreal(minimumHeight()) * 1.25) { if (m_applet->backgroundHints() != Plasma::Applet::NoBackground &&
m_rect.height() > qreal(minimumHeight()) * 1.25) {
if (m_buttonsOnRight) { if (m_buttonsOnRight) {
qreal opaquePoint = qreal opaquePoint =
(m_background->marginSize(LeftMargin) - translation) / m_decorationRect.width(); (m_background->marginSize(LeftMargin) - translation) / m_decorationRect.width();
//kDebug() << "opaquePoint" << opaquePoint //kDebug() << "opaquePoint" << opaquePoint
// << m_background->marginSize(LeftMargin) << m_decorationRect.width(); // << m_background->marginSize(LeftMargin) << m_decorationRect.width();
g.setColorAt(0.0, Qt::transparent); g.setColorAt(0.0, Qt::transparent);
g.setColorAt(qMax(0.0, opaquePoint - 0.05), Qt::transparent); //krazy:exclude=qminmax g.setColorAt(qMax(0.0, opaquePoint - 0.01), Qt::transparent); //krazy:exclude=qminmax
g.setColorAt(opaquePoint, transparencyColor); g.setColorAt(opaquePoint, transparencyColor);
g.setColorAt(1.0, transparencyColor); g.setColorAt(1.0, transparencyColor);
} else { } else {
qreal opaquePoint = qreal opaquePoint =
1 - ((m_background->marginSize(RightMargin) + translation) / m_decorationRect.width()); 1 - ((m_background->marginSize(RightMargin) + translation) / m_decorationRect.width());
g.setColorAt(1.0, Qt::transparent); g.setColorAt(1.0, Qt::transparent);
g.setColorAt(opaquePoint + 0.05, Qt::transparent); g.setColorAt(opaquePoint + 0.01, Qt::transparent);
g.setColorAt(qMax(qreal(0), opaquePoint), transparencyColor); g.setColorAt(qMax(qreal(0), opaquePoint), transparencyColor);
g.setColorAt(0.0, transparencyColor); g.setColorAt(0.0, transparencyColor);
} }
@ -864,6 +865,41 @@ bool AppletHandle::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{ {
if (watched == m_applet && event->type() == QEvent::GraphicsSceneHoverLeave) { if (watched == m_applet && event->type() == QEvent::GraphicsSceneHoverLeave) {
hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent*>(event)); hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent*>(event));
} else if (watched == m_applet && event->type() == QEvent::GraphicsSceneMousePress) {
QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(event);
QPointF pos = mapFromScene(me->scenePos());
if (m_applet->contentsRect().contains(pos)) {
return false;
}
me->setPos(pos);
mousePressEvent(me);
return true;
} else if (watched == m_applet && event->type() == QEvent::GraphicsSceneMouseRelease) {
if (m_pressedButton == NoButton) {
return false;
}
QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(event);
QPointF pos = mapFromScene(me->scenePos());
me->setPos(pos);
mouseReleaseEvent(me);
return true;
} else if (watched == m_applet && event->type() == QEvent::GraphicsSceneMouseMove) {
if (m_pressedButton == NoButton) {
return false;
}
QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent *>(event);
QPointF pos = mapFromScene(me->scenePos());
me->setPos(pos);
mouseMoveEvent(me);
return true;
} }
return false; return false;
@ -987,7 +1023,7 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos, bool pres
m_animType = anim; m_animType = anim;
//kDebug() << "animating for " << time << "ms"; //kDebug() << "animating for " << time << "ms";
if (m_animType == FadeIn) { if (m_animType == FadeIn && propAnim) {
propAnim->setDirection(QAbstractAnimation::Forward); propAnim->setDirection(QAbstractAnimation::Forward);
propAnim->start(); propAnim->start();
} else if (propAnim) { } else if (propAnim) {
@ -1030,29 +1066,32 @@ void AppletHandle::calculateSize()
qreal marginLeft, marginTop, marginRight, marginBottom; qreal marginLeft, marginTop, marginRight, marginBottom;
m_background->getMargins(marginLeft, marginTop, marginRight, marginBottom); m_background->getMargins(marginLeft, marginTop, marginRight, marginBottom);
if (m_buttonsOnRight) { int leftShadowWidth = m_background->elementSize("hint-left-shadow").width();
//put the rect on the right of the applet int rightShadowWidth = m_background->elementSize("hint-right-shadow").width();
m_rect = QRectF(m_applet->size().width(), top, handleWidth, handleHeight);
} else { //no precise hint? let's go for heuristics
//put the rect on the left of the applet if (leftShadowWidth <= 0) {
m_rect = QRectF(-handleWidth, top, handleWidth, handleHeight); leftShadowWidth = marginLeft/1.6;
}
if (rightShadowWidth <= 0) {
rightShadowWidth = marginRight/1.6;
} }
if (m_applet->contentsRect().height() > qreal(minimumHeight()) * 1.25) { if (m_applet->backgroundHints() == Plasma::Applet::NoBackground) {
int addedMargin = marginLeft / 2; leftShadowWidth = 0;
rightShadowWidth = 0;
}
if (m_buttonsOnRight) {
//put the rect on the right of the applet
m_rect = QRectF(m_applet->size().width() - rightShadowWidth + HANDLE_MARGIN, top, handleWidth, handleHeight);
} else {
//put the rect on the left of the applet
m_rect = QRectF(-handleWidth + leftShadowWidth - HANDLE_MARGIN, top, handleWidth, handleHeight);
}
// now we check to see if the shape is smaller than the contents, if (m_applet->backgroundHints() != Plasma::Applet::NoBackground &&
// and that the shape is not just the bounding rect; in those cases m_applet->contentsRect().height() > qreal(minimumHeight()) * 1.25) {
// we have a shaped guy and we draw a full panel; int addedMargin = HANDLE_MARGIN;
// TODO: allow applets to mark when they have translucent areas and
// should therefore skip this test?
if (!m_applet->shape().contains(m_applet->contentsRect())) {
QPainterPath p;
p.addRect(m_applet->boundingRect());
if (m_applet->shape() != p) {
addedMargin = m_applet->contentsRect().width() / 2;
}
}
if (m_buttonsOnRight) { if (m_buttonsOnRight) {
marginLeft += addedMargin; marginLeft += addedMargin;

View File

@ -31,6 +31,7 @@ public:
ContainmentActionsPrivate(KService::Ptr service, ContainmentActions *containmentActions) : ContainmentActionsPrivate(KService::Ptr service, ContainmentActions *containmentActions) :
q(containmentActions), q(containmentActions),
containmentActionsDescription(service), containmentActionsDescription(service),
package(0),
initialized(false), initialized(false),
needsConfig(false), needsConfig(false),
containment(0) containment(0)

View File

@ -44,7 +44,8 @@ public:
bottomMargin(0), bottomMargin(0),
noBorderPadding(false), noBorderPadding(false),
stretchBorders(false), stretchBorders(false),
tileCenter(false) tileCenter(false),
composeOverBorder(false)
{ {
ref(svg); ref(svg);
} }

View File

@ -38,6 +38,7 @@ class ClientPrivate : public QObject
public: public:
ClientPrivate(Client *client) ClientPrivate(Client *client)
: q(client), : q(client),
readerThread(0),
error(Client::NoError) {} error(Client::NoError) {}
public slots: public slots:

View File

@ -305,6 +305,26 @@ QRect Style::subControlRect(ComplexControl control, const QStyleOptionComplex *o
} }
break; break;
} }
case CC_ScrollBar: {
const bool hasButtons = d->scrollbar->hasElement("arrow-up");
switch (subControl) {
//If one of the arrows is missing, don't reserve space for them
case SC_ScrollBarAddLine:
if (!hasButtons) {
rect.setRect(0,0,0,0);
}
break;
case SC_ScrollBarSubLine:
if (!hasButtons) {
rect.setRect(0,0,0,0);
}
break;
default:
break;
}
}
default: default:
break; break;
} }
@ -331,11 +351,21 @@ int Style::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWi
switch (metric) { switch (metric) {
case PM_ScrollBarExtent: { case PM_ScrollBarExtent: {
d->createScrollbar(); d->createScrollbar();
const QSizeF hintSize = d->scrollbar->elementSize("hint-scrollbar-size");
const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option); const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
if (scrollOption && scrollOption->orientation == Qt::Vertical) { if (scrollOption && scrollOption->orientation == Qt::Vertical) {
return d->scrollbar->elementSize("arrow-down").width() + 2; if (hintSize.isEmpty()) {
return d->scrollbar->elementSize("arrow-down").width() + 2;
} else {
return hintSize.width();
}
} else { } else {
return d->scrollbar->elementSize("arrow-left").height() + 2; if (hintSize.isEmpty()) {
return d->scrollbar->elementSize("arrow-left").height() + 2;
} else {
return hintSize.height();
}
} }
} }
default: default:

View File

@ -46,6 +46,7 @@ public:
DeclarativeWidgetPrivate(DeclarativeWidget *parent) DeclarativeWidgetPrivate(DeclarativeWidget *parent)
: q(parent), : q(parent),
engine(0), engine(0),
scriptEngine(0),
component(0), component(0),
root(0), root(0),
delay(false) delay(false)