diff --git a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/HintingLineEdit.h b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/HintingLineEdit.h index 377573916d05..76df20b98b42 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/HintingLineEdit.h +++ b/Code/Mantid/MantidQt/MantidWidgets/inc/MantidQtMantidWidgets/HintingLineEdit.h @@ -57,6 +57,7 @@ namespace MantidQt std::map m_matches; std::map m_hints; bool m_dontComplete; + QLabel* m_hintLabel; protected slots: void updateHints(const QString& text); }; diff --git a/Code/Mantid/MantidQt/MantidWidgets/src/HintingLineEdit.cpp b/Code/Mantid/MantidQt/MantidWidgets/src/HintingLineEdit.cpp index 5759348605c4..0c128d666905 100644 --- a/Code/Mantid/MantidQt/MantidWidgets/src/HintingLineEdit.cpp +++ b/Code/Mantid/MantidQt/MantidWidgets/src/HintingLineEdit.cpp @@ -9,6 +9,18 @@ namespace MantidQt { HintingLineEdit::HintingLineEdit(QWidget *parent, const std::map &hints) : QLineEdit(parent), m_hints(hints), m_dontComplete(false) { + m_hintLabel = new QLabel(this, Qt::ToolTip); + m_hintLabel->setMargin(1 + style()->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, m_hintLabel)); + m_hintLabel->setFrameStyle(QFrame::StyledPanel); + m_hintLabel->setAlignment(Qt::AlignLeft); + m_hintLabel->setWordWrap(true); + m_hintLabel->setIndent(1); + m_hintLabel->setAutoFillBackground(true); + m_hintLabel->setPalette(QToolTip::palette()); + m_hintLabel->setForegroundRole(QPalette::ToolTipText); + m_hintLabel->setBackgroundRole(QPalette::ToolTipBase); + m_hintLabel->ensurePolished(); + connect(this, SIGNAL(textEdited(const QString&)), this, SLOT(updateHints(const QString&))); } @@ -103,7 +115,17 @@ namespace MantidQt hintList += QString::fromStdString(mIt->second) + "
\n"; } - QToolTip::showText(mapToGlobal(QPoint(0, 5)), hintList.trimmed()); + if(!hintList.trimmed().isEmpty()) + { + m_hintLabel->show(); + m_hintLabel->setText(hintList.trimmed()); + m_hintLabel->adjustSize(); + m_hintLabel->move(mapToGlobal(QPoint(0, height()))); + } + else + { + m_hintLabel->hide(); + } } /** Insert an auto completion suggestion beneath the user's cursor and select it */