Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, June 2007
Qt 4.3.0 PATCH: implement QToolTip::setGloballyEnabled()


Message 1 in thread

Since QToolTip has no way of being globally disabled in Qt4, and
the task #84805 - "QToolTip lacking functionality" has apparently
been abandoned by TT, I made the attached small patch that
implements this feature.

Maybe it is of use for others, too...

Klaus Schmidinger
# allow globally deactivating tooltips (TT#84805):
# allow globally deactivating tooltips (TT#84805):
--- src/gui/kernel/qtooltip.cpp.001	2007-05-25 15:30:24.000000000 +0200
+++ src/gui/kernel/qtooltip.cpp	2007-06-06 13:17:23.221387531 +0200
@@ -321,6 +321,8 @@
        return false;
 }
 
+bool QToolTip::globallyEnabled = true; //XXX allow globally deactivating tooltips (TT#84805):
+
 /*!
     Shows \a text as a tool tip, at global position \a pos. If you
     specify a non-empty rect the tip will be hidden as soon as you
@@ -339,6 +341,7 @@
 
 void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect)
 {
+    if (!globallyEnabled) return; //XXX allow globally deactivating tooltips (TT#84805):
     if (QTipLabel::instance){ // a tip does already exist
         if (text.isEmpty()){ // empty text means hide current tip
             QTipLabel::instance->hideTip();
# allow globally deactivating tooltips (TT#84805):
# allow globally deactivating tooltips (TT#84805):
--- src/gui/kernel/qtooltip.h.001	2007-05-25 15:30:24.000000000 +0200
+++ src/gui/kernel/qtooltip.h	2007-06-06 13:40:46.767122198 +0200
@@ -33,6 +33,14 @@
 class Q_GUI_EXPORT QToolTip
 {
     QToolTip();
+#define QT_PATCH_CS20070606_1
+//XXX allow globally deactivating tooltips (TT#84805):
+private:
+    static bool globallyEnabled;
+public:
+    static void setGloballyEnabled(bool enable) { globallyEnabled = enable; }
+    static bool isGloballyEnabled(void) { return globallyEnabled; }
+//XXX
 public:
     static void showText(const QPoint &pos, const QString &text, QWidget *w = 0);
     static void showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect);

Message 2 in thread

Klaus Schmidinger wrote:

> Since QToolTip has no way of being globally disabled in Qt4, and
> the task #84805 - "QToolTip lacking functionality" has apparently
> been abandoned by TT, I made the attached small patch that
> implements this feature.

I haven't been following this issue, so excuse me if this is off the mark,
but could you say why you chose to take your approach instead of the one
outlined in the Porting to Qt 4 document?

Under QToolTip:

  The QToolTip::setGloballyEnabled() function no longer exists.
  Tooltips can be disabled by installing an event filter on qApp (the
  unique QApplication object) to block events of type QEvent::ToolTip.

-- 
 [ signature omitted ] 

Message 3 in thread

On 06/06/07 17:10, David Boddie wrote:
> Klaus Schmidinger wrote:
> 
>> Since QToolTip has no way of being globally disabled in Qt4, and
>> the task #84805 - "QToolTip lacking functionality" has apparently
>> been abandoned by TT, I made the attached small patch that
>> implements this feature.
> 
> I haven't been following this issue, so excuse me if this is off the mark,
> but could you say why you chose to take your approach instead of the one
> outlined in the Porting to Qt 4 document?

Well, Qt4 has taken away quite a few things that worked out of the
box in Qt3, and I'm just not willing to fiddle around with application
wide event filters just to get something back that shouldn't have been
taken away in the first place.

I've just posted this here because apparently there was at least one
other Qt user who also wanted this (hence the task tracker entry).

Klaus Schmidinger

--
 [ signature omitted ] 

Message 4 in thread

Klaus Schmidinger wrote:

> Well, Qt4 has taken away quite a few things that worked out of the
> box in Qt3, and I'm just not willing to fiddle around with application
> wide event filters just to get something back that shouldn't have been
> taken away in the first place.

Fair enough. Without benchmarking, I don't know how efficient it is, but
an application-wide event filter might be good enough to give you what
you need without requiring you to patch Qt.

Since you want to discard all ToolTip events for all widgets (in certain
cases), the filter only needs to check for the event type, so it could be
as simple as this to implement:

bool FilterObject::eventFilter(QObject *obj, QEvent *event)
{
    if (event.type() == QEvent::ToolTip)
        return true;
    else
        return false;
}

Of course, there may be extra work, depending on whether you are using other
event filters and where you decide to implement the event filter.

> I've just posted this here because apparently there was at least one
> other Qt user who also wanted this (hence the task tracker entry).

Well, I suppose that's one of the benefits of having the source code.

David
-- 
 [ signature omitted ] 

Message 5 in thread

> 
> Klaus Schmidinger wrote:
> 
> > Since QToolTip has no way of being globally disabled in Qt4, and
> > the task #84805 - "QToolTip lacking functionality" has apparently
> > been abandoned by TT, I made the attached small patch that
> > implements this feature.
> 
> I haven't been following this issue, so excuse me if this is off the
mark,
> but could you say why you chose to take your approach instead of the
one
> outlined in the Porting to Qt 4 document?
> 
> Under QToolTip:
> 
>   The QToolTip::setGloballyEnabled() function no longer exists.
>   Tooltips can be disabled by installing an event filter on qApp (the
>   unique QApplication object) to block events of type QEvent::ToolTip.
> 
> --
> David Boddie
> Lead Technical Writer, Trolltech ASA

While I was not the original poster, it seems to me, that adding a event
filter, is overkill for something like turning on and off tool tips..

While it will clearly work, now the developer has to create a set/get
function to store if its turned on or off... 

I guess it's the old... Code less Create more....

Scott

--
 [ signature omitted ] 

Message 6 in thread

On 06/06/07 18:43, Scott Aron Bloom wrote:
>...
> While I was not the original poster, it seems to me, that adding a event
> filter, is overkill for something like turning on and off tool tips..
> 
> While it will clearly work, now the developer has to create a set/get
> function to store if its turned on or off... 
> 
> I guess it's the old... Code less Create more....

Well, lately I get the feeling that its "Code more, create less"...

Klaus Schmidinger

--
 [ signature omitted ] 

Message 7 in thread

Klaus... Thanks for the post... however, I did find a potential bug in
your code...

As I had to deal with this myself, but I did it in the event filter, if
the user turns off the global tool tips (via a short cut key) you need
to hide the tool tips if its currently being shown.

With your method, it will go away in the normal way (and then not be
reshown)

Scott

> -----Original Message-----
> From: Klaus Schmidinger [mailto:Klaus.Schmidinger@xxxxxxxxxx]
> Sent: Wednesday, June 06, 2007 4:56 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Qt 4.3.0 PATCH: implement QToolTip::setGloballyEnabled()
> 
> Since QToolTip has no way of being globally disabled in Qt4, and
> the task #84805 - "QToolTip lacking functionality" has apparently
> been abandoned by TT, I made the attached small patch that
> implements this feature.
> 
> Maybe it is of use for others, too...
> 
> Klaus Schmidinger

--
 [ signature omitted ] 

Message 8 in thread

On 06/06/07 18:43, Scott Aron Bloom wrote:
> Klaus... Thanks for the post... however, I did find a potential bug in
> your code...
> 
> As I had to deal with this myself, but I did it in the event filter, if
> the user turns off the global tool tips (via a short cut key) you need
> to hide the tool tips if its currently being shown.
> 
> With your method, it will go away in the normal way (and then not be
> reshown)

Hi Scott,

are you saying that a tooltip that is shown at the moment when the user
globally turns off tooltips will go away after the timeout (instead of
immediately when the user turns it off)? That's something I can well
live with.
Or is there a different problem and I didn't quite understand what you
meant?

Klaus Schmidinger

--
 [ signature omitted ] 

Message 9 in thread

> -----Original Message-----
> From: Klaus Schmidinger [mailto:Klaus.Schmidinger@xxxxxxxxxx]
> Sent: Wednesday, June 06, 2007 2:31 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Re: Qt 4.3.0 PATCH: implement QToolTip::setGloballyEnabled()
> 
> On 06/06/07 18:43, Scott Aron Bloom wrote:
> > Klaus... Thanks for the post... however, I did find a potential bug
in
> > your code...
> >
> > As I had to deal with this myself, but I did it in the event filter,
if
> > the user turns off the global tool tips (via a short cut key) you
need
> > to hide the tool tips if its currently being shown.
> >
> > With your method, it will go away in the normal way (and then not be
> > reshown)
> 
> Hi Scott,
> 
> are you saying that a tooltip that is shown at the moment when the
user
> globally turns off tooltips will go away after the timeout (instead of
> immediately when the user turns it off)? That's something I can well
> live with.
> Or is there a different problem and I didn't quite understand what you
> meant?
> 
> Klaus Schmidinger
Yes... That's exactly what I was talking about... Its not so bad for
"normal" 500ms timeouts... but since the timout can be quite long on
accessable systems, it can be annoying.

Not a problem, just a note...

Scott

--
 [ signature omitted ] 

Message 10 in thread

I just want to say a BIG thank you for this.  It' will save me a lot of 
work (I was the one who asked the list about this last week sometime)
 :-D

--Susan

Klaus Schmidinger wrote:
> Since QToolTip has no way of being globally disabled in Qt4, and
> the task #84805 - "QToolTip lacking functionality" has apparently
> been abandoned by TT, I made the attached small patch that
> implements this feature.
>
> Maybe it is of use for others, too...
>
> Klaus Schmidinger
>   



---

This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records.

Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den Absender zurück und löschen Sie die E-mail aus Ihrem System.

--
 [ signature omitted ]