LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
tooltipitem.cpp
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2010-2013 Oleg Linkin <MaledictusDeMagog@gmail.com>
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#include "tooltipitem.h"
10#include <QToolTip>
11#include <QtDebug>
12
13namespace LC::Util
14{
15 ToolTipItem::ToolTipItem (QQuickItem *parent)
16 : QQuickItem (parent)
17 {
18 setAcceptHoverEvents (true);
19 connect (&ShowTimer_,
20 &QTimer::timeout,
21 this,
23 ShowTimer_.setSingleShot (true);
24 }
25
26 void ToolTipItem::SetText (const QString& text)
27 {
28 if (Text_ != text)
29 {
30 Text_ = text;
31 emit textChanged ();
32 }
33 }
34
35 QString ToolTipItem::GetText () const
36 {
37 return Text_;
38 }
39
41 {
42 return ContainsMouse_;
43 }
44
45 void ToolTipItem::ShowToolTip (const QString& text) const
46 {
47 QToolTip::showText (cursor ().pos (), text);
48 }
49
50 void ToolTipItem::hoverEnterEvent (QHoverEvent *event)
51 {
52 ShowTimer_.start (1000);
53 ContainsMouse_ = true;
55 QQuickItem::hoverEnterEvent (event);
56 }
57
58 void ToolTipItem::hoverLeaveEvent (QHoverEvent *event)
59 {
60 ShowTimer_.stop ();
61 ContainsMouse_ = false;
63 QQuickItem::hoverLeaveEvent (event);
64 }
65
67 {
68 ShowToolTip (Text_);
69 }
70}
void showToolTip()
Shows the tooltip immediately.
void hoverEnterEvent(QHoverEvent *) override
QString text
The text of this tooltip item (rich text supported).
Definition tooltipitem.h:56
bool ContainsMouse() const
Returns whether the tooltip contains the mouse.
QString GetText() const
Returns the text of this tooltip.
void ShowToolTip(const QString &text) const
Shows tooltip with the given text immediately.
void containsMouseChanged()
Emitted when the containsMouse property changes.
ToolTipItem(QQuickItem *parent=nullptr)
Constructs the tooltip with the given parent item.
void textChanged()
Emitted when the text of this tooltip changes.
void SetText(const QString &text)
Sets the text contained in this tooltip to text.
void hoverLeaveEvent(QHoverEvent *) override