Changeset View
Changeset View
Standalone View
Standalone View
src/declarativeimports/core/tooltipdialog.cpp
Context not available. | |||||
82 | 82 | | |||
---|---|---|---|---|---|
83 | void ToolTipDialog::showEvent(QShowEvent *event) | 83 | void ToolTipDialog::showEvent(QShowEvent *event) | ||
84 | { | 84 | { | ||
85 | m_showTimer->start(m_hideTimeout); | 85 | if (m_autoShowHide) { | ||
86 | m_showTimer->start(m_hideTimeout); | ||||
87 | } else { | ||||
88 | m_showTimer->stop(); | ||||
89 | } | ||||
86 | 90 | | |||
87 | Dialog::showEvent(event); | 91 | Dialog::showEvent(event); | ||
88 | } | 92 | } | ||
Context not available. | |||||
102 | bool ToolTipDialog::event(QEvent *e) | 106 | bool ToolTipDialog::event(QEvent *e) | ||
103 | { | 107 | { | ||
104 | if (e->type() == QEvent::Enter) { | 108 | if (e->type() == QEvent::Enter) { | ||
109 | setContainsMouse(true); | ||||
105 | if (m_interactive) { | 110 | if (m_interactive) { | ||
106 | m_showTimer->stop(); | 111 | m_showTimer->stop(); | ||
107 | } | 112 | } | ||
108 | } else if (e->type() == QEvent::Leave) { | 113 | } else if (e->type() == QEvent::Leave) { | ||
109 | dismiss(); | 114 | setContainsMouse(false); | ||
115 | if (m_autoShowHide) { | ||||
116 | dismiss(m_owner); | ||||
117 | } | ||||
110 | } | 118 | } | ||
111 | 119 | | |||
112 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) | 120 | #if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) | ||
Context not available. | |||||
136 | 144 | | |||
137 | void ToolTipDialog::setOwner(QObject *owner) | 145 | void ToolTipDialog::setOwner(QObject *owner) | ||
138 | { | 146 | { | ||
139 | m_owner = owner; | 147 | if(m_owner != owner) { | ||
148 | m_owner = owner; | ||||
149 | m_showTimer->stop(); // if the owner changes then don't hide the dialog | ||||
150 | } | ||||
140 | } | 151 | } | ||
141 | 152 | | |||
142 | void ToolTipDialog::dismiss() | 153 | void ToolTipDialog::dismiss(QObject *owner) | ||
143 | { | 154 | { | ||
144 | m_showTimer->start(m_hideTimeout / 20); // pretty short: 200ms | 155 | if(m_owner == owner) { // only dismiss if the dialog is owned by the requester | ||
156 | m_showTimer->start(m_hideTimeout / 20); // pretty short: 200ms | ||||
157 | } | ||||
145 | } | 158 | } | ||
146 | 159 | | |||
147 | void ToolTipDialog::keepalive() | 160 | void ToolTipDialog::keepalive() | ||
148 | { | 161 | { | ||
149 | m_showTimer->start(m_hideTimeout); | 162 | if(m_autoShowHide) { | ||
163 | m_showTimer->start(m_hideTimeout); | ||||
164 | } else { | ||||
165 | m_showTimer->stop(); | ||||
166 | } | ||||
150 | } | 167 | } | ||
151 | 168 | | |||
152 | bool ToolTipDialog::interactive() | 169 | bool ToolTipDialog::interactive() | ||
Context not available. | |||||
165 | setPosition(value.toPoint()); | 182 | setPosition(value.toPoint()); | ||
166 | } | 183 | } | ||
167 | 184 | | |||
185 | bool ToolTipDialog::autoShowHide() | ||||
186 | { | ||||
187 | return m_autoShowHide; | ||||
188 | } | ||||
189 | | ||||
190 | void ToolTipDialog::setAutoShowHide(bool autoShowHide) | ||||
191 | { | ||||
192 | m_autoShowHide = autoShowHide; | ||||
193 | } | ||||
194 | | ||||
195 | bool ToolTipDialog::containsMouse() | ||||
196 | { | ||||
197 | return m_containsMouse; | ||||
198 | } | ||||
199 | | ||||
200 | void ToolTipDialog::setContainsMouse(bool contains) | ||||
201 | { | ||||
202 | if (m_containsMouse != contains) { | ||||
203 | m_containsMouse = contains; | ||||
204 | emit containsMouseChanged(); | ||||
205 | } | ||||
206 | } | ||||
207 | | ||||
168 | #include "moc_tooltipdialog.cpp" | 208 | #include "moc_tooltipdialog.cpp" | ||
Context not available. |