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 <hjk@qt.io>
This commit is contained in:
Christian Stenger
2020-08-20 15:54:21 +02:00
parent 70a1c6ccf5
commit e6c750bd13
2 changed files with 18 additions and 4 deletions

View File

@@ -161,7 +161,8 @@ class TextDisplayPrivate
public: public:
QString m_message; QString m_message;
QString m_tooltip; QString m_tooltip;
QPointer<QLabel> m_label; Utils::InfoLabel::InfoType m_type;
QPointer<InfoLabel> m_label;
}; };
} // Internal } // Internal
@@ -894,10 +895,11 @@ void StringListAspect::setValue(const QStringList &value)
\class ProjectExplorer::TextDisplay \class ProjectExplorer::TextDisplay
*/ */
TextDisplay::TextDisplay(const QString &message) TextDisplay::TextDisplay(const QString &message, InfoLabel::InfoType type)
: d(new Internal::TextDisplayPrivate) : d(new Internal::TextDisplayPrivate)
{ {
d->m_message = message; d->m_message = message;
d->m_type = type;
} }
TextDisplay::~TextDisplay() = default; TextDisplay::~TextDisplay() = default;
@@ -905,9 +907,11 @@ TextDisplay::~TextDisplay() = default;
void TextDisplay::addToLayout(LayoutBuilder &builder) void TextDisplay::addToLayout(LayoutBuilder &builder)
{ {
if (!d->m_label) { 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->setTextInteractionFlags(Qt::TextSelectableByMouse);
d->m_label->setToolTip(d->m_tooltip); d->m_label->setToolTip(d->m_tooltip);
d->m_label->setElideMode(Qt::ElideNone);
d->m_label->setWordWrap(true);
} }
builder.addItem(d->m_label.data()); builder.addItem(d->m_label.data());
d->m_label->setVisible(isVisible()); d->m_label->setVisible(isVisible());
@@ -927,6 +931,13 @@ void TextDisplay::setToolTip(const QString &tooltip)
d->m_label->setToolTip(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 \class ProjectExplorer::AspectContainer
*/ */

View File

@@ -29,6 +29,7 @@
#include "environmentaspect.h" #include "environmentaspect.h"
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <utils/infolabel.h>
#include <utils/macroexpander.h> #include <utils/macroexpander.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
@@ -262,13 +263,15 @@ class PROJECTEXPLORER_EXPORT TextDisplay : public ProjectConfigurationAspect
Q_OBJECT Q_OBJECT
public: public:
TextDisplay(const QString &message = {}); TextDisplay(const QString &message = {},
Utils::InfoLabel::InfoType type = Utils::InfoLabel::None);
~TextDisplay() override; ~TextDisplay() override;
void addToLayout(LayoutBuilder &builder) override; void addToLayout(LayoutBuilder &builder) override;
void setVisible(bool visible); void setVisible(bool visible);
void setToolTip(const QString &tooltip); void setToolTip(const QString &tooltip);
void setIconType(Utils::InfoLabel::InfoType t);
private: private:
std::unique_ptr<Internal::TextDisplayPrivate> d; std::unique_ptr<Internal::TextDisplayPrivate> d;