forked from qt-creator/qt-creator
TextEditor: Polish separator in text mark tooltip
Use one row instead of two for showing "Other annotations" and the separator line. Change-Id: I25234fc2fb49ccb71125a1cf762c89b668032b77 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -839,6 +839,35 @@ TextEditorWidgetPrivate::~TextEditorWidgetPrivate()
|
||||
delete m_highlightScrollBarController;
|
||||
}
|
||||
|
||||
static QFrame *createSeparator(const QString &styleSheet)
|
||||
{
|
||||
QFrame* separator = new QFrame();
|
||||
separator->setStyleSheet(styleSheet);
|
||||
separator->setFrameShape(QFrame::HLine);
|
||||
QSizePolicy sizePolicy = separator->sizePolicy();
|
||||
sizePolicy.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
|
||||
separator->setSizePolicy(sizePolicy);
|
||||
|
||||
return separator;
|
||||
}
|
||||
|
||||
static QLayout *createSeparatorLayout()
|
||||
{
|
||||
QString styleSheet = "color: gray";
|
||||
|
||||
QFrame* separator1 = createSeparator(styleSheet);
|
||||
QFrame* separator2 = createSeparator(styleSheet);
|
||||
auto label = new QLabel(TextEditorWidget::tr("Other annotations"));
|
||||
label->setStyleSheet(styleSheet);
|
||||
|
||||
auto layout = new QHBoxLayout;
|
||||
layout->addWidget(separator1);
|
||||
layout->addWidget(label);
|
||||
layout->addWidget(separator2);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
void TextEditorWidgetPrivate::showTextMarksToolTip(const QPoint &pos,
|
||||
const TextMarks &marks,
|
||||
const TextMark *mainTextMark) const
|
||||
@@ -854,16 +883,8 @@ void TextEditorWidgetPrivate::showTextMarksToolTip(const QPoint &pos,
|
||||
|
||||
if (mainTextMark) {
|
||||
mainTextMark->addToToolTipLayout(layout);
|
||||
if (allMarks.size() > 1) {
|
||||
QFrame* separator = new QFrame();
|
||||
separator->setFrameShape(QFrame::HLine);
|
||||
layout->addWidget(separator, layout->rowCount(), 0, 1, -1);
|
||||
layout->addWidget(new QLabel(TextEditorWidget::tr("Other annotations:")),
|
||||
layout->rowCount(),
|
||||
0,
|
||||
1,
|
||||
-1);
|
||||
}
|
||||
if (allMarks.size() > 1)
|
||||
layout->addLayout(createSeparatorLayout(), layout->rowCount(), 0, 1, -1);
|
||||
}
|
||||
|
||||
Utils::sort(allMarks, [](const TextMark *mark1, const TextMark *mark2) {
|
||||
|
Reference in New Issue
Block a user