From 0454e939e186350da446788ce5a3abaa0c98b696 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 19 Jan 2023 12:49:50 +0100 Subject: [PATCH] Utils: Make all labels created by the LayoutBuilder ... selectable with the mouse. Change-Id: Ied2677a517239ca55a15daeae088bc09998d2b3b Reviewed-by: Eike Ziller --- src/libs/utils/layoutbuilder.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libs/utils/layoutbuilder.cpp b/src/libs/utils/layoutbuilder.cpp index 4854b69f6cf..3fd498279de 100644 --- a/src/libs/utils/layoutbuilder.cpp +++ b/src/libs/utils/layoutbuilder.cpp @@ -140,6 +140,13 @@ static QWidget *widgetForItem(QLayoutItem *item) return nullptr; } +static QLabel *createLabel(const QString &text) +{ + auto label = new QLabel(text); + label->setTextInteractionFlags(Qt::TextSelectableByMouse); + return label; +} + static void addItemToBoxLayout(QBoxLayout *layout, const LayoutBuilder::LayoutItem &item) { if (QWidget *w = item.widget) { @@ -153,7 +160,7 @@ static void addItemToBoxLayout(QBoxLayout *layout, const LayoutBuilder::LayoutIt } else if (item.specialType == LayoutBuilder::SpecialType::HorizontalRule) { layout->addWidget(Layouting::createHr()); } else if (!item.text.isEmpty()) { - layout->addWidget(new QLabel(item.text)); + layout->addWidget(createLabel(item.text)); } else { QTC_CHECK(false); } @@ -250,7 +257,7 @@ static void doLayoutHelper(QLayout *layout, else if (item.layout) gridLayout->addLayout(item.layout, currentGridRow, currentGridColumn, 1, item.span, align); else if (!item.text.isEmpty()) - gridLayout->addWidget(new QLabel(item.text), currentGridRow, currentGridColumn, 1, 1, align); + gridLayout->addWidget(createLabel(item.text), currentGridRow, currentGridColumn, 1, 1, align); currentGridColumn += item.span; } else if (boxLayout) { addItemToBoxLayout(boxLayout, item);