[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/utils/filelight/src/part/radialMap
From: Martin Tobias Holmedahl Sandsmark <sandsmark () samfundet ! no>
Date: 2009-05-12 16:52:48
Message-ID: 1242147168.497798.19881.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 967134 by sandsmark:
Fix the updating of tooltips when moving between file "slices", clean up includes, \
move around some code (we don't do fake transparency).
M +24 -51 segmentTip.cpp
M +2 -2 segmentTip.h
M +22 -23 widgetEvents.cpp
--- trunk/playground/utils/filelight/src/part/radialMap/segmentTip.cpp #967133:967134
@@ -25,19 +25,16 @@
#include "part/Config.h"
#include <cstdlib>
-#include <kapplication.h> //installing eventFilters
-#include <kglobal.h>
-#include <kglobalsettings.h>
-#include <klocale.h>
-#include <qimageblitz/qimageblitz.h>
+#include <KApplication> //installing eventFilters
+#include <KGlobal>
+#include <KGlobalSettings>
+#include <KLocale>
+
#include <QPainter>
-#include <qtooltip.h> //for its palette
-//Added by qt3to4:
#include <QEvent>
+#include <QToolTip>
-
-
namespace RadialMap {
SegmentTip::SegmentTip(uint h)
@@ -47,7 +44,7 @@
}
void
-SegmentTip::moveTo(QPoint p, QWidget &canvas, bool placeAbove)
+SegmentTip::moveTo(QPoint p, bool placeAbove)
{
//**** this function is very slow and seems to be visibly influenced by \
operations like mapFromGlobal() (who knows why!) // ** so any improvements are much \
desired @@ -56,51 +53,11 @@
p.rx() -= rect().center().x();
p.ry() -= (placeAbove ? 8 + height() : m_cursorHeight - 8);
- const QRect screen = KGlobalSettings::desktopGeometry(parentWidget());
-
const int x = p.x();
const int y = p.y();
- const int x2 = x + width();
- const int y2 = y + height(); //how's it ever gunna get below screen height?! \
(well you never know I spose)
- const int sw = screen.width();
- const int sh = screen.height();
- if (x < 0 ) p.setX(0);
- if (y < 0 ) p.setY(0);
- if (x2 > sw) p.rx() -= x2 - sw;
- if (y2 > sh) p.ry() -= y2 - sh;
-
-
- //I'm using this QPoint to determine where to offset the bitBlt in m_pixmap
- QPoint offset = canvas.mapToGlobal(QPoint()) - p;
- if (offset.x() < 0) offset.setX(0);
- if (offset.y() < 0) offset.setY(0);
-
-
- const QRect alphaMaskRect(canvas.mapFromGlobal(p), size());
- const QRect intersection(alphaMaskRect.intersect(canvas.rect()));
-
- m_pixmap = QPixmap(size()); //move to updateTip once you are sure it can never \
be null
-
- const QColor bg = QToolTip::palette().color(QPalette::Active, \
QPalette::Background);
- const QColor fg = QToolTip::palette().color(QPalette::Active, \
QPalette::WindowText);
-
- m_pixmap.fill(bg);
-
- QPainter paint(&m_pixmap);
- if (Config::antialias) paint.setRenderHint(QPainter::Antialiasing);
-
- paint.setPen(fg);
- paint.setBrush(Qt::NoBrush);
- paint.drawRect(rect());
- paint.drawText(rect(), Qt::AlignCenter, m_text);
- paint.end();
-
- p += screen.topLeft(); //for Xinerama users
-
move(x, y);
show();
- update();
}
void
@@ -122,7 +79,7 @@
if (file->isDirectory())
{
- double files = static_cast<const Directory*>(file)->children();
+ int files = static_cast<const Directory*>(file)->children();
const uint pc = uint((100 * files) / (double)root->children());
QString s3 = i18np("File: %1", "Files: %1", files);
@@ -141,6 +98,22 @@
if (w > maxw) maxw = w;
resize(maxw + 2 * MARGIN, h);
+
+ // Paint
+ m_pixmap = QPixmap(size()); //move to updateTip once you are sure it can never \
be null +
+ const QColor bg = QToolTip::palette().color(QPalette::Active, \
QPalette::Background); + const QColor fg = \
QToolTip::palette().color(QPalette::Active, QPalette::WindowText); +
+ m_pixmap.fill(bg);
+
+ QPainter paint(&m_pixmap);
+ if (Config::antialias) paint.setRenderHint(QPainter::Antialiasing);
+
+ paint.setPen(fg);
+ paint.drawRect(rect());
+ paint.drawText(rect(), Qt::AlignCenter, m_text);
+ update();
}
bool
--- trunk/playground/utils/filelight/src/part/radialMap/segmentTip.h #967133:967134
@@ -22,8 +22,8 @@
#ifndef SEGMENTTIP_H
#define SEGMENTTIP_H
+#include <QEvent>
#include <QWidget>
-#include <QEvent>
class File;
class Directory;
@@ -36,7 +36,7 @@
SegmentTip(uint);
void updateTip(const File*, const Directory*);
- void moveTo(QPoint, QWidget&, bool);
+ void moveTo(QPoint, bool);
private:
virtual bool eventFilter(QObject*, QEvent*);
--- trunk/playground/utils/filelight/src/part/radialMap/widgetEvents.cpp \
#967133:967134 @@ -25,32 +25,30 @@
#include "widget.h"
#include <cmath> //::segmentAt()
-#include <kcursor.h> //::mouseMoveEvent()
+
+#include <KCursor> //::mouseMoveEvent()
#include <KDebug>
-#include <kiconeffect.h> //::mousePressEvent()
-#include <kiconloader.h> //::mousePressEvent()
-#include <kio/job.h> //::mousePressEvent()
+#include <KIconLoader> //::mousePressEvent()
+#include <KIO/Job> //::mousePressEvent()
#include <KJob>
-#include <kio/deletejob.h>
-#include <kio/jobuidelegate.h>
-#include <klocale.h>
-#include <kmessagebox.h> //::mousePressEvent()
-#include <kmenu.h> //::mousePressEvent()
-#include <krun.h> //::mousePressEvent()
-#include <kurl.h>
-#include <qapplication.h>//QApplication::setOverrideCursor()
-#include <qclipboard.h>
-#include <qpainter.h>
-#include <qtimer.h> //::resizeEvent()
-//Added by qt3to4:
+#include <KIO/DeleteJob>
+#include <KIO/JobUiDelegate>
+#include <KLocale>
+#include <KMessageBox> //::mousePressEvent()
+#include <KMenu> //::mousePressEvent()
+#include <KRun> //::mousePressEvent()
+#include <KUrl>
+
+#include <QApplication> //QApplication::setOverrideCursor()
+#include <QClipboard>
+#include <QPainter>
+#include <QTimer> //::resizeEvent()
#include <QDropEvent>
#include <QPaintEvent>
#include <QResizeEvent>
#include <QMouseEvent>
#include <QDragEnterEvent>
-
-
void
RadialMap::Widget::resizeEvent(QResizeEvent*)
{
@@ -148,14 +146,15 @@
if (m_focus != oldFocus) //if not same as last time
{
setCursor(Qt::PointingHandCursor);
+
+ m_tip->hide(); //HACK: hack to force tooltip to be updated.
m_tip->updateTip(m_focus->file(), m_tree);
- emit mouseHover(m_focus->file()->fullPath());
+ m_tip->show(); //HACK: repaint(), update() et al doesn't work.
- //repaint required to update labels now before transparency is generated
- repaint();
+ emit mouseHover(m_focus->file()->fullPath());
+ update();
}
-
- m_tip->moveTo(e->globalPos(), *this, (p.y() < 0)); //updates tooltip \
pseudo-transparent background + m_tip->moveTo(e->globalPos(), (p.y() < 0));
}
else if (oldFocus && oldFocus->file() != m_tree)
{
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic