mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-06-06 10:55:29 +08:00
feat: FluRectangle支持修改边框样式
This commit is contained in:
parent
97e88dbd6f
commit
ce4fb06084
@ -70,17 +70,17 @@
|
|||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/window/CrashWindow.qml" line="50"/>
|
<location filename="qml/window/CrashWindow.qml" line="53"/>
|
||||||
<source>We apologize for the inconvenience caused by an unexpected error</source>
|
<source>We apologize for the inconvenience caused by an unexpected error</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/window/CrashWindow.qml" line="62"/>
|
<location filename="qml/window/CrashWindow.qml" line="65"/>
|
||||||
<source>Report Logs</source>
|
<source>Report Logs</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/window/CrashWindow.qml" line="72"/>
|
<location filename="qml/window/CrashWindow.qml" line="75"/>
|
||||||
<source>Restart Program</source>
|
<source>Restart Program</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -70,17 +70,17 @@
|
|||||||
<translation type="unfinished">友情提示</translation>
|
<translation type="unfinished">友情提示</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/window/CrashWindow.qml" line="50"/>
|
<location filename="qml/window/CrashWindow.qml" line="53"/>
|
||||||
<source>We apologize for the inconvenience caused by an unexpected error</source>
|
<source>We apologize for the inconvenience caused by an unexpected error</source>
|
||||||
<translation type="unfinished">对于意外错误给您带来的不便,我们深表歉意</translation>
|
<translation type="unfinished">对于意外错误给您带来的不便,我们深表歉意</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/window/CrashWindow.qml" line="62"/>
|
<location filename="qml/window/CrashWindow.qml" line="65"/>
|
||||||
<source>Report Logs</source>
|
<source>Report Logs</source>
|
||||||
<translation type="unfinished">上报日志</translation>
|
<translation type="unfinished">上报日志</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="qml/window/CrashWindow.qml" line="72"/>
|
<location filename="qml/window/CrashWindow.qml" line="75"/>
|
||||||
<source>Restart Program</source>
|
<source>Restart Program</source>
|
||||||
<translation type="unfinished">重启程序</translation>
|
<translation type="unfinished">重启程序</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -11,69 +11,71 @@ FluScrollablePage{
|
|||||||
|
|
||||||
FluFrame{
|
FluFrame{
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: 80
|
|
||||||
padding: 10
|
padding: 10
|
||||||
|
|
||||||
Column{
|
Flow{
|
||||||
|
width: parent.width
|
||||||
spacing: 15
|
spacing: 15
|
||||||
anchors{
|
FluRectangle{
|
||||||
left: parent.left
|
width: 50
|
||||||
verticalCenter: parent.verticalCenter
|
height: 50
|
||||||
|
color:"#0078d4"
|
||||||
|
radius:[0,0,0,0]
|
||||||
}
|
}
|
||||||
RowLayout{
|
FluRectangle{
|
||||||
Layout.topMargin: 20
|
width: 50
|
||||||
FluRectangle{
|
height: 50
|
||||||
width: 50
|
color:"#744da9"
|
||||||
height: 50
|
radius:[15,15,15,15]
|
||||||
color:"#0078d4"
|
}
|
||||||
radius:[0,0,0,0]
|
FluRectangle{
|
||||||
}
|
width: 50
|
||||||
FluRectangle{
|
height: 50
|
||||||
width: 50
|
color:"#ffeb3b"
|
||||||
height: 50
|
radius:[15,0,0,0]
|
||||||
color:"#744da9"
|
}
|
||||||
radius:[15,15,15,15]
|
FluRectangle{
|
||||||
}
|
width: 50
|
||||||
FluRectangle{
|
height: 50
|
||||||
width: 50
|
color:"#f7630c"
|
||||||
height: 50
|
radius:[0,15,0,0]
|
||||||
color:"#ffeb3b"
|
}
|
||||||
radius:[15,0,0,0]
|
FluRectangle{
|
||||||
}
|
width: 50
|
||||||
FluRectangle{
|
height: 50
|
||||||
width: 50
|
color:"#e71123"
|
||||||
height: 50
|
radius:[0,0,15,0]
|
||||||
color:"#f7630c"
|
}
|
||||||
radius:[0,15,0,0]
|
FluRectangle{
|
||||||
}
|
width: 50
|
||||||
FluRectangle{
|
height: 50
|
||||||
width: 50
|
color:"#b4009e"
|
||||||
height: 50
|
radius:[0,0,0,15]
|
||||||
color:"#e71123"
|
}
|
||||||
radius:[0,0,15,0]
|
FluRectangle{
|
||||||
}
|
width: 50
|
||||||
FluRectangle{
|
height: 50
|
||||||
width: 50
|
color:"#a8d5ba"
|
||||||
height: 50
|
radius:[15,15,15,15]
|
||||||
color:"#b4009e"
|
borderWidth: 3
|
||||||
radius:[0,0,0,15]
|
borderColor: "#5b8a72"
|
||||||
}
|
}
|
||||||
FluRectangle{
|
FluRectangle{
|
||||||
width: 50
|
width: 50
|
||||||
height: 50
|
height: 50
|
||||||
color:"#a8d5ba"
|
color:"#dbe2ef"
|
||||||
radius:[15,15,15,15]
|
radius:[15,0,0,0]
|
||||||
borderWidth: 3
|
borderWidth: 2
|
||||||
borderColor: "#5b8a72"
|
borderColor: "#3f72af"
|
||||||
}
|
}
|
||||||
FluRectangle{
|
FluRectangle{
|
||||||
width: 50
|
width: 50
|
||||||
height: 50
|
height: 50
|
||||||
color:"#dbe2ef"
|
color:"#dbe2ef"
|
||||||
radius:[15,0,0,0]
|
borderWidth: 2
|
||||||
borderWidth: 2
|
borderColor: "#3f72af"
|
||||||
borderColor: "#3f72af"
|
borderStyle: Qt.DashLine
|
||||||
}
|
dashPattern: [4,2]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,6 +86,8 @@ FluScrollablePage{
|
|||||||
radius: [25,25,25,25]
|
radius: [25,25,25,25]
|
||||||
borderWidth: 2
|
borderWidth: 2
|
||||||
borderColor: "#000000"
|
borderColor: "#000000"
|
||||||
|
borderStyle: Qt.DashLine
|
||||||
|
dashPattern: [4,2]
|
||||||
width: 50
|
width: 50
|
||||||
height: 50
|
height: 50
|
||||||
}'
|
}'
|
||||||
|
@ -19,6 +19,9 @@ FluWindow {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
window.stayTop = true
|
window.stayTop = true
|
||||||
}
|
}
|
||||||
|
Component.onDestruction: {
|
||||||
|
FluRouter.exit()
|
||||||
|
}
|
||||||
|
|
||||||
onInitArgument:
|
onInitArgument:
|
||||||
(argument)=>{
|
(argument)=>{
|
||||||
|
@ -6,10 +6,14 @@ FluRectangle::FluRectangle(QQuickItem *parent) : QQuickPaintedItem(parent) {
|
|||||||
radius({0, 0, 0, 0});
|
radius({0, 0, 0, 0});
|
||||||
borderWidth(0);
|
borderWidth(0);
|
||||||
borderColor(Qt::black);
|
borderColor(Qt::black);
|
||||||
|
borderStyle(Qt::SolidLine);
|
||||||
|
dashPattern({});
|
||||||
connect(this, &FluRectangle::colorChanged, this, [=] { update(); });
|
connect(this, &FluRectangle::colorChanged, this, [=] { update(); });
|
||||||
connect(this, &FluRectangle::radiusChanged, this, [=] { update(); });
|
connect(this, &FluRectangle::radiusChanged, this, [=] { update(); });
|
||||||
connect(this, &FluRectangle::borderWidthChanged, this, [=] { update(); });
|
connect(this, &FluRectangle::borderWidthChanged, this, [=] { update(); });
|
||||||
connect(this, &FluRectangle::borderColorChanged, this, [=] { update(); });
|
connect(this, &FluRectangle::borderColorChanged, this, [=] { update(); });
|
||||||
|
connect(this, &FluRectangle::borderStyleChanged, this, [=] { update(); });
|
||||||
|
connect(this, &FluRectangle::dashPatternChanged, this, [=] { update(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FluRectangle::borderValid() const {
|
bool FluRectangle::borderValid() const {
|
||||||
@ -21,8 +25,8 @@ void FluRectangle::paint(QPainter *painter) {
|
|||||||
painter->setRenderHint(QPainter::Antialiasing);
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
QRectF rect = boundingRect();
|
QRectF rect = boundingRect();
|
||||||
bool valid = borderValid();
|
bool drawBorder = borderValid();
|
||||||
if (valid) {
|
if (drawBorder) {
|
||||||
// 绘制边框时画笔的宽度从路径向两侧扩充
|
// 绘制边框时画笔的宽度从路径向两侧扩充
|
||||||
// 因此实际绘制的矩形应向内侧收缩边框宽度的一半,避免边框裁剪导致不完整
|
// 因此实际绘制的矩形应向内侧收缩边框宽度的一半,避免边框裁剪导致不完整
|
||||||
qreal halfBorderWidth = _borderWidth / 2.0;
|
qreal halfBorderWidth = _borderWidth / 2.0;
|
||||||
@ -54,8 +58,12 @@ void FluRectangle::paint(QPainter *painter) {
|
|||||||
painter->fillPath(path, _color);
|
painter->fillPath(path, _color);
|
||||||
|
|
||||||
// 绘制边框
|
// 绘制边框
|
||||||
if (valid) {
|
if (drawBorder) {
|
||||||
painter->strokePath(path, QPen(_borderColor, _borderWidth));
|
QPen pen(_borderColor, _borderWidth, _borderStyle);
|
||||||
|
if (_borderStyle == Qt::DashLine || _borderStyle == Qt::CustomDashLine) {
|
||||||
|
pen.setDashPattern(_dashPattern);
|
||||||
|
}
|
||||||
|
painter->strokePath(path, pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
|
@ -14,6 +14,8 @@ class FluRectangle : public QQuickPaintedItem {
|
|||||||
Q_PROPERTY_AUTO(QList<int>, radius)
|
Q_PROPERTY_AUTO(QList<int>, radius)
|
||||||
Q_PROPERTY_AUTO(qreal, borderWidth)
|
Q_PROPERTY_AUTO(qreal, borderWidth)
|
||||||
Q_PROPERTY_AUTO(QColor, borderColor)
|
Q_PROPERTY_AUTO(QColor, borderColor)
|
||||||
|
Q_PROPERTY_AUTO(Qt::PenStyle, borderStyle)
|
||||||
|
Q_PROPERTY_AUTO(QVector<qreal>, dashPattern)
|
||||||
QML_NAMED_ELEMENT(FluRectangle)
|
QML_NAMED_ELEMENT(FluRectangle)
|
||||||
public:
|
public:
|
||||||
explicit FluRectangle(QQuickItem *parent = nullptr);
|
explicit FluRectangle(QQuickItem *parent = nullptr);
|
||||||
|
@ -233,6 +233,8 @@ Module {
|
|||||||
Property { name: "radius"; type: "QList<int>" }
|
Property { name: "radius"; type: "QList<int>" }
|
||||||
Property { name: "borderWidth"; type: "double" }
|
Property { name: "borderWidth"; type: "double" }
|
||||||
Property { name: "borderColor"; type: "QColor" }
|
Property { name: "borderColor"; type: "QColor" }
|
||||||
|
Property { name: "borderStyle"; type: "Qt::PenStyle" }
|
||||||
|
Property { name: "dashPattern"; type: "QVector<qreal>" }
|
||||||
}
|
}
|
||||||
Component {
|
Component {
|
||||||
name: "FluSheetType"
|
name: "FluSheetType"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user