[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdegraphics/kolourpaint/widgets/toolbars/options
From: Clarence Dang <dang () kde ! org>
Date: 2007-08-22 8:56:54
Message-ID: 1187773014.218803.24017.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 703254 by dang:
Make tooltips work again in the tool options widget [careless Qt4 porting breakage].
M +57 -6 kpToolWidgetBase.cpp
M +2 -0 kpToolWidgetBase.h
--- trunk/KDE/kdegraphics/kolourpaint/widgets/toolbars/options/kpToolWidgetBase.cpp #703253:703254
@@ -34,11 +34,12 @@
#include <qbitmap.h>
#include <qcolor.h>
#include <qevent.h>
+#include <QHelpEvent>
#include <qimage.h>
#include <qpainter.h>
#include <qpixmap.h>
+#include <QToolTip>
-
#include <kapplication.h>
#include <kconfig.h>
#include <kdebug.h>
@@ -326,11 +327,7 @@
h = rowYOffset [r + 1] - y;
m_pixmapRects [r][c] = QRect (x, y, w, h);
-
- if (!m_toolTips [r][c].isEmpty ())
- this->setToolTip(m_toolTips [r][c]);
-
- }
+ }
}
update ();
@@ -544,6 +541,60 @@
// protected virtual [base QWidget]
+bool kpToolWidgetBase::event (QEvent *e)
+{
+ // HITODO: It's unclear when we should call the base, call accept() and
+ // return true or false. Look at other event() handlers. The
+ // kpToolText one is wrong since after calling accept(), it calls
+ // its base which calls ignore() :)
+ if (e->type () == QEvent::ToolTip)
+ {
+ QHelpEvent *he = (QHelpEvent *) e;
+ #if DEBUG_KP_TOOL_WIDGET_BASE || 1
+ kDebug () << "kpToolWidgetBase::event() QHelpEvent pos=" << he->pos () << endl;
+ #endif
+
+ bool showedText = false;
+ for (int r = 0; r < (int) m_pixmapRects.count (); r++)
+ {
+ for (int c = 0; c < (int) m_pixmapRects [r].count (); c++)
+ {
+ if (m_pixmapRects [r][c].contains (he->pos ()))
+ {
+ const QString tip = m_toolTips [r][c];
+ #if DEBUG_KP_TOOL_WIDGET_BASE || 1
+ kDebug () << "\tin option: r=" << r << "c=" << c
+ << "tip='" << tip << "'" << endl;
+ #endif
+ if (!tip.isEmpty ())
+ {
+ QToolTip::showText (he->globalPos (), tip, this);
+ showedText = true;
+ }
+
+ e->accept ();
+ goto exit_loops;
+ }
+ }
+ }
+
+ exit_loops:
+ if (!showedText)
+ {
+ #if DEBUG_KP_TOOL_WIDGET_BASE || 1
+ kDebug () << "\thiding text" << endl;
+ #endif
+ QToolTip::hideText ();
+ }
+
+ return true;
+ }
+ else
+ return QWidget::event (e);
+}
+
+
+// protected virtual [base QWidget]
void kpToolWidgetBase::mousePressEvent (QMouseEvent *e)
{
e->ignore ();
--- trunk/KDE/kdegraphics/kolourpaint/widgets/toolbars/options/kpToolWidgetBase.h #703253:703254
@@ -96,6 +96,8 @@
void optionSelected (int row, int col);
protected:
+ virtual bool event (QEvent *e);
+
virtual void mousePressEvent (QMouseEvent *e);
virtual void paintEvent (QPaintEvent *e);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic