forked from qt-creator/qt-creator
ProjectExplorer: Introduce TextDisplay for simple display tasks
That's effectively a beefed-up TextDisplay previously used only in Incredibuild. Change-Id: I0cedef24cede8b8513e80b64f589abe62a68814e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -220,16 +220,5 @@ void CommandBuilderAspect::updateGui()
|
||||
d->makeArgumentsLineEdit->setText(d->m_activeCommandBuilder->arguments());
|
||||
}
|
||||
|
||||
// TextDisplay
|
||||
|
||||
void TextDisplay::addToLayout(LayoutBuilder &builder)
|
||||
{
|
||||
if (!m_label) {
|
||||
m_label = new QLabel(m_message);
|
||||
m_label->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
}
|
||||
builder.addItem(m_label.data());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace IncrediBuild
|
||||
|
@@ -52,17 +52,5 @@ private:
|
||||
class CommandBuilderAspectPrivate *d = nullptr;
|
||||
};
|
||||
|
||||
class TextDisplay final : public ProjectExplorer::ProjectConfigurationAspect
|
||||
{
|
||||
public:
|
||||
TextDisplay(const QString &message) : m_message(message) {}
|
||||
|
||||
private:
|
||||
void addToLayout(ProjectExplorer::LayoutBuilder &builder) final;
|
||||
|
||||
QString m_message;
|
||||
QPointer<QLabel> m_label;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace IncrediBuild
|
||||
|
@@ -156,6 +156,15 @@ public:
|
||||
QList<ProjectConfigurationAspect *> m_items;
|
||||
};
|
||||
|
||||
class TextDisplayPrivate
|
||||
{
|
||||
public:
|
||||
QString m_message;
|
||||
QString m_tooltip;
|
||||
QPixmap m_pixmap;
|
||||
QPointer<QLabel> m_label;
|
||||
};
|
||||
|
||||
} // Internal
|
||||
|
||||
/*!
|
||||
@@ -876,6 +885,51 @@ void StringListAspect::setValue(const QStringList &value)
|
||||
d->m_value = value;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::TextDisplay
|
||||
*/
|
||||
|
||||
TextDisplay::TextDisplay(const QString &message)
|
||||
: d(new Internal::TextDisplayPrivate)
|
||||
{
|
||||
d->m_message = message;
|
||||
}
|
||||
|
||||
TextDisplay::~TextDisplay() = default;
|
||||
|
||||
void TextDisplay::addToLayout(LayoutBuilder &builder)
|
||||
{
|
||||
if (!d->m_label) {
|
||||
d->m_label = new QLabel(d->m_message);
|
||||
d->m_label->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
||||
d->m_label->setVisible(isVisible());
|
||||
d->m_label->setToolTip(d->m_tooltip);
|
||||
d->m_label->setPixmap(d->m_pixmap);
|
||||
}
|
||||
builder.addItem(d->m_label.data());
|
||||
}
|
||||
|
||||
void TextDisplay::setVisible(bool visible)
|
||||
{
|
||||
ProjectConfigurationAspect::setVisible(visible);
|
||||
if (d->m_label)
|
||||
d->m_label->setVisible(visible);
|
||||
}
|
||||
|
||||
void TextDisplay::setToolTip(const QString &tooltip)
|
||||
{
|
||||
d->m_tooltip = tooltip;
|
||||
if (d->m_label)
|
||||
d->m_label->setToolTip(tooltip);
|
||||
}
|
||||
|
||||
void TextDisplay::setPixmap(const QPixmap &pixmap)
|
||||
{
|
||||
d->m_pixmap = pixmap;
|
||||
if (d->m_label)
|
||||
d->m_label->setPixmap(pixmap);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::AspectContainer
|
||||
*/
|
||||
|
@@ -257,6 +257,24 @@ private:
|
||||
std::unique_ptr<Internal::StringListAspectPrivate> d;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT TextDisplay : public ProjectConfigurationAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TextDisplay(const QString &message = {});
|
||||
~TextDisplay() override;
|
||||
|
||||
void addToLayout(LayoutBuilder &builder) override;
|
||||
|
||||
void setVisible(bool visible);
|
||||
void setToolTip(const QString &tooltip);
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
|
||||
private:
|
||||
std::unique_ptr<Internal::TextDisplayPrivate> d;
|
||||
};
|
||||
|
||||
class PROJECTEXPLORER_EXPORT AspectContainer : public ProjectConfigurationAspect
|
||||
{
|
||||
Q_OBJECT
|
||||
|
Reference in New Issue
Block a user