From e6c750bd13697636dad02f9bb8a7bf94e8029a30 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 20 Aug 2020 15:54:21 +0200 Subject: [PATCH] PE: Use InfoLabel for TextDisplay This restores using an additional icon for the label, but limits it to common ones. Change-Id: Ic9b1a419525d1fefb071b9f612e910b56a600edf Reviewed-by: hjk --- .../projectconfigurationaspects.cpp | 17 ++++++++++++++--- .../projectconfigurationaspects.h | 5 ++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.cpp b/src/plugins/projectexplorer/projectconfigurationaspects.cpp index 74b260a6967..d5d45e51dc2 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/projectconfigurationaspects.cpp @@ -161,7 +161,8 @@ class TextDisplayPrivate public: QString m_message; QString m_tooltip; - QPointer m_label; + Utils::InfoLabel::InfoType m_type; + QPointer m_label; }; } // Internal @@ -894,10 +895,11 @@ void StringListAspect::setValue(const QStringList &value) \class ProjectExplorer::TextDisplay */ -TextDisplay::TextDisplay(const QString &message) +TextDisplay::TextDisplay(const QString &message, InfoLabel::InfoType type) : d(new Internal::TextDisplayPrivate) { d->m_message = message; + d->m_type = type; } TextDisplay::~TextDisplay() = default; @@ -905,9 +907,11 @@ TextDisplay::~TextDisplay() = default; void TextDisplay::addToLayout(LayoutBuilder &builder) { if (!d->m_label) { - d->m_label = new QLabel(d->m_message); + d->m_label = new InfoLabel(d->m_message, d->m_type); d->m_label->setTextInteractionFlags(Qt::TextSelectableByMouse); d->m_label->setToolTip(d->m_tooltip); + d->m_label->setElideMode(Qt::ElideNone); + d->m_label->setWordWrap(true); } builder.addItem(d->m_label.data()); d->m_label->setVisible(isVisible()); @@ -927,6 +931,13 @@ void TextDisplay::setToolTip(const QString &tooltip) d->m_label->setToolTip(tooltip); } +void TextDisplay::setIconType(InfoLabel::InfoType t) +{ + d->m_type = t; + if (d->m_label) + d->m_label->setType(t); +} + /*! \class ProjectExplorer::AspectContainer */ diff --git a/src/plugins/projectexplorer/projectconfigurationaspects.h b/src/plugins/projectexplorer/projectconfigurationaspects.h index 11d266d9c90..df0dc94eaa0 100644 --- a/src/plugins/projectexplorer/projectconfigurationaspects.h +++ b/src/plugins/projectexplorer/projectconfigurationaspects.h @@ -29,6 +29,7 @@ #include "environmentaspect.h" #include +#include #include #include @@ -262,13 +263,15 @@ class PROJECTEXPLORER_EXPORT TextDisplay : public ProjectConfigurationAspect Q_OBJECT public: - TextDisplay(const QString &message = {}); + TextDisplay(const QString &message = {}, + Utils::InfoLabel::InfoType type = Utils::InfoLabel::None); ~TextDisplay() override; void addToLayout(LayoutBuilder &builder) override; void setVisible(bool visible); void setToolTip(const QString &tooltip); + void setIconType(Utils::InfoLabel::InfoType t); private: std::unique_ptr d;