more coding style fixes
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=870169
This commit is contained in:
parent
a7aebfa60a
commit
3674a94a99
@ -60,14 +60,14 @@ public:
|
||||
QString globalName() const;
|
||||
QString instanceName();
|
||||
void scheduleConstraintsUpdate(Plasma::Constraints c);
|
||||
KConfigGroup* mainConfigGroup();
|
||||
QString visibleFailureText(const QString& reason);
|
||||
KConfigGroup *mainConfigGroup();
|
||||
QString visibleFailureText(const QString &reason);
|
||||
void checkImmutability();
|
||||
void themeChanged();
|
||||
void resetConfigurationObject();
|
||||
void appletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim);
|
||||
void selectItemToDestroy();
|
||||
void updateRect(const QRectF& rect);
|
||||
void updateRect(const QRectF &rect);
|
||||
void setFocus();
|
||||
void cleanUpAndDelete();
|
||||
|
||||
|
@ -70,7 +70,8 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
|
||||
m_buttonsOnRight(false),
|
||||
m_pendingFade(false)
|
||||
{
|
||||
KColorScheme colorScheme(QPalette::Active, KColorScheme::View, Theme::defaultTheme()->colorScheme());
|
||||
KColorScheme colorScheme(QPalette::Active, KColorScheme::View,
|
||||
Theme::defaultTheme()->colorScheme());
|
||||
m_gradientColor = colorScheme.background(KColorScheme::NormalBackground).color();
|
||||
|
||||
QTransform originalMatrix = m_applet->transform();
|
||||
@ -201,18 +202,22 @@ QPainterPath handleRect(const QRectF &rect, int radius, bool onRight)
|
||||
// make the left side straight
|
||||
path.moveTo(rect.left(), rect.top()); // Top left
|
||||
path.lineTo(rect.right() - radius, rect.top()); // Top side
|
||||
path.quadTo(rect.right(), rect.top(), rect.right(), rect.top() + radius); // Top right corner
|
||||
path.lineTo(rect.right(), rect.bottom() - radius); // Right side
|
||||
path.quadTo(rect.right(), rect.bottom(), rect.right() - radius, rect.bottom()); // Bottom right corner
|
||||
path.lineTo(rect.left(), rect.bottom()); // Bottom side
|
||||
path.quadTo(rect.right(), rect.top(),
|
||||
rect.right(), rect.top() + radius); // Top right corner
|
||||
path.lineTo(rect.right(), rect.bottom() - radius); // Right side
|
||||
path.quadTo(rect.right(), rect.bottom(),
|
||||
rect.right() - radius, rect.bottom()); // Bottom right corner
|
||||
path.lineTo(rect.left(), rect.bottom()); // Bottom side
|
||||
} else {
|
||||
// make the right side straight
|
||||
path.moveTo(QPointF(rect.left(), rect.top() + radius));
|
||||
path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner
|
||||
path.lineTo(rect.right(), rect.top()); // Top side
|
||||
path.lineTo(rect.right(), rect.bottom()); // Right side
|
||||
path.lineTo(rect.left() + radius, rect.bottom()); // Bottom side
|
||||
path.quadTo(rect.left(), rect.bottom(), rect.left(), rect.bottom() - radius); // Bottom left corner
|
||||
path.quadTo(rect.left(), rect.top(),
|
||||
rect.left() + radius, rect.top()); // Top left corner
|
||||
path.lineTo(rect.right(), rect.top()); // Top side
|
||||
path.lineTo(rect.right(), rect.bottom()); // Right side
|
||||
path.lineTo(rect.left() + radius, rect.bottom()); // Bottom side
|
||||
path.quadTo(rect.left(), rect.bottom(),
|
||||
rect.left(), rect.bottom() - radius); // Bottom left corner
|
||||
}
|
||||
|
||||
path.closeSubpath();
|
||||
@ -236,7 +241,8 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
qreal translation;
|
||||
|
||||
if (m_buttonsOnRight) {
|
||||
//kDebug() << "translating by" << m_opacity << (-(1 - m_opacity) * m_rect.width()) << m_rect.width();
|
||||
//kDebug() << "translating by" << m_opacity
|
||||
// << (-(1 - m_opacity) * m_rect.width()) << m_rect.width();
|
||||
translation = -(1 - m_opacity) * m_rect.width();
|
||||
} else {
|
||||
translation = (1 - m_opacity) * m_rect.width();
|
||||
@ -247,10 +253,10 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setRenderHints(QPainter::Antialiasing);
|
||||
|
||||
|
||||
int iconMargin = m_iconSize / 2;
|
||||
|
||||
const QSize pixmapSize(int(m_decorationRect.width()), int(m_decorationRect.height()) + m_iconSize*4 + 1);
|
||||
const QSize pixmapSize(int(m_decorationRect.width()),
|
||||
int(m_decorationRect.height()) + m_iconSize * 4 + 1);
|
||||
const QSize iconSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
|
||||
|
||||
//regenerate our buffer?
|
||||
@ -258,11 +264,12 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
QColor transparencyColor = Qt::black;
|
||||
transparencyColor.setAlphaF(qMin(m_opacity, qreal(0.99)));
|
||||
|
||||
QLinearGradient g(QPoint(0,0), QPoint(m_decorationRect.width(),0));
|
||||
QLinearGradient g(QPoint(0, 0), QPoint(m_decorationRect.width(), 0));
|
||||
//fading out panel
|
||||
if (m_rect.height() > qreal(minimumHeight()) * 1.25) {
|
||||
if (m_buttonsOnRight) {
|
||||
qreal opaquePoint = (m_background->marginSize(LeftMargin) - translation) / m_decorationRect.width();
|
||||
qreal opaquePoint =
|
||||
(m_background->marginSize(LeftMargin) - translation) / m_decorationRect.width();
|
||||
//kDebug() << "opaquePoint" << opaquePoint
|
||||
// << m_background->marginSize(LeftMargin) << m_decorationRect.width();
|
||||
g.setColorAt(0.0, Qt::transparent);
|
||||
@ -270,7 +277,8 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
g.setColorAt(opaquePoint, transparencyColor);
|
||||
g.setColorAt(1.0, transparencyColor);
|
||||
} else {
|
||||
qreal opaquePoint = 1 - ((m_background->marginSize(RightMargin) + translation) / m_decorationRect.width());
|
||||
qreal opaquePoint =
|
||||
1 - ((m_background->marginSize(RightMargin) + translation) / m_decorationRect.width());
|
||||
g.setColorAt(1.0, Qt::transparent);
|
||||
g.setColorAt(opaquePoint, Qt::transparent);
|
||||
g.setColorAt(qMax(0.0, opaquePoint - 0.05), transparencyColor);
|
||||
@ -297,7 +305,8 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
//QRectF iconRect(QPointF(pixmapSize.width() - m_iconSize + 1, m_iconSize), iconSize);
|
||||
QRectF iconRect(QPointF(0, m_decorationRect.height() + 1), iconSize);
|
||||
if (m_buttonsOnRight) {
|
||||
iconRect.moveLeft(pixmapSize.width() - m_iconSize - m_background->marginSize(LeftMargin));
|
||||
iconRect.moveLeft(
|
||||
pixmapSize.width() - m_iconSize - m_background->marginSize(LeftMargin));
|
||||
m_configureIcons->paint(&buffPainter, iconRect, "size-diagonal-tr2bl");
|
||||
} else {
|
||||
iconRect.moveLeft(m_background->marginSize(RightMargin));
|
||||
@ -318,10 +327,12 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
//blend the background
|
||||
buffPainter.fillRect(m_backgroundBuffer->rect(), g);
|
||||
//blend the icons
|
||||
//buffPainter.fillRect(QRect(QPoint((int)m_decorationRect.width(), 0), QSize(m_iconSize + 1, (int)m_decorationRect.height())), transparencyColor);
|
||||
//buffPainter.fillRect(QRect(QPoint((int)m_decorationRect.width(), 0), QSize(m_iconSize + 1,
|
||||
// (int)m_decorationRect.height())), transparencyColor);
|
||||
}
|
||||
|
||||
painter->drawPixmap(m_decorationRect.toRect(), *m_backgroundBuffer, QRect(QPoint(0,0), m_decorationRect.size().toSize()));
|
||||
painter->drawPixmap(m_decorationRect.toRect(), *m_backgroundBuffer,
|
||||
QRect(QPoint(0, 0), m_decorationRect.size().toSize()));
|
||||
|
||||
//XXX this code is duplicated in the next function
|
||||
QPointF basePoint = m_rect.topLeft() + QPointF(HANDLE_MARGIN, iconMargin);
|
||||
@ -354,14 +365,16 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
|
||||
QRectF sourceIconRect(QPointF(0, m_decorationRect.height() + 1), iconSize);
|
||||
if (m_buttonsOnRight) {
|
||||
sourceIconRect.moveLeft(pixmapSize.width() - m_iconSize - m_background->marginSize(LeftMargin));
|
||||
sourceIconRect.moveLeft(
|
||||
pixmapSize.width() - m_iconSize - m_background->marginSize(LeftMargin));
|
||||
} else {
|
||||
sourceIconRect.moveLeft(m_background->marginSize(RightMargin));
|
||||
}
|
||||
|
||||
if (m_applet && m_applet->aspectRatioMode() != FixedSize) {
|
||||
//resize
|
||||
painter->drawPixmap(QRectF(basePoint + shiftM, iconSize), *m_backgroundBuffer, sourceIconRect);
|
||||
painter->drawPixmap(
|
||||
QRectF(basePoint + shiftM, iconSize), *m_backgroundBuffer, sourceIconRect);
|
||||
basePoint += step;
|
||||
}
|
||||
|
||||
@ -372,7 +385,8 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
if (m_applet && m_applet->hasConfigurationInterface()) {
|
||||
basePoint += step;
|
||||
sourceIconRect.translate(0, m_iconSize);
|
||||
painter->drawPixmap(QRectF(basePoint + shiftC, iconSize), *m_backgroundBuffer, sourceIconRect);
|
||||
painter->drawPixmap(
|
||||
QRectF(basePoint + shiftC, iconSize), *m_backgroundBuffer, sourceIconRect);
|
||||
}
|
||||
|
||||
//close
|
||||
@ -426,7 +440,6 @@ AppletHandle::ButtonType AppletHandle::mapToButton(const QPointF &point) const
|
||||
//return m_applet->mapToParent(m_applet->shape()).contains(point) ? NoButton : MoveButton;
|
||||
}
|
||||
|
||||
|
||||
void AppletHandle::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
//containment recently switched?
|
||||
@ -474,9 +487,10 @@ bool AppletHandle::leaveCurrentView(const QPoint &pos) const
|
||||
//is this widget a plasma view, a different view then our current one,
|
||||
//AND not a dashboardview?
|
||||
Plasma::View *v = qobject_cast<Plasma::View *>(widget);
|
||||
if (v && v != m_currentView
|
||||
&& v != m_topview
|
||||
&& v->containment() != m_containment) {
|
||||
if (v &&
|
||||
v != m_currentView &&
|
||||
v != m_topview &&
|
||||
v->containment() != m_containment) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -484,7 +498,6 @@ bool AppletHandle::leaveCurrentView(const QPoint &pos) const
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
//kDebug() << "button pressed:" << m_pressedButton << ", fade pending?" << m_pendingFade;
|
||||
@ -498,98 +511,102 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
||||
if (m_applet && event->button() == Qt::LeftButton) {
|
||||
switch (m_pressedButton) {
|
||||
case ResizeButton:
|
||||
case RotateButton: {
|
||||
if (m_scaleWidth > 0 && m_scaleHeight > 0) {
|
||||
QRectF rect(m_applet->boundingRect());
|
||||
const qreal newWidth = rect.width() * m_scaleWidth;
|
||||
const qreal newHeight = rect.height() * m_scaleHeight;
|
||||
m_applet->resetTransform();
|
||||
m_applet->resize(newWidth, newHeight);
|
||||
scale(1.0/m_scaleWidth, 1.0/m_scaleHeight);
|
||||
moveBy((rect.width() - newWidth) / 2, (rect.height() - newHeight) / 2);
|
||||
m_scaleWidth = m_scaleHeight = 0;
|
||||
}
|
||||
QRectF rect = QRectF(m_applet->pos(), m_applet->size());
|
||||
QPointF center = rect.center();
|
||||
|
||||
m_angle += m_tempAngle;
|
||||
m_tempAngle = 0;
|
||||
|
||||
QTransform matrix;
|
||||
matrix.translate(center.x(), center.y());
|
||||
matrix.rotateRadians(m_angle);
|
||||
matrix.translate(-center.x(), -center.y());
|
||||
|
||||
setTransform(matrix);
|
||||
m_applet->update();
|
||||
break;
|
||||
case ResizeButton:
|
||||
case RotateButton:
|
||||
{
|
||||
if (m_scaleWidth > 0 && m_scaleHeight > 0) {
|
||||
QRectF rect(m_applet->boundingRect());
|
||||
const qreal newWidth = rect.width() * m_scaleWidth;
|
||||
const qreal newHeight = rect.height() * m_scaleHeight;
|
||||
m_applet->resetTransform();
|
||||
m_applet->resize(newWidth, newHeight);
|
||||
scale(1.0 / m_scaleWidth, 1.0 / m_scaleHeight);
|
||||
moveBy((rect.width() - newWidth) / 2, (rect.height() - newHeight) / 2);
|
||||
m_scaleWidth = m_scaleHeight = 0;
|
||||
}
|
||||
case ConfigureButton:
|
||||
//FIXME: Remove this call once the configuration management change was done
|
||||
if (m_pressedButton == releasedAtButton) {
|
||||
m_applet->showConfigurationInterface();
|
||||
}
|
||||
break;
|
||||
case RemoveButton:
|
||||
if (m_pressedButton == releasedAtButton) {
|
||||
forceDisappear();
|
||||
m_applet->destroy();
|
||||
}
|
||||
break;
|
||||
case MoveButton: {
|
||||
if (m_topview) {
|
||||
m_topview->hide();
|
||||
delete m_topview;
|
||||
m_topview = 0;
|
||||
m_applet->d->ghost = false;
|
||||
m_applet->update();
|
||||
}
|
||||
QRectF rect = QRectF(m_applet->pos(), m_applet->size());
|
||||
QPointF center = rect.center();
|
||||
|
||||
//find out if we were dropped on a panel or something
|
||||
if (leaveCurrentView(event->screenPos())) {
|
||||
startFading(FadeOut, m_entryPos);
|
||||
Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
|
||||
if (v && v != m_currentView) {
|
||||
Containment *c = v->containment();
|
||||
QPoint pos = v->mapFromGlobal(event->screenPos());
|
||||
//we actually have been dropped on another containment, so
|
||||
//move there: we have a screenpos, we need a scenepos
|
||||
//FIXME how reliable is this transform?
|
||||
switchContainment(c, v->mapToScene(pos));
|
||||
}
|
||||
} else {
|
||||
// test for containment change
|
||||
//kDebug() << "testing for containment change, sceneBoundingRect = " << m_containment->sceneBoundingRect();
|
||||
if (!m_containment->sceneBoundingRect().contains(m_applet->scenePos())) {
|
||||
// see which containment it belongs to
|
||||
Corona * corona = qobject_cast<Corona*>(scene());
|
||||
if (corona) {
|
||||
QList<Containment*> containments = corona->containments();
|
||||
for (int i = 0; i < containments.size(); ++i) {
|
||||
QPointF pos;
|
||||
QGraphicsView *v;
|
||||
v = containments[i]->view();
|
||||
if (v) {
|
||||
pos = v->mapToScene(v->mapFromGlobal(event->screenPos() - m_mousePos));
|
||||
m_angle += m_tempAngle;
|
||||
m_tempAngle = 0;
|
||||
|
||||
if (containments[i]->sceneBoundingRect().contains(pos)) {
|
||||
//kDebug() << "new containment = " << containments[i];
|
||||
//kDebug() << "rect = " << containments[i]->sceneBoundingRect();
|
||||
// add the applet to the new containment and take it from the old one
|
||||
//kDebug() << "moving to other containment with position" << pos;;
|
||||
switchContainment(containments[i], pos);
|
||||
break;
|
||||
}
|
||||
QTransform matrix;
|
||||
matrix.translate(center.x(), center.y());
|
||||
matrix.rotateRadians(m_angle);
|
||||
matrix.translate(-center.x(), -center.y());
|
||||
|
||||
setTransform(matrix);
|
||||
m_applet->update();
|
||||
break;
|
||||
}
|
||||
case ConfigureButton:
|
||||
//FIXME: Remove this call once the configuration management change was done
|
||||
if (m_pressedButton == releasedAtButton) {
|
||||
m_applet->showConfigurationInterface();
|
||||
}
|
||||
break;
|
||||
case RemoveButton:
|
||||
if (m_pressedButton == releasedAtButton) {
|
||||
forceDisappear();
|
||||
m_applet->destroy();
|
||||
}
|
||||
break;
|
||||
case MoveButton:
|
||||
{
|
||||
if (m_topview) {
|
||||
m_topview->hide();
|
||||
delete m_topview;
|
||||
m_topview = 0;
|
||||
m_applet->d->ghost = false;
|
||||
m_applet->update();
|
||||
}
|
||||
|
||||
//find out if we were dropped on a panel or something
|
||||
if (leaveCurrentView(event->screenPos())) {
|
||||
startFading(FadeOut, m_entryPos);
|
||||
Plasma::View *v = Plasma::View::topLevelViewAt(event->screenPos());
|
||||
if (v && v != m_currentView) {
|
||||
Containment *c = v->containment();
|
||||
QPoint pos = v->mapFromGlobal(event->screenPos());
|
||||
//we actually have been dropped on another containment, so
|
||||
//move there: we have a screenpos, we need a scenepos
|
||||
//FIXME how reliable is this transform?
|
||||
switchContainment(c, v->mapToScene(pos));
|
||||
}
|
||||
} else {
|
||||
// test for containment change
|
||||
//kDebug() << "testing for containment change, sceneBoundingRect = "
|
||||
// << m_containment->sceneBoundingRect();
|
||||
if (!m_containment->sceneBoundingRect().contains(m_applet->scenePos())) {
|
||||
// see which containment it belongs to
|
||||
Corona * corona = qobject_cast<Corona*>(scene());
|
||||
if (corona) {
|
||||
QList<Containment*> containments = corona->containments();
|
||||
for (int i = 0; i < containments.size(); ++i) {
|
||||
QPointF pos;
|
||||
QGraphicsView *v;
|
||||
v = containments[i]->view();
|
||||
if (v) {
|
||||
pos = v->mapToScene(
|
||||
v->mapFromGlobal(event->screenPos() - m_mousePos));
|
||||
|
||||
if (containments[i]->sceneBoundingRect().contains(pos)) {
|
||||
//kDebug() << "new containment = " << containments[i];
|
||||
//kDebug() << "rect = " << containments[i]->sceneBoundingRect();
|
||||
// add the applet to the new containment and take it from the old one
|
||||
//kDebug() << "moving to other containment with position" << pos;;
|
||||
switchContainment(containments[i], pos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -599,7 +616,7 @@ void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
||||
qreal _k_distanceForPoint(QPointF point)
|
||||
{
|
||||
return std::sqrt(point.x()*point.x()+point.y()*point.y());
|
||||
return std::sqrt(point.x() * point.x() + point.y() * point.y());
|
||||
}
|
||||
|
||||
qreal _k_angleForPoints(const QPointF ¢er, const QPointF &pt1, const QPointF &pt2)
|
||||
@ -653,8 +670,8 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
m_topview = new View(m_containment, -1, 0);
|
||||
|
||||
m_topview->setTrackContainmentChanges(false);
|
||||
m_topview->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint
|
||||
| Qt::WindowStaysOnTopHint);
|
||||
m_topview->setWindowFlags(
|
||||
Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||
m_topview->setWallpaperEnabled(false);
|
||||
m_topview->resize(screenRect.size());
|
||||
m_topview->setSceneRect(m_applet->sceneBoundingRect());
|
||||
@ -710,8 +727,8 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
if (m_pressedButton == RotateButton) {
|
||||
m_tempAngle = _k_angleForPoints(center, pressPos, event->pos());
|
||||
|
||||
if (fabs(remainder(m_angle+m_tempAngle, snapAngle)) < 0.15) {
|
||||
m_tempAngle = m_tempAngle - remainder(m_angle+m_tempAngle, snapAngle);
|
||||
if (fabs(remainder(m_angle + m_tempAngle, snapAngle)) < 0.15) {
|
||||
m_tempAngle = m_tempAngle - remainder(m_angle + m_tempAngle, snapAngle);
|
||||
}
|
||||
|
||||
m_scaleWidth = m_scaleHeight = 1.0;
|
||||
@ -769,7 +786,9 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
// maintain aspect ratio
|
||||
qreal newScale = 0;
|
||||
|
||||
newScale = _k_distanceForPoint(event->pos()-center) / _k_distanceForPoint(pressPos-center);
|
||||
newScale =
|
||||
_k_distanceForPoint(event->pos()-center) /
|
||||
_k_distanceForPoint(pressPos - center);
|
||||
if (qAbs(h - (newScale * h)) <= KGlobalSettings::dndEventDelay()) {
|
||||
newScale = 1.0;
|
||||
}
|
||||
@ -786,7 +805,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
|
||||
QTransform matrix;
|
||||
matrix.translate(center.x(), center.y());
|
||||
matrix.rotateRadians(m_angle+m_tempAngle);
|
||||
matrix.rotateRadians(m_angle + m_tempAngle);
|
||||
matrix.scale(m_scaleWidth, m_scaleHeight);
|
||||
matrix.translate(-center.x(), -center.y());
|
||||
setTransform(matrix);
|
||||
@ -795,7 +814,6 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//pos relative to scene
|
||||
void AppletHandle::switchContainment(Containment *containment, const QPointF &pos)
|
||||
{
|
||||
@ -944,7 +962,8 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
|
||||
// ok, both sides failed to be perfect... which one is more perfect?
|
||||
QRectF f1 = region.boundingRect();
|
||||
QRectF f2 = region2.boundingRect();
|
||||
//kDebug() << "still not a perfect world" << f2.width() << f2.height() << f1.width() << f1.height();
|
||||
//kDebug() << "still not a perfect world"
|
||||
// << f2.width() << f2.height() << f1.width() << f1.height();
|
||||
if ((f2.width() * f2.height()) < (f1.width() * f1.height())) {
|
||||
//kDebug() << "we did better the first time";
|
||||
m_buttonsOnRight = !m_buttonsOnRight;
|
||||
@ -953,7 +972,10 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
|
||||
}
|
||||
}
|
||||
|
||||
if (wasOnRight != m_buttonsOnRight && m_anim == FadeIn && anim == FadeIn && m_opacity <= 1) {
|
||||
if (wasOnRight != m_buttonsOnRight &&
|
||||
m_anim == FadeIn &&
|
||||
anim == FadeIn &&
|
||||
m_opacity <= 1) {
|
||||
m_opacity = 0.0;
|
||||
}
|
||||
|
||||
@ -964,7 +986,8 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
|
||||
|
||||
m_anim = anim;
|
||||
//kDebug() << "animating for " << time << "ms";
|
||||
m_animId = Animator::self()->customAnimation(80*(time/1000.0), (int)time, Animator::EaseInCurve, this, "fadeAnimation");
|
||||
m_animId = Animator::self()->customAnimation(
|
||||
80 * (time / 1000.0), (int)time, Animator::EaseInCurve, this, "fadeAnimation");
|
||||
}
|
||||
|
||||
void AppletHandle::forceDisappear()
|
||||
@ -977,11 +1000,11 @@ int AppletHandle::minimumHeight()
|
||||
{
|
||||
int iconMargin = m_iconSize / 2;
|
||||
int requiredHeight = iconMargin + //first margin
|
||||
(m_iconSize + iconMargin ) * 4 + //XXX remember to update this if the number of buttons changes
|
||||
(m_iconSize + iconMargin) * 4 + //XXX remember to update this if the number of buttons changes
|
||||
iconMargin ; //blank space before the close button
|
||||
|
||||
if (m_applet && m_applet->hasConfigurationInterface()) {
|
||||
requiredHeight += (m_iconSize + iconMargin );
|
||||
requiredHeight += (m_iconSize + iconMargin);
|
||||
}
|
||||
|
||||
return requiredHeight;
|
||||
@ -995,7 +1018,8 @@ void AppletHandle::calculateSize()
|
||||
|
||||
int handleHeight = qMax(minimumHeight(), int(m_applet->contentsRect().height() * 0.8));
|
||||
int handleWidth = m_iconSize + 2 * HANDLE_MARGIN;
|
||||
int top = m_applet->contentsRect().top() + (m_applet->contentsRect().height() - handleHeight) / 2.0;
|
||||
int top =
|
||||
m_applet->contentsRect().top() + (m_applet->contentsRect().height() - handleHeight) / 2.0;
|
||||
|
||||
qreal marginLeft, marginTop, marginRight, marginBottom;
|
||||
m_background->getMargins(marginLeft, marginTop, marginRight, marginBottom);
|
||||
@ -1008,9 +1032,8 @@ void AppletHandle::calculateSize()
|
||||
m_rect = QRectF(-handleWidth, top, handleWidth, handleHeight);
|
||||
}
|
||||
|
||||
|
||||
if (m_applet->contentsRect().height() > qreal(minimumHeight()) * 1.25) {
|
||||
int addedMargin = marginLeft/2;
|
||||
int addedMargin = marginLeft / 2;
|
||||
|
||||
// now we check to see if the shape is smaller than the contents,
|
||||
// and that the shape is not just the bounding rect; in those cases
|
||||
@ -1021,7 +1044,7 @@ void AppletHandle::calculateSize()
|
||||
QPainterPath p;
|
||||
p.addRect(m_applet->boundingRect());
|
||||
if (m_applet->shape() != p) {
|
||||
addedMargin = m_applet->contentsRect().width()/2;
|
||||
addedMargin = m_applet->contentsRect().width() / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,18 @@ class AppletHandle : public QObject, public QGraphicsItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum FadeType { FadeIn, FadeOut };
|
||||
enum ButtonType { NoButton, MoveButton, RotateButton, ConfigureButton, RemoveButton, ResizeButton };
|
||||
enum FadeType {
|
||||
FadeIn,
|
||||
FadeOut
|
||||
};
|
||||
enum ButtonType {
|
||||
NoButton,
|
||||
MoveButton,
|
||||
RotateButton,
|
||||
ConfigureButton,
|
||||
RemoveButton,
|
||||
ResizeButton
|
||||
};
|
||||
|
||||
AppletHandle(Containment *parent, Applet *applet, const QPointF &hoverPos);
|
||||
virtual ~AppletHandle();
|
||||
|
@ -33,7 +33,7 @@ class ToolBox;
|
||||
class ContainmentPrivate
|
||||
{
|
||||
public:
|
||||
ContainmentPrivate(Containment* c)
|
||||
ContainmentPrivate(Containment *c)
|
||||
: q(c),
|
||||
formFactor(Planar),
|
||||
location(Floating),
|
||||
@ -54,7 +54,7 @@ public:
|
||||
applets.clear();
|
||||
}
|
||||
|
||||
ToolBox* createToolBox();
|
||||
ToolBox *createToolBox();
|
||||
void positionToolBox();
|
||||
void triggerShowAddWidgets();
|
||||
|
||||
@ -83,11 +83,11 @@ public:
|
||||
*/
|
||||
void toggleDesktopImmutability();
|
||||
|
||||
Applet* addApplet(const QString& name, const QVariantList& args = QVariantList(),
|
||||
Applet *addApplet(const QString &name, const QVariantList &args = QVariantList(),
|
||||
const QRectF &geometry = QRectF(-1, -1, -1, -1), uint id = 0,
|
||||
bool delayedInit = false);
|
||||
|
||||
KActionCollection& actions();
|
||||
KActionCollection &actions();
|
||||
|
||||
/**
|
||||
* give keyboard focus to applet within this containment
|
||||
@ -97,7 +97,7 @@ public:
|
||||
/**
|
||||
* returns the Context for this Containment
|
||||
*/
|
||||
Context* context();
|
||||
Context *context();
|
||||
|
||||
Containment *q;
|
||||
FormFactor formFactor;
|
||||
|
@ -23,8 +23,9 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
SignalRelay* DataContainerPrivate::signalRelay(const DataContainer* dc, QObject *visualization,
|
||||
uint pollingInterval, Plasma::IntervalAlignment align,
|
||||
SignalRelay *DataContainerPrivate::signalRelay(const DataContainer *dc, QObject *visualization,
|
||||
uint pollingInterval,
|
||||
Plasma::IntervalAlignment align,
|
||||
bool immediateUpdate)
|
||||
{
|
||||
QMap<uint, SignalRelay *>::const_iterator relayIt = relays.find(pollingInterval);
|
||||
@ -32,7 +33,8 @@ SignalRelay* DataContainerPrivate::signalRelay(const DataContainer* dc, QObject
|
||||
|
||||
//FIXME what if we have two applets with the same interval and different alignment?
|
||||
if (relayIt == relays.end()) {
|
||||
relay = new SignalRelay(const_cast<DataContainer*>(dc), this, pollingInterval, align, immediateUpdate);
|
||||
relay = new SignalRelay(const_cast<DataContainer*>(dc), this,
|
||||
pollingInterval, align, immediateUpdate);
|
||||
relays[pollingInterval] = relay;
|
||||
} else {
|
||||
relay = relayIt.value();
|
||||
@ -53,7 +55,7 @@ bool DataContainerPrivate::hasUpdates()
|
||||
return dirty;
|
||||
}
|
||||
|
||||
SignalRelay::SignalRelay(DataContainer* parent, DataContainerPrivate *data, uint ival,
|
||||
SignalRelay::SignalRelay(DataContainer *parent, DataContainerPrivate *data, uint ival,
|
||||
Plasma::IntervalAlignment align, bool immediateUpdate)
|
||||
: QObject(parent),
|
||||
dc(parent),
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
: dirty(false), cached(false)
|
||||
{}
|
||||
|
||||
SignalRelay* signalRelay(const DataContainer* dc, QObject *visualization,
|
||||
SignalRelay *signalRelay(const DataContainer *dc, QObject *visualization,
|
||||
uint pollingInterval, Plasma::IntervalAlignment align,
|
||||
bool immediateUpdate);
|
||||
|
||||
@ -54,7 +54,7 @@ class SignalRelay : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SignalRelay(DataContainer* parent, DataContainerPrivate *data,
|
||||
SignalRelay(DataContainer *parent, DataContainerPrivate *data,
|
||||
uint ival, Plasma::IntervalAlignment align, bool immediateUpdate);
|
||||
|
||||
int receiverCount() const;
|
||||
@ -72,7 +72,7 @@ public:
|
||||
bool m_queued;
|
||||
|
||||
signals:
|
||||
void dataUpdated(const QString&, const Plasma::DataEngine::Data&);
|
||||
void dataUpdated(const QString &, const Plasma::DataEngine::Data &);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent *event);
|
||||
|
@ -31,12 +31,12 @@ namespace Plasma
|
||||
class DataEnginePrivate
|
||||
{
|
||||
public:
|
||||
DataEnginePrivate(DataEngine* e, KService::Ptr service);
|
||||
DataEnginePrivate(DataEngine *e, KService::Ptr service);
|
||||
~DataEnginePrivate();
|
||||
DataContainer* source(const QString& sourceName, bool createWhenMissing = true);
|
||||
void connectSource(DataContainer* s, QObject* visualization, uint pollingInterval,
|
||||
DataContainer *source(const QString &sourceName, bool createWhenMissing = true);
|
||||
void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval,
|
||||
Plasma::IntervalAlignment align, bool immediateCall = true);
|
||||
DataContainer* requestSource(const QString& sourceName, bool* newSource = 0);
|
||||
DataContainer *requestSource(const QString &sourceName, bool *newSource = 0);
|
||||
void trimQueue();
|
||||
void queueUpdate();
|
||||
void internalUpdateSource(DataContainer*);
|
||||
@ -60,19 +60,18 @@ class DataEnginePrivate
|
||||
**/
|
||||
bool isUsed() const;
|
||||
|
||||
|
||||
DataEngine* q;
|
||||
DataEngine *q;
|
||||
int refCount;
|
||||
int updateTimerId;
|
||||
int minPollingInterval;
|
||||
QTime updateTimestamp;
|
||||
DataEngine::SourceDict sources;
|
||||
QQueue<DataContainer*> sourceQueue;
|
||||
QTimer* updateTimer;
|
||||
QTimer *updateTimer;
|
||||
QString icon;
|
||||
uint limit;
|
||||
bool valid;
|
||||
DataEngineScript* script;
|
||||
DataEngineScript *script;
|
||||
QString engineName;
|
||||
Package *package;
|
||||
};
|
||||
|
@ -33,7 +33,6 @@
|
||||
|
||||
#include <plasma/applet.h>
|
||||
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -64,7 +63,7 @@ class EmptyGraphicsItem : public QGraphicsItem
|
||||
setPos(rect.topLeft());
|
||||
}
|
||||
|
||||
void paint(QPainter * p, const QStyleOptionGraphicsItem*, QWidget*)
|
||||
void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
{
|
||||
Q_UNUSED(p)
|
||||
//p->setPen(Qt::red);
|
||||
@ -105,7 +104,8 @@ DesktopToolBox::DesktopToolBox(QGraphicsItem *parent)
|
||||
: ToolBox(parent),
|
||||
d(new DesktopToolBoxPrivate)
|
||||
{
|
||||
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*)));
|
||||
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)),
|
||||
this, SLOT(toolMoved(QGraphicsItem*)));
|
||||
connect(this, SIGNAL(toggled()), this, SLOT(toggle()));
|
||||
|
||||
setZValue(10000000);
|
||||
@ -126,9 +126,9 @@ QRectF DesktopToolBox::boundingRect() const
|
||||
qreal height;
|
||||
|
||||
if (c == Left || c == Right) {
|
||||
height = size()*4;
|
||||
height = size() * 4;
|
||||
} else {
|
||||
height = size()*2;
|
||||
height = size() * 2;
|
||||
}
|
||||
|
||||
if (c == Bottom || c == BottomRight || c == BottomLeft) {
|
||||
@ -136,9 +136,9 @@ QRectF DesktopToolBox::boundingRect() const
|
||||
}
|
||||
|
||||
if (c == Top || c == Bottom) {
|
||||
width = size()*4;
|
||||
width = size() * 4;
|
||||
} else {
|
||||
width = size()*2;
|
||||
width = size() * 2;
|
||||
}
|
||||
|
||||
if (c == Right || c == TopRight || c == BottomRight) {
|
||||
@ -148,7 +148,8 @@ QRectF DesktopToolBox::boundingRect() const
|
||||
return QRectF(0, 0, width, height);
|
||||
}
|
||||
|
||||
void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void DesktopToolBox::paint(QPainter *painter,
|
||||
const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(widget)
|
||||
@ -157,11 +158,11 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
painter->translate(boundingRect().topLeft());
|
||||
|
||||
QColor color1 = KColorScheme(QPalette::Active, KColorScheme::Window,
|
||||
Plasma::Theme::defaultTheme()->colorScheme()).background().color();
|
||||
Plasma::Theme::defaultTheme()->colorScheme()).background().color();
|
||||
color1.setAlpha(64);
|
||||
|
||||
QColor color2 = KColorScheme(QPalette::Active, KColorScheme::Window,
|
||||
Plasma::Theme::defaultTheme()->colorScheme()).foreground().color();
|
||||
Plasma::Theme::defaultTheme()->colorScheme()).foreground().color();
|
||||
color2.setAlpha(64);
|
||||
|
||||
QPainterPath p = shape();
|
||||
@ -186,7 +187,8 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
gradientCenter = QPointF(boundingRect().left(), boundingRect().center().y());
|
||||
break;
|
||||
case Right:
|
||||
iconPos = QPoint((int)boundingRect().left() - iconSize().width() + 2, boundingRect().center().y() - iconSize().height() / 2);
|
||||
iconPos = QPoint((int)boundingRect().left() - iconSize().width() + 2,
|
||||
boundingRect().center().y() - iconSize().height() / 2);
|
||||
gradientCenter = QPointF(boundingRect().left(), boundingRect().center().y());
|
||||
break;
|
||||
case BottomLeft:
|
||||
@ -194,12 +196,14 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
gradientCenter = boundingRect().topLeft();
|
||||
break;
|
||||
case Bottom:
|
||||
iconPos = QPoint(boundingRect().center().x() - iconSize().width() / 2, boundingRect().top() - iconSize().height() - 2);
|
||||
iconPos = QPoint(boundingRect().center().x() - iconSize().width() / 2,
|
||||
boundingRect().top() - iconSize().height() - 2);
|
||||
gradientCenter = QPointF(boundingRect().center().x(), boundingRect().top());
|
||||
break;
|
||||
case BottomRight:
|
||||
default:
|
||||
iconPos = QPoint((int)boundingRect().left() - iconSize().width() - 2, (int)boundingRect().top() - iconSize().height() - 2);
|
||||
iconPos = QPoint((int)boundingRect().left() - iconSize().width() - 2,
|
||||
(int)boundingRect().top() - iconSize().height() - 2);
|
||||
gradientCenter = boundingRect().topLeft();
|
||||
break;
|
||||
}
|
||||
@ -223,11 +227,14 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
if (qFuzzyCompare(qreal(1.0), progress)) {
|
||||
d->icon.paint(painter, QRect(iconPos, iconSize()));
|
||||
} else if (qFuzzyCompare(qreal(1.0), 1 + progress)) {
|
||||
d->icon.paint(painter, QRect(iconPos, iconSize()), Qt::AlignCenter, QIcon::Disabled, QIcon::Off);
|
||||
d->icon.paint(painter, QRect(iconPos, iconSize()),
|
||||
Qt::AlignCenter, QIcon::Disabled, QIcon::Off);
|
||||
} else {
|
||||
QPixmap disabled = d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off);
|
||||
QPixmap enabled = d->icon.pixmap(iconSize());
|
||||
QPixmap result = PaintUtils::transition(d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off), d->icon.pixmap(iconSize()), progress);
|
||||
QPixmap result = PaintUtils::transition(
|
||||
d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off),
|
||||
d->icon.pixmap(iconSize()), progress);
|
||||
painter->drawPixmap(QRect(iconPos, iconSize()), result);
|
||||
}
|
||||
|
||||
@ -241,29 +248,44 @@ QPainterPath DesktopToolBox::shape() const
|
||||
|
||||
switch (corner()) {
|
||||
case TopRight:
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().top() - toolSize, toolSize*2, toolSize*2), 180, 90);
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().top() - toolSize,
|
||||
toolSize * 2, toolSize * 2), 180, 90);
|
||||
break;
|
||||
case Top:
|
||||
path.arcTo(QRectF(boundingRect().center().x() - toolSize, boundingRect().top() - toolSize, toolSize*2, toolSize*2), 180, 180);
|
||||
path.arcTo(QRectF(boundingRect().center().x() - toolSize,
|
||||
boundingRect().top() - toolSize,
|
||||
toolSize * 2, toolSize * 2), 180, 180);
|
||||
break;
|
||||
case TopLeft:
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().top() - toolSize, toolSize*2, toolSize*2), 270, 90);
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize,
|
||||
boundingRect().top() - toolSize,
|
||||
toolSize * 2, toolSize * 2), 270, 90);
|
||||
break;
|
||||
case Left:
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().center().y() - toolSize, toolSize*2, toolSize*2), 270, 180);
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize,
|
||||
boundingRect().center().y() - toolSize,
|
||||
toolSize * 2, toolSize * 2), 270, 180);
|
||||
break;
|
||||
case Right:
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().center().y() - toolSize, toolSize*2, toolSize*2), 90, 180);
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize,
|
||||
boundingRect().center().y() - toolSize,
|
||||
toolSize * 2, toolSize * 2), 90, 180);
|
||||
break;
|
||||
case BottomLeft:
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().top() - toolSize, toolSize*2, toolSize*2), 0, 90);
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize,
|
||||
boundingRect().top() - toolSize,
|
||||
toolSize * 2, toolSize * 2), 0, 90);
|
||||
break;
|
||||
case Bottom:
|
||||
path.arcTo(QRectF(boundingRect().center().x() - toolSize, boundingRect().top() - toolSize, toolSize*2, toolSize*2), 0, 180);
|
||||
path.arcTo(QRectF(boundingRect().center().x() - toolSize,
|
||||
boundingRect().top() - toolSize,
|
||||
toolSize * 2, toolSize * 2), 0, 180);
|
||||
break;
|
||||
case BottomRight:
|
||||
default:
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().top() - toolSize, toolSize*2, toolSize*2), 90, 90);
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize,
|
||||
boundingRect().top() - toolSize,
|
||||
toolSize * 2, toolSize * 2), 90, 90);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -276,12 +298,14 @@ void DesktopToolBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
|
||||
QGraphicsItem::hoverEnterEvent(event);
|
||||
return;
|
||||
}
|
||||
Plasma::Animator* animdriver = Plasma::Animator::self();
|
||||
Plasma::Animator *animdriver = Plasma::Animator::self();
|
||||
if (d->animHighlightId) {
|
||||
animdriver->stopCustomAnimation(d->animHighlightId);
|
||||
}
|
||||
d->hovering = true;
|
||||
d->animHighlightId = animdriver->customAnimation(10, 240, Plasma::Animator::EaseInCurve, this, "animateHighlight");
|
||||
d->animHighlightId =
|
||||
animdriver->customAnimation(
|
||||
10, 240, Plasma::Animator::EaseInCurve, this, "animateHighlight");
|
||||
|
||||
QGraphicsItem::hoverEnterEvent(event);
|
||||
}
|
||||
@ -293,7 +317,7 @@ void DesktopToolBox::showToolBox()
|
||||
}
|
||||
|
||||
int maxwidth = 0;
|
||||
foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
|
||||
foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
|
||||
if (!tool->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
@ -339,8 +363,8 @@ void DesktopToolBox::showToolBox()
|
||||
y = (int)boundingRect().bottom() - iconWidth - 5;
|
||||
break;
|
||||
}
|
||||
Plasma::Animator* animdriver = Plasma::Animator::self();
|
||||
foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
|
||||
Plasma::Animator *animdriver = Plasma::Animator::self();
|
||||
foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
|
||||
if (tool == d->toolBacker) {
|
||||
continue;
|
||||
}
|
||||
@ -348,7 +372,8 @@ void DesktopToolBox::showToolBox()
|
||||
if (!tool->isEnabled()) {
|
||||
if (tool->isVisible()) {
|
||||
const int height = static_cast<int>(tool->boundingRect().height());
|
||||
animdriver->moveItem(tool, Plasma::Animator::SlideOutMovement, toolPosition(height));
|
||||
animdriver->moveItem(tool, Plasma::Animator::SlideOutMovement,
|
||||
toolPosition(height));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -373,24 +398,28 @@ void DesktopToolBox::showToolBox()
|
||||
setShowing(true);
|
||||
// TODO: 10 and 200 shouldn't be hardcoded here. There needs to be a way to
|
||||
// match whatever the time is that moveItem() takes. Same in hoverLeaveEvent().
|
||||
d->animCircleId = animdriver->customAnimation(10, 240, Plasma::Animator::EaseInCurve, this, "animateCircle");
|
||||
d->animCircleId =
|
||||
animdriver->customAnimation(10, 240, Plasma::Animator::EaseInCurve, this, "animateCircle");
|
||||
}
|
||||
|
||||
void DesktopToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
//kDebug() << event->pos() << event->scenePos() << d->toolBacker->rect().contains(event->scenePos().toPoint());
|
||||
//kDebug() << event->pos() << event->scenePos()
|
||||
// << d->toolBacker->rect().contains(event->scenePos().toPoint());
|
||||
if (! d->hovering) {
|
||||
QGraphicsItem::hoverLeaveEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
hideToolBox();
|
||||
Plasma::Animator* animdriver = Plasma::Animator::self();
|
||||
Plasma::Animator *animdriver = Plasma::Animator::self();
|
||||
if (d->animHighlightId) {
|
||||
animdriver->stopCustomAnimation(d->animHighlightId);
|
||||
}
|
||||
d->hovering = false;
|
||||
d->animHighlightId = animdriver->customAnimation(10, 240, Plasma::Animator::EaseOutCurve, this, "animateHighlight");
|
||||
d->animHighlightId =
|
||||
animdriver->customAnimation(
|
||||
10, 240, Plasma::Animator::EaseOutCurve, this, "animateHighlight");
|
||||
|
||||
QGraphicsItem::hoverLeaveEvent(event);
|
||||
}
|
||||
@ -401,8 +430,8 @@ void DesktopToolBox::hideToolBox()
|
||||
return;
|
||||
}
|
||||
|
||||
Plasma::Animator* animdriver = Plasma::Animator::self();
|
||||
foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
|
||||
Plasma::Animator *animdriver = Plasma::Animator::self();
|
||||
foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
|
||||
if (tool == d->toolBacker) {
|
||||
continue;
|
||||
}
|
||||
@ -416,7 +445,8 @@ void DesktopToolBox::hideToolBox()
|
||||
}
|
||||
|
||||
setShowing(false);
|
||||
d->animCircleId = animdriver->customAnimation(10, 240, Plasma::Animator::EaseOutCurve, this, "animateCircle");
|
||||
d->animCircleId =
|
||||
animdriver->customAnimation(10, 240, Plasma::Animator::EaseOutCurve, this, "animateCircle");
|
||||
|
||||
if (d->toolBacker) {
|
||||
d->toolBacker->hide();
|
||||
@ -474,4 +504,3 @@ void DesktopToolBox::toggle()
|
||||
} // plasma namespace
|
||||
|
||||
#include "desktoptoolbox_p.moc"
|
||||
|
||||
|
@ -59,10 +59,10 @@ void ExtenderApplet::adjustSize()
|
||||
|
||||
setPreferredSize(QSizeF(left + right + layout()->preferredWidth(),
|
||||
top + bottom + layout()->preferredHeight()));
|
||||
setMinimumSize( QSizeF(left + right + layout()->minimumWidth(),
|
||||
top + bottom + layout()->minimumHeight()));
|
||||
setMaximumSize( QSizeF(left + right + layout()->maximumWidth(),
|
||||
top + bottom + layout()->maximumHeight()));
|
||||
setMinimumSize(QSizeF(left + right + layout()->minimumWidth(),
|
||||
top + bottom + layout()->minimumHeight()));
|
||||
setMaximumSize(QSizeF(left + right + layout()->maximumWidth(),
|
||||
top + bottom + layout()->maximumHeight()));
|
||||
|
||||
updateGeometry();
|
||||
//This wasn't necesarry before... but it is now. weirdness.
|
||||
@ -70,7 +70,7 @@ void ExtenderApplet::adjustSize()
|
||||
layout()->invalidate();
|
||||
}
|
||||
|
||||
void ExtenderApplet::itemDetached(Plasma::ExtenderItem*)
|
||||
void ExtenderApplet::itemDetached(Plasma::ExtenderItem *)
|
||||
{
|
||||
kDebug() << "item detached: " << extender()->attachedItems().count();
|
||||
if (!extender()->attachedItems().count()) {
|
||||
@ -80,6 +80,5 @@ void ExtenderApplet::itemDetached(Plasma::ExtenderItem*)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "extenderapplet_p.moc"
|
||||
|
||||
|
@ -32,7 +32,7 @@ class ExtenderApplet : public Plasma::Applet
|
||||
void init();
|
||||
|
||||
public Q_SLOTS:
|
||||
void itemDetached(Plasma::ExtenderItem*);
|
||||
void itemDetached(Plasma::ExtenderItem *);
|
||||
void adjustSize();
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#ifndef WIDGETS_EXTENDERITEM_P_H
|
||||
#define WIDGETS_EXTENDERITEM_P_H
|
||||
|
||||
|
||||
#endif // WIDGETS_EXTENDERITEM_P_H
|
||||
|
@ -44,7 +44,6 @@
|
||||
|
||||
#include "private/style.h"
|
||||
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
@ -98,8 +97,6 @@ void NativeTabBarPrivate::storeLastIndex()
|
||||
lastIndex[1] = q->currentIndex();
|
||||
}
|
||||
|
||||
|
||||
|
||||
NativeTabBar::NativeTabBar(QWidget *parent)
|
||||
: QTabBar(parent),
|
||||
d(new NativeTabBarPrivate(this))
|
||||
@ -117,7 +114,7 @@ NativeTabBar::NativeTabBar(QWidget *parent)
|
||||
d->lastIndex[0] = -1;
|
||||
connect(this, SIGNAL(currentChanged(int)), this, SLOT(startAnimation()));
|
||||
|
||||
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
}
|
||||
|
||||
NativeTabBar::~NativeTabBar()
|
||||
@ -209,7 +206,7 @@ QSize NativeTabBar::sizeHint() const
|
||||
|
||||
height = tabRect(0).height();
|
||||
}
|
||||
return QSize(width+d->left+d->right, height+d->top+d->bottom);
|
||||
return QSize(width + d->left + d->right, height + d->top + d->bottom);
|
||||
}
|
||||
|
||||
void NativeTabBar::paintEvent(QPaintEvent *event)
|
||||
@ -238,7 +235,6 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
|
||||
d->buttonSvg->resizePanel(movingRect.size());
|
||||
d->buttonSvg->paintPanel(&painter, movingRect.topLeft());
|
||||
|
||||
|
||||
QFontMetrics metrics(painter.font());
|
||||
|
||||
for (int i = 0; i < count(); i++) {
|
||||
@ -300,17 +296,18 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
|
||||
|
||||
QStyleOption so;
|
||||
so.initFrom(this);
|
||||
so.palette.setColor(QPalette::ButtonText, Plasma::Theme::defaultTheme()->color(Theme::TextColor));
|
||||
so.palette.setColor(QPalette::ButtonText,
|
||||
Plasma::Theme::defaultTheme()->color(Theme::TextColor));
|
||||
|
||||
so.rect = scrollButtonsRect.adjusted(0, 0, -scrollButtonsRect.width()/2, 0);
|
||||
so.rect = scrollButtonsRect.adjusted(0, 0, -scrollButtonsRect.width() / 2, 0);
|
||||
style()->drawPrimitive(QStyle::PE_IndicatorArrowLeft, &so, &painter, this);
|
||||
|
||||
so.rect = scrollButtonsRect.adjusted(scrollButtonsRect.width()/2, 0, 0, 0);
|
||||
so.rect = scrollButtonsRect.adjusted(scrollButtonsRect.width() / 2, 0, 0, 0);
|
||||
style()->drawPrimitive(QStyle::PE_IndicatorArrowRight, &so, &painter, this);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeTabBar::resizeEvent(QResizeEvent* event)
|
||||
void NativeTabBar::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
QTabBar::resizeEvent(event);
|
||||
d->currentAnimRect = tabRect(currentIndex());
|
||||
@ -344,7 +341,8 @@ void NativeTabBar::tabLayoutChange()
|
||||
void NativeTabBar::startAnimation()
|
||||
{
|
||||
d->storeLastIndex();
|
||||
Plasma::Animator::self()->customAnimation(10, 150, Plasma::Animator::EaseInOutCurve, this, "onValueChanged");
|
||||
Plasma::Animator::self()->customAnimation(
|
||||
10, 150, Plasma::Animator::EaseInOutCurve, this, "onValueChanged");
|
||||
}
|
||||
|
||||
void NativeTabBar::onValueChanged(qreal value)
|
||||
@ -373,10 +371,10 @@ void NativeTabBar::animationFinished()
|
||||
bool NativeTabBar::isVertical() const
|
||||
{
|
||||
Shape s = shape();
|
||||
if( s == RoundedWest ||
|
||||
s == RoundedEast ||
|
||||
s == TriangularWest ||
|
||||
s == TriangularEast ) {
|
||||
if(s == RoundedWest ||
|
||||
s == RoundedEast ||
|
||||
s == TriangularWest ||
|
||||
s == TriangularEast) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -45,7 +45,7 @@ protected:
|
||||
|
||||
// reimplemented from QTabBar
|
||||
virtual void paintEvent(QPaintEvent *event);
|
||||
virtual void resizeEvent(QResizeEvent* event);
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
void tabInserted(int index);
|
||||
void tabRemoved(int index);
|
||||
void tabLayoutChange();
|
||||
|
@ -100,7 +100,8 @@ ThemePackage::ThemePackage(QObject *parent)
|
||||
addFileDefinition("opaque/widgets/tooltip", "opaque/widgets/tooltip.svg",
|
||||
i18n("Opaque background image for tooltips"));
|
||||
|
||||
addDirectoryDefinition("locolor/dialogs", "locolor/dialogs/", i18n("Low color images for dialogs"));
|
||||
addDirectoryDefinition("locolor/dialogs", "locolor/dialogs/",
|
||||
i18n("Low color images for dialogs"));
|
||||
addFileDefinition("locolor/dialogs/background", "locolor/dialogs/background.svg",
|
||||
i18n("Low color generic dialog background"));
|
||||
addFileDefinition("locolor/dialogs/shutdowndialog", "locolor/dialogs/shutdowndialog.svg",
|
||||
|
@ -63,7 +63,7 @@ class EmptyGraphicsItem : public QGraphicsItem
|
||||
setPos(rect.topLeft());
|
||||
}
|
||||
|
||||
void paint(QPainter * p, const QStyleOptionGraphicsItem*, QWidget*)
|
||||
void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
|
||||
{
|
||||
Q_UNUSED(p)
|
||||
//p->setPen(Qt::red);
|
||||
@ -100,7 +100,8 @@ PanelToolBox::PanelToolBox(QGraphicsItem *parent)
|
||||
: ToolBox(parent),
|
||||
d(new PanelToolBoxPrivate)
|
||||
{
|
||||
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*)));
|
||||
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)),
|
||||
this, SLOT(toolMoved(QGraphicsItem*)));
|
||||
connect(this, SIGNAL(toggled()), this, SLOT(toggle()));
|
||||
|
||||
setZValue(10000000);
|
||||
@ -119,12 +120,12 @@ PanelToolBox::~PanelToolBox()
|
||||
QRectF PanelToolBox::boundingRect() const
|
||||
{
|
||||
if (corner() == ToolBox::Bottom) {
|
||||
return QRectF(0, 0, size()*2, -size());
|
||||
return QRectF(0, 0, size() * 2, -size());
|
||||
} else if (corner() == ToolBox::Left) {
|
||||
return QRectF(0, 0, size(), size()*2);
|
||||
return QRectF(0, 0, size(), size() * 2);
|
||||
//Only Left,Right and Bottom supported, default to Right
|
||||
} else {
|
||||
return QRectF(0, 0, -size(), size()*2);
|
||||
return QRectF(0, 0, -size(), size() * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,12 +174,14 @@ void PanelToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
QRect iconRect;
|
||||
|
||||
if (corner() == ToolBox::Bottom) {
|
||||
iconRect = QRect(QPoint(gradientCenter.x() - iconSize().width()/2, (int)boundingRect().top() - iconSize().height() - 2), iconSize());
|
||||
iconRect = QRect(QPoint(gradientCenter.x() - iconSize().width() / 2,
|
||||
(int)boundingRect().top() - iconSize().height() - 2), iconSize());
|
||||
} else if (corner() == ToolBox::Left) {
|
||||
iconRect = QRect(QPoint(2, gradientCenter.y() - iconSize().height()/2), iconSize());
|
||||
iconRect = QRect(QPoint(2, gradientCenter.y() - iconSize().height() / 2), iconSize());
|
||||
//Only Left,Right and Bottom supported, default to Right
|
||||
} else {
|
||||
iconRect = QRect(QPoint((int)boundingRect().left() - iconSize().width() + 1, gradientCenter.y() - iconSize().height()/2), iconSize());
|
||||
iconRect = QRect(QPoint((int)boundingRect().left() - iconSize().width() + 1,
|
||||
gradientCenter.y() - iconSize().height() / 2), iconSize());
|
||||
}
|
||||
|
||||
if (qFuzzyCompare(qreal(1.0), progress)) {
|
||||
@ -188,7 +191,9 @@ void PanelToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
|
||||
} else {
|
||||
QPixmap disabled = d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off);
|
||||
QPixmap enabled = d->icon.pixmap(iconSize());
|
||||
QPixmap result = PaintUtils::transition(d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off), d->icon.pixmap(iconSize()), progress);
|
||||
QPixmap result = PaintUtils::transition(
|
||||
d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off),
|
||||
d->icon.pixmap(iconSize()), progress);
|
||||
painter->drawPixmap(iconRect, result);
|
||||
}
|
||||
}
|
||||
@ -199,12 +204,21 @@ QPainterPath PanelToolBox::shape() const
|
||||
int toolSize = size();// + (int)d->animFrame;
|
||||
|
||||
if (corner() == ToolBox::Bottom) {
|
||||
path.arcTo(QRectF(boundingRect().center().x() - toolSize, boundingRect().top() - toolSize, toolSize*2, toolSize*2), 0, 180);
|
||||
path.arcTo(QRectF(boundingRect().center().x() - toolSize,
|
||||
boundingRect().top() - toolSize,
|
||||
toolSize * 2,
|
||||
toolSize * 2), 0, 180);
|
||||
} else if (corner() == ToolBox::Left) {
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().center().y() - toolSize, toolSize*2, toolSize*2), 90, -180);
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize,
|
||||
boundingRect().center().y() - toolSize,
|
||||
toolSize * 2,
|
||||
toolSize * 2), 90, -180);
|
||||
//Only Left,Right and Bottom supported, default to Right
|
||||
} else {
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().center().y() - toolSize, toolSize*2, toolSize*2), 90, 180);
|
||||
path.arcTo(QRectF(boundingRect().left() - toolSize,
|
||||
boundingRect().center().y() - toolSize,
|
||||
toolSize * 2,
|
||||
toolSize * 2), 90, 180);
|
||||
}
|
||||
|
||||
return path;
|
||||
@ -228,7 +242,7 @@ void PanelToolBox::showToolBox()
|
||||
}
|
||||
|
||||
int maxwidth = 0;
|
||||
foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
|
||||
foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
|
||||
if (!tool->isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
@ -237,10 +251,10 @@ void PanelToolBox::showToolBox()
|
||||
|
||||
// put tools 5px from icon edge
|
||||
const int iconWidth = 32;
|
||||
int x = size()*2 - maxwidth - iconWidth - 5;
|
||||
int x = size() * 2 - maxwidth - iconWidth - 5;
|
||||
int y = 5; // pos().y();
|
||||
Plasma::Animator* animdriver = Plasma::Animator::self();
|
||||
foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
|
||||
Plasma::Animator *animdriver = Plasma::Animator::self();
|
||||
foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
|
||||
if (tool == d->toolBacker) {
|
||||
continue;
|
||||
}
|
||||
@ -248,7 +262,8 @@ void PanelToolBox::showToolBox()
|
||||
if (!tool->isEnabled()) {
|
||||
if (tool->isVisible()) {
|
||||
const int height = static_cast<int>(tool->boundingRect().height());
|
||||
animdriver->moveItem(tool, Plasma::Animator::SlideOutMovement, QPoint(size() * 2, -height));
|
||||
animdriver->moveItem(tool, Plasma::Animator::SlideOutMovement,
|
||||
QPoint(size() * 2, -height));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -273,13 +288,15 @@ void PanelToolBox::showToolBox()
|
||||
setShowing(true);
|
||||
// TODO: 10 and 200 shouldn't be hardcoded here. There needs to be a way to
|
||||
// match whatever the time is that moveItem() takes. Same in hoverLeaveEvent().
|
||||
d->animId = animdriver->customAnimation(10, 240, Plasma::Animator::EaseInCurve, this, "animate");
|
||||
d->animId = animdriver->customAnimation(
|
||||
10, 240, Plasma::Animator::EaseInCurve, this, "animate");
|
||||
d->stopwatch.restart();
|
||||
}
|
||||
|
||||
void PanelToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
|
||||
{
|
||||
//kDebug() << event->pos() << event->scenePos() << d->toolBacker->rect().contains(event->scenePos().toPoint());
|
||||
//kDebug() << event->pos() << event->scenePos()
|
||||
// << d->toolBacker->rect().contains(event->scenePos().toPoint());
|
||||
if ((d->toolBacker && d->toolBacker->rect().contains(event->scenePos().toPoint())) ||
|
||||
d->stopwatch.elapsed() < 100 || d->toggled) {
|
||||
QGraphicsItem::hoverLeaveEvent(event);
|
||||
@ -299,8 +316,8 @@ void PanelToolBox::hideToolBox()
|
||||
d->toggled = false;
|
||||
int x = size() * 2;
|
||||
int y = 0;
|
||||
Plasma::Animator* animdriver = Plasma::Animator::self();
|
||||
foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
|
||||
Plasma::Animator *animdriver = Plasma::Animator::self();
|
||||
foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
|
||||
if (tool == d->toolBacker) {
|
||||
continue;
|
||||
}
|
||||
@ -314,7 +331,8 @@ void PanelToolBox::hideToolBox()
|
||||
}
|
||||
|
||||
setShowing(false);
|
||||
d->animId = animdriver->customAnimation(10, 240, Plasma::Animator::EaseOutCurve, this, "animate");
|
||||
d->animId = animdriver->customAnimation(
|
||||
10, 240, Plasma::Animator::EaseOutCurve, this, "animate");
|
||||
|
||||
if (d->toolBacker) {
|
||||
d->toolBacker->hide();
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
delete tempFile;
|
||||
}
|
||||
|
||||
void jobFinished(KJob* job)
|
||||
void jobFinished(KJob *job)
|
||||
{
|
||||
emit q->finished(static_cast<ServiceJob*>(job));
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_SHAREDTIMER_P_H
|
||||
#define PLASMA_SHAREDTIMER_P_H
|
||||
|
||||
@ -38,7 +37,7 @@ public:
|
||||
void unregisterTimer(const Timer *t, int msec);
|
||||
|
||||
protected:
|
||||
void timerEvent(QTimerEvent* event);
|
||||
void timerEvent(QTimerEvent *event);
|
||||
|
||||
private:
|
||||
friend class TimerDriveSingleton;
|
||||
|
@ -29,7 +29,8 @@
|
||||
|
||||
namespace Plasma {
|
||||
|
||||
class StylePrivate {
|
||||
class StylePrivate
|
||||
{
|
||||
public:
|
||||
StylePrivate()
|
||||
: scrollbar(0)
|
||||
@ -70,7 +71,7 @@ void Style::drawComplexControl(ComplexControl control,
|
||||
painter->save();
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
const bool sunken =option->state & State_Sunken;
|
||||
const bool sunken = option->state & State_Sunken;
|
||||
const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
|
||||
QString prefix;
|
||||
|
||||
@ -91,7 +92,8 @@ void Style::drawComplexControl(ComplexControl control,
|
||||
subLine.moveCenter(subControlRect(control, option, SC_ScrollBarSubLine, widget).center());
|
||||
addLine.moveCenter(subControlRect(control, option, SC_ScrollBarAddLine, widget).center());
|
||||
|
||||
const QRect slider = subControlRect(control, option, SC_ScrollBarSlider, widget).adjusted(1, 0, -1, 0);
|
||||
const QRect slider =
|
||||
subControlRect(control, option, SC_ScrollBarSlider, widget).adjusted(1, 0, -1, 0);
|
||||
|
||||
d->scrollbar->setElementPrefix("background");
|
||||
d->scrollbar->resizePanel(option->rect.size());
|
||||
|
@ -18,7 +18,6 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_STYLE_H
|
||||
#define PLASMA_STYLE_H
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
||||
* Copyright 2008 by Marco Martin <notmart@gmail.com>
|
||||
@ -69,22 +68,22 @@ QPoint ToolBox::toolPosition(int toolHeight)
|
||||
{
|
||||
switch (d->corner) {
|
||||
case TopRight:
|
||||
return QPoint( d->size*2, -toolHeight);
|
||||
return QPoint(d->size * 2, -toolHeight);
|
||||
case Top:
|
||||
return QPoint( (int)boundingRect().center().x() - d->iconSize.width(), -toolHeight);
|
||||
return QPoint((int)boundingRect().center().x() - d->iconSize.width(), -toolHeight);
|
||||
case TopLeft:
|
||||
return QPoint( -d->size*2, -toolHeight);
|
||||
return QPoint(-d->size * 2, -toolHeight);
|
||||
case Left:
|
||||
return QPoint( -d->size*2, (int)boundingRect().center().y() - d->iconSize.height());
|
||||
return QPoint(-d->size * 2, (int)boundingRect().center().y() - d->iconSize.height());
|
||||
case Right:
|
||||
return QPoint( d->size*2, (int)boundingRect().center().y() - d->iconSize.height());
|
||||
return QPoint(d->size * 2, (int)boundingRect().center().y() - d->iconSize.height());
|
||||
case BottomLeft:
|
||||
return QPoint( -d->size*2,toolHeight);
|
||||
return QPoint(-d->size * 2, toolHeight);
|
||||
case Bottom:
|
||||
return QPoint( (int)boundingRect().center().x() - d->iconSize.width(), toolHeight);
|
||||
return QPoint((int)boundingRect().center().x() - d->iconSize.width(), toolHeight);
|
||||
case BottomRight:
|
||||
default:
|
||||
return QPoint( d->size*2, toolHeight);
|
||||
return QPoint(d->size * 2, toolHeight);
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +111,7 @@ void ToolBox::addTool(QAction *action)
|
||||
|
||||
void ToolBox::updateToolBox()
|
||||
{
|
||||
if ( d->showing) {
|
||||
if (d->showing) {
|
||||
d->showing = false;
|
||||
showToolBox();
|
||||
}
|
||||
|
@ -43,15 +43,16 @@ public:
|
||||
/**
|
||||
* These flags represents what borders should be drawn
|
||||
*/
|
||||
enum Corner { Top = 0,
|
||||
TopRight,
|
||||
TopLeft,
|
||||
Left,
|
||||
Right,
|
||||
Bottom,
|
||||
BottomRight,
|
||||
BottomLeft
|
||||
};
|
||||
enum Corner {
|
||||
Top = 0,
|
||||
TopRight,
|
||||
TopLeft,
|
||||
Left,
|
||||
Right,
|
||||
Bottom,
|
||||
BottomRight,
|
||||
BottomLeft
|
||||
};
|
||||
|
||||
explicit ToolBox(QGraphicsItem *parent = 0);
|
||||
~ToolBox();
|
||||
|
@ -41,12 +41,12 @@ class ToolTipPrivate
|
||||
{
|
||||
public:
|
||||
ToolTipPrivate(QObject *s)
|
||||
: label(0)
|
||||
, imageLabel(0)
|
||||
, preview(0)
|
||||
, windowToPreview(0)
|
||||
, source(s)
|
||||
, isActivated(true)
|
||||
: label(0),
|
||||
imageLabel(0),
|
||||
preview(0),
|
||||
windowToPreview(0),
|
||||
source(s),
|
||||
isActivated(true)
|
||||
{ }
|
||||
|
||||
QLabel *label;
|
||||
@ -72,7 +72,7 @@ void ToolTip::hideEvent(QHideEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void ToolTip::mouseReleaseEvent(QMouseEvent* event)
|
||||
void ToolTip::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (rect().contains(event->pos())) {
|
||||
hide();
|
||||
@ -80,8 +80,8 @@ void ToolTip::mouseReleaseEvent(QMouseEvent* event)
|
||||
}
|
||||
|
||||
ToolTip::ToolTip(QObject *source)
|
||||
: QWidget(0)
|
||||
, d(new ToolTipPrivate(source))
|
||||
: QWidget(0),
|
||||
d(new ToolTipPrivate(source))
|
||||
{
|
||||
if (source) {
|
||||
connect(source, SIGNAL(destroyed(QObject*)), this, SLOT(sourceDestroyed()));
|
||||
@ -116,7 +116,7 @@ void ToolTip::setContent(const ToolTipManager::ToolTipContent &data)
|
||||
d->label->setText("<qt><b>" + data.mainText + "</b><br>" + data.subText + "</qt>");
|
||||
d->imageLabel->setPixmap(data.image);
|
||||
d->windowToPreview = data.windowToPreview;
|
||||
d->preview->setWindowId( d->windowToPreview );
|
||||
d->preview->setWindowId(d->windowToPreview);
|
||||
|
||||
if (isVisible()) {
|
||||
resize(sizeHint());
|
||||
@ -163,7 +163,7 @@ void ToolTip::paintEvent(QPaintEvent *e)
|
||||
QPainter painter(this);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
painter.setClipRect(e->rect());
|
||||
painter.setCompositionMode(QPainter::CompositionMode_Source );
|
||||
painter.setCompositionMode(QPainter::CompositionMode_Source);
|
||||
painter.fillRect(rect(), Qt::transparent);
|
||||
|
||||
d->background->paintPanel(&painter);
|
||||
@ -187,13 +187,14 @@ void ToolTip::updateTheme()
|
||||
|
||||
// Make the tooltip use Plasma's colorscheme
|
||||
QPalette plasmaPalette = QPalette();
|
||||
plasmaPalette.setColor(QPalette::Window, Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
|
||||
plasmaPalette.setColor(QPalette::WindowText, Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
|
||||
plasmaPalette.setColor(QPalette::Window,
|
||||
Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
|
||||
plasmaPalette.setColor(QPalette::WindowText,
|
||||
Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
|
||||
setAutoFillBackground(true);
|
||||
setPalette(plasmaPalette);
|
||||
}
|
||||
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include "tooltip_p.moc"
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include <fixx11h.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace Plasma {
|
||||
|
||||
bool WindowPreview::previewsAvailable() // static
|
||||
@ -40,12 +39,12 @@ bool WindowPreview::previewsAvailable() // static
|
||||
#ifdef Q_WS_X11
|
||||
// hackish way to find out if KWin has the effect enabled,
|
||||
// TODO provide proper support
|
||||
Display* dpy = QX11Info::display();
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom(dpy, "_KDE_WINDOW_PREVIEW", False);
|
||||
int cnt;
|
||||
Atom* list = XListProperties(dpy, DefaultRootWindow( dpy ), &cnt);
|
||||
Atom *list = XListProperties(dpy, DefaultRootWindow(dpy), &cnt);
|
||||
if (list != NULL) {
|
||||
bool ret = ( qFind(list, list + cnt, atom) != list + cnt );
|
||||
bool ret = (qFind(list, list + cnt, atom) != list + cnt);
|
||||
XFree(list);
|
||||
return ret;
|
||||
}
|
||||
@ -53,7 +52,6 @@ bool WindowPreview::previewsAvailable() // static
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
WindowPreview::WindowPreview(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
@ -89,7 +87,7 @@ void WindowPreview::readWindowSize() const
|
||||
int x, y;
|
||||
unsigned int w, h, b, d;
|
||||
if (XGetGeometry(QX11Info::display(), id, &r, &x, &y, &w, &h, &b, &d)) {
|
||||
windowSize = QSize( w, h );
|
||||
windowSize = QSize(w, h);
|
||||
} else {
|
||||
windowSize = QSize();
|
||||
}
|
||||
@ -114,10 +112,10 @@ void WindowPreview::setInfo()
|
||||
XDeleteProperty(dpy, parentWidget()->winId(), atom);
|
||||
return;
|
||||
}
|
||||
Q_ASSERT( parentWidget()->isWindow()); // parent must be toplevel
|
||||
Q_ASSERT(parentWidget()->isWindow()); // parent must be toplevel
|
||||
long data[] = { 1, 5, id, x(), y(), width(), height() };
|
||||
XChangeProperty(dpy, parentWidget()->winId(), atom, atom, 32, PropModeReplace,
|
||||
reinterpret_cast< unsigned char* >( data ), sizeof( data ) / sizeof( data[ 0 ] ));
|
||||
reinterpret_cast<unsigned char *>(data), sizeof(data) / sizeof(data[ 0 ]));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user