more comparison fixes

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=696656
This commit is contained in:
Aaron J. Seigo 2007-08-05 14:24:24 +00:00
parent b41bd5f532
commit 5d05c8ac7e
2 changed files with 9 additions and 3 deletions

View File

@ -19,6 +19,9 @@
#include "applet.h"
#include <cmath>
#include <limits>
#include <QApplication>
#include <QEvent>
#include <QFile>
@ -665,7 +668,8 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
}
qreal zoomLevel = painter->transform().m11() / transform().m11();
if (zoomLevel == scalingFactor(Plasma::DesktopZoom)) { // Show Desktop
//kDebug() << "qreal " << zoomLevel << " = " << painter->transform().m11() << " / " << transform().m11();
if (fabs(zoomLevel - scalingFactor(Plasma::DesktopZoom)) < std::numeric_limits<double>::epsilon()) { // Show Desktop
if (d->background) {
d->paintBackground(painter, this);
}
@ -675,7 +679,8 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
}
d->paintHover(painter, this);
} else if (zoomLevel == scalingFactor(Plasma::GroupZoom)) { // Show Groups + Applet outline
} else if (fabs(zoomLevel - scalingFactor(Plasma::GroupZoom)) < std::numeric_limits<double>::epsilon()) {
// Show Groups + Applet outline
//TODO: make pretty.
painter->setBrush(QBrush(color(), Qt::SolidPattern));
painter->drawRoundRect(boundingRect());

View File

@ -20,6 +20,7 @@
#include "widget.h"
#include <cmath>
#include <limits>
#include <QtCore/QList>
@ -54,7 +55,7 @@ class Widget::Private
bool Widget::Private::shouldPaint(QPainter *painter, const QTransform &transform)
{
qreal zoomLevel = painter->transform().m11() / transform.m11();
return (zoomLevel - scalingFactor(Plasma::DesktopZoom)) < std::numeric_limits<double>::epsilon();
return (fabs(zoomLevel - scalingFactor(Plasma::DesktopZoom))) < std::numeric_limits<double>::epsilon();
}
Widget::Widget(QGraphicsItem *parent)