mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
plasma: prepare for Katie changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
2c74b5da7b
commit
442d5e6c88
3 changed files with 1 additions and 115 deletions
|
@ -76,7 +76,6 @@ AppletHandle::AppletHandle(Containment *containment, Applet *applet, const QPoin
|
||||||
setFlags(flags() | QGraphicsItem::ItemStacksBehindParent);
|
setFlags(flags() | QGraphicsItem::ItemStacksBehindParent);
|
||||||
KColorScheme colorScheme(QPalette::Active, KColorScheme::View,
|
KColorScheme colorScheme(QPalette::Active, KColorScheme::View,
|
||||||
Theme::defaultTheme()->colorScheme());
|
Theme::defaultTheme()->colorScheme());
|
||||||
setAcceptTouchEvents(true);
|
|
||||||
m_gradientColor = colorScheme.background(KColorScheme::NormalBackground).color();
|
m_gradientColor = colorScheme.background(KColorScheme::NormalBackground).color();
|
||||||
m_originalGeom = mapToScene(QRectF(QPoint(0,0), m_applet->size())).boundingRect();
|
m_originalGeom = mapToScene(QRectF(QPoint(0,0), m_applet->size())).boundingRect();
|
||||||
m_originalTransform = m_applet->transform();
|
m_originalTransform = m_applet->transform();
|
||||||
|
@ -750,63 +749,6 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppletHandle::sceneEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
switch (event->type()) {
|
|
||||||
case QEvent::TouchEnd: {
|
|
||||||
QTransform t = m_applet->transform();
|
|
||||||
QRectF geom = m_applet->geometry();
|
|
||||||
QPointF translation(t.m31(), t.m32());
|
|
||||||
QPointF center = geom.center();
|
|
||||||
geom.setWidth(geom.width()*qAbs(t.m11()));
|
|
||||||
geom.setHeight(geom.height()*qAbs(t.m22()));
|
|
||||||
geom.moveCenter(center);
|
|
||||||
|
|
||||||
m_applet->setGeometry(geom);
|
|
||||||
t.reset();
|
|
||||||
t.translate(m_applet->size().width()/2, m_applet->size().height()/2);
|
|
||||||
t.rotateRadians(m_angle);
|
|
||||||
t.translate(-m_applet->size().width()/2, -m_applet->size().height()/2);
|
|
||||||
|
|
||||||
|
|
||||||
m_applet->setTransform(t);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case QEvent::TouchBegin:
|
|
||||||
case QEvent::TouchUpdate: {
|
|
||||||
QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(event)->touchPoints();
|
|
||||||
if (touchPoints.count() == 2) {
|
|
||||||
const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
|
|
||||||
const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
|
|
||||||
|
|
||||||
//rotation
|
|
||||||
QLineF line0(touchPoint0.lastScenePos(), touchPoint1.lastScenePos());
|
|
||||||
QLineF line1(touchPoint0.scenePos(), touchPoint1.scenePos());
|
|
||||||
m_angle = m_angle+(line1.angleTo(line0)*M_PI_2/90);
|
|
||||||
QTransform t = m_applet->transform();
|
|
||||||
t.translate(m_applet->size().width()/2, m_applet->size().height()/2);
|
|
||||||
t.rotate(line1.angleTo(line0));
|
|
||||||
|
|
||||||
//scaling
|
|
||||||
qreal scaleFactor = 1;
|
|
||||||
if (line0.length() > 0) {
|
|
||||||
scaleFactor = line1.length() / line0.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
t.scale(scaleFactor, scaleFactor);
|
|
||||||
t.translate(-m_applet->size().width()/2, -m_applet->size().height()/2);
|
|
||||||
m_applet->setTransform(t);
|
|
||||||
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return QGraphicsItem::sceneEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
//pos relative to scene
|
//pos relative to scene
|
||||||
void AppletHandle::switchContainment(Containment *containment, const QPointF &pos)
|
void AppletHandle::switchContainment(Containment *containment, const QPointF &pos)
|
||||||
{
|
{
|
||||||
|
|
|
@ -82,7 +82,6 @@ class AppletHandle : public QGraphicsObject
|
||||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
||||||
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
||||||
bool sceneEvent(QEvent*);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void disappearDone(AppletHandle *self);
|
void disappearDone(AppletHandle *self);
|
||||||
|
|
|
@ -91,13 +91,6 @@ namespace Plasma
|
||||||
class ScrollWidgetPrivate
|
class ScrollWidgetPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Gesture {
|
|
||||||
GestureNone = 0,
|
|
||||||
GestureUndefined,
|
|
||||||
GestureScroll,
|
|
||||||
GestureZoom
|
|
||||||
};
|
|
||||||
|
|
||||||
ScrollWidgetPrivate(ScrollWidget *parent)
|
ScrollWidgetPrivate(ScrollWidget *parent)
|
||||||
: q(parent),
|
: q(parent),
|
||||||
topBorder(0),
|
topBorder(0),
|
||||||
|
@ -105,8 +98,7 @@ public:
|
||||||
leftBorder(0),
|
leftBorder(0),
|
||||||
rightBorder(0),
|
rightBorder(0),
|
||||||
dragging(false),
|
dragging(false),
|
||||||
overflowBordersVisible(true),
|
overflowBordersVisible(true)
|
||||||
multitouchGesture(GestureNone)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1099,8 +1091,6 @@ public:
|
||||||
|
|
||||||
Qt::Alignment alignment;
|
Qt::Alignment alignment;
|
||||||
|
|
||||||
Gesture multitouchGesture;
|
|
||||||
|
|
||||||
bool hasContentsProperty;
|
bool hasContentsProperty;
|
||||||
bool hasOffsetProperty;
|
bool hasOffsetProperty;
|
||||||
bool hasXProperty;
|
bool hasXProperty;
|
||||||
|
@ -1509,51 +1499,6 @@ bool ScrollWidget::sceneEventFilter(QGraphicsItem *i, QEvent *e)
|
||||||
d->handleMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent*>(e));
|
d->handleMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent*>(e));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//Multitouch related events, we actually need only TouchUpdate
|
|
||||||
case QEvent::TouchUpdate: {
|
|
||||||
QList<QTouchEvent::TouchPoint> touchPoints = static_cast<QTouchEvent *>(e)->touchPoints();
|
|
||||||
if (touchPoints.count() == 2) {
|
|
||||||
const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
|
|
||||||
const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
|
|
||||||
const QLineF line0(touchPoint0.lastPos(), touchPoint1.lastPos());
|
|
||||||
const QLineF line1(touchPoint0.pos(), touchPoint1.pos());
|
|
||||||
const QLineF startLine(touchPoint0.startPos(), touchPoint1.startPos());
|
|
||||||
const QPointF point = line1.pointAt(0.5);
|
|
||||||
const QPointF lastPoint = line0.pointAt(0.5);
|
|
||||||
|
|
||||||
if (d->multitouchGesture == ScrollWidgetPrivate::GestureNone) {
|
|
||||||
d->multitouchGesture = ScrollWidgetPrivate::GestureUndefined;
|
|
||||||
}
|
|
||||||
if (d->multitouchGesture == ScrollWidgetPrivate::GestureUndefined) {
|
|
||||||
const int zoomDistance = qAbs(line1.length() - startLine.length());
|
|
||||||
const int dragDistance = (startLine.pointAt(0.5) - point).manhattanLength();
|
|
||||||
|
|
||||||
if (zoomDistance - dragDistance > 30) {
|
|
||||||
d->multitouchGesture = ScrollWidgetPrivate::GestureZoom;
|
|
||||||
} else if (dragDistance - zoomDistance > 30) {
|
|
||||||
d->multitouchGesture = ScrollWidgetPrivate::GestureScroll;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (d->multitouchGesture == ScrollWidgetPrivate::GestureScroll) {
|
|
||||||
QGraphicsSceneMouseEvent fakeEvent;
|
|
||||||
fakeEvent.setPos(point);
|
|
||||||
fakeEvent.setLastPos(lastPoint);
|
|
||||||
d->handleMouseMoveEvent(&fakeEvent);
|
|
||||||
} else if (d->multitouchGesture == ScrollWidgetPrivate::GestureZoom) {
|
|
||||||
if (d->widget && d->widget.data()->property("zoomFactor").isValid()) {
|
|
||||||
qreal scaleFactor = 1;
|
|
||||||
if (line0.length() > 0) {
|
|
||||||
scaleFactor = line1.length() / line0.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal zoom = d->widget.data()->property("zoomFactor").toReal();
|
|
||||||
d->widget.data()->setProperty("zoomFactor", zoom * scaleFactor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue