forked from qt-creator/qt-creator
Core: Style message popups
First rough adaptations to the current Figma-based design specs. Change-Id: I77c4bd5b185c2c175ea732401e5c686072244d5c Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -71,6 +71,7 @@ public:
|
|||||||
|
|
||||||
void setInfoBar(InfoBar *infoBar);
|
void setInfoBar(InfoBar *infoBar);
|
||||||
InfoBar *infoBar() const;
|
InfoBar *infoBar() const;
|
||||||
|
void paintEvent(QPaintEvent *ev) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update();
|
void update();
|
||||||
@@ -94,7 +95,7 @@ private:
|
|||||||
PopupInfoBarDisplay::PopupInfoBarDisplay()
|
PopupInfoBarDisplay::PopupInfoBarDisplay()
|
||||||
{
|
{
|
||||||
m_layout = new QVBoxLayout;
|
m_layout = new QVBoxLayout;
|
||||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
m_layout->setContentsMargins(0, 2, 0, 0);
|
||||||
m_layout->setSpacing(0);
|
m_layout->setSpacing(0);
|
||||||
setLayout(m_layout);
|
setLayout(m_layout);
|
||||||
}
|
}
|
||||||
@@ -117,6 +118,15 @@ InfoBar *PopupInfoBarDisplay::infoBar() const
|
|||||||
return m_infoBar;
|
return m_infoBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PopupInfoBarDisplay::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter p(this);
|
||||||
|
const QRect r = rect().adjusted(0, layout()->contentsMargins().top(), 0, 0);
|
||||||
|
StyleHelper::drawCardBg(&p, r, creatorColor(Theme::Token_Background_Muted),
|
||||||
|
creatorColor(Theme::Token_Stroke_Subtle),
|
||||||
|
StyleHelper::SpacingTokens::HPaddingXs);
|
||||||
|
}
|
||||||
|
|
||||||
static void disconnectRecursively(QObject *obj)
|
static void disconnectRecursively(QObject *obj)
|
||||||
{
|
{
|
||||||
obj->disconnect();
|
obj->disconnect();
|
||||||
@@ -164,14 +174,12 @@ InfoWidget::InfoWidget(const InfoBarEntry &info, QPointer<InfoBar> infoBar)
|
|||||||
}
|
}
|
||||||
return info.infoType();
|
return info.infoType();
|
||||||
}();
|
}();
|
||||||
QPalette pal = palette();
|
|
||||||
pal.setColor(QPalette::Window, InfoBarEntry::backgroundColor(infoType));
|
|
||||||
setPalette(pal);
|
|
||||||
|
|
||||||
const Id id = info.id();
|
const Id id = info.id();
|
||||||
|
|
||||||
QToolButton *infoWidgetCloseButton = nullptr;
|
QToolButton *infoWidgetCloseButton = nullptr;
|
||||||
QLayout *buttonLayout;
|
QLayout *buttonLayout;
|
||||||
|
QLabel *titleLabel;
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
Column {
|
Column {
|
||||||
@@ -179,10 +187,11 @@ InfoWidget::InfoWidget(const InfoBarEntry &info, QPointer<InfoBar> infoBar)
|
|||||||
Column {
|
Column {
|
||||||
Layouting::IconDisplay { icon(InfoBarEntry::icon(infoType)) },
|
Layouting::IconDisplay { icon(InfoBarEntry::icon(infoType)) },
|
||||||
st,
|
st,
|
||||||
|
customMargins(0, 0, StyleHelper::SpacingTokens::ExPaddingGapS, 0),
|
||||||
},
|
},
|
||||||
Column {
|
Column {
|
||||||
Row {
|
Row {
|
||||||
Label { text("<b>" + info.title() + "</b>")},
|
Label { bindTo(&titleLabel), text(info.title()) },
|
||||||
st,
|
st,
|
||||||
If { info.hasCancelButton(), { ToolButton { bindTo(&infoWidgetCloseButton) } } }
|
If { info.hasCancelButton(), { ToolButton { bindTo(&infoWidgetCloseButton) } } }
|
||||||
},
|
},
|
||||||
@@ -191,10 +200,17 @@ InfoWidget::InfoWidget(const InfoBarEntry &info, QPointer<InfoBar> infoBar)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Flow{ bindTo(&buttonLayout), alignment(Qt::AlignRight) }
|
Space(StyleHelper::SpacingTokens::HGapS),
|
||||||
|
Flow{ bindTo(&buttonLayout), alignment(Qt::AlignRight) },
|
||||||
|
customMargins(StyleHelper::SpacingTokens::HPaddingS,
|
||||||
|
StyleHelper::SpacingTokens::ExPaddingGapL,
|
||||||
|
StyleHelper::SpacingTokens::HPaddingS,
|
||||||
|
StyleHelper::SpacingTokens::ExPaddingGapL),
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
titleLabel->setFont(StyleHelper::uiFont(StyleHelper::UiElementH5));
|
||||||
|
|
||||||
if (info.hasCancelButton() && QTC_GUARD(infoWidgetCloseButton)) {
|
if (info.hasCancelButton() && QTC_GUARD(infoWidgetCloseButton)) {
|
||||||
// need to connect to cancelObjectbefore connecting to cancelButtonClicked,
|
// need to connect to cancelObjectbefore connecting to cancelButtonClicked,
|
||||||
// because the latter removes the button and with it any connect
|
// because the latter removes the button and with it any connect
|
||||||
@@ -278,9 +294,9 @@ InfoWidget::InfoWidget(const InfoBarEntry &info, QPointer<InfoBar> infoBar)
|
|||||||
void InfoWidget::paintEvent(QPaintEvent *)
|
void InfoWidget::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
p.setPen({palette().color(QPalette::Window).darker(105)});
|
p.setPen(creatorColor(Theme::Token_Stroke_Subtle));
|
||||||
p.setBrush(palette().brush(QPalette::Window));
|
p.drawLine(Utils::StyleHelper::SpacingTokens::HPaddingXs, 0,
|
||||||
p.drawRoundedRect(rect().adjusted(0, 2, 0, -1), 10, 10);
|
width() - Utils::StyleHelper::SpacingTokens::HPaddingXs - 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
class ProgressTimer : public QObject
|
class ProgressTimer : public QObject
|
||||||
|
Reference in New Issue
Block a user