diff options
author | David Schulz <david.schulz@qt.io> | 2016-08-16 14:19:41 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2016-09-06 09:12:36 +0000 |
commit | 50a6c478304adb40020d6ccdacc41e9a77a7ad77 (patch) | |
tree | d35459c60e42e687a2f61ecdb2b104754677489e /src/plugins/texteditor/textmark.cpp | |
parent | 0e542a6a2914a73b42ae3d1af3c68a6bfe51e939 (diff) | |
download | qt-creator-50a6c478304adb40020d6ccdacc41e9a77a7ad77.tar.gz |
Use icons and default tool tips in text mark popup
Change-Id: I4487d642e066479e8e344ed77e539de92fbca651
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/texteditor/textmark.cpp')
-rw-r--r-- | src/plugins/texteditor/textmark.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index 86f4b551b4..dea5ca70c0 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -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) +{ + 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) { - if (!m_toolTip.isEmpty()) - target->addWidget(new QLabel(m_toolTip)); + 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 |