diff --git a/example/qml/page/T_QRCode.qml b/example/qml/page/T_QRCode.qml index f7a89401..24f60f20 100644 --- a/example/qml/page/T_QRCode.qml +++ b/example/qml/page/T_QRCode.qml @@ -16,6 +16,8 @@ FluScrollablePage{ size:slider_size.value text:text_box.text color:color_picker.colorValue + bgColor: bgcolor_picker.colorValue + margins:slider_margins.value Layout.preferredWidth: size Layout.preferredHeight: size } @@ -48,6 +50,35 @@ FluScrollablePage{ } } + RowLayout{ + spacing: 10 + Layout.topMargin: 10 + FluText{ + text:"bgColor:" + Layout.alignment: Qt.AlignVCenter + } + FluColorPicker{ + id:bgcolor_picker + Component.onCompleted: { + setColor(Qt.rgba(1,1,1,1)) + } + } + } + + RowLayout{ + spacing: 10 + FluText{ + text:"margins:" + Layout.alignment: Qt.AlignVCenter + } + FluSlider{ + id:slider_margins + from:0 + to:80 + value: 0 + } + } + RowLayout{ spacing: 10 FluText{ @@ -56,7 +87,7 @@ FluScrollablePage{ } FluSlider{ id:slider_size - from:60 + from:120 to:260 value: 120 } diff --git a/example/qml/page/T_Timeline.qml b/example/qml/page/T_Timeline.qml index 9dda8c10..a313039d 100644 --- a/example/qml/page/T_Timeline.qml +++ b/example/qml/page/T_Timeline.qml @@ -16,7 +16,7 @@ FluScrollablePage{ height: 16 radius: 8 border.width: 4 - border.color: FluColors.Red.dark + border.color: FluTheme.dark ? FluColors.Teal.lighter : FluColors.Teal.dark } } @@ -24,9 +24,10 @@ FluScrollablePage{ id:com_lable FluText{ wrapMode: Text.WrapAnywhere + font.bold: true horizontalAlignment: isRight ? Qt.AlignRight : Qt.AlignLeft text: modelData.lable - color: FluTheme.primaryColor.dark + color: FluTheme.dark ? FluColors.Teal.lighter : FluColors.Teal.dark MouseArea{ anchors.fill: parent cursorShape: Qt.PointingHandCursor @@ -44,13 +45,19 @@ FluScrollablePage{ horizontalAlignment: isRight ? Qt.AlignRight : Qt.AlignLeft text: modelData.text font.bold: true - MouseArea{ - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - onClicked: { - showSuccess(modelData.text) + linkColor: FluTheme.dark ? FluColors.Teal.lighter : FluColors.Teal.dark + onLinkActivated: + (link)=> { + Qt.openUrlExternally(link) + } + onLinkHovered: + (link)=> { + if(link === ""){ + FluTools.restoreOverrideCursor() + }else{ + FluTools.setOverrideCursor(Qt.PointingHandCursor) + } } - } } } @@ -58,8 +65,6 @@ FluScrollablePage{ id:list_model ListElement{ lable:"2013-09-01" - lableDelegate:()=>com_lable - textDelegate:()=>com_text text:"考上家里蹲大学" } ListElement{ @@ -69,7 +74,6 @@ FluScrollablePage{ ListElement{ lable:"2017-09-01" text:"开始找工作,毕业即失业!回农村老家躺平,继承三亩良田!!" - dot:()=>com_dot } ListElement{ lable:"2018-02-01" @@ -91,6 +95,13 @@ FluScrollablePage{ lable:"2023-02-28" text:"开发FluentUI组件库" } + ListElement{ + lable:"2023-03-28" + text:'将FluentUI源码开源到github,并发布视频到B站' + lableDelegate:()=>com_lable + textDelegate:()=>com_text + dot:()=>com_dot + } } RowLayout{ @@ -150,6 +161,8 @@ FluScrollablePage{ FluTimeline{ id:time_line Layout.fillWidth: true + Layout.topMargin: 20 + Layout.bottomMargin: 20 mode: FluTimelineType.Alternate model:list_model } diff --git a/src/FluQRCode.cpp b/src/QRCode.cpp similarity index 70% rename from src/FluQRCode.cpp rename to src/QRCode.cpp index ef0ccbf7..8790e3d1 100644 --- a/src/FluQRCode.cpp +++ b/src/QRCode.cpp @@ -1,4 +1,4 @@ -#include "FluQRCode.h" +#include "QRCode.h" #include "BarcodeFormat.h" #include "BitMatrix.h" @@ -6,15 +6,17 @@ using namespace ZXing; -FluQRCode::FluQRCode(QQuickItem* parent) : QQuickPaintedItem(parent) +QRCode::QRCode(QQuickItem* parent) : QQuickPaintedItem(parent) { color(QColor(0,0,0,255)); + bgColor(QColor(255,255,255,255)); size(100); setWidth(_size); setHeight(_size); - connect(this,&FluQRCode::textChanged,this,[=]{update();}); - connect(this,&FluQRCode::colorChanged,this,[=]{update();}); - connect(this,&FluQRCode::sizeChanged,this,[=]{ + connect(this,&QRCode::textChanged,this,[=]{update();}); + connect(this,&QRCode::colorChanged,this,[=]{update();}); + connect(this,&QRCode::bgColorChanged,this,[=]{update();}); + connect(this,&QRCode::sizeChanged,this,[=]{ setWidth(_size); setHeight(_size); update(); @@ -22,7 +24,7 @@ FluQRCode::FluQRCode(QQuickItem* parent) : QQuickPaintedItem(parent) } -void FluQRCode::paint(QPainter* painter) +void QRCode::paint(QPainter* painter) { if(_text.isEmpty()){ return; @@ -31,7 +33,6 @@ void FluQRCode::paint(QPainter* painter) return; } painter->save(); - painter->eraseRect(boundingRect()); auto format = ZXing::BarcodeFormatFromString("QRCode"); auto writer = MultiFormatWriter(format); writer.setMargin(0); @@ -46,6 +47,9 @@ void FluQRCode::paint(QPainter* painter) if (qRed(pixel) == 0 && qGreen(pixel) == 0 && qBlue(pixel) == 0) { rgbImage.setPixelColor(x, y, _color); } + if (qRed(pixel) == 255 && qGreen(pixel) == 255 && qBlue(pixel) == 255) { + rgbImage.setPixelColor(x, y, _bgColor); + } } } painter->drawImage(QRect(0, 0, static_cast(width()), static_cast(height())), rgbImage); diff --git a/src/FluQRCode.h b/src/QRCode.h similarity index 55% rename from src/FluQRCode.h rename to src/QRCode.h index f36c37c4..ea9789da 100644 --- a/src/FluQRCode.h +++ b/src/QRCode.h @@ -1,22 +1,23 @@ -#ifndef FLUQRCODE_H -#define FLUQRCODE_H +#ifndef QRCODE_H +#define QRCODE_H #include #include #include #include "stdafx.h" -class FluQRCode : public QQuickPaintedItem +class QRCode : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY_AUTO(QString,text) Q_PROPERTY_AUTO(QColor,color) + Q_PROPERTY_AUTO(QColor,bgColor) Q_PROPERTY_AUTO(int,size); - QML_NAMED_ELEMENT(FluQRCode) + QML_NAMED_ELEMENT(QRCode) public: - explicit FluQRCode(QQuickItem *parent = nullptr); + explicit QRCode(QQuickItem *parent = nullptr); void paint(QPainter* painter) override; }; -#endif // FLUQRCODE_H +#endif // QRCODE_H diff --git a/src/imports/FluentUI/Controls/FluQRCode.qml b/src/imports/FluentUI/Controls/FluQRCode.qml new file mode 100644 index 00000000..60bfcc77 --- /dev/null +++ b/src/imports/FluentUI/Controls/FluQRCode.qml @@ -0,0 +1,23 @@ +import QtQuick +import QtQuick.Controls +import FluentUI + +Item{ + property alias text: qrcode.text + property alias color: qrcode.color + property alias bgColor: qrcode.bgColor + property int size: 50 + property int margins: 0 + id:control + width: size + height: size + Rectangle{ + color: bgColor + anchors.fill: parent + } + QRCode{ + id:qrcode + size:control.size-margins + anchors.centerIn: parent + } +} diff --git a/src/imports/FluentUI/Controls/FluTimeline.qml b/src/imports/FluentUI/Controls/FluTimeline.qml index 298ae8f1..a12282ff 100644 --- a/src/imports/FluentUI/Controls/FluTimeline.qml +++ b/src/imports/FluentUI/Controls/FluTimeline.qml @@ -92,7 +92,7 @@ Item{ wrapMode: Text.WrapAnywhere horizontalAlignment: isRight ? Qt.AlignRight : Qt.AlignLeft text: modelData.lable - color: FluTheme.primaryColor.dark + color: FluTheme.dark ? FluTheme.primaryColor.lighter : FluTheme.primaryColor.dark } } @@ -286,10 +286,7 @@ Item{ } } ] - } - - } } } diff --git a/src/imports/FluentUI/qmldir b/src/imports/FluentUI/qmldir index 91c3a2c3..70f7e096 100644 --- a/src/imports/FluentUI/qmldir +++ b/src/imports/FluentUI/qmldir @@ -83,4 +83,5 @@ FluTreeView 1.0 Controls/FluTreeView.qml FluWindow 1.0 Controls/FluWindow.qml FluTimeline 1.0 Controls/FluTimeline.qml FluChart 1.0 Controls/FluChart.qml +FluQRCode 1.0 Controls/FluQRCode.qml plugin fluentuiplugin