forked from qt-creator/qt-creator
tooltip: make TextTip links clickable
This enables the text to contain links which the user can click on to follow. Change-Id: I892d1d915a48974e72adb0e712d46220560f5537 Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
c3a5eecfc5
commit
9ccb089870
@@ -127,9 +127,21 @@ TextTip::TextTip(QWidget *parent) : QTipLabel(parent)
|
||||
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
|
||||
}
|
||||
|
||||
static bool likelyContainsLink(const QString &s)
|
||||
{
|
||||
return s.contains(QLatin1String("href"), Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
void TextTip::setContent(const QVariant &content)
|
||||
{
|
||||
m_text = content.toString();
|
||||
bool containsLink = likelyContainsLink(m_text);
|
||||
setOpenExternalLinks(containsLink);
|
||||
}
|
||||
|
||||
bool TextTip::isInteractive() const
|
||||
{
|
||||
return likelyContainsLink(m_text);
|
||||
}
|
||||
|
||||
void TextTip::configure(const QPoint &pos, QWidget *w)
|
||||
|
@@ -64,6 +64,7 @@ public:
|
||||
TextTip(QWidget *parent);
|
||||
|
||||
virtual void setContent(const QVariant &content);
|
||||
virtual bool isInteractive() const;
|
||||
virtual void configure(const QPoint &pos, QWidget *w);
|
||||
virtual bool canHandleContentReplacement(int typeId) const;
|
||||
virtual int showTime() const;
|
||||
|
Reference in New Issue
Block a user