void ToolTip::showInternal(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect) { if (acceptShow(content, pos, w, rect)) { QWidget *target = 0; if (HostOsInfo::isWindowsHost()) target = QApplication::desktop()->screen(Internal::screenNumber(pos, w)); else target = w; switch (content.typeId()) { case TextContent::TEXT_CONTENT_ID: m_tip = new TextTip(target); break; case ColorContent::COLOR_CONTENT_ID: m_tip = new ColorTip(target); break; case WidgetContent::WIDGET_CONTENT_ID: m_tip = new WidgetTip(target); break; } setUp(pos, content, w, rect); qApp->installEventFilter(this); showTip(); } }
bool ToolTip::validateContent(const TipContent &content) { if (!content.isValid()) { if (isVisible()) hideTipWithDelay(); return false; } return true; }
void ToolTip::setUp(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect) { m_tip->setContent(content); m_tip->configure(pos, w); placeTip(pos, w); setTipRect(w, rect); if (m_hideDelayTimer.isActive()) m_hideDelayTimer.stop(); m_showTimer.start(content.showTime()); }
bool TextTip::canHandleContentReplacement(const TipContent &content) const { if (content.typeId() == TextContent::TEXT_CONTENT_ID) return true; return false; }
bool ColorTip::canHandleContentReplacement(const TipContent &content) const { if (content.typeId() == ColorContent::COLOR_CONTENT_ID) return true; return false; }