Commit 5383bc2a authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk

widgethelper: add optional rounded corner for VignetteWidget

Change-Id: If8672292c9da6b9339b960ae29dd11241aac32dc
parent e3a7b894
......@@ -161,7 +161,17 @@ VignetteWidget::paintEvent(QPaintEvent *event)
gradient.setColorAt(0, QColor(0, 0, 0, 96));
gradient.setColorAt(0.5, QColor(0, 0, 0, 32));
gradient.setColorAt(1, Qt::transparent);
painter.fillRect(rect(), gradient);
// draw rounded corner
if (drawRoundedCorner_) {
QBrush brush(gradient);
brush.setTransform(QTransform::fromTranslate(this->rect().x(), this->rect().y()));
QPainterPath previewPath;
previewPath.addRoundRect(this->rect(), cornerRadius_);
painter.fillPath(previewPath, brush);
} else {
painter.fillRect(rect(), gradient);
}
// bottom
gradient.setStart(0, rect().bottom() - height_);
......@@ -169,5 +179,16 @@ VignetteWidget::paintEvent(QPaintEvent *event)
gradient.setColorAt(0, Qt::transparent);
gradient.setColorAt(0.5, QColor(0, 0, 0, 32));
gradient.setColorAt(1, QColor(0, 0, 0, 96));
painter.fillRect(rect(), gradient);
}
\ No newline at end of file
// draw rounded corner
if (drawRoundedCorner_) {
QBrush brush(gradient);
brush.setTransform(QTransform::fromTranslate(this->rect().x(), this->rect().y()));
QPainterPath previewPath;
previewPath.addRoundRect(this->rect(), cornerRadius_);
painter.fillPath(previewPath, brush);
} else {
painter.fillRect(rect(), gradient);
}
}
......@@ -96,6 +96,8 @@ public:
explicit VignetteWidget(QWidget* parent = nullptr);
~VignetteWidget();
void setDrawRoundedCorner(bool state) { drawRoundedCorner_ = state; }
public slots:
void slotWillFadeOut();
void slotWillResetOpacity();
......@@ -105,8 +107,10 @@ protected:
private:
FadeAnimation* fadeOutAnimation_;
constexpr static qreal cornerRadius_ = 10.0f;
quint64 height_{ 128 };
quint64 fadeTime_{ 1000 };
bool drawRoundedCorner_{ false };
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment