more coding style fixes

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=870169
This commit is contained in:
Allen Winter 2008-10-11 23:28:20 +00:00
parent a7aebfa60a
commit 3674a94a99
23 changed files with 365 additions and 288 deletions

View File

@ -60,14 +60,14 @@ public:
QString globalName() const; QString globalName() const;
QString instanceName(); QString instanceName();
void scheduleConstraintsUpdate(Plasma::Constraints c); void scheduleConstraintsUpdate(Plasma::Constraints c);
KConfigGroup* mainConfigGroup(); KConfigGroup *mainConfigGroup();
QString visibleFailureText(const QString& reason); QString visibleFailureText(const QString &reason);
void checkImmutability(); void checkImmutability();
void themeChanged(); void themeChanged();
void resetConfigurationObject(); void resetConfigurationObject();
void appletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim); void appletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim);
void selectItemToDestroy(); void selectItemToDestroy();
void updateRect(const QRectF& rect); void updateRect(const QRectF &rect);
void setFocus(); void setFocus();
void cleanUpAndDelete(); void cleanUpAndDelete();

View File

@ -70,7 +70,8 @@ AppletHandle::AppletHandle(Containment *parent, Applet *applet, const QPointF &h
m_buttonsOnRight(false), m_buttonsOnRight(false),
m_pendingFade(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(); m_gradientColor = colorScheme.background(KColorScheme::NormalBackground).color();
QTransform originalMatrix = m_applet->transform(); QTransform originalMatrix = m_applet->transform();
@ -201,18 +202,22 @@ QPainterPath handleRect(const QRectF &rect, int radius, bool onRight)
// make the left side straight // make the left side straight
path.moveTo(rect.left(), rect.top()); // Top left path.moveTo(rect.left(), rect.top()); // Top left
path.lineTo(rect.right() - radius, rect.top()); // Top side path.lineTo(rect.right() - radius, rect.top()); // Top side
path.quadTo(rect.right(), rect.top(), rect.right(), rect.top() + radius); // Top right corner path.quadTo(rect.right(), rect.top(),
path.lineTo(rect.right(), rect.bottom() - radius); // Right side rect.right(), rect.top() + radius); // Top right corner
path.quadTo(rect.right(), rect.bottom(), rect.right() - radius, rect.bottom()); // Bottom right corner path.lineTo(rect.right(), rect.bottom() - radius); // Right side
path.lineTo(rect.left(), rect.bottom()); // Bottom side path.quadTo(rect.right(), rect.bottom(),
rect.right() - radius, rect.bottom()); // Bottom right corner
path.lineTo(rect.left(), rect.bottom()); // Bottom side
} else { } else {
// make the right side straight // make the right side straight
path.moveTo(QPointF(rect.left(), rect.top() + radius)); path.moveTo(QPointF(rect.left(), rect.top() + radius));
path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner path.quadTo(rect.left(), rect.top(),
path.lineTo(rect.right(), rect.top()); // Top side rect.left() + radius, rect.top()); // Top left corner
path.lineTo(rect.right(), rect.bottom()); // Right side path.lineTo(rect.right(), rect.top()); // Top side
path.lineTo(rect.left() + radius, rect.bottom()); // Bottom side path.lineTo(rect.right(), rect.bottom()); // Right side
path.quadTo(rect.left(), rect.bottom(), rect.left(), rect.bottom() - radius); // Bottom left corner 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(); path.closeSubpath();
@ -236,7 +241,8 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
qreal translation; qreal translation;
if (m_buttonsOnRight) { 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(); translation = -(1 - m_opacity) * m_rect.width();
} else { } else {
translation = (1 - m_opacity) * m_rect.width(); translation = (1 - m_opacity) * m_rect.width();
@ -247,10 +253,10 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
painter->setPen(Qt::NoPen); painter->setPen(Qt::NoPen);
painter->setRenderHints(QPainter::Antialiasing); painter->setRenderHints(QPainter::Antialiasing);
int iconMargin = m_iconSize / 2; 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); const QSize iconSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall);
//regenerate our buffer? //regenerate our buffer?
@ -258,11 +264,12 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
QColor transparencyColor = Qt::black; QColor transparencyColor = Qt::black;
transparencyColor.setAlphaF(qMin(m_opacity, qreal(0.99))); 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 //fading out panel
if (m_rect.height() > qreal(minimumHeight()) * 1.25) { if (m_rect.height() > qreal(minimumHeight()) * 1.25) {
if (m_buttonsOnRight) { 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 //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);
@ -270,7 +277,8 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
g.setColorAt(opaquePoint, transparencyColor); g.setColorAt(opaquePoint, transparencyColor);
g.setColorAt(1.0, transparencyColor); g.setColorAt(1.0, transparencyColor);
} else { } 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(1.0, Qt::transparent);
g.setColorAt(opaquePoint, Qt::transparent); g.setColorAt(opaquePoint, Qt::transparent);
g.setColorAt(qMax(0.0, opaquePoint - 0.05), transparencyColor); 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(pixmapSize.width() - m_iconSize + 1, m_iconSize), iconSize);
QRectF iconRect(QPointF(0, m_decorationRect.height() + 1), iconSize); QRectF iconRect(QPointF(0, m_decorationRect.height() + 1), iconSize);
if (m_buttonsOnRight) { 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"); m_configureIcons->paint(&buffPainter, iconRect, "size-diagonal-tr2bl");
} else { } else {
iconRect.moveLeft(m_background->marginSize(RightMargin)); iconRect.moveLeft(m_background->marginSize(RightMargin));
@ -318,10 +327,12 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
//blend the background //blend the background
buffPainter.fillRect(m_backgroundBuffer->rect(), g); buffPainter.fillRect(m_backgroundBuffer->rect(), g);
//blend the icons //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 //XXX this code is duplicated in the next function
QPointF basePoint = m_rect.topLeft() + QPointF(HANDLE_MARGIN, iconMargin); 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); QRectF sourceIconRect(QPointF(0, m_decorationRect.height() + 1), iconSize);
if (m_buttonsOnRight) { if (m_buttonsOnRight) {
sourceIconRect.moveLeft(pixmapSize.width() - m_iconSize - m_background->marginSize(LeftMargin)); sourceIconRect.moveLeft(
pixmapSize.width() - m_iconSize - m_background->marginSize(LeftMargin));
} else { } else {
sourceIconRect.moveLeft(m_background->marginSize(RightMargin)); sourceIconRect.moveLeft(m_background->marginSize(RightMargin));
} }
if (m_applet && m_applet->aspectRatioMode() != FixedSize) { if (m_applet && m_applet->aspectRatioMode() != FixedSize) {
//resize //resize
painter->drawPixmap(QRectF(basePoint + shiftM, iconSize), *m_backgroundBuffer, sourceIconRect); painter->drawPixmap(
QRectF(basePoint + shiftM, iconSize), *m_backgroundBuffer, sourceIconRect);
basePoint += step; basePoint += step;
} }
@ -372,7 +385,8 @@ void AppletHandle::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
if (m_applet && m_applet->hasConfigurationInterface()) { if (m_applet && m_applet->hasConfigurationInterface()) {
basePoint += step; basePoint += step;
sourceIconRect.translate(0, m_iconSize); sourceIconRect.translate(0, m_iconSize);
painter->drawPixmap(QRectF(basePoint + shiftC, iconSize), *m_backgroundBuffer, sourceIconRect); painter->drawPixmap(
QRectF(basePoint + shiftC, iconSize), *m_backgroundBuffer, sourceIconRect);
} }
//close //close
@ -426,7 +440,6 @@ AppletHandle::ButtonType AppletHandle::mapToButton(const QPointF &point) const
//return m_applet->mapToParent(m_applet->shape()).contains(point) ? NoButton : MoveButton; //return m_applet->mapToParent(m_applet->shape()).contains(point) ? NoButton : MoveButton;
} }
void AppletHandle::mousePressEvent(QGraphicsSceneMouseEvent *event) void AppletHandle::mousePressEvent(QGraphicsSceneMouseEvent *event)
{ {
//containment recently switched? //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, //is this widget a plasma view, a different view then our current one,
//AND not a dashboardview? //AND not a dashboardview?
Plasma::View *v = qobject_cast<Plasma::View *>(widget); Plasma::View *v = qobject_cast<Plasma::View *>(widget);
if (v && v != m_currentView if (v &&
&& v != m_topview v != m_currentView &&
&& v->containment() != m_containment) { v != m_topview &&
v->containment() != m_containment) {
return true; return true;
} }
} }
@ -484,7 +498,6 @@ bool AppletHandle::leaveCurrentView(const QPoint &pos) const
return false; return false;
} }
void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void AppletHandle::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{ {
//kDebug() << "button pressed:" << m_pressedButton << ", fade pending?" << m_pendingFade; //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) { if (m_applet && event->button() == Qt::LeftButton) {
switch (m_pressedButton) { switch (m_pressedButton) {
case ResizeButton: case ResizeButton:
case RotateButton: { case RotateButton:
if (m_scaleWidth > 0 && m_scaleHeight > 0) { {
QRectF rect(m_applet->boundingRect()); if (m_scaleWidth > 0 && m_scaleHeight > 0) {
const qreal newWidth = rect.width() * m_scaleWidth; QRectF rect(m_applet->boundingRect());
const qreal newHeight = rect.height() * m_scaleHeight; const qreal newWidth = rect.width() * m_scaleWidth;
m_applet->resetTransform(); const qreal newHeight = rect.height() * m_scaleHeight;
m_applet->resize(newWidth, newHeight); m_applet->resetTransform();
scale(1.0/m_scaleWidth, 1.0/m_scaleHeight); m_applet->resize(newWidth, newHeight);
moveBy((rect.width() - newWidth) / 2, (rect.height() - newHeight) / 2); scale(1.0 / m_scaleWidth, 1.0 / m_scaleHeight);
m_scaleWidth = m_scaleHeight = 0; 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 ConfigureButton: QRectF rect = QRectF(m_applet->pos(), m_applet->size());
//FIXME: Remove this call once the configuration management change was done QPointF center = rect.center();
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 m_angle += m_tempAngle;
if (leaveCurrentView(event->screenPos())) { m_tempAngle = 0;
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)) { QTransform matrix;
//kDebug() << "new containment = " << containments[i]; matrix.translate(center.x(), center.y());
//kDebug() << "rect = " << containments[i]->sceneBoundingRect(); matrix.rotateRadians(m_angle);
// add the applet to the new containment and take it from the old one matrix.translate(-center.x(), -center.y());
//kDebug() << "moving to other containment with position" << pos;;
switchContainment(containments[i], pos); setTransform(matrix);
break; 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) 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 &center, const QPointF &pt1, const QPointF &pt2) qreal _k_angleForPoints(const QPointF &center, 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 = new View(m_containment, -1, 0);
m_topview->setTrackContainmentChanges(false); m_topview->setTrackContainmentChanges(false);
m_topview->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint m_topview->setWindowFlags(
| Qt::WindowStaysOnTopHint); Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
m_topview->setWallpaperEnabled(false); m_topview->setWallpaperEnabled(false);
m_topview->resize(screenRect.size()); m_topview->resize(screenRect.size());
m_topview->setSceneRect(m_applet->sceneBoundingRect()); m_topview->setSceneRect(m_applet->sceneBoundingRect());
@ -710,8 +727,8 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
if (m_pressedButton == RotateButton) { if (m_pressedButton == RotateButton) {
m_tempAngle = _k_angleForPoints(center, pressPos, event->pos()); m_tempAngle = _k_angleForPoints(center, pressPos, event->pos());
if (fabs(remainder(m_angle+m_tempAngle, snapAngle)) < 0.15) { if (fabs(remainder(m_angle + m_tempAngle, snapAngle)) < 0.15) {
m_tempAngle = m_tempAngle - remainder(m_angle+m_tempAngle, snapAngle); m_tempAngle = m_tempAngle - remainder(m_angle + m_tempAngle, snapAngle);
} }
m_scaleWidth = m_scaleHeight = 1.0; m_scaleWidth = m_scaleHeight = 1.0;
@ -769,7 +786,9 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// maintain aspect ratio // maintain aspect ratio
qreal newScale = 0; 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()) { if (qAbs(h - (newScale * h)) <= KGlobalSettings::dndEventDelay()) {
newScale = 1.0; newScale = 1.0;
} }
@ -786,7 +805,7 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QTransform matrix; QTransform matrix;
matrix.translate(center.x(), center.y()); 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.scale(m_scaleWidth, m_scaleHeight);
matrix.translate(-center.x(), -center.y()); matrix.translate(-center.x(), -center.y());
setTransform(matrix); setTransform(matrix);
@ -795,7 +814,6 @@ void AppletHandle::mouseMoveEvent(QGraphicsSceneMouseEvent *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)
{ {
@ -944,7 +962,8 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
// ok, both sides failed to be perfect... which one is more perfect? // ok, both sides failed to be perfect... which one is more perfect?
QRectF f1 = region.boundingRect(); QRectF f1 = region.boundingRect();
QRectF f2 = region2.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())) { if ((f2.width() * f2.height()) < (f1.width() * f1.height())) {
//kDebug() << "we did better the first time"; //kDebug() << "we did better the first time";
m_buttonsOnRight = !m_buttonsOnRight; 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; m_opacity = 0.0;
} }
@ -964,7 +986,8 @@ void AppletHandle::startFading(FadeType anim, const QPointF &hoverPos)
m_anim = anim; m_anim = anim;
//kDebug() << "animating for " << time << "ms"; //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() void AppletHandle::forceDisappear()
@ -977,11 +1000,11 @@ int AppletHandle::minimumHeight()
{ {
int iconMargin = m_iconSize / 2; int iconMargin = m_iconSize / 2;
int requiredHeight = iconMargin + //first margin 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 iconMargin ; //blank space before the close button
if (m_applet && m_applet->hasConfigurationInterface()) { if (m_applet && m_applet->hasConfigurationInterface()) {
requiredHeight += (m_iconSize + iconMargin ); requiredHeight += (m_iconSize + iconMargin);
} }
return requiredHeight; return requiredHeight;
@ -995,7 +1018,8 @@ void AppletHandle::calculateSize()
int handleHeight = qMax(minimumHeight(), int(m_applet->contentsRect().height() * 0.8)); int handleHeight = qMax(minimumHeight(), int(m_applet->contentsRect().height() * 0.8));
int handleWidth = m_iconSize + 2 * HANDLE_MARGIN; 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; qreal marginLeft, marginTop, marginRight, marginBottom;
m_background->getMargins(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); m_rect = QRectF(-handleWidth, top, handleWidth, handleHeight);
} }
if (m_applet->contentsRect().height() > qreal(minimumHeight()) * 1.25) { 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, // 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 // and that the shape is not just the bounding rect; in those cases
@ -1021,7 +1044,7 @@ void AppletHandle::calculateSize()
QPainterPath p; QPainterPath p;
p.addRect(m_applet->boundingRect()); p.addRect(m_applet->boundingRect());
if (m_applet->shape() != p) { if (m_applet->shape() != p) {
addedMargin = m_applet->contentsRect().width()/2; addedMargin = m_applet->contentsRect().width() / 2;
} }
} }

View File

@ -40,8 +40,18 @@ class AppletHandle : public QObject, public QGraphicsItem
{ {
Q_OBJECT Q_OBJECT
public: public:
enum FadeType { FadeIn, FadeOut }; enum FadeType {
enum ButtonType { NoButton, MoveButton, RotateButton, ConfigureButton, RemoveButton, ResizeButton }; FadeIn,
FadeOut
};
enum ButtonType {
NoButton,
MoveButton,
RotateButton,
ConfigureButton,
RemoveButton,
ResizeButton
};
AppletHandle(Containment *parent, Applet *applet, const QPointF &hoverPos); AppletHandle(Containment *parent, Applet *applet, const QPointF &hoverPos);
virtual ~AppletHandle(); virtual ~AppletHandle();

View File

@ -33,7 +33,7 @@ class ToolBox;
class ContainmentPrivate class ContainmentPrivate
{ {
public: public:
ContainmentPrivate(Containment* c) ContainmentPrivate(Containment *c)
: q(c), : q(c),
formFactor(Planar), formFactor(Planar),
location(Floating), location(Floating),
@ -54,7 +54,7 @@ public:
applets.clear(); applets.clear();
} }
ToolBox* createToolBox(); ToolBox *createToolBox();
void positionToolBox(); void positionToolBox();
void triggerShowAddWidgets(); void triggerShowAddWidgets();
@ -83,11 +83,11 @@ public:
*/ */
void toggleDesktopImmutability(); 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, const QRectF &geometry = QRectF(-1, -1, -1, -1), uint id = 0,
bool delayedInit = false); bool delayedInit = false);
KActionCollection& actions(); KActionCollection &actions();
/** /**
* give keyboard focus to applet within this containment * give keyboard focus to applet within this containment
@ -97,7 +97,7 @@ public:
/** /**
* returns the Context for this Containment * returns the Context for this Containment
*/ */
Context* context(); Context *context();
Containment *q; Containment *q;
FormFactor formFactor; FormFactor formFactor;

View File

@ -23,8 +23,9 @@
namespace Plasma namespace Plasma
{ {
SignalRelay* DataContainerPrivate::signalRelay(const DataContainer* dc, QObject *visualization, SignalRelay *DataContainerPrivate::signalRelay(const DataContainer *dc, QObject *visualization,
uint pollingInterval, Plasma::IntervalAlignment align, uint pollingInterval,
Plasma::IntervalAlignment align,
bool immediateUpdate) bool immediateUpdate)
{ {
QMap<uint, SignalRelay *>::const_iterator relayIt = relays.find(pollingInterval); 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? //FIXME what if we have two applets with the same interval and different alignment?
if (relayIt == relays.end()) { 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; relays[pollingInterval] = relay;
} else { } else {
relay = relayIt.value(); relay = relayIt.value();
@ -53,7 +55,7 @@ bool DataContainerPrivate::hasUpdates()
return dirty; return dirty;
} }
SignalRelay::SignalRelay(DataContainer* parent, DataContainerPrivate *data, uint ival, SignalRelay::SignalRelay(DataContainer *parent, DataContainerPrivate *data, uint ival,
Plasma::IntervalAlignment align, bool immediateUpdate) Plasma::IntervalAlignment align, bool immediateUpdate)
: QObject(parent), : QObject(parent),
dc(parent), dc(parent),

View File

@ -35,7 +35,7 @@ public:
: dirty(false), cached(false) : dirty(false), cached(false)
{} {}
SignalRelay* signalRelay(const DataContainer* dc, QObject *visualization, SignalRelay *signalRelay(const DataContainer *dc, QObject *visualization,
uint pollingInterval, Plasma::IntervalAlignment align, uint pollingInterval, Plasma::IntervalAlignment align,
bool immediateUpdate); bool immediateUpdate);
@ -54,7 +54,7 @@ class SignalRelay : public QObject
Q_OBJECT Q_OBJECT
public: public:
SignalRelay(DataContainer* parent, DataContainerPrivate *data, SignalRelay(DataContainer *parent, DataContainerPrivate *data,
uint ival, Plasma::IntervalAlignment align, bool immediateUpdate); uint ival, Plasma::IntervalAlignment align, bool immediateUpdate);
int receiverCount() const; int receiverCount() const;
@ -72,7 +72,7 @@ public:
bool m_queued; bool m_queued;
signals: signals:
void dataUpdated(const QString&, const Plasma::DataEngine::Data&); void dataUpdated(const QString &, const Plasma::DataEngine::Data &);
protected: protected:
void timerEvent(QTimerEvent *event); void timerEvent(QTimerEvent *event);

View File

@ -31,12 +31,12 @@ namespace Plasma
class DataEnginePrivate class DataEnginePrivate
{ {
public: public:
DataEnginePrivate(DataEngine* e, KService::Ptr service); DataEnginePrivate(DataEngine *e, KService::Ptr service);
~DataEnginePrivate(); ~DataEnginePrivate();
DataContainer* source(const QString& sourceName, bool createWhenMissing = true); DataContainer *source(const QString &sourceName, bool createWhenMissing = true);
void connectSource(DataContainer* s, QObject* visualization, uint pollingInterval, void connectSource(DataContainer *s, QObject *visualization, uint pollingInterval,
Plasma::IntervalAlignment align, bool immediateCall = true); 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 trimQueue();
void queueUpdate(); void queueUpdate();
void internalUpdateSource(DataContainer*); void internalUpdateSource(DataContainer*);
@ -60,19 +60,18 @@ class DataEnginePrivate
**/ **/
bool isUsed() const; bool isUsed() const;
DataEngine *q;
DataEngine* q;
int refCount; int refCount;
int updateTimerId; int updateTimerId;
int minPollingInterval; int minPollingInterval;
QTime updateTimestamp; QTime updateTimestamp;
DataEngine::SourceDict sources; DataEngine::SourceDict sources;
QQueue<DataContainer*> sourceQueue; QQueue<DataContainer*> sourceQueue;
QTimer* updateTimer; QTimer *updateTimer;
QString icon; QString icon;
uint limit; uint limit;
bool valid; bool valid;
DataEngineScript* script; DataEngineScript *script;
QString engineName; QString engineName;
Package *package; Package *package;
}; };

View File

@ -33,7 +33,6 @@
#include <plasma/applet.h> #include <plasma/applet.h>
namespace Plasma namespace Plasma
{ {
@ -64,7 +63,7 @@ class EmptyGraphicsItem : public QGraphicsItem
setPos(rect.topLeft()); setPos(rect.topLeft());
} }
void paint(QPainter * p, const QStyleOptionGraphicsItem*, QWidget*) void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{ {
Q_UNUSED(p) Q_UNUSED(p)
//p->setPen(Qt::red); //p->setPen(Qt::red);
@ -105,7 +104,8 @@ DesktopToolBox::DesktopToolBox(QGraphicsItem *parent)
: ToolBox(parent), : ToolBox(parent),
d(new DesktopToolBoxPrivate) 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())); connect(this, SIGNAL(toggled()), this, SLOT(toggle()));
setZValue(10000000); setZValue(10000000);
@ -126,9 +126,9 @@ QRectF DesktopToolBox::boundingRect() const
qreal height; qreal height;
if (c == Left || c == Right) { if (c == Left || c == Right) {
height = size()*4; height = size() * 4;
} else { } else {
height = size()*2; height = size() * 2;
} }
if (c == Bottom || c == BottomRight || c == BottomLeft) { if (c == Bottom || c == BottomRight || c == BottomLeft) {
@ -136,19 +136,20 @@ QRectF DesktopToolBox::boundingRect() const
} }
if (c == Top || c == Bottom) { if (c == Top || c == Bottom) {
width = size()*4; width = size() * 4;
} else { } else {
width = size()*2; width = size() * 2;
} }
if (c == Right || c == TopRight || c == BottomRight) { if (c == Right || c == TopRight || c == BottomRight) {
width = -width; width = -width;
} }
return QRectF(0, 0, width, height); 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(option)
Q_UNUSED(widget) Q_UNUSED(widget)
@ -157,11 +158,11 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
painter->translate(boundingRect().topLeft()); painter->translate(boundingRect().topLeft());
QColor color1 = KColorScheme(QPalette::Active, KColorScheme::Window, QColor color1 = KColorScheme(QPalette::Active, KColorScheme::Window,
Plasma::Theme::defaultTheme()->colorScheme()).background().color(); Plasma::Theme::defaultTheme()->colorScheme()).background().color();
color1.setAlpha(64); color1.setAlpha(64);
QColor color2 = KColorScheme(QPalette::Active, KColorScheme::Window, QColor color2 = KColorScheme(QPalette::Active, KColorScheme::Window,
Plasma::Theme::defaultTheme()->colorScheme()).foreground().color(); Plasma::Theme::defaultTheme()->colorScheme()).foreground().color();
color2.setAlpha(64); color2.setAlpha(64);
QPainterPath p = shape(); QPainterPath p = shape();
@ -186,7 +187,8 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
gradientCenter = QPointF(boundingRect().left(), boundingRect().center().y()); gradientCenter = QPointF(boundingRect().left(), boundingRect().center().y());
break; break;
case Right: 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()); gradientCenter = QPointF(boundingRect().left(), boundingRect().center().y());
break; break;
case BottomLeft: case BottomLeft:
@ -194,12 +196,14 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
gradientCenter = boundingRect().topLeft(); gradientCenter = boundingRect().topLeft();
break; break;
case Bottom: 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()); gradientCenter = QPointF(boundingRect().center().x(), boundingRect().top());
break; break;
case BottomRight: case BottomRight:
default: 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(); gradientCenter = boundingRect().topLeft();
break; break;
} }
@ -223,11 +227,14 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
if (qFuzzyCompare(qreal(1.0), progress)) { if (qFuzzyCompare(qreal(1.0), progress)) {
d->icon.paint(painter, QRect(iconPos, iconSize())); d->icon.paint(painter, QRect(iconPos, iconSize()));
} else if (qFuzzyCompare(qreal(1.0), 1 + progress)) { } 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 { } else {
QPixmap disabled = d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off); QPixmap disabled = d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off);
QPixmap enabled = d->icon.pixmap(iconSize()); 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); painter->drawPixmap(QRect(iconPos, iconSize()), result);
} }
@ -241,29 +248,44 @@ QPainterPath DesktopToolBox::shape() const
switch (corner()) { switch (corner()) {
case TopRight: 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; break;
case Top: 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; break;
case TopLeft: 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; break;
case Left: 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; break;
case Right: 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; break;
case BottomLeft: 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; break;
case Bottom: 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; break;
case BottomRight: case BottomRight:
default: 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; break;
} }
@ -276,12 +298,14 @@ void DesktopToolBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
QGraphicsItem::hoverEnterEvent(event); QGraphicsItem::hoverEnterEvent(event);
return; return;
} }
Plasma::Animator* animdriver = Plasma::Animator::self(); Plasma::Animator *animdriver = Plasma::Animator::self();
if (d->animHighlightId) { if (d->animHighlightId) {
animdriver->stopCustomAnimation(d->animHighlightId); animdriver->stopCustomAnimation(d->animHighlightId);
} }
d->hovering = true; 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); QGraphicsItem::hoverEnterEvent(event);
} }
@ -293,7 +317,7 @@ void DesktopToolBox::showToolBox()
} }
int maxwidth = 0; int maxwidth = 0;
foreach (QGraphicsItem* tool, QGraphicsItem::children()) { foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
if (!tool->isEnabled()) { if (!tool->isEnabled()) {
continue; continue;
} }
@ -339,8 +363,8 @@ void DesktopToolBox::showToolBox()
y = (int)boundingRect().bottom() - iconWidth - 5; y = (int)boundingRect().bottom() - iconWidth - 5;
break; break;
} }
Plasma::Animator* animdriver = Plasma::Animator::self(); Plasma::Animator *animdriver = Plasma::Animator::self();
foreach (QGraphicsItem* tool, QGraphicsItem::children()) { foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
if (tool == d->toolBacker) { if (tool == d->toolBacker) {
continue; continue;
} }
@ -348,7 +372,8 @@ void DesktopToolBox::showToolBox()
if (!tool->isEnabled()) { if (!tool->isEnabled()) {
if (tool->isVisible()) { if (tool->isVisible()) {
const int height = static_cast<int>(tool->boundingRect().height()); 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; continue;
} }
@ -373,24 +398,28 @@ void DesktopToolBox::showToolBox()
setShowing(true); setShowing(true);
// TODO: 10 and 200 shouldn't be hardcoded here. There needs to be a way to // 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(). // 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) 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) { if (! d->hovering) {
QGraphicsItem::hoverLeaveEvent(event); QGraphicsItem::hoverLeaveEvent(event);
return; return;
} }
hideToolBox(); hideToolBox();
Plasma::Animator* animdriver = Plasma::Animator::self(); Plasma::Animator *animdriver = Plasma::Animator::self();
if (d->animHighlightId) { if (d->animHighlightId) {
animdriver->stopCustomAnimation(d->animHighlightId); animdriver->stopCustomAnimation(d->animHighlightId);
} }
d->hovering = false; 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); QGraphicsItem::hoverLeaveEvent(event);
} }
@ -401,8 +430,8 @@ void DesktopToolBox::hideToolBox()
return; return;
} }
Plasma::Animator* animdriver = Plasma::Animator::self(); Plasma::Animator *animdriver = Plasma::Animator::self();
foreach (QGraphicsItem* tool, QGraphicsItem::children()) { foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
if (tool == d->toolBacker) { if (tool == d->toolBacker) {
continue; continue;
} }
@ -416,7 +445,8 @@ void DesktopToolBox::hideToolBox()
} }
setShowing(false); 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) { if (d->toolBacker) {
d->toolBacker->hide(); d->toolBacker->hide();
@ -474,4 +504,3 @@ void DesktopToolBox::toggle()
} // plasma namespace } // plasma namespace
#include "desktoptoolbox_p.moc" #include "desktoptoolbox_p.moc"

View File

@ -59,10 +59,10 @@ void ExtenderApplet::adjustSize()
setPreferredSize(QSizeF(left + right + layout()->preferredWidth(), setPreferredSize(QSizeF(left + right + layout()->preferredWidth(),
top + bottom + layout()->preferredHeight())); top + bottom + layout()->preferredHeight()));
setMinimumSize( QSizeF(left + right + layout()->minimumWidth(), setMinimumSize(QSizeF(left + right + layout()->minimumWidth(),
top + bottom + layout()->minimumHeight())); top + bottom + layout()->minimumHeight()));
setMaximumSize( QSizeF(left + right + layout()->maximumWidth(), setMaximumSize(QSizeF(left + right + layout()->maximumWidth(),
top + bottom + layout()->maximumHeight())); top + bottom + layout()->maximumHeight()));
updateGeometry(); updateGeometry();
//This wasn't necesarry before... but it is now. weirdness. //This wasn't necesarry before... but it is now. weirdness.
@ -70,7 +70,7 @@ void ExtenderApplet::adjustSize()
layout()->invalidate(); layout()->invalidate();
} }
void ExtenderApplet::itemDetached(Plasma::ExtenderItem*) void ExtenderApplet::itemDetached(Plasma::ExtenderItem *)
{ {
kDebug() << "item detached: " << extender()->attachedItems().count(); kDebug() << "item detached: " << extender()->attachedItems().count();
if (!extender()->attachedItems().count()) { if (!extender()->attachedItems().count()) {
@ -80,6 +80,5 @@ void ExtenderApplet::itemDetached(Plasma::ExtenderItem*)
} }
} }
#include "extenderapplet_p.moc" #include "extenderapplet_p.moc"

View File

@ -32,7 +32,7 @@ class ExtenderApplet : public Plasma::Applet
void init(); void init();
public Q_SLOTS: public Q_SLOTS:
void itemDetached(Plasma::ExtenderItem*); void itemDetached(Plasma::ExtenderItem *);
void adjustSize(); void adjustSize();
}; };

View File

@ -1,5 +1,4 @@
#ifndef WIDGETS_EXTENDERITEM_P_H #ifndef WIDGETS_EXTENDERITEM_P_H
#define WIDGETS_EXTENDERITEM_P_H #define WIDGETS_EXTENDERITEM_P_H
#endif // WIDGETS_EXTENDERITEM_P_H #endif // WIDGETS_EXTENDERITEM_P_H

View File

@ -44,7 +44,6 @@
#include "private/style.h" #include "private/style.h"
namespace Plasma namespace Plasma
{ {
@ -98,8 +97,6 @@ void NativeTabBarPrivate::storeLastIndex()
lastIndex[1] = q->currentIndex(); lastIndex[1] = q->currentIndex();
} }
NativeTabBar::NativeTabBar(QWidget *parent) NativeTabBar::NativeTabBar(QWidget *parent)
: QTabBar(parent), : QTabBar(parent),
d(new NativeTabBarPrivate(this)) d(new NativeTabBarPrivate(this))
@ -117,7 +114,7 @@ NativeTabBar::NativeTabBar(QWidget *parent)
d->lastIndex[0] = -1; d->lastIndex[0] = -1;
connect(this, SIGNAL(currentChanged(int)), this, SLOT(startAnimation())); connect(this, SIGNAL(currentChanged(int)), this, SLOT(startAnimation()));
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
} }
NativeTabBar::~NativeTabBar() NativeTabBar::~NativeTabBar()
@ -209,7 +206,7 @@ QSize NativeTabBar::sizeHint() const
height = tabRect(0).height(); 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) void NativeTabBar::paintEvent(QPaintEvent *event)
@ -238,7 +235,6 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
d->buttonSvg->resizePanel(movingRect.size()); d->buttonSvg->resizePanel(movingRect.size());
d->buttonSvg->paintPanel(&painter, movingRect.topLeft()); d->buttonSvg->paintPanel(&painter, movingRect.topLeft());
QFontMetrics metrics(painter.font()); QFontMetrics metrics(painter.font());
for (int i = 0; i < count(); i++) { for (int i = 0; i < count(); i++) {
@ -300,17 +296,18 @@ void NativeTabBar::paintEvent(QPaintEvent *event)
QStyleOption so; QStyleOption so;
so.initFrom(this); 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); 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); style()->drawPrimitive(QStyle::PE_IndicatorArrowRight, &so, &painter, this);
} }
} }
void NativeTabBar::resizeEvent(QResizeEvent* event) void NativeTabBar::resizeEvent(QResizeEvent *event)
{ {
QTabBar::resizeEvent(event); QTabBar::resizeEvent(event);
d->currentAnimRect = tabRect(currentIndex()); d->currentAnimRect = tabRect(currentIndex());
@ -344,7 +341,8 @@ void NativeTabBar::tabLayoutChange()
void NativeTabBar::startAnimation() void NativeTabBar::startAnimation()
{ {
d->storeLastIndex(); 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) void NativeTabBar::onValueChanged(qreal value)
@ -373,10 +371,10 @@ void NativeTabBar::animationFinished()
bool NativeTabBar::isVertical() const bool NativeTabBar::isVertical() const
{ {
Shape s = shape(); Shape s = shape();
if( s == RoundedWest || if(s == RoundedWest ||
s == RoundedEast || s == RoundedEast ||
s == TriangularWest || s == TriangularWest ||
s == TriangularEast ) { s == TriangularEast) {
return true; return true;
} }
return false; return false;

View File

@ -45,7 +45,7 @@ protected:
// reimplemented from QTabBar // reimplemented from QTabBar
virtual void paintEvent(QPaintEvent *event); virtual void paintEvent(QPaintEvent *event);
virtual void resizeEvent(QResizeEvent* event); virtual void resizeEvent(QResizeEvent *event);
void tabInserted(int index); void tabInserted(int index);
void tabRemoved(int index); void tabRemoved(int index);
void tabLayoutChange(); void tabLayoutChange();

View File

@ -100,7 +100,8 @@ ThemePackage::ThemePackage(QObject *parent)
addFileDefinition("opaque/widgets/tooltip", "opaque/widgets/tooltip.svg", addFileDefinition("opaque/widgets/tooltip", "opaque/widgets/tooltip.svg",
i18n("Opaque background image for tooltips")); 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", addFileDefinition("locolor/dialogs/background", "locolor/dialogs/background.svg",
i18n("Low color generic dialog background")); i18n("Low color generic dialog background"));
addFileDefinition("locolor/dialogs/shutdowndialog", "locolor/dialogs/shutdowndialog.svg", addFileDefinition("locolor/dialogs/shutdowndialog", "locolor/dialogs/shutdowndialog.svg",

View File

@ -63,7 +63,7 @@ class EmptyGraphicsItem : public QGraphicsItem
setPos(rect.topLeft()); setPos(rect.topLeft());
} }
void paint(QPainter * p, const QStyleOptionGraphicsItem*, QWidget*) void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{ {
Q_UNUSED(p) Q_UNUSED(p)
//p->setPen(Qt::red); //p->setPen(Qt::red);
@ -100,7 +100,8 @@ PanelToolBox::PanelToolBox(QGraphicsItem *parent)
: ToolBox(parent), : ToolBox(parent),
d(new PanelToolBoxPrivate) 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())); connect(this, SIGNAL(toggled()), this, SLOT(toggle()));
setZValue(10000000); setZValue(10000000);
@ -119,12 +120,12 @@ PanelToolBox::~PanelToolBox()
QRectF PanelToolBox::boundingRect() const QRectF PanelToolBox::boundingRect() const
{ {
if (corner() == ToolBox::Bottom) { if (corner() == ToolBox::Bottom) {
return QRectF(0, 0, size()*2, -size()); return QRectF(0, 0, size() * 2, -size());
} else if (corner() == ToolBox::Left) { } 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 //Only Left,Right and Bottom supported, default to Right
} else { } 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; QRect iconRect;
if (corner() == ToolBox::Bottom) { 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) { } 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 //Only Left,Right and Bottom supported, default to Right
} else { } 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)) { if (qFuzzyCompare(qreal(1.0), progress)) {
@ -188,7 +191,9 @@ void PanelToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
} else { } else {
QPixmap disabled = d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off); QPixmap disabled = d->icon.pixmap(iconSize(), QIcon::Disabled, QIcon::Off);
QPixmap enabled = d->icon.pixmap(iconSize()); 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); painter->drawPixmap(iconRect, result);
} }
} }
@ -199,12 +204,21 @@ QPainterPath PanelToolBox::shape() const
int toolSize = size();// + (int)d->animFrame; int toolSize = size();// + (int)d->animFrame;
if (corner() == ToolBox::Bottom) { 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) { } 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 //Only Left,Right and Bottom supported, default to Right
} else { } 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; return path;
@ -228,7 +242,7 @@ void PanelToolBox::showToolBox()
} }
int maxwidth = 0; int maxwidth = 0;
foreach (QGraphicsItem* tool, QGraphicsItem::children()) { foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
if (!tool->isEnabled()) { if (!tool->isEnabled()) {
continue; continue;
} }
@ -237,10 +251,10 @@ void PanelToolBox::showToolBox()
// put tools 5px from icon edge // put tools 5px from icon edge
const int iconWidth = 32; const int iconWidth = 32;
int x = size()*2 - maxwidth - iconWidth - 5; int x = size() * 2 - maxwidth - iconWidth - 5;
int y = 5; // pos().y(); int y = 5; // pos().y();
Plasma::Animator* animdriver = Plasma::Animator::self(); Plasma::Animator *animdriver = Plasma::Animator::self();
foreach (QGraphicsItem* tool, QGraphicsItem::children()) { foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
if (tool == d->toolBacker) { if (tool == d->toolBacker) {
continue; continue;
} }
@ -248,7 +262,8 @@ void PanelToolBox::showToolBox()
if (!tool->isEnabled()) { if (!tool->isEnabled()) {
if (tool->isVisible()) { if (tool->isVisible()) {
const int height = static_cast<int>(tool->boundingRect().height()); 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; continue;
} }
@ -273,13 +288,15 @@ void PanelToolBox::showToolBox()
setShowing(true); setShowing(true);
// TODO: 10 and 200 shouldn't be hardcoded here. There needs to be a way to // 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(). // 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(); d->stopwatch.restart();
} }
void PanelToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) 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())) || if ((d->toolBacker && d->toolBacker->rect().contains(event->scenePos().toPoint())) ||
d->stopwatch.elapsed() < 100 || d->toggled) { d->stopwatch.elapsed() < 100 || d->toggled) {
QGraphicsItem::hoverLeaveEvent(event); QGraphicsItem::hoverLeaveEvent(event);
@ -299,8 +316,8 @@ void PanelToolBox::hideToolBox()
d->toggled = false; d->toggled = false;
int x = size() * 2; int x = size() * 2;
int y = 0; int y = 0;
Plasma::Animator* animdriver = Plasma::Animator::self(); Plasma::Animator *animdriver = Plasma::Animator::self();
foreach (QGraphicsItem* tool, QGraphicsItem::children()) { foreach (QGraphicsItem *tool, QGraphicsItem::children()) {
if (tool == d->toolBacker) { if (tool == d->toolBacker) {
continue; continue;
} }
@ -314,7 +331,8 @@ void PanelToolBox::hideToolBox()
} }
setShowing(false); 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) { if (d->toolBacker) {
d->toolBacker->hide(); d->toolBacker->hide();

View File

@ -79,7 +79,7 @@ public:
delete tempFile; delete tempFile;
} }
void jobFinished(KJob* job) void jobFinished(KJob *job)
{ {
emit q->finished(static_cast<ServiceJob*>(job)); emit q->finished(static_cast<ServiceJob*>(job));
} }

View File

@ -17,7 +17,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#ifndef PLASMA_SHAREDTIMER_P_H #ifndef PLASMA_SHAREDTIMER_P_H
#define PLASMA_SHAREDTIMER_P_H #define PLASMA_SHAREDTIMER_P_H
@ -38,7 +37,7 @@ public:
void unregisterTimer(const Timer *t, int msec); void unregisterTimer(const Timer *t, int msec);
protected: protected:
void timerEvent(QTimerEvent* event); void timerEvent(QTimerEvent *event);
private: private:
friend class TimerDriveSingleton; friend class TimerDriveSingleton;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2008 Fredrik Höglund <fredrik@kde.org> * Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
* Copyright © 2008 Marco Martin <notmart@gmail.com> * Copyright © 2008 Marco Martin <notmart@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
@ -29,7 +29,8 @@
namespace Plasma { namespace Plasma {
class StylePrivate { class StylePrivate
{
public: public:
StylePrivate() StylePrivate()
: scrollbar(0) : scrollbar(0)
@ -39,7 +40,7 @@ public:
~StylePrivate() ~StylePrivate()
{ {
} }
Plasma::PanelSvg *scrollbar; Plasma::PanelSvg *scrollbar;
}; };
@ -70,7 +71,7 @@ void Style::drawComplexControl(ComplexControl control,
painter->save(); painter->save();
painter->setRenderHint(QPainter::Antialiasing); 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); const QStyleOptionSlider *scrollOption = qstyleoption_cast<const QStyleOptionSlider *>(option);
QString prefix; QString prefix;
@ -91,7 +92,8 @@ void Style::drawComplexControl(ComplexControl control,
subLine.moveCenter(subControlRect(control, option, SC_ScrollBarSubLine, widget).center()); subLine.moveCenter(subControlRect(control, option, SC_ScrollBarSubLine, widget).center());
addLine.moveCenter(subControlRect(control, option, SC_ScrollBarAddLine, 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->setElementPrefix("background");
d->scrollbar->resizePanel(option->rect.size()); d->scrollbar->resizePanel(option->rect.size());

View File

@ -1,6 +1,6 @@
/* /*
* Copyright © 2008 Fredrik Höglund <fredrik@kde.org> * Copyright © 2008 Fredrik Höglund <fredrik@kde.org>
* Copyright © 2008 Marco Martin <notmart@gmail.com> * Copyright © 2008 Marco Martin <notmart@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as * it under the terms of the GNU Library General Public License as
@ -18,7 +18,6 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#ifndef PLASMA_STYLE_H #ifndef PLASMA_STYLE_H
#define PLASMA_STYLE_H #define PLASMA_STYLE_H

View File

@ -1,4 +1,3 @@
/* /*
* Copyright 2007 by Aaron Seigo <aseigo@kde.org> * Copyright 2007 by Aaron Seigo <aseigo@kde.org>
* Copyright 2008 by Marco Martin <notmart@gmail.com> * Copyright 2008 by Marco Martin <notmart@gmail.com>
@ -69,22 +68,22 @@ QPoint ToolBox::toolPosition(int toolHeight)
{ {
switch (d->corner) { switch (d->corner) {
case TopRight: case TopRight:
return QPoint( d->size*2, -toolHeight); return QPoint(d->size * 2, -toolHeight);
case Top: case Top:
return QPoint( (int)boundingRect().center().x() - d->iconSize.width(), -toolHeight); return QPoint((int)boundingRect().center().x() - d->iconSize.width(), -toolHeight);
case TopLeft: case TopLeft:
return QPoint( -d->size*2, -toolHeight); return QPoint(-d->size * 2, -toolHeight);
case Left: 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: 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: case BottomLeft:
return QPoint( -d->size*2,toolHeight); return QPoint(-d->size * 2, toolHeight);
case Bottom: case Bottom:
return QPoint( (int)boundingRect().center().x() - d->iconSize.width(), toolHeight); return QPoint((int)boundingRect().center().x() - d->iconSize.width(), toolHeight);
case BottomRight: case BottomRight:
default: 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() void ToolBox::updateToolBox()
{ {
if ( d->showing) { if (d->showing) {
d->showing = false; d->showing = false;
showToolBox(); showToolBox();
} }

View File

@ -43,15 +43,16 @@ public:
/** /**
* These flags represents what borders should be drawn * These flags represents what borders should be drawn
*/ */
enum Corner { Top = 0, enum Corner {
TopRight, Top = 0,
TopLeft, TopRight,
Left, TopLeft,
Right, Left,
Bottom, Right,
BottomRight, Bottom,
BottomLeft BottomRight,
}; BottomLeft
};
explicit ToolBox(QGraphicsItem *parent = 0); explicit ToolBox(QGraphicsItem *parent = 0);
~ToolBox(); ~ToolBox();

View File

@ -41,12 +41,12 @@ class ToolTipPrivate
{ {
public: public:
ToolTipPrivate(QObject *s) ToolTipPrivate(QObject *s)
: label(0) : label(0),
, imageLabel(0) imageLabel(0),
, preview(0) preview(0),
, windowToPreview(0) windowToPreview(0),
, source(s) source(s),
, isActivated(true) isActivated(true)
{ } { }
QLabel *label; 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())) { if (rect().contains(event->pos())) {
hide(); hide();
@ -80,8 +80,8 @@ void ToolTip::mouseReleaseEvent(QMouseEvent* event)
} }
ToolTip::ToolTip(QObject *source) ToolTip::ToolTip(QObject *source)
: QWidget(0) : QWidget(0),
, d(new ToolTipPrivate(source)) d(new ToolTipPrivate(source))
{ {
if (source) { if (source) {
connect(source, SIGNAL(destroyed(QObject*)), this, SLOT(sourceDestroyed())); 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->label->setText("<qt><b>" + data.mainText + "</b><br>" + data.subText + "</qt>");
d->imageLabel->setPixmap(data.image); d->imageLabel->setPixmap(data.image);
d->windowToPreview = data.windowToPreview; d->windowToPreview = data.windowToPreview;
d->preview->setWindowId( d->windowToPreview ); d->preview->setWindowId(d->windowToPreview);
if (isVisible()) { if (isVisible()) {
resize(sizeHint()); resize(sizeHint());
@ -163,7 +163,7 @@ void ToolTip::paintEvent(QPaintEvent *e)
QPainter painter(this); QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setClipRect(e->rect()); painter.setClipRect(e->rect());
painter.setCompositionMode(QPainter::CompositionMode_Source ); painter.setCompositionMode(QPainter::CompositionMode_Source);
painter.fillRect(rect(), Qt::transparent); painter.fillRect(rect(), Qt::transparent);
d->background->paintPanel(&painter); d->background->paintPanel(&painter);
@ -187,13 +187,14 @@ void ToolTip::updateTheme()
// Make the tooltip use Plasma's colorscheme // Make the tooltip use Plasma's colorscheme
QPalette plasmaPalette = QPalette(); QPalette plasmaPalette = QPalette();
plasmaPalette.setColor(QPalette::Window, Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor)); plasmaPalette.setColor(QPalette::Window,
plasmaPalette.setColor(QPalette::WindowText, Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor)); Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor));
plasmaPalette.setColor(QPalette::WindowText,
Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor));
setAutoFillBackground(true); setAutoFillBackground(true);
setPalette(plasmaPalette); setPalette(plasmaPalette);
} }
} // namespace Plasma } // namespace Plasma
#include "tooltip_p.moc" #include "tooltip_p.moc"

View File

@ -29,7 +29,6 @@
#include <fixx11h.h> #include <fixx11h.h>
#endif #endif
namespace Plasma { namespace Plasma {
bool WindowPreview::previewsAvailable() // static bool WindowPreview::previewsAvailable() // static
@ -40,12 +39,12 @@ bool WindowPreview::previewsAvailable() // static
#ifdef Q_WS_X11 #ifdef Q_WS_X11
// hackish way to find out if KWin has the effect enabled, // hackish way to find out if KWin has the effect enabled,
// TODO provide proper support // TODO provide proper support
Display* dpy = QX11Info::display(); Display *dpy = QX11Info::display();
Atom atom = XInternAtom(dpy, "_KDE_WINDOW_PREVIEW", False); Atom atom = XInternAtom(dpy, "_KDE_WINDOW_PREVIEW", False);
int cnt; int cnt;
Atom* list = XListProperties(dpy, DefaultRootWindow( dpy ), &cnt); Atom *list = XListProperties(dpy, DefaultRootWindow(dpy), &cnt);
if (list != NULL) { if (list != NULL) {
bool ret = ( qFind(list, list + cnt, atom) != list + cnt ); bool ret = (qFind(list, list + cnt, atom) != list + cnt);
XFree(list); XFree(list);
return ret; return ret;
} }
@ -53,7 +52,6 @@ bool WindowPreview::previewsAvailable() // static
return false; return false;
} }
WindowPreview::WindowPreview(QWidget *parent) WindowPreview::WindowPreview(QWidget *parent)
: QWidget(parent) : QWidget(parent)
{ {
@ -89,7 +87,7 @@ void WindowPreview::readWindowSize() const
int x, y; int x, y;
unsigned int w, h, b, d; unsigned int w, h, b, d;
if (XGetGeometry(QX11Info::display(), id, &r, &x, &y, &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 { } else {
windowSize = QSize(); windowSize = QSize();
} }
@ -114,10 +112,10 @@ void WindowPreview::setInfo()
XDeleteProperty(dpy, parentWidget()->winId(), atom); XDeleteProperty(dpy, parentWidget()->winId(), atom);
return; 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() }; long data[] = { 1, 5, id, x(), y(), width(), height() };
XChangeProperty(dpy, parentWidget()->winId(), atom, atom, 32, PropModeReplace, 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 #endif
} }