[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/plasma-desktoplayout/kdelibs-plasma (silent)
From: Ambroz Bizjak <ambro () b4ever ! net>
Date: 2008-12-25 11:44:40
Message-ID: 1230205480.002837.19138.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 901350 by abizjak:
SVN_SILENT merge changes from trunk
M +4 -0 applet.h
M +7 -1 popupapplet.cpp
M +14 -9 private/applethandle.cpp
M +0 -2 private/applethandle_p.h
M +34 -9 private/toolbox.cpp
--- branches/work/plasma-desktoplayout/kdelibs-plasma/applet.h #901349:901350
@@ -650,6 +650,10 @@
* If the applet requires a QGraphicsScene or has an particularly intensive
* set of initialization routines to go through, consider implementing it
* in this method instead of the constructor.
+ *
+ * Note: paintInterface may get called before init() depending on \
initialization + * order. Painting is managed by the canvas (QGraphisScene), \
and may schedule a + * paint event prior to init() being called.
**/
virtual void init();
--- branches/work/plasma-desktoplayout/kdelibs-plasma/popupapplet.cpp #901349:901350
@@ -210,6 +210,12 @@
QSize prefSize;
if (gWidget) {
+ Corona *corona = qobject_cast<Corona *>(gWidget->scene());
+
+ if (corona) {
+ corona->removeOffscreenWidget(gWidget);
+ }
+
lay->addItem(gWidget);
prefSize = gWidget->preferredSize().toSize();
} else if (qWidget) {
@@ -453,9 +459,9 @@
if (dialog->isVisible()) {
dialog->hide();
} else {
- dialog->show();
updateDialogPosition();
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | \
NET::SkipPager); + dialog->show();
}
dialog->clearFocus();
--- branches/work/plasma-desktoplayout/kdelibs-plasma/private/applethandle.cpp \
#901349:901350 @@ -476,7 +476,6 @@
}
m_resizeGrabPoint = mapToScene(event->pos());
QPointF cursorRelativeToStatic = m_resizeGrabPoint - \
m_resizeStaticPoint;
- m_aspectResizeOrigRadius = sqrt(pow(cursorRelativeToStatic.x(), 2) + \
pow(cursorRelativeToStatic.y(), 2));
// rotate
m_rotateAngleOffset = m_angle - _k_pointAngle(mapToScene(event->pos()) - \
m_origAppletCenter); @@ -585,7 +584,7 @@
qreal _k_pointAngle(QPointF in)
{
- qreal r = sqrt(pow(in.x(), 2) + pow(in.y(), 2));
+ qreal r = sqrt(in.x()*in.x() + in.y()*in.y());
qreal cosine = in.x()/r;
qreal sine = in.y()/r;
@@ -598,7 +597,7 @@
QPointF _k_rotatePoint(QPointF in, qreal rotateAngle)
{
- qreal r = sqrt(pow(in.x(), 2) + pow(in.y(), 2));
+ qreal r = sqrt(in.x()*in.x() + in.y()*in.y());
qreal cosine = in.x()/r;
qreal sine = in.y()/r;
@@ -695,15 +694,21 @@
qreal sx = newSize.x();
qreal sy = newSize.y();
- qreal x = ox*(sx*ox+sy*oy)/(pow(ox,2)+pow(oy,2));
- qreal y = oy*x/ox;
+ qreal x = ox*(sx*ox+sy*oy)/(ox*ox+oy*oy);
+ qreal y = (oy/ox)*x;
newSize = QPointF(x, y);
+
+ // limit size, preserve ratio
+ newSize.rx() = qMin(max.width(), qMax(min.width(), newSize.x()));
+ newSize.ry() = newSize.x()*(oy/ox);
+ newSize.ry() = qMin(max.height(), qMax(min.height(), newSize.y()));
+ newSize.rx() = newSize.y()/(oy/ox);
+ } else {
+ // limit size
+ newSize.rx() = qMin(max.width(), qMax(min.width(), newSize.x()));
+ newSize.ry() = qMin(max.height(), qMax(min.height(), newSize.y()));
}
- // limit size
- newSize.rx() = qMin(max.width(), qMax(min.width(), newSize.x()));
- newSize.ry() = qMin(max.height(), qMax(min.height(), newSize.y()));
-
// move center such that the static corner remains in the same place
if (m_buttonsOnRight) {
newCenter = _k_rotatePoint(QPointF(rStaticPoint.x() + \
newSize.x()/2, rStaticPoint.y() - newSize.y()/2), m_angle);
--- branches/work/plasma-desktoplayout/kdelibs-plasma/private/applethandle_p.h \
#901349:901350 @@ -137,8 +137,6 @@
// used for resize
QPointF m_resizeStaticPoint;
QPointF m_resizeGrabPoint;
- // used during aspect-ratio preserving resize
- qreal m_aspectResizeOrigRadius;
// used for rotate
qreal m_rotateAngleOffset; // applet angle minus cursor angle
--- branches/work/plasma-desktoplayout/kdelibs-plasma/private/toolbox.cpp \
#901349:901350 @@ -58,7 +58,7 @@
int size;
QSize iconSize;
ToolBox::Corner corner;
- QPoint dragStart;
+ QPoint dragStartRelative;
QTransform viewTransform;
bool hidden : 1;
bool showing : 1;
@@ -194,7 +194,8 @@
void ToolBox::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
event->accept();
- d->dragStart = mapToParent(event->pos()).toPoint();
+ // set grab position relative to toolbox
+ d->dragStartRelative = mapToParent(event->pos()).toPoint() - pos().toPoint();
}
void ToolBox::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
@@ -203,9 +204,6 @@
return;
}
- //TODOs:
- // move relative to where on the toolbox it was grabbed
- // sticky points at midpoints
d->dragging = true;
d->userMoved = true;
const QPoint newPos = mapToParent(event->pos()).toPoint();
@@ -219,6 +217,36 @@
int x = curPos.x();
int y = curPos.y();
+ // jump to the nearest desktop border
+ int distanceToLeft = newPos.x() - d->dragStartRelative.x();
+ int distanceToRight = areaWidth - w - distanceToLeft;
+ int distanceToTop = newPos.y() - d->dragStartRelative.y();
+ int distanceToBottom = areaHeight - h - distanceToTop;
+
+ // decide which border is the nearest
+ if (distanceToLeft < distanceToTop && distanceToLeft < distanceToRight &&
+ distanceToLeft < distanceToBottom ) {
+ x = 0;
+ y = (newPos.y() - d->dragStartRelative.y());
+ }
+ else if (distanceToRight < distanceToTop && distanceToRight < distanceToLeft &&
+ distanceToRight < distanceToBottom) {
+ x = areaWidth - w;
+ y = (newPos.y() - d->dragStartRelative.y());
+ }
+ else if (distanceToTop < distanceToLeft && distanceToTop < distanceToRight &&
+ distanceToTop < distanceToBottom ) {
+ y = 0;
+ x = (newPos.x() - d->dragStartRelative.x());
+ }
+ else if (distanceToBottom < distanceToLeft && distanceToBottom < distanceToRight \
&& + distanceToBottom < distanceToTop) {
+ y = areaHeight - h;
+ x = (newPos.x() - d->dragStartRelative.x());
+ }
+
+ //kDebug() << "distances from borders" << (newPos - d->dragStartRelative) << \
distanceToLeft << distanceToRight << distanceToTop << distanceToBottom << "=>" << x \
<< y; +/*
if (y == 0 || y + h >= areaHeight) {
x = curPos.x() + (newPos.x() - d->dragStart.x());
if (x < 0) {
@@ -239,11 +267,10 @@
y = areaHeight - h;
}
}
-
+*/
x = qBound(0, x, areaWidth - w);
y = qBound(0, y, areaHeight - h);
-
Corner newCorner = d->corner;
if (x == 0) {
if (y == 0) {
@@ -275,7 +302,6 @@
}
setPos(x, y);
- d->dragStart = newPos;
}
void ToolBox::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
@@ -284,7 +310,6 @@
emit toggled();
}
- d->dragStart = QPoint();
d->dragging = false;
KConfigGroup cg(d->containment->config());
save(cg);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic