forked from qt-creator/qt-creator
ClangTools: Use Utils::InfoLabel in ClangTool
Task-number: QTCREATORBUG-23346 Change-Id: I3141010b4e5ace54fa85aeb991dd749d28b30bfa Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -63,6 +63,7 @@
|
|||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/fancylineedit.h>
|
#include <utils/fancylineedit.h>
|
||||||
#include <utils/fancymainwindow.h>
|
#include <utils/fancymainwindow.h>
|
||||||
|
#include <utils/infolabel.h>
|
||||||
#include <utils/progressindicator.h>
|
#include <utils/progressindicator.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
@@ -91,54 +92,6 @@ static QString makeLink(const QString &text)
|
|||||||
return QString("<a href=t>%1</a>").arg(text);
|
return QString("<a href=t>%1</a>").arg(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
class IconAndLabel : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
IconAndLabel(const QPixmap &pixmap, const QString &text = {})
|
|
||||||
: m_icon(new QLabel)
|
|
||||||
, m_label(new QLabel)
|
|
||||||
{
|
|
||||||
QSizePolicy minSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
||||||
minSizePolicy.setHorizontalStretch(0);
|
|
||||||
|
|
||||||
m_icon->setPixmap(pixmap);
|
|
||||||
m_icon->setSizePolicy(minSizePolicy);
|
|
||||||
|
|
||||||
m_label->setSizePolicy(minSizePolicy);
|
|
||||||
m_label->setText(text);
|
|
||||||
m_label->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
|
||||||
layout->setContentsMargins(0, 0, 0, 0);
|
|
||||||
layout->addWidget(m_icon);
|
|
||||||
layout->addWidget(m_label);
|
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
connect(m_label, &QLabel::linkActivated, this, &IconAndLabel::linkActivated);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIcon(const QPixmap &pixmap) {
|
|
||||||
m_icon->setPixmap(pixmap);
|
|
||||||
m_icon->setVisible(!pixmap.isNull());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString text() const { return m_label->text(); }
|
|
||||||
void setText(const QString &text)
|
|
||||||
{
|
|
||||||
m_label->setText(text);
|
|
||||||
setVisible(!text.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void linkActivated(const QString &link);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QLabel *m_icon;
|
|
||||||
QLabel *m_label;
|
|
||||||
};
|
|
||||||
|
|
||||||
class InfoBarWidget : public QFrame
|
class InfoBarWidget : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -146,10 +99,13 @@ class InfoBarWidget : public QFrame
|
|||||||
public:
|
public:
|
||||||
InfoBarWidget()
|
InfoBarWidget()
|
||||||
: m_progressIndicator(new Utils::ProgressIndicator(ProgressIndicatorSize::Small))
|
: m_progressIndicator(new Utils::ProgressIndicator(ProgressIndicatorSize::Small))
|
||||||
, m_info(new IconAndLabel(Utils::Icons::INFO.pixmap()))
|
, m_info(new InfoLabel({}, InfoLabel::Information))
|
||||||
, m_error(new IconAndLabel(Utils::Icons::WARNING.pixmap()))
|
, m_error(new InfoLabel({}, InfoLabel::Warning))
|
||||||
, m_diagStats(new QLabel)
|
, m_diagStats(new QLabel)
|
||||||
{
|
{
|
||||||
|
m_info->setElideMode(Qt::ElideNone);
|
||||||
|
m_error->setElideMode(Qt::ElideNone);
|
||||||
|
|
||||||
m_diagStats->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
m_diagStats->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
|
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
@@ -175,11 +131,12 @@ public:
|
|||||||
{
|
{
|
||||||
const bool showProgress = type == ProgressIcon;
|
const bool showProgress = type == ProgressIcon;
|
||||||
m_progressIndicator->setVisible(showProgress);
|
m_progressIndicator->setVisible(showProgress);
|
||||||
m_info->setIcon(showProgress ? QPixmap() : Utils::Icons::INFO.pixmap());
|
m_info->setType(showProgress ? InfoLabel::None : InfoLabel::Information);
|
||||||
}
|
}
|
||||||
QString infoText() const { return m_info->text(); }
|
QString infoText() const { return m_info->text(); }
|
||||||
void setInfoText(const QString &text)
|
void setInfoText(const QString &text)
|
||||||
{
|
{
|
||||||
|
m_info->setVisible(!text.isEmpty());
|
||||||
m_info->setText(text);
|
m_info->setText(text);
|
||||||
evaluateVisibility();
|
evaluateVisibility();
|
||||||
}
|
}
|
||||||
@@ -193,12 +150,12 @@ public:
|
|||||||
const QString &text,
|
const QString &text,
|
||||||
const OnLinkActivated &linkAction = OnLinkActivated())
|
const OnLinkActivated &linkAction = OnLinkActivated())
|
||||||
{
|
{
|
||||||
|
m_error->setVisible(!text.isEmpty());
|
||||||
m_error->setText(text);
|
m_error->setText(text);
|
||||||
m_error->setIcon(type == Warning ? Utils::Icons::WARNING.pixmap()
|
m_error->setType(type == Warning ? InfoLabel::Warning : InfoLabel::Error);
|
||||||
: Utils::Icons::CRITICAL.pixmap());
|
|
||||||
m_error->disconnect();
|
m_error->disconnect();
|
||||||
if (linkAction)
|
if (linkAction)
|
||||||
connect(m_error, &IconAndLabel::linkActivated, this, linkAction);
|
connect(m_error, &QLabel::linkActivated, this, linkAction);
|
||||||
evaluateVisibility();
|
evaluateVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,8 +177,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Utils::ProgressIndicator *m_progressIndicator;
|
Utils::ProgressIndicator *m_progressIndicator;
|
||||||
IconAndLabel *m_info;
|
InfoLabel *m_info;
|
||||||
IconAndLabel *m_error;
|
InfoLabel *m_error;
|
||||||
QLabel *m_diagStats;
|
QLabel *m_diagStats;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user