forked from qt-creator/qt-creator
Use icons and default tool tips in text mark popup
Change-Id: I4487d642e066479e8e344ed77e539de92fbca651 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -33,7 +33,7 @@
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QLayout>
|
||||
#include <QGridLayout>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Utils;
|
||||
@@ -114,6 +114,11 @@ void TextMark::setIcon(const QIcon &icon)
|
||||
m_icon = icon;
|
||||
}
|
||||
|
||||
const QIcon &TextMark::icon() const
|
||||
{
|
||||
return m_icon;
|
||||
}
|
||||
|
||||
Theme::Color TextMark::categoryColor(Id category)
|
||||
{
|
||||
return TextEditorPlugin::baseTextMarkRegistry()->categoryColor(category);
|
||||
@@ -195,10 +200,37 @@ void TextMark::dragToLine(int lineNumber)
|
||||
Q_UNUSED(lineNumber);
|
||||
}
|
||||
|
||||
void TextMark::addToToolTipLayout(QLayout *target)
|
||||
void TextMark::addToToolTipLayout(QGridLayout *target)
|
||||
{
|
||||
if (!m_toolTip.isEmpty())
|
||||
target->addWidget(new QLabel(m_toolTip));
|
||||
auto *contentLayout = new QVBoxLayout;
|
||||
addToolTipContent(contentLayout);
|
||||
if (contentLayout->count() > 0) {
|
||||
const int row = target->rowCount();
|
||||
if (!m_icon.isNull()) {
|
||||
auto iconLabel = new QLabel;
|
||||
iconLabel->setPixmap(m_icon.pixmap(16, 16));
|
||||
target->addWidget(iconLabel, row, 0, Qt::AlignTop | Qt::AlignHCenter);
|
||||
}
|
||||
target->addLayout(contentLayout, row, 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool TextMark::addToolTipContent(QLayout *target)
|
||||
{
|
||||
QString text = m_toolTip;
|
||||
if (text.isEmpty()) {
|
||||
text = TextEditorPlugin::baseTextMarkRegistry()->defaultToolTip(m_category);
|
||||
if (text.isEmpty())
|
||||
return false;
|
||||
}
|
||||
|
||||
auto textLabel = new QLabel;
|
||||
textLabel->setText(text);
|
||||
// Differentiate between tool tips that where explicitly set and default tool tips.
|
||||
textLabel->setEnabled(!m_toolTip.isEmpty());
|
||||
target->addWidget(textLabel);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TextDocument *TextMark::baseTextDocument() const
|
||||
|
||||
Reference in New Issue
Block a user