diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-04-14 17:24:29 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-04-15 15:08:51 +0200 |
commit | 20636f529b83aecd3ea8be5ea30143a8ae4f6349 (patch) | |
tree | 677ba1b31c157e19823597bafe4add278123c918 /src/plugins/cpptools/cppcodecompletion.cpp | |
parent | 990ec1be914b3f6bed20b8355ea4211a0de9a4d6 (diff) | |
download | qt-creator-20636f529b83aecd3ea8be5ea30143a8ae4f6349.tar.gz |
Unified the three fake tooltip copies
Reviewed-by: mae
Diffstat (limited to 'src/plugins/cpptools/cppcodecompletion.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodecompletion.cpp | 52 |
1 files changed, 5 insertions, 47 deletions
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index b7b26caf1b..a01e63b18d 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -60,6 +60,8 @@ #include <texteditor/itexteditable.h> #include <texteditor/basetexteditor.h> #include <projectexplorer/projectexplorer.h> + +#include <utils/faketooltip.h> #include <utils/qtcassert.h> #include <QtCore/QDebug> @@ -70,8 +72,7 @@ #include <QtGui/QDesktopWidget> #include <QtGui/QKeyEvent> #include <QtGui/QLabel> -#include <QtGui/QStyleOption> -#include <QtGui/QStylePainter> +#include <QtGui/QStyle> #include <QtGui/QTextDocument> // Qt::escape() #include <QtGui/QToolButton> #include <QtGui/QVBoxLayout> @@ -81,29 +82,6 @@ using namespace CPlusPlus; namespace CppTools { 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 { Q_OBJECT @@ -137,7 +115,7 @@ private: QWidget *m_pager; QLabel *m_numberLabel; - FakeToolTipFrame *m_popupFrame; + Utils::FakeToolTip *m_popupFrame; QList<Function *> m_items; LookupContext m_context; }; @@ -238,24 +216,6 @@ using namespace CppTools::Internal; Q_DECLARE_METATYPE(CompleteFunctionDeclaration) -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_startpos(-1), @@ -265,7 +225,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()); QToolButton *downArrow = new QToolButton; downArrow->setArrowType(Qt::DownArrow); @@ -300,8 +260,6 @@ FunctionArgumentWidget::FunctionArgumentWidget(): connect(downArrow, SIGNAL(clicked()), SLOT(nextPage())); setTextFormat(Qt::RichText); - setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, this)); - setIndent(1); qApp->installEventFilter(this); } |