LeechCraft
0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
Toggle main menu visibility
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
13
namespace
LC::Util
14
{
15
ToolTipItem::ToolTipItem
(QQuickItem *parent)
16
: QQuickItem (parent)
17
{
18
setAcceptHoverEvents (
true
);
19
connect (&ShowTimer_,
20
&QTimer::timeout,
21
this
,
22
&
ToolTipItem::showToolTip
);
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
40
bool
ToolTipItem::ContainsMouse
()
const
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
;
54
emit
containsMouseChanged
();
55
QQuickItem::hoverEnterEvent (event);
56
}
57
58
void
ToolTipItem::hoverLeaveEvent
(QHoverEvent *event)
59
{
60
ShowTimer_.stop ();
61
ContainsMouse_ =
false
;
62
emit
containsMouseChanged
();
63
QQuickItem::hoverLeaveEvent (event);
64
}
65
66
void
ToolTipItem::showToolTip
()
67
{
68
ShowToolTip
(Text_);
69
}
70
}
LC::Util::ToolTipItem::showToolTip
void showToolTip()
Shows the tooltip immediately.
Definition
tooltipitem.cpp:66
LC::Util::ToolTipItem::hoverEnterEvent
void hoverEnterEvent(QHoverEvent *) override
Definition
tooltipitem.cpp:50
LC::Util::ToolTipItem::text
QString text
The text of this tooltip item (rich text supported).
Definition
tooltipitem.h:56
LC::Util::ToolTipItem::ContainsMouse
bool ContainsMouse() const
Returns whether the tooltip contains the mouse.
Definition
tooltipitem.cpp:40
LC::Util::ToolTipItem::GetText
QString GetText() const
Returns the text of this tooltip.
Definition
tooltipitem.cpp:35
LC::Util::ToolTipItem::ShowToolTip
void ShowToolTip(const QString &text) const
Shows tooltip with the given text immediately.
Definition
tooltipitem.cpp:45
LC::Util::ToolTipItem::containsMouseChanged
void containsMouseChanged()
Emitted when the containsMouse property changes.
LC::Util::ToolTipItem::ToolTipItem
ToolTipItem(QQuickItem *parent=nullptr)
Constructs the tooltip with the given parent item.
Definition
tooltipitem.cpp:15
LC::Util::ToolTipItem::textChanged
void textChanged()
Emitted when the text of this tooltip changes.
LC::Util::ToolTipItem::SetText
void SetText(const QString &text)
Sets the text contained in this tooltip to text.
Definition
tooltipitem.cpp:26
LC::Util::ToolTipItem::hoverLeaveEvent
void hoverLeaveEvent(QHoverEvent *) override
Definition
tooltipitem.cpp:58
LC::Util
Definition
icoreproxy.h:34
tooltipitem.h
src
util
qml
tooltipitem.cpp
Generated by
1.17.0