This commit is contained in:
zhuzichu 2023-08-14 18:10:37 +08:00
parent 7fe71c892b
commit 0b6491e730
7 changed files with 99 additions and 29 deletions

View File

@ -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
}

View File

@ -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,11 +45,17 @@ 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源码开源到<a href="https://github.com/zhuzichu520/FluentUI">github</a>,并发布视频到<a href="https://www.bilibili.com/video/BV1mg4y1M71w">B站</a>'
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
}

View File

@ -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<int>(width()), static_cast<int>(height())), rgbImage);

View File

@ -1,22 +1,23 @@
#ifndef FLUQRCODE_H
#define FLUQRCODE_H
#ifndef QRCODE_H
#define QRCODE_H
#include <QQuickItem>
#include <QQuickPaintedItem>
#include <QPainter>
#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

View File

@ -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
}
}

View File

@ -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{
}
}
]
}
}
}
}

View File

@ -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