Utils: Simplify tooltip architecture and cleanup

This mainly merges TipContents into the the actual
tooltip labels.

Change-Id: I64b576c987bce034842f7e3f324b81595dae0713
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2014-12-13 00:18:59 +01:00
parent 8815990903
commit e8396f4c8d
10 changed files with 156 additions and 315 deletions

View File

@@ -1,101 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://www.qt.io/licensing. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "tipcontents.h"
#include "tooltip.h"
#include "tips.h"
#include <utils/qtcassert.h>
#include <QtGlobal>
namespace Utils {
TipContent::TipContent()
: m_typeId(0), m_widget(0), m_interactive(false)
{
}
TipContent::TipContent(const QString &text)
: m_typeId(TEXT_CONTENT_ID), m_text(text), m_widget(0), m_interactive(false)
{
}
TipContent::TipContent(const QColor &color)
: m_typeId(COLOR_CONTENT_ID), m_color(color), m_widget(0), m_interactive(false)
{
}
TipContent::TipContent(QWidget *w, bool interactive)
: m_typeId(WIDGET_CONTENT_ID), m_widget(w), m_interactive(interactive)
{
}
bool TipContent::isValid() const
{
if (m_typeId == TEXT_CONTENT_ID)
return !m_text.isEmpty();
if (m_typeId == COLOR_CONTENT_ID)
return m_color.isValid();
return m_widget;
}
int TipContent::showTime() const
{
if (m_typeId == TEXT_CONTENT_ID)
return 10000 + 40 * qMax(0, m_text.length() - 100);
if (m_typeId == COLOR_CONTENT_ID)
return 4000;
return 30000;
}
bool TipContent::equals(const TipContent &other) const
{
return m_typeId == other.m_typeId
&& m_text == other.m_text
&& m_widget == other.m_widget;
}
bool TipContent::pinToolTip(QWidget *w, QWidget *parent)
{
QTC_ASSERT(w, return false);
// Find the parent WidgetTip, tell it to pin/release the
// widget and close.
for (QWidget *p = w->parentWidget(); p ; p = p->parentWidget()) {
if (Internal::WidgetTip *wt = qobject_cast<Internal::WidgetTip *>(p)) {
wt->pinToolTipWidget(parent);
ToolTip::hide();
return true;
}
}
return false;
}
} // namespace Utils

View File

@@ -1,81 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://www.qt.io/licensing. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef TIPCONTENTS_H
#define TIPCONTENTS_H
#include "../utils_global.h"
#include <QString>
#include <QColor>
#include <QWidget>
namespace Utils {
class QTCREATOR_UTILS_EXPORT TipContent
{
public:
TipContent();
explicit TipContent(const QString &text);
explicit TipContent(const QColor &color);
explicit TipContent(QWidget *w, bool interactive);
int typeId() const { return m_typeId; }
bool isValid() const;
bool isInteractive() const { return m_interactive; }
int showTime() const;
bool equals(const TipContent &other) const;
const QString &text() const { return m_text; }
const QColor &color() const { return m_color; }
QWidget *widget() const { return m_widget; }
enum {
COLOR_CONTENT_ID = 0,
TEXT_CONTENT_ID = 1,
WIDGET_CONTENT_ID = 42
};
void setInteractive(bool i) { m_interactive = i; }
// Helper to 'pin' (show as real window) a tooltip shown
// using WidgetContent
static bool pinToolTip(QWidget *w, QWidget *parent);
private:
int m_typeId;
QString m_text;
QColor m_color;
QWidget *m_widget;
bool m_interactive;
};
} // namespace Utils
#endif // TIPCONTENTS_H

View File

@@ -29,7 +29,7 @@
****************************************************************************/ ****************************************************************************/
#include "tips.h" #include "tips.h"
#include "tipcontents.h" #include "tooltip.h"
#include "reuse.h" #include "reuse.h"
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
@@ -49,50 +49,32 @@
#include <QVBoxLayout> #include <QVBoxLayout>
namespace Utils { namespace Utils {
namespace Internal { namespace Internal {
// @todo: Reuse...
static QPixmap tilePixMap(int size)
{
const int checkerbordSize= size;
QPixmap tilePixmap(checkerbordSize * 2, checkerbordSize * 2);
tilePixmap.fill(Qt::white);
QPainter tilePainter(&tilePixmap);
QColor color(220, 220, 220);
tilePainter.fillRect(0, 0, checkerbordSize, checkerbordSize, color);
tilePainter.fillRect(checkerbordSize, checkerbordSize, checkerbordSize, checkerbordSize, color);
return tilePixmap;
}
QTipLabel::QTipLabel(QWidget *parent) : QTipLabel::QTipLabel(QWidget *parent) :
QLabel(parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget) QLabel(parent, Qt::ToolTip | Qt::BypassGraphicsProxyWidget)
{} {}
QTipLabel::~QTipLabel()
ColorTip::ColorTip(QWidget *parent)
: QTipLabel(parent)
{ {
resize(40, 40);
} }
bool QTipLabel::isInteractive() const void ColorTip::setContent(const QVariant &content)
{ {
return m_tipContent.isInteractive(); m_color = content.value<QColor>();
const int size = 10;
m_tilePixmap = QPixmap(size * 2, size * 2);
m_tilePixmap.fill(Qt::white);
QPainter tilePainter(&m_tilePixmap);
QColor col(220, 220, 220);
tilePainter.fillRect(0, 0, size, size, col);
tilePainter.fillRect(size, size, size, size, col);
} }
void QTipLabel::setContent(const TipContent &content)
{
m_tipContent = content;
}
ColorTip::ColorTip(QWidget *parent) : QTipLabel(parent)
{
resize(QSize(40, 40));
m_tilePixMap = tilePixMap(10);
}
ColorTip::~ColorTip()
{}
void ColorTip::configure(const QPoint &pos, QWidget *w) void ColorTip::configure(const QPoint &pos, QWidget *w)
{ {
Q_UNUSED(pos) Q_UNUSED(pos)
@@ -101,29 +83,32 @@ void ColorTip::configure(const QPoint &pos, QWidget *w)
update(); update();
} }
bool ColorTip::canHandleContentReplacement(const TipContent &content) const bool ColorTip::canHandleContentReplacement(int typeId) const
{ {
return content.typeId() == TipContent::COLOR_CONTENT_ID; return typeId == ToolTip::ColorContent;
}
bool ColorTip::equals(int typeId, const QVariant &other) const
{
return typeId == ToolTip::ColorContent && other == m_color;
} }
void ColorTip::paintEvent(QPaintEvent *event) void ColorTip::paintEvent(QPaintEvent *event)
{ {
QTipLabel::paintEvent(event); QTipLabel::paintEvent(event);
const QColor &color = content().color();
QPen pen; QPen pen;
pen.setWidth(1); pen.setWidth(1);
if (color.value() > 100) if (m_color.value() > 100)
pen.setColor(color.darker()); pen.setColor(m_color.darker());
else else
pen.setColor(color.lighter()); pen.setColor(m_color.lighter());
QPainter painter(this); QPainter painter(this);
painter.setPen(pen); painter.setPen(pen);
painter.setBrush(color); painter.setBrush(m_color);
QRect r(0, 0, rect().width() - 1, rect().height() - 1); QRect r(0, 0, rect().width() - 1, rect().height() - 1);
painter.drawTiledPixmap(r, m_tilePixMap); painter.drawTiledPixmap(r, m_tilePixmap);
painter.drawRect(r); painter.drawRect(r);
} }
@@ -139,12 +124,14 @@ TextTip::TextTip(QWidget *parent) : QTipLabel(parent)
setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0); setWindowOpacity(style()->styleHint(QStyle::SH_ToolTipLabel_Opacity, 0, this) / 255.0);
} }
TextTip::~TextTip() void TextTip::setContent(const QVariant &content)
{} {
m_text = content.toString();
}
void TextTip::configure(const QPoint &pos, QWidget *w) void TextTip::configure(const QPoint &pos, QWidget *w)
{ {
setText(content().text()); setText(m_text);
// Make it look good with the default ToolTip font on Mac, which has a small descent. // Make it look good with the default ToolTip font on Mac, which has a small descent.
QFontMetrics fm(font()); QFontMetrics fm(font());
@@ -169,9 +156,19 @@ void TextTip::configure(const QPoint &pos, QWidget *w)
resize(tipWidth, heightForWidth(tipWidth) + extraHeight); resize(tipWidth, heightForWidth(tipWidth) + extraHeight);
} }
bool TextTip::canHandleContentReplacement(const TipContent &content) const bool TextTip::canHandleContentReplacement(int typeId) const
{ {
return content.typeId() == TipContent::TEXT_CONTENT_ID; return typeId == ToolTip::TextContent;
}
int TextTip::showTime() const
{
return 10000 + 40 * qMax(0, m_text.size() - 100);
}
bool TextTip::equals(int typeId, const QVariant &other) const
{
return typeId == ToolTip::TextContent && other.toString() == m_text;
} }
void TextTip::paintEvent(QPaintEvent *event) void TextTip::paintEvent(QPaintEvent *event)
@@ -203,14 +200,17 @@ WidgetTip::WidgetTip(QWidget *parent) :
setLayout(m_layout); setLayout(m_layout);
} }
void WidgetTip::setContent(const QVariant &content)
{
m_widget = content.value<QWidget *>();
}
void WidgetTip::configure(const QPoint &pos, QWidget *) void WidgetTip::configure(const QPoint &pos, QWidget *)
{ {
QWidget *widget = content().widget(); QTC_ASSERT(m_widget && m_layout->count() == 0, return);
QTC_ASSERT(widget && m_layout->count() == 0, return);
move(pos); move(pos);
m_layout->addWidget(widget); m_layout->addWidget(m_widget);
m_layout->setSizeConstraint(QLayout::SetFixedSize); m_layout->setSizeConstraint(QLayout::SetFixedSize);
adjustSize(); adjustSize();
} }
@@ -238,12 +238,18 @@ void WidgetTip::pinToolTipWidget(QWidget *parent)
widget->setAttribute(Qt::WA_DeleteOnClose); widget->setAttribute(Qt::WA_DeleteOnClose);
} }
bool WidgetTip::canHandleContentReplacement(const TipContent & ) const bool WidgetTip::canHandleContentReplacement(int typeId) const
{ {
// Always create a new widget. // Always create a new widget.
Q_UNUSED(typeId);
return false; return false;
} }
bool WidgetTip::equals(int typeId, const QVariant &other) const
{
return typeId == ToolTip::WidgetContent && other.value<QWidget *>() == m_widget;
}
// need to include it here to force it to be inside the namespaces // need to include it here to force it to be inside the namespaces
#include "moc_tips.cpp" #include "moc_tips.cpp"

View File

@@ -31,13 +31,13 @@
#ifndef TIPS_H #ifndef TIPS_H
#define TIPS_H #define TIPS_H
#include "tipcontents.h" #include "../utils_global.h"
#include <QSharedPointer>
#include <QLabel> #include <QLabel>
#include <QPixmap> #include <QPixmap>
#include <QSharedPointer>
QT_FORWARD_DECLARE_CLASS(QVBoxLayout) #include <QVariant>
#include <QVBoxLayout>
#ifndef Q_MOC_RUN #ifndef Q_MOC_RUN
namespace Utils { namespace Utils {
@@ -48,68 +48,68 @@ namespace Internal {
class QTipLabel : public QLabel class QTipLabel : public QLabel
{ {
Q_OBJECT Q_OBJECT
protected: public:
QTipLabel(QWidget *parent); QTipLabel(QWidget *parent);
public: virtual void setContent(const QVariant &content) = 0;
virtual ~QTipLabel(); virtual bool isInteractive() const { return false; }
virtual int showTime() const = 0;
void setContent(const TipContent &content);
const TipContent &content() const { return m_tipContent; }
virtual void configure(const QPoint &pos, QWidget *w) = 0; virtual void configure(const QPoint &pos, QWidget *w) = 0;
virtual bool canHandleContentReplacement(const TipContent &content) const = 0; virtual bool canHandleContentReplacement(int typeId) const = 0;
virtual bool equals(int typeId, const QVariant &other) const = 0;
bool isInteractive() const;
private:
TipContent m_tipContent;
}; };
class TextTip : public QTipLabel class TextTip : public QTipLabel
{ {
Q_OBJECT
public: public:
TextTip(QWidget *parent); TextTip(QWidget *parent);
virtual ~TextTip();
virtual void setContent(const QVariant &content);
virtual void configure(const QPoint &pos, QWidget *w); virtual void configure(const QPoint &pos, QWidget *w);
virtual bool canHandleContentReplacement(const TipContent &content) const; virtual bool canHandleContentReplacement(int typeId) const;
virtual int showTime() const;
private: virtual bool equals(int typeId, const QVariant &other) const;
virtual void paintEvent(QPaintEvent *event); virtual void paintEvent(QPaintEvent *event);
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
private:
QString m_text;
}; };
class ColorTip : public QTipLabel class ColorTip : public QTipLabel
{ {
Q_OBJECT
public: public:
ColorTip(QWidget *parent); ColorTip(QWidget *parent);
virtual ~ColorTip();
virtual void setContent(const QVariant &content);
virtual void configure(const QPoint &pos, QWidget *w); virtual void configure(const QPoint &pos, QWidget *w);
virtual bool canHandleContentReplacement(const TipContent &content) const; virtual bool canHandleContentReplacement(int typeId) const;
virtual int showTime() const { return 4000; }
private: virtual bool equals(int typeId, const QVariant &other) const;
virtual void paintEvent(QPaintEvent *event); virtual void paintEvent(QPaintEvent *event);
QPixmap m_tilePixMap; private:
QColor m_color;
QPixmap m_tilePixmap;
}; };
class WidgetTip : public QTipLabel class WidgetTip : public QTipLabel
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit WidgetTip(QWidget *parent = 0); explicit WidgetTip(QWidget *parent = 0);
virtual void configure(const QPoint &pos, QWidget *w);
virtual bool canHandleContentReplacement(const TipContent &content) const;
public slots:
void pinToolTipWidget(QWidget *parent); void pinToolTipWidget(QWidget *parent);
virtual void setContent(const QVariant &content);
virtual void configure(const QPoint &pos, QWidget *w);
virtual bool canHandleContentReplacement(int typeId) const;
virtual int showTime() const { return 30000; }
virtual bool equals(int typeId, const QVariant &other) const;
virtual bool isInteractive() const { return true; }
private: private:
QWidget *m_widget;
QVBoxLayout *m_layout; QVBoxLayout *m_layout;
}; };

View File

@@ -30,11 +30,11 @@
#include "tooltip.h" #include "tooltip.h"
#include "tips.h" #include "tips.h"
#include "tipcontents.h"
#include "effects.h" #include "effects.h"
#include "reuse.h" #include "reuse.h"
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QString> #include <QString>
#include <QColor> #include <QColor>
@@ -68,17 +68,26 @@ ToolTip *ToolTip::instance()
void ToolTip::show(const QPoint &pos, const QString &content, QWidget *w, const QRect &rect) void ToolTip::show(const QPoint &pos, const QString &content, QWidget *w, const QRect &rect)
{ {
instance()->showInternal(pos, TipContent(content), w, rect); if (content.isEmpty())
instance()->hideTipWithDelay();
else
instance()->showInternal(pos, QVariant(content), TextContent, w, rect);
} }
void ToolTip::show(const QPoint &pos, const QColor &color, QWidget *w, const QRect &rect) void ToolTip::show(const QPoint &pos, const QColor &color, QWidget *w, const QRect &rect)
{ {
instance()->showInternal(pos, TipContent(color), w, rect); if (!color.isValid())
instance()->hideTipWithDelay();
else
instance()->showInternal(pos, QVariant(color), ColorContent, w, rect);
} }
void ToolTip::show(const QPoint &pos, QWidget *content, QWidget *w, const QRect &rect) void ToolTip::show(const QPoint &pos, QWidget *content, QWidget *w, const QRect &rect)
{ {
instance()->showInternal(pos, TipContent(content, true), w, rect); if (!content)
instance()->hideTipWithDelay();
else
instance()->showInternal(pos, QVariant::fromValue(content), WidgetContent, w, rect);
} }
void ToolTip::move(const QPoint &pos, QWidget *w) void ToolTip::move(const QPoint &pos, QWidget *w)
@@ -87,22 +96,37 @@ void ToolTip::move(const QPoint &pos, QWidget *w)
instance()->placeTip(pos, w); instance()->placeTip(pos, w);
} }
bool ToolTip::acceptShow(const TipContent &content, bool ToolTip::pinToolTip(QWidget *w, QWidget *parent)
{
QTC_ASSERT(w, return false);
// Find the parent WidgetTip, tell it to pin/release the
// widget and close.
for (QWidget *p = w->parentWidget(); p ; p = p->parentWidget()) {
if (Internal::WidgetTip *wt = qobject_cast<Internal::WidgetTip *>(p)) {
wt->pinToolTipWidget(parent);
ToolTip::hide();
return true;
}
}
return false;
}
bool ToolTip::acceptShow(const QVariant &content,
int typeId,
const QPoint &pos, const QPoint &pos,
QWidget *w, QWidget *w,
const QRect &rect) const QRect &rect)
{ {
if (!validateContent(content))
return false;
if (isVisible()) { if (isVisible()) {
if (m_tip->canHandleContentReplacement(content)) { if (m_tip->canHandleContentReplacement(typeId)) {
// Reuse current tip. // Reuse current tip.
QPoint localPos = pos; QPoint localPos = pos;
if (w) if (w)
localPos = w->mapFromGlobal(pos); localPos = w->mapFromGlobal(pos);
if (tipChanged(localPos, content, w)) if (tipChanged(localPos, content, typeId, w)) {
setUp(pos, content, w, rect); m_tip->setContent(content);
setUp(pos, w, rect);
}
return false; return false;
} }
hideTipImmediately(); hideTipImmediately();
@@ -119,19 +143,8 @@ bool ToolTip::acceptShow(const TipContent &content,
return true; return true;
} }
bool ToolTip::validateContent(const TipContent &content) void ToolTip::setUp(const QPoint &pos, QWidget *w, const QRect &rect)
{ {
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); m_tip->configure(pos, w);
placeTip(pos, w); placeTip(pos, w);
@@ -139,12 +152,12 @@ void ToolTip::setUp(const QPoint &pos, const TipContent &content, QWidget *w, co
if (m_hideDelayTimer.isActive()) if (m_hideDelayTimer.isActive())
m_hideDelayTimer.stop(); m_hideDelayTimer.stop();
m_showTimer.start(content.showTime()); m_showTimer.start(m_tip->showTime());
} }
bool ToolTip::tipChanged(const QPoint &pos, const TipContent &content, QWidget *w) const bool ToolTip::tipChanged(const QPoint &pos, const QVariant &content, int typeId, QWidget *w) const
{ {
if (!m_tip->content().equals(content) || m_widget != w) if (!m_tip->equals(typeId, content) || m_widget != w)
return true; return true;
if (!m_rect.isNull()) if (!m_rect.isNull())
return !m_rect.contains(pos); return !m_rect.contains(pos);
@@ -204,27 +217,29 @@ void ToolTip::hideTipImmediately()
qApp->removeEventFilter(this); qApp->removeEventFilter(this);
} }
void ToolTip::showInternal(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect) void ToolTip::showInternal(const QPoint &pos, const QVariant &content,
int typeId, QWidget *w, const QRect &rect)
{ {
if (acceptShow(content, pos, w, rect)) { if (acceptShow(content, typeId, pos, w, rect)) {
QWidget *target = 0; QWidget *target = 0;
if (HostOsInfo::isWindowsHost()) if (HostOsInfo::isWindowsHost())
target = QApplication::desktop()->screen(Internal::screenNumber(pos, w)); target = QApplication::desktop()->screen(Internal::screenNumber(pos, w));
else else
target = w; target = w;
switch (content.typeId()) { switch (typeId) {
case TipContent::COLOR_CONTENT_ID: case ColorContent:
m_tip = new ColorTip(target); m_tip = new ColorTip(target);
break; break;
case TipContent::TEXT_CONTENT_ID: case TextContent:
m_tip = new TextTip(target); m_tip = new TextTip(target);
break; break;
case TipContent::WIDGET_CONTENT_ID: case WidgetContent:
m_tip = new WidgetTip(target); m_tip = new WidgetTip(target);
break; break;
} }
setUp(pos, content, w, rect); m_tip->setContent(content);
setUp(pos, w, rect);
qApp->installEventFilter(this); qApp->installEventFilter(this);
showTip(); showTip();
} }

View File

@@ -50,14 +50,13 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QPoint; class QPoint;
class QVariant;
class QWidget; class QWidget;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils { namespace Utils {
namespace Internal { class QTipLabel; } namespace Internal { class QTipLabel; }
class TipContent;
class QTCREATOR_UTILS_EXPORT ToolTip : public QObject class QTCREATOR_UTILS_EXPORT ToolTip : public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -67,6 +66,12 @@ protected:
public: public:
~ToolTip(); ~ToolTip();
enum {
ColorContent = 0,
TextContent = 1,
WidgetContent = 42
};
bool eventFilter(QObject *o, QEvent *event); bool eventFilter(QObject *o, QEvent *event);
static ToolTip *instance(); static ToolTip *instance();
@@ -78,13 +83,16 @@ public:
static void hide(); static void hide();
static bool isVisible(); static bool isVisible();
// Helper to 'pin' (show as real window) a tooltip shown
// using WidgetContent
static bool pinToolTip(QWidget *w, QWidget *parent);
private: private:
void showInternal(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect); void showInternal(const QPoint &pos, const QVariant &content, int typeId, QWidget *w, const QRect &rect);
void hideTipImmediately(); void hideTipImmediately();
bool acceptShow(const TipContent &content, const QPoint &pos, QWidget *w, const QRect &rect); bool acceptShow(const QVariant &content, int typeId, const QPoint &pos, QWidget *w, const QRect &rect);
bool validateContent(const TipContent &content); void setUp(const QPoint &pos, QWidget *w, const QRect &rect);
void setUp(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect); bool tipChanged(const QPoint &pos, const QVariant &content, int typeId, QWidget *w) const;
bool tipChanged(const QPoint &pos, const TipContent &content, QWidget *w) const;
void setTipRect(QWidget *w, const QRect &rect); void setTipRect(QWidget *w, const QRect &rect);
void placeTip(const QPoint &pos, QWidget *w); void placeTip(const QPoint &pos, QWidget *w);
void showTip(); void showTip();

View File

@@ -82,7 +82,6 @@ SOURCES += $$PWD/environment.cpp \
$$PWD/hostosinfo.cpp \ $$PWD/hostosinfo.cpp \
$$PWD/tooltip/tooltip.cpp \ $$PWD/tooltip/tooltip.cpp \
$$PWD/tooltip/tips.cpp \ $$PWD/tooltip/tips.cpp \
$$PWD/tooltip/tipcontents.cpp \
$$PWD/unixutils.cpp \ $$PWD/unixutils.cpp \
$$PWD/ansiescapecodehandler.cpp \ $$PWD/ansiescapecodehandler.cpp \
$$PWD/execmenu.cpp \ $$PWD/execmenu.cpp \
@@ -175,7 +174,6 @@ HEADERS += \
$$PWD/elidinglabel.h \ $$PWD/elidinglabel.h \
$$PWD/tooltip/tooltip.h \ $$PWD/tooltip/tooltip.h \
$$PWD/tooltip/tips.h \ $$PWD/tooltip/tips.h \
$$PWD/tooltip/tipcontents.h \
$$PWD/tooltip/reuse.h \ $$PWD/tooltip/reuse.h \
$$PWD/tooltip/effects.h \ $$PWD/tooltip/effects.h \
$$PWD/unixutils.h \ $$PWD/unixutils.h \

View File

@@ -219,8 +219,6 @@ QtcLibrary {
files: [ files: [
"effects.h", "effects.h",
"reuse.h", "reuse.h",
"tipcontents.cpp",
"tipcontents.h",
"tips.cpp", "tips.cpp",
"tips.h", "tips.h",
"tooltip.cpp", "tooltip.cpp",

View File

@@ -44,7 +44,6 @@
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <utils/tooltip/tooltip.h> #include <utils/tooltip/tooltip.h>
#include <utils/tooltip/tipcontents.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QAbstractItemModel> #include <QAbstractItemModel>
@@ -688,7 +687,7 @@ public:
if (parentWidget()) { if (parentWidget()) {
// We are currently within a text editor tooltip: // We are currently within a text editor tooltip:
// Rip out of parent widget and re-show as a tooltip // Rip out of parent widget and re-show as a tooltip
Utils::TipContent::pinToolTip(this, ICore::mainWindow()); Utils::ToolTip::pinToolTip(this, ICore::mainWindow());
} else { } else {
// We have just be restored from session data. // We have just be restored from session data.
setWindowFlags(Qt::ToolTip); setWindowFlags(Qt::ToolTip);

View File

@@ -60,7 +60,6 @@
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/tooltip/tipcontents.h>
#include <utils/tooltip/tooltip.h> #include <utils/tooltip/tooltip.h>
//static const int FILE_LEVEL = 1; //static const int FILE_LEVEL = 1;