KTutorial
0.5.1
|
Utility class to highlight a widget. More...
#include <WidgetHighlighter.h>
Public Slots | |
void | start () |
Starts highlighting the target widget. | |
void | stop () |
Stops highlighting the target widget. | |
Signals | |
void | stopped (extendedinformation::WidgetHighlighter *widgetHighlighter) |
Emitted when the animation has stopped. | |
Public Member Functions | |
WidgetHighlighter (QWidget *targetWidget) | |
Creates a new WidgetHighlighter for the given widget. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Resizes this WidgetHighlighter to the size of its parent widget when it receives a resize event. | |
Protected Member Functions | |
virtual void | paintEvent (QPaintEvent *event) |
Paints a frame with a semi-transparent highlight color. |
Utility class to highlight a widget.
WidgetHighlighter executes an animation that tints its parent widget, changing its colors from normal to highlighted and back again.
Once started, the animation goes on indefinitely until the stop slot is called. The parent widget recovers its original appearance animating the change from the current color of the widget to the normal one. If the highlighting is started again while the stop animation is running, the highlighting animation is started again from the current color (that is, the stop animation is cancelled and a new highlight animation is started from that point).
To tint the widget, the WidgetHighlighter paints itself over the parent widget with a semi-transparent highlight color. However, due to performance reasons, only a frame is tinted instead of the whole widget. The center of the frame is always transparent.
WidgetHighlighter should not be created directly. Instead, WidgetHighlighterManager should be used, as it takes care of deleting the highlighter when no longer needed.
Definition at line 53 of file WidgetHighlighter.h.
ktutorial::extendedinformation::WidgetHighlighter::WidgetHighlighter | ( | QWidget * | targetWidget | ) | [explicit] |
Creates a new WidgetHighlighter for the given widget.
targetWidget | The widget to highlight. |
Definition at line 30 of file WidgetHighlighter.cpp.
bool ktutorial::extendedinformation::WidgetHighlighter::eventFilter | ( | QObject * | watched, |
QEvent * | event | ||
) | [virtual] |
Resizes this WidgetHighlighter to the size of its parent widget when it receives a resize event.
watched | The filtered object that received an event. |
event | The event received. |
Definition at line 59 of file WidgetHighlighter.cpp.
void ktutorial::extendedinformation::WidgetHighlighter::paintEvent | ( | QPaintEvent * | event | ) | [protected, virtual] |
Paints a frame with a semi-transparent highlight color.
The degree of opacity depends on the progress of the animation.
event | The paint event. |
Definition at line 91 of file WidgetHighlighter.cpp.
void ktutorial::extendedinformation::WidgetHighlighter::start | ( | ) | [slot] |
Starts highlighting the target widget.
If there is a normal animation already running nothing is done. However, if there is a stop animation running, it is cancelled and the highlighting animation is started again from the current color.
Definition at line 72 of file WidgetHighlighter.cpp.
Referenced by ktutorial::extendedinformation::WidgetHighlighterManager::highlight().
void ktutorial::extendedinformation::WidgetHighlighter::stop | ( | ) | [slot] |
Stops highlighting the target widget.
The animation is not stopped sharply, but a stop animation (the widget recovering its normal color) is executed.
Definition at line 79 of file WidgetHighlighter.cpp.
References stopped().
Referenced by ktutorial::extendedinformation::WidgetHighlighterManager::stopHighlighting().
void ktutorial::extendedinformation::WidgetHighlighter::stopped | ( | extendedinformation::WidgetHighlighter * | widgetHighlighter | ) | [signal] |
Emitted when the animation has stopped.
Note that it is emitted when the animation has truly stopped, that is, when there is not even an stop animation.
widgetHighlighter | This WidgetHighlighter. |
Referenced by stop().