This commit is contained in:
朱子楚\zhuzi 2024-04-04 01:10:14 +08:00
parent ef96618151
commit fe08b08c1f
24 changed files with 53 additions and 47 deletions

View File

@ -71,7 +71,7 @@ FluScrollablePage{
anchors.centerIn: parent anchors.centerIn: parent
text: "Acrylic" text: "Acrylic"
color: "#FFFFFF" color: "#FFFFFF"
font.bold: true font: FluTextStyle.Subtitle
} }
MouseArea { MouseArea {
property point clickPos: Qt.point(0,0) property point clickPos: Qt.point(0,0)

View File

@ -58,6 +58,7 @@ FluContentPage {
FluText { FluText {
id:item_name id:item_name
font.pixelSize: 10 font.pixelSize: 10
font.family: FluTextStyle.family
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.top: item_icon.bottom anchors.top: item_icon.bottom
width:parent.width width:parent.width

View File

@ -103,7 +103,6 @@ FluScrollablePage{
horizontalAlignment: Qt.AlignHCenter horizontalAlignment: Qt.AlignHCenter
text:model.title text:model.title
color: FluColors.Grey10 color: FluColors.Grey10
font.pixelSize: 15
} }
} }
} }

View File

@ -122,6 +122,7 @@ FluScrollablePage{
Layout.leftMargin: 20 Layout.leftMargin: 20
color: FluColors.Grey120 color: FluColors.Grey120
font.pixelSize: 12 font.pixelSize: 12
font.family: FluTextStyle.family
wrapMode: Text.WrapAnywhere wrapMode: Text.WrapAnywhere
} }
} }

View File

@ -42,8 +42,7 @@ FluContentPage{
FluText{ FluText{
color:"#FFFFFF" color:"#FFFFFF"
text:model.index text:model.index
font.bold: true font: FluTextStyle.Title
font.pixelSize: 18
anchors.centerIn: parent anchors.centerIn: parent
} }
} }

View File

@ -41,7 +41,7 @@ FluWindow {
} }
FluText{ FluText{
text: qsTr("Drag in a qml file") text: qsTr("Drag in a qml file")
font.pixelSize: 26 font: FluTextStyle.Title
anchors.centerIn: parent anchors.centerIn: parent
visible: !loader.itemLodaer().item && loader.statusMode === FluStatusLayoutType.Success visible: !loader.itemLodaer().item && loader.statusMode === FluStatusLayoutType.Success
} }

View File

@ -101,7 +101,7 @@ FluWindow {
width: 186 width: 186
FluMenuItem{ FluMenuItem{
text: qsTr("Open in Separate Window") text: qsTr("Open in Separate Window")
font.pixelSize: 12 font: FluTextStyle.Caption
onClicked: { onClicked: {
FluRouter.navigate("/pageWindow",{title:modelData.title,url:modelData.url}) FluRouter.navigate("/pageWindow",{title:modelData.title,url:modelData.url})
} }

View File

@ -76,7 +76,7 @@ void FluFrameless::componentComplete(){
HWND hwnd = reinterpret_cast<HWND>(window()->winId()); HWND hwnd = reinterpret_cast<HWND>(window()->winId());
DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE); DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
if(_fixSize){ if(_fixSize){
::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME); ::SetWindowLongPtr(hwnd, GWL_STYLE, style | WS_THICKFRAME | WS_CAPTION);
for (int i = 0; i < qApp->screens().count(); ++i) { for (int i = 0; i < qApp->screens().count(); ++i) {
connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{ connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{
SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED); SetWindowPos(hwnd,nullptr,0,0,0,0,SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_FRAMECHANGED);
@ -228,12 +228,6 @@ bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message,
return true; return true;
}else if(uMsg == WM_GETMINMAXINFO){ }else if(uMsg == WM_GETMINMAXINFO){
MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam); MINMAXINFO* minmaxInfo = reinterpret_cast<MINMAXINFO *>(lParam);
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
minmaxInfo->ptMaxPosition.x = 0;
minmaxInfo->ptMaxPosition.y = 0;
minmaxInfo->ptMaxSize.x = 0;
minmaxInfo->ptMaxSize.y = 0;
#else
auto pixelRatio = window()->devicePixelRatio(); auto pixelRatio = window()->devicePixelRatio();
auto geometry = window()->screen()->availableGeometry(); auto geometry = window()->screen()->availableGeometry();
RECT rect; RECT rect;
@ -242,7 +236,6 @@ bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message,
minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x(); minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x();
minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2; minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2;
minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2; minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2;
#endif
return false; return false;
}else if(uMsg == WM_NCRBUTTONDOWN){ }else if(uMsg == WM_NCRBUTTONDOWN){
if (wParam == HTCAPTION) { if (wParam == HTCAPTION) {

View File

@ -1,35 +1,47 @@
#include "FluTextStyle.h" #include "FluTextStyle.h"
FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{ FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{
_family = QFont().defaultFamily();
#ifdef Q_OS_WIN
_family = "微软雅黑";
#endif
QFont caption; QFont caption;
caption.setFamily(_family);
caption.setPixelSize(12); caption.setPixelSize(12);
Caption(caption); Caption(caption);
QFont body; QFont body;
body.setFamily(_family);
body.setPixelSize(13); body.setPixelSize(13);
Body(body); Body(body);
QFont bodyStrong; QFont bodyStrong;
bodyStrong.setFamily(_family);
bodyStrong.setPixelSize(13); bodyStrong.setPixelSize(13);
bodyStrong.setWeight(QFont::DemiBold); bodyStrong.setWeight(QFont::DemiBold);
BodyStrong(bodyStrong); BodyStrong(bodyStrong);
QFont subtitle; QFont subtitle;
subtitle.setFamily(_family);
subtitle.setPixelSize(20); subtitle.setPixelSize(20);
subtitle.setWeight(QFont::DemiBold); subtitle.setWeight(QFont::DemiBold);
Subtitle(subtitle); Subtitle(subtitle);
QFont title; QFont title;
title.setFamily(_family);
title.setPixelSize(28); title.setPixelSize(28);
title.setWeight(QFont::DemiBold); title.setWeight(QFont::DemiBold);
Title(title); Title(title);
QFont titleLarge; QFont titleLarge;
titleLarge.setFamily(_family);
titleLarge.setPixelSize(40); titleLarge.setPixelSize(40);
titleLarge.setWeight(QFont::DemiBold); titleLarge.setWeight(QFont::DemiBold);
TitleLarge(titleLarge); TitleLarge(titleLarge);
QFont display; QFont display;
display.setFamily(_family);
display.setPixelSize(68); display.setPixelSize(68);
display.setWeight(QFont::DemiBold); display.setWeight(QFont::DemiBold);
Display(display); Display(display);

View File

@ -14,6 +14,7 @@ class FluTextStyle : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
Q_PROPERTY_AUTO(QString,family)
Q_PROPERTY_AUTO(QFont,Caption); Q_PROPERTY_AUTO(QFont,Caption);
Q_PROPERTY_AUTO(QFont,Body); Q_PROPERTY_AUTO(QFont,Body);
Q_PROPERTY_AUTO(QFont,BodyStrong); Q_PROPERTY_AUTO(QFont,BodyStrong);

View File

@ -149,11 +149,6 @@ void FluentUI::registerTypes(const char *uri){
} }
void FluentUI::initializeEngine(QQmlEngine *engine, const char *uri){ void FluentUI::initializeEngine(QQmlEngine *engine, const char *uri){
#ifdef Q_OS_WIN
QFont font;
font.setFamily("微软雅黑");
QGuiApplication::setFont(font);
#endif
engine->rootContext()->setContextProperty("FluApp",FluApp::getInstance()); engine->rootContext()->setContextProperty("FluApp",FluApp::getInstance());
engine->rootContext()->setContextProperty("FluColors",FluColors::getInstance()); engine->rootContext()->setContextProperty("FluColors",FluColors::getInstance());
engine->rootContext()->setContextProperty("FluTheme",FluTheme::getInstance()); engine->rootContext()->setContextProperty("FluTheme",FluTheme::getInstance());

View File

@ -449,7 +449,7 @@ FluButton {
DayOfWeekRow { DayOfWeekRow {
id: dayOfWeekRow id: dayOfWeekRow
locale: FluApp.locale locale: FluApp.locale
font.bold: false font: FluTextStyle.Body
delegate: Label { delegate: Label {
text: model.shortName text: model.shortName
font: dayOfWeekRow.font font: dayOfWeekRow.font

View File

@ -68,7 +68,12 @@ T.ComboBox {
rightInset:1 rightInset:1
background: FluTextBoxBackground{ background: FluTextBoxBackground{
border.width: 0 border.width: 0
bottomMargin: 0 bottomMargin: {
if(!control.editable){
return 0
}
return contentItem && contentItem.activeFocus ? 2 : 1
}
inputItem: contentItem inputItem: contentItem
} }
Component.onCompleted: { Component.onCompleted: {

View File

@ -42,7 +42,7 @@ FluButton {
id:divider_1 id:divider_1
width: 1 width: 1
x: parent.width/3 x: parent.width/3
height: parent.height height: parent.height - 1
color: control.dividerColor color: control.dividerColor
visible: showYear visible: showYear
} }
@ -50,7 +50,7 @@ FluButton {
id:divider_2 id:divider_2
width: 1 width: 1
x: showYear ? parent.width*2/3 : parent.width/2 x: showYear ? parent.width*2/3 : parent.width/2
height: parent.height height: parent.height - 1
color: control.dividerColor color: control.dividerColor
} }
FluText{ FluText{

View File

@ -7,19 +7,18 @@ Page {
property alias currentIndex: nav_list.currentIndex property alias currentIndex: nav_list.currentIndex
property color textNormalColor: FluTheme.dark ? FluColors.Grey120 : FluColors.Grey120 property color textNormalColor: FluTheme.dark ? FluColors.Grey120 : FluColors.Grey120
property color textHoverColor: FluTheme.dark ? FluColors.Grey10 : FluColors.Black property color textHoverColor: FluTheme.dark ? FluColors.Grey10 : FluColors.Black
property int textSize: 28
property bool textBold: true
property int textSpacing: 10 property int textSpacing: 10
property int headerSpacing: 20 property int headerSpacing: 20
property int headerHeight: 40 property int headerHeight: 40
id:control id:control
width: 400 width: 400
height: 300 height: 300
font: FluTextStyle.Title
implicitHeight: height implicitHeight: height
implicitWidth: width implicitWidth: width
FluObject{ FluObject{
id:d id:d
property int tabY: control.headerHeight/2+control.textSize/2 + 3 property int tabY: control.headerHeight/2+control.font.pixelSize/2 + 3
} }
background:Item{} background:Item{}
header:ListView{ header:ListView{
@ -65,8 +64,7 @@ Page {
id:item_title id:item_title
text: modelData.title text: modelData.title
anchors.centerIn: parent anchors.centerIn: parent
font.pixelSize: control.textSize font: control.font
font.bold: control.textBold
color: { color: {
if(item_button.hovered) if(item_button.hovered)
return textHoverColor return textHoverColor

View File

@ -131,10 +131,9 @@ FluIconButton {
width: Math.max(item_text.implicitWidth+12,28) width: Math.max(item_text.implicitWidth+12,28)
height: Math.max(item_text.implicitHeight,28) height: Math.max(item_text.implicitHeight,28)
radius: 4 radius: 4
Text{ FluText{
id:item_text id:item_text
color: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1) color: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
font.pixelSize: 13
text: keyText text: keyText
anchors.centerIn: parent anchors.centerIn: parent
} }

View File

@ -58,14 +58,14 @@ FluButton {
id: divider_1 id: divider_1
width: 1 width: 1
x: isH ? parent.width/3 : parent.width/2 x: isH ? parent.width/3 : parent.width/2
height: parent.height height: parent.height - 1
color: dividerColor color: dividerColor
} }
Rectangle{ Rectangle{
id: divider_2 id: divider_2
width: 1 width: 1
x: parent.width*2/3 x: parent.width*2/3
height: parent.height height: parent.height - 1
color: dividerColor color: dividerColor
visible: isH visible: isH
} }

View File

@ -448,7 +448,7 @@ FluButton {
DayOfWeekRow { DayOfWeekRow {
id: dayOfWeekRow id: dayOfWeekRow
locale: FluApp.locale locale: FluApp.locale
font.bold: false font: FluTextStyle.Body
delegate: Label { delegate: Label {
text: model.shortName text: model.shortName
font: dayOfWeekRow.font font: dayOfWeekRow.font

View File

@ -68,7 +68,12 @@ T.ComboBox {
rightInset:1 rightInset:1
background: FluTextBoxBackground{ background: FluTextBoxBackground{
border.width: 0 border.width: 0
bottomMargin: 0 bottomMargin: {
if(!control.editable){
return 0
}
return contentItem && contentItem.activeFocus ? 2 : 1
}
inputItem: contentItem inputItem: contentItem
} }
Component.onCompleted: { Component.onCompleted: {

View File

@ -41,7 +41,7 @@ FluButton {
id:divider_1 id:divider_1
width: 1 width: 1
x: parent.width/3 x: parent.width/3
height: parent.height height: parent.height-1
color: control.dividerColor color: control.dividerColor
visible: showYear visible: showYear
} }
@ -49,7 +49,7 @@ FluButton {
id:divider_2 id:divider_2
width: 1 width: 1
x: showYear ? parent.width*2/3 : parent.width/2 x: showYear ? parent.width*2/3 : parent.width/2
height: parent.height height: parent.height-1
color: control.dividerColor color: control.dividerColor
} }
FluText{ FluText{

View File

@ -8,19 +8,18 @@ Page {
property alias currentIndex: nav_list.currentIndex property alias currentIndex: nav_list.currentIndex
property color textNormalColor: FluTheme.dark ? FluColors.Grey120 : FluColors.Grey120 property color textNormalColor: FluTheme.dark ? FluColors.Grey120 : FluColors.Grey120
property color textHoverColor: FluTheme.dark ? FluColors.Grey10 : FluColors.Black property color textHoverColor: FluTheme.dark ? FluColors.Grey10 : FluColors.Black
property int textSize: 28
property bool textBold: true
property int textSpacing: 10 property int textSpacing: 10
property int headerSpacing: 20 property int headerSpacing: 20
property int headerHeight: 40 property int headerHeight: 40
id:control id:control
width: 400 width: 400
height: 300 height: 300
font: FluTextStyle.Title
implicitHeight: height implicitHeight: height
implicitWidth: width implicitWidth: width
FluObject{ FluObject{
id:d id:d
property int tabY: control.headerHeight/2+control.textSize/2 + 3 property int tabY: control.headerHeight/2+control.font.pixelSize/2 + 3
} }
background:Item{} background:Item{}
header:ListView{ header:ListView{
@ -66,10 +65,9 @@ Page {
id:item_title id:item_title
text: modelData.title text: modelData.title
anchors.centerIn: parent anchors.centerIn: parent
font.pixelSize: control.textSize font: control.font
font.bold: control.textBold
color: { color: {
if(item_button.hovered || nav_list.currentIndex === index) if(item_button.hovered)
return textHoverColor return textHoverColor
return textNormalColor return textNormalColor
} }

View File

@ -131,10 +131,9 @@ FluIconButton {
width: Math.max(item_text.implicitWidth+12,28) width: Math.max(item_text.implicitWidth+12,28)
height: Math.max(item_text.implicitHeight,28) height: Math.max(item_text.implicitHeight,28)
radius: 4 radius: 4
Text{ FluText{
id:item_text id:item_text
color: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1) color: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1)
font.pixelSize: 13
text: keyText text: keyText
anchors.centerIn: parent anchors.centerIn: parent
} }

View File

@ -20,12 +20,13 @@ FluControlBackground{
border.width: 1 border.width: 1
gradient: Gradient { gradient: Gradient {
GradientStop { position: 0.0; color: d.startColor } GradientStop { position: 0.0; color: d.startColor }
GradientStop { position: 0.92; color: d.startColor } GradientStop { position: d.position; color: d.startColor }
GradientStop { position: 1.0; color: d.endColor } GradientStop { position: 1.0; color: d.endColor }
} }
bottomMargin: inputItem && inputItem.activeFocus ? 2 : 1 bottomMargin: inputItem && inputItem.activeFocus ? 2 : 1
QtObject{ QtObject{
id:d id:d
property real position: 1 - 3/control.height
property color startColor: FluTheme.dark ? Qt.rgba(66/255,66/255,66/255,1) : Qt.rgba(232/255,232/255,232/255,1) property color startColor: FluTheme.dark ? Qt.rgba(66/255,66/255,66/255,1) : Qt.rgba(232/255,232/255,232/255,1)
property color endColor: { property color endColor: {
if(!control.enabled){ if(!control.enabled){

View File

@ -58,14 +58,14 @@ FluButton {
id: divider_1 id: divider_1
width: 1 width: 1
x: isH ? parent.width/3 : parent.width/2 x: isH ? parent.width/3 : parent.width/2
height: parent.height height: parent.height-1
color: dividerColor color: dividerColor
} }
Rectangle{ Rectangle{
id: divider_2 id: divider_2
width: 1 width: 1
x: parent.width*2/3 x: parent.width*2/3
height: parent.height height: parent.height-1
color: dividerColor color: dividerColor
visible: isH visible: isH
} }