forked from qt-creator/qt-creator
Utils: Cleanup of Tooltip interface
Change-Id: If4908e7a5d5ce749ff1e2efc7a026604821737be Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
@@ -185,7 +185,7 @@ bool WidgetContent::pinToolTip(QWidget *w)
|
||||
for (QWidget *p = w->parentWidget(); p ; p = p->parentWidget()) {
|
||||
if (Internal::WidgetTip *wt = qobject_cast<Internal::WidgetTip *>(p)) {
|
||||
wt->pinToolTipWidget();
|
||||
ToolTip::instance()->hide();
|
||||
ToolTip::hide();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ ToolTip *ToolTip::instance()
|
||||
|
||||
void ToolTip::show(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect)
|
||||
{
|
||||
if (acceptShow(content, pos, w, rect)) {
|
||||
ToolTip *t = instance();
|
||||
if (t->acceptShow(content, pos, w, rect)) {
|
||||
QWidget *target = 0;
|
||||
if (HostOsInfo::isWindowsHost())
|
||||
target = QApplication::desktop()->screen(Internal::screenNumber(pos, w));
|
||||
@@ -76,18 +77,18 @@ void ToolTip::show(const QPoint &pos, const TipContent &content, QWidget *w, con
|
||||
|
||||
switch (content.typeId()) {
|
||||
case TextContent::TEXT_CONTENT_ID:
|
||||
m_tip = new TextTip(target);
|
||||
t->m_tip = new TextTip(target);
|
||||
break;
|
||||
case ColorContent::COLOR_CONTENT_ID:
|
||||
m_tip = new ColorTip(target);
|
||||
t->m_tip = new ColorTip(target);
|
||||
break;
|
||||
case WidgetContent::WIDGET_CONTENT_ID:
|
||||
m_tip = new WidgetTip(target);
|
||||
t->m_tip = new WidgetTip(target);
|
||||
break;
|
||||
}
|
||||
setUp(pos, content, w, rect);
|
||||
qApp->installEventFilter(this);
|
||||
showTip();
|
||||
t->setUp(pos, content, w, rect);
|
||||
qApp->installEventFilter(t);
|
||||
t->showTip();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,9 +171,10 @@ void ToolTip::setTipRect(QWidget *w, const QRect &rect)
|
||||
}
|
||||
}
|
||||
|
||||
bool ToolTip::isVisible() const
|
||||
bool ToolTip::isVisible()
|
||||
{
|
||||
return m_tip && m_tip->isVisible();
|
||||
ToolTip *t = instance();
|
||||
return t->m_tip && t->m_tip->isVisible();
|
||||
}
|
||||
|
||||
void ToolTip::showTip()
|
||||
@@ -191,7 +193,7 @@ void ToolTip::showTip()
|
||||
|
||||
void ToolTip::hide()
|
||||
{
|
||||
hideTipWithDelay();
|
||||
instance()->hideTipWithDelay();
|
||||
}
|
||||
|
||||
void ToolTip::hideTipWithDelay()
|
||||
@@ -293,13 +295,3 @@ bool ToolTip::eventFilter(QObject *o, QEvent *event)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QFont ToolTip::font() const
|
||||
{
|
||||
return QApplication::font("QTipLabel");
|
||||
}
|
||||
|
||||
void ToolTip::setFont(const QFont &font)
|
||||
{
|
||||
QApplication::setFont(font, "QTipLabel");
|
||||
}
|
||||
|
||||
@@ -60,28 +60,24 @@ class TipContent;
|
||||
class QTCREATOR_UTILS_EXPORT ToolTip : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
ToolTip();
|
||||
|
||||
public:
|
||||
virtual ~ToolTip();
|
||||
~ToolTip();
|
||||
|
||||
bool eventFilter(QObject *o, QEvent *event);
|
||||
|
||||
static ToolTip *instance();
|
||||
|
||||
void show(const QPoint &pos, const TipContent &content, QWidget *w = 0);
|
||||
void show(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect);
|
||||
void hide();
|
||||
bool isVisible() const;
|
||||
|
||||
QFont font() const;
|
||||
void setFont(const QFont &font);
|
||||
|
||||
virtual bool eventFilter(QObject *o, QEvent *event);
|
||||
static void show(const QPoint &pos, const TipContent &content, QWidget *w = 0);
|
||||
static void show(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect);
|
||||
static void hide();
|
||||
static bool isVisible();
|
||||
|
||||
private slots:
|
||||
void hideTipImmediately();
|
||||
|
||||
private:
|
||||
ToolTip();
|
||||
bool acceptShow(const TipContent &content, const QPoint &pos, QWidget *w, const QRect &rect);
|
||||
bool validateContent(const TipContent &content);
|
||||
void setUp(const QPoint &pos, const TipContent &content, QWidget *w, const QRect &rect);
|
||||
|
||||
@@ -61,6 +61,7 @@ using namespace Bookmarks;
|
||||
using namespace Bookmarks::Internal;
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
|
||||
BookmarkDelegate::BookmarkDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent), m_normalPixmap(0), m_selectedPixmap(0)
|
||||
@@ -829,9 +830,9 @@ void BookmarkManager::operateTooltip(TextEditor::ITextEditor *textEditor, const
|
||||
return;
|
||||
|
||||
if (mark->note().isEmpty())
|
||||
Utils::ToolTip::instance()->hide();
|
||||
ToolTip::hide();
|
||||
else
|
||||
Utils::ToolTip::instance()->show(pos, Utils::TextContent(mark->note()), textEditor->widget());
|
||||
ToolTip::show(pos, TextContent(mark->note()), textEditor->widget());
|
||||
}
|
||||
|
||||
/* Loads the bookmarks from the session settings. */
|
||||
|
||||
@@ -46,8 +46,10 @@
|
||||
#include <QPropertyAnimation>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Internal;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
FancyToolButton::FancyToolButton(QWidget *parent)
|
||||
: QToolButton(parent), m_fader(0)
|
||||
@@ -78,7 +80,7 @@ bool FancyToolButton::event(QEvent *e)
|
||||
case QEvent::ToolTip:
|
||||
{
|
||||
QHelpEvent *he = static_cast<QHelpEvent *>(e);
|
||||
Utils::ToolTip::instance()->show(mapToGlobal(he->pos()), Utils::TextContent(toolTip()), this);
|
||||
ToolTip::show(mapToGlobal(he->pos()), TextContent(toolTip()), this);
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
@@ -340,3 +342,5 @@ QSize FancyActionBar::minimumSizeHint() const
|
||||
return sizeHint();
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
@@ -55,6 +55,7 @@ using namespace CppEditor;
|
||||
using namespace CppEditor::Internal;
|
||||
using namespace CppTools;
|
||||
using namespace TextEditor;
|
||||
using namespace Utils;
|
||||
|
||||
FunctionDeclDefLinkFinder::FunctionDeclDefLinkFinder(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -300,7 +301,7 @@ void FunctionDeclDefLink::apply(CPPEditorWidget *editor, bool jumpToMatch)
|
||||
const int targetStart = newTargetFile->position(targetLine, targetColumn);
|
||||
const int targetEnd = targetStart + targetInitial.size();
|
||||
if (targetInitial == newTargetFile->textOf(targetStart, targetEnd)) {
|
||||
const Utils::ChangeSet changeset = changes(snapshot, targetStart);
|
||||
const ChangeSet changeset = changes(snapshot, targetStart);
|
||||
newTargetFile->setChangeSet(changeset);
|
||||
if (jumpToMatch) {
|
||||
const int jumpTarget = newTargetFile->position(targetFunction->line(), targetFunction->column());
|
||||
@@ -308,10 +309,8 @@ void FunctionDeclDefLink::apply(CPPEditorWidget *editor, bool jumpToMatch)
|
||||
}
|
||||
newTargetFile->apply();
|
||||
} else {
|
||||
Utils::ToolTip::instance()->show(
|
||||
editor->toolTipPosition(linkSelection),
|
||||
Utils::TextContent(
|
||||
tr("Target file was changed, could not apply changes")));
|
||||
ToolTip::show(editor->toolTipPosition(linkSelection),
|
||||
TextContent(tr("Target file was changed, could not apply changes")));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1114,7 +1114,7 @@ void DebuggerToolTipManager::showToolTip(const QPoint &p, IEditor *editor,
|
||||
if (debugToolTipPositioning)
|
||||
qDebug() << "DebuggerToolTipManager::showToolTip" << p << " Mouse at " << QCursor::pos();
|
||||
const Utils::WidgetContent widgetContent(toolTipWidget, true);
|
||||
Utils::ToolTip::instance()->show(p, widgetContent, widget);
|
||||
Utils::ToolTip::show(p, widgetContent, widget);
|
||||
registerToolTip(toolTipWidget);
|
||||
}
|
||||
|
||||
|
||||
@@ -323,11 +323,10 @@ void DiffViewEditorEditable::slotTooltipRequested(TextEditor::ITextEditor *edito
|
||||
QMap<int, DiffEditorWidget::DiffFileInfo>::const_iterator it
|
||||
= fi.constFind(ew->document()->findBlock(position).blockNumber());
|
||||
if (it != fi.constEnd()) {
|
||||
Utils::ToolTip::instance()->show(globalPoint,
|
||||
Utils::TextContent(it.value().fileName),
|
||||
Utils::ToolTip::show(globalPoint, Utils::TextContent(it.value().fileName),
|
||||
editor->widget());
|
||||
} else {
|
||||
Utils::ToolTip::instance()->hide();
|
||||
Utils::ToolTip::hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -378,11 +378,11 @@ void HoverHandler::reset()
|
||||
void HoverHandler::operateTooltip(TextEditor::ITextEditor *editor, const QPoint &point)
|
||||
{
|
||||
if (toolTip().isEmpty())
|
||||
Utils::ToolTip::instance()->hide();
|
||||
Utils::ToolTip::hide();
|
||||
else if (m_colorTip.isValid())
|
||||
Utils::ToolTip::instance()->show(point, Utils::ColorContent(m_colorTip), editor->widget());
|
||||
Utils::ToolTip::show(point, Utils::ColorContent(m_colorTip), editor->widget());
|
||||
else
|
||||
Utils::ToolTip::instance()->show(point, Utils::TextContent(toolTip()), editor->widget());
|
||||
Utils::ToolTip::show(point, Utils::TextContent(toolTip()), editor->widget());
|
||||
}
|
||||
|
||||
void HoverHandler::prettyPrintTooltip(const QmlJS::Value *value,
|
||||
|
||||
@@ -84,7 +84,7 @@ void BaseHoverHandler::updateContextHelpId(TextEditor::ITextEditor *editor, int
|
||||
|
||||
// If the tooltip is visible and there is a help match, this match is used to update
|
||||
// the help id. Otherwise, let the identification process happen.
|
||||
if (!Utils::ToolTip::instance()->isVisible() || !lastHelpItemIdentified().isValid())
|
||||
if (!Utils::ToolTip::isVisible() || !lastHelpItemIdentified().isValid())
|
||||
process(editor, pos);
|
||||
|
||||
if (lastHelpItemIdentified().isValid())
|
||||
@@ -157,9 +157,9 @@ void BaseHoverHandler::decorateToolTip()
|
||||
void BaseHoverHandler::operateTooltip(ITextEditor *editor, const QPoint &point)
|
||||
{
|
||||
if (m_toolTip.isEmpty())
|
||||
Utils::ToolTip::instance()->hide();
|
||||
Utils::ToolTip::hide();
|
||||
else
|
||||
Utils::ToolTip::instance()->show(point, Utils::TextContent(m_toolTip), editor->widget());
|
||||
Utils::ToolTip::show(point, Utils::TextContent(m_toolTip), editor->widget());
|
||||
}
|
||||
|
||||
BaseTextEditorWidget *BaseHoverHandler::baseTextEditor(ITextEditor *editor)
|
||||
|
||||
@@ -1546,7 +1546,7 @@ void BaseTextEditorWidget::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
if (!isModifier(e))
|
||||
viewport()->setCursor(Qt::BlankCursor);
|
||||
ToolTip::instance()->hide();
|
||||
ToolTip::hide();
|
||||
|
||||
d->m_moveLineUndoHack = false;
|
||||
d->clearVisibleFoldedBlock();
|
||||
@@ -2599,8 +2599,7 @@ bool BaseTextEditorWidget::viewportEvent(QEvent *event)
|
||||
|
||||
RefactorMarker refactorMarker = d->m_refactorOverlay->markerAt(pos);
|
||||
if (refactorMarker.isValid() && !refactorMarker.tooltip.isEmpty()) {
|
||||
ToolTip::instance()->show(he->globalPos(),
|
||||
TextContent(refactorMarker.tooltip),
|
||||
ToolTip::show(he->globalPos(), TextContent(refactorMarker.tooltip),
|
||||
viewport(),
|
||||
refactorMarker.rect);
|
||||
return true;
|
||||
@@ -4267,8 +4266,8 @@ void BaseTextEditorWidget::keyReleaseEvent(QKeyEvent *e)
|
||||
clearLink();
|
||||
} else if (e->key() == Qt::Key_Shift
|
||||
&& d->m_behaviorSettings.m_constrainHoverTooltips
|
||||
&& ToolTip::instance()->isVisible()) {
|
||||
ToolTip::instance()->hide();
|
||||
&& ToolTip::isVisible()) {
|
||||
ToolTip::hide();
|
||||
} else if (e->key() == Qt::Key_Alt
|
||||
&& d->m_maybeFakeTooltipEvent) {
|
||||
d->m_maybeFakeTooltipEvent = false;
|
||||
|
||||
Reference in New Issue
Block a user