forked from qt-creator/qt-creator
Unified the three fake tooltip copies
Reviewed-by: mae
This commit is contained in:
@@ -43,6 +43,8 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <utils/faketooltip.h>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDir>
|
||||
@@ -51,8 +53,7 @@
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QStylePainter>
|
||||
#include <QtGui/QStyleOption>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QApplication>
|
||||
@@ -263,29 +264,6 @@ private:
|
||||
namespace QmlJSEditor {
|
||||
namespace Internal {
|
||||
|
||||
class FakeToolTipFrame : public QWidget
|
||||
{
|
||||
public:
|
||||
FakeToolTipFrame(QWidget *parent = 0) :
|
||||
QWidget(parent, Qt::ToolTip | Qt::WindowStaysOnTopHint)
|
||||
{
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
// Set the window and button text to the tooltip text color, since this
|
||||
// widget draws the background as a tooltip.
|
||||
QPalette p = palette();
|
||||
const QColor toolTipTextColor = p.color(QPalette::Inactive, QPalette::ToolTipText);
|
||||
p.setColor(QPalette::Inactive, QPalette::WindowText, toolTipTextColor);
|
||||
p.setColor(QPalette::Inactive, QPalette::ButtonText, toolTipTextColor);
|
||||
setPalette(p);
|
||||
}
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent *e);
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
};
|
||||
|
||||
class FunctionArgumentWidget : public QLabel
|
||||
{
|
||||
public:
|
||||
@@ -313,27 +291,9 @@ private:
|
||||
|
||||
QWidget *m_pager;
|
||||
QLabel *m_numberLabel;
|
||||
FakeToolTipFrame *m_popupFrame;
|
||||
Utils::FakeToolTip *m_popupFrame;
|
||||
};
|
||||
|
||||
void FakeToolTipFrame::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStylePainter p(this);
|
||||
QStyleOptionFrame opt;
|
||||
opt.init(this);
|
||||
p.drawPrimitive(QStyle::PE_PanelTipLabel, opt);
|
||||
p.end();
|
||||
}
|
||||
|
||||
void FakeToolTipFrame::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
QStyleHintReturnMask frameMask;
|
||||
QStyleOption option;
|
||||
option.init(this);
|
||||
if (style()->styleHint(QStyle::SH_ToolTip_Mask, &option, this, &frameMask))
|
||||
setMask(frameMask.region);
|
||||
}
|
||||
|
||||
|
||||
FunctionArgumentWidget::FunctionArgumentWidget():
|
||||
m_minimumArgumentCount(0),
|
||||
@@ -344,7 +304,7 @@ FunctionArgumentWidget::FunctionArgumentWidget():
|
||||
QObject *editorObject = Core::EditorManager::instance()->currentEditor();
|
||||
m_editor = qobject_cast<TextEditor::ITextEditor *>(editorObject);
|
||||
|
||||
m_popupFrame = new FakeToolTipFrame(m_editor->widget());
|
||||
m_popupFrame = new Utils::FakeToolTip(m_editor->widget());
|
||||
|
||||
setParent(m_popupFrame);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
@@ -364,8 +324,6 @@ FunctionArgumentWidget::FunctionArgumentWidget():
|
||||
m_popupFrame->setLayout(layout);
|
||||
|
||||
setTextFormat(Qt::RichText);
|
||||
setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this));
|
||||
setIndent(1);
|
||||
|
||||
qApp->installEventFilter(this);
|
||||
}
|
||||
@@ -399,7 +357,6 @@ void FunctionArgumentWidget::updateArgumentHighlight()
|
||||
|
||||
updateHintText();
|
||||
|
||||
|
||||
QString str = m_editor->textAt(m_startpos, curpos - m_startpos);
|
||||
int argnr = 0;
|
||||
int parcount = 0;
|
||||
|
||||
Reference in New Issue
Block a user