mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-05 17:55:25 +08:00
update
This commit is contained in:
@ -2,22 +2,22 @@
|
||||
|
||||
#include "FluTextStyle.h"
|
||||
|
||||
FluWatermark::FluWatermark(QQuickItem* parent) : QQuickPaintedItem(parent){
|
||||
gap(QPoint(100,100));
|
||||
offset(QPoint(_gap.x()/2,_gap.y()/2));
|
||||
rotate(22);
|
||||
FluWatermark::FluWatermark(QQuickItem *parent) : QQuickPaintedItem(parent) {
|
||||
_gap = QPoint(100, 100);
|
||||
_offset = QPoint(_gap.x() / 2, _gap.y() / 2);
|
||||
_rotate = 22;
|
||||
_textColor = QColor(222, 222, 222, 222);
|
||||
_textSize = 16;
|
||||
setZ(9999);
|
||||
textColor(QColor(222,222,222,222));
|
||||
textSize(16);
|
||||
connect(this,&FluWatermark::textColorChanged,this,[=]{update();});
|
||||
connect(this,&FluWatermark::gapChanged,this,[=]{update();});
|
||||
connect(this,&FluWatermark::offsetChanged,this,[=]{update();});
|
||||
connect(this,&FluWatermark::textChanged,this,[=]{update();});
|
||||
connect(this,&FluWatermark::rotateChanged,this,[=]{update();});
|
||||
connect(this,&FluWatermark::textSizeChanged,this,[=]{update();});
|
||||
connect(this, &FluWatermark::textColorChanged, this, [=] { update(); });
|
||||
connect(this, &FluWatermark::gapChanged, this, [=] { update(); });
|
||||
connect(this, &FluWatermark::offsetChanged, this, [=] { update(); });
|
||||
connect(this, &FluWatermark::textChanged, this, [=] { update(); });
|
||||
connect(this, &FluWatermark::rotateChanged, this, [=] { update(); });
|
||||
connect(this, &FluWatermark::textSizeChanged, this, [=] { update(); });
|
||||
}
|
||||
|
||||
void FluWatermark::paint(QPainter* painter){
|
||||
void FluWatermark::paint(QPainter *painter) {
|
||||
QFont font;
|
||||
font.setFamily(FluTextStyle::getInstance()->family());
|
||||
font.setPixelSize(_textSize);
|
||||
@ -26,14 +26,12 @@ void FluWatermark::paint(QPainter* painter){
|
||||
QFontMetricsF fontMetrics(font);
|
||||
qreal fontWidth = fontMetrics.horizontalAdvance(_text);
|
||||
qreal fontHeight = fontMetrics.height();
|
||||
int stepX = fontWidth + _gap.x();
|
||||
int stepY = fontHeight + _gap.y();
|
||||
int rowCount = width() / stepX+1;
|
||||
int colCount = height() / stepY+1;
|
||||
for (int r = 0; r < rowCount; r++)
|
||||
{
|
||||
for (int c = 0; c < colCount; c++)
|
||||
{
|
||||
int stepX = qRound(fontWidth + _gap.x());
|
||||
int stepY = qRound(fontHeight + _gap.y());
|
||||
int rowCount = qRound(width() / stepX + 1);
|
||||
int colCount = qRound(height() / stepY + 1);
|
||||
for (int r = 0; r < rowCount; r++) {
|
||||
for (int c = 0; c < colCount; c++) {
|
||||
qreal centerX = stepX * r + _offset.x() + fontWidth / 2.0;
|
||||
qreal centerY = stepY * c + _offset.y() + fontHeight / 2.0;
|
||||
painter->save();
|
||||
|
Reference in New Issue
Block a user