diff --git a/example/qml/page/T_Acrylic.qml b/example/qml/page/T_Acrylic.qml index baf638c3..441c37f1 100644 --- a/example/qml/page/T_Acrylic.qml +++ b/example/qml/page/T_Acrylic.qml @@ -71,7 +71,7 @@ FluScrollablePage{ anchors.centerIn: parent text: "Acrylic" color: "#FFFFFF" - font.bold: true + font: FluTextStyle.Subtitle } MouseArea { property point clickPos: Qt.point(0,0) diff --git a/example/qml/page/T_Awesome.qml b/example/qml/page/T_Awesome.qml index ef192196..5f304426 100644 --- a/example/qml/page/T_Awesome.qml +++ b/example/qml/page/T_Awesome.qml @@ -58,6 +58,7 @@ FluContentPage { FluText { id:item_name font.pixelSize: 10 + font.family: FluTextStyle.family anchors.horizontalCenter: parent.horizontalCenter anchors.top: item_icon.bottom width:parent.width diff --git a/example/qml/page/T_Carousel.qml b/example/qml/page/T_Carousel.qml index 72e2d471..4d65ff2b 100644 --- a/example/qml/page/T_Carousel.qml +++ b/example/qml/page/T_Carousel.qml @@ -103,7 +103,6 @@ FluScrollablePage{ horizontalAlignment: Qt.AlignHCenter text:model.title color: FluColors.Grey10 - font.pixelSize: 15 } } } diff --git a/example/qml/page/T_Home.qml b/example/qml/page/T_Home.qml index 14738a7d..f291e8e7 100644 --- a/example/qml/page/T_Home.qml +++ b/example/qml/page/T_Home.qml @@ -122,6 +122,7 @@ FluScrollablePage{ Layout.leftMargin: 20 color: FluColors.Grey120 font.pixelSize: 12 + font.family: FluTextStyle.family wrapMode: Text.WrapAnywhere } } diff --git a/example/qml/page/T_StaggeredLayout.qml b/example/qml/page/T_StaggeredLayout.qml index 87470d7a..3569de9e 100644 --- a/example/qml/page/T_StaggeredLayout.qml +++ b/example/qml/page/T_StaggeredLayout.qml @@ -42,8 +42,7 @@ FluContentPage{ FluText{ color:"#FFFFFF" text:model.index - font.bold: true - font.pixelSize: 18 + font: FluTextStyle.Title anchors.centerIn: parent } } diff --git a/example/qml/window/HotloadWindow.qml b/example/qml/window/HotloadWindow.qml index 84ff9977..b6ddd0e3 100644 --- a/example/qml/window/HotloadWindow.qml +++ b/example/qml/window/HotloadWindow.qml @@ -41,7 +41,7 @@ FluWindow { } FluText{ text: qsTr("Drag in a qml file") - font.pixelSize: 26 + font: FluTextStyle.Title anchors.centerIn: parent visible: !loader.itemLodaer().item && loader.statusMode === FluStatusLayoutType.Success } diff --git a/example/qml/window/MainWindow.qml b/example/qml/window/MainWindow.qml index 544affc0..0e393dc8 100644 --- a/example/qml/window/MainWindow.qml +++ b/example/qml/window/MainWindow.qml @@ -101,7 +101,7 @@ FluWindow { width: 186 FluMenuItem{ text: qsTr("Open in Separate Window") - font.pixelSize: 12 + font: FluTextStyle.Caption onClicked: { FluRouter.navigate("/pageWindow",{title:modelData.title,url:modelData.url}) } diff --git a/src/FluFrameless.cpp b/src/FluFrameless.cpp index d8a1dc29..520c3613 100644 --- a/src/FluFrameless.cpp +++ b/src/FluFrameless.cpp @@ -76,7 +76,7 @@ void FluFrameless::componentComplete(){ HWND hwnd = reinterpret_cast(window()->winId()); DWORD style = ::GetWindowLongPtr(hwnd, GWL_STYLE); 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) { connect( qApp->screens().at(i),&QScreen::logicalDotsPerInchChanged,this,[=]{ 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; }else if(uMsg == WM_GETMINMAXINFO){ MINMAXINFO* minmaxInfo = reinterpret_cast(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 geometry = window()->screen()->availableGeometry(); RECT rect; @@ -242,7 +236,6 @@ bool FluFrameless::nativeEventFilter(const QByteArray &eventType, void *message, minmaxInfo->ptMaxPosition.y = rect.top - offsetXY.x(); minmaxInfo->ptMaxSize.x = geometry.width()*pixelRatio + offsetXY.x() * 2; minmaxInfo->ptMaxSize.y = geometry.height()*pixelRatio + offsetXY.y() * 2; -#endif return false; }else if(uMsg == WM_NCRBUTTONDOWN){ if (wParam == HTCAPTION) { diff --git a/src/FluTextStyle.cpp b/src/FluTextStyle.cpp index 7d60d838..7e81de1a 100644 --- a/src/FluTextStyle.cpp +++ b/src/FluTextStyle.cpp @@ -1,35 +1,47 @@ #include "FluTextStyle.h" FluTextStyle::FluTextStyle(QObject *parent):QObject{parent}{ + _family = QFont().defaultFamily(); +#ifdef Q_OS_WIN + _family = "微软雅黑"; +#endif + QFont caption; + caption.setFamily(_family); caption.setPixelSize(12); Caption(caption); QFont body; + body.setFamily(_family); body.setPixelSize(13); Body(body); QFont bodyStrong; + bodyStrong.setFamily(_family); bodyStrong.setPixelSize(13); bodyStrong.setWeight(QFont::DemiBold); BodyStrong(bodyStrong); QFont subtitle; + subtitle.setFamily(_family); subtitle.setPixelSize(20); subtitle.setWeight(QFont::DemiBold); Subtitle(subtitle); QFont title; + title.setFamily(_family); title.setPixelSize(28); title.setWeight(QFont::DemiBold); Title(title); QFont titleLarge; + titleLarge.setFamily(_family); titleLarge.setPixelSize(40); titleLarge.setWeight(QFont::DemiBold); TitleLarge(titleLarge); QFont display; + display.setFamily(_family); display.setPixelSize(68); display.setWeight(QFont::DemiBold); Display(display); diff --git a/src/FluTextStyle.h b/src/FluTextStyle.h index 60736254..8cbabe45 100644 --- a/src/FluTextStyle.h +++ b/src/FluTextStyle.h @@ -14,6 +14,7 @@ class FluTextStyle : public QObject { Q_OBJECT public: + Q_PROPERTY_AUTO(QString,family) Q_PROPERTY_AUTO(QFont,Caption); Q_PROPERTY_AUTO(QFont,Body); Q_PROPERTY_AUTO(QFont,BodyStrong); diff --git a/src/FluentUI.cpp b/src/FluentUI.cpp index adfe36de..ec0f525e 100644 --- a/src/FluentUI.cpp +++ b/src/FluentUI.cpp @@ -149,11 +149,6 @@ void FluentUI::registerTypes(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("FluColors",FluColors::getInstance()); engine->rootContext()->setContextProperty("FluTheme",FluTheme::getInstance()); diff --git a/src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml b/src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml index 91999550..8badce7a 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluCalendarPicker.qml @@ -449,7 +449,7 @@ FluButton { DayOfWeekRow { id: dayOfWeekRow locale: FluApp.locale - font.bold: false + font: FluTextStyle.Body delegate: Label { text: model.shortName font: dayOfWeekRow.font diff --git a/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml b/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml index 6763690a..0cbd9405 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluComboBox.qml @@ -68,7 +68,12 @@ T.ComboBox { rightInset:1 background: FluTextBoxBackground{ border.width: 0 - bottomMargin: 0 + bottomMargin: { + if(!control.editable){ + return 0 + } + return contentItem && contentItem.activeFocus ? 2 : 1 + } inputItem: contentItem } Component.onCompleted: { diff --git a/src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml b/src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml index 51ca5d6b..1f03ae30 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluDatePicker.qml @@ -42,7 +42,7 @@ FluButton { id:divider_1 width: 1 x: parent.width/3 - height: parent.height + height: parent.height - 1 color: control.dividerColor visible: showYear } @@ -50,7 +50,7 @@ FluButton { id:divider_2 width: 1 x: showYear ? parent.width*2/3 : parent.width/2 - height: parent.height + height: parent.height - 1 color: control.dividerColor } FluText{ diff --git a/src/Qt5/imports/FluentUI/Controls/FluPivot.qml b/src/Qt5/imports/FluentUI/Controls/FluPivot.qml index 8fe520bf..866af6b6 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluPivot.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluPivot.qml @@ -7,19 +7,18 @@ Page { property alias currentIndex: nav_list.currentIndex property color textNormalColor: FluTheme.dark ? FluColors.Grey120 : FluColors.Grey120 property color textHoverColor: FluTheme.dark ? FluColors.Grey10 : FluColors.Black - property int textSize: 28 - property bool textBold: true property int textSpacing: 10 property int headerSpacing: 20 property int headerHeight: 40 id:control width: 400 height: 300 + font: FluTextStyle.Title implicitHeight: height implicitWidth: width FluObject{ 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{} header:ListView{ @@ -65,8 +64,7 @@ Page { id:item_title text: modelData.title anchors.centerIn: parent - font.pixelSize: control.textSize - font.bold: control.textBold + font: control.font color: { if(item_button.hovered) return textHoverColor diff --git a/src/Qt5/imports/FluentUI/Controls/FluShortcutPicker.qml b/src/Qt5/imports/FluentUI/Controls/FluShortcutPicker.qml index 98272d75..f3d0aaa0 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluShortcutPicker.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluShortcutPicker.qml @@ -131,10 +131,9 @@ FluIconButton { width: Math.max(item_text.implicitWidth+12,28) height: Math.max(item_text.implicitHeight,28) radius: 4 - Text{ + FluText{ id:item_text color: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1) - font.pixelSize: 13 text: keyText anchors.centerIn: parent } diff --git a/src/Qt5/imports/FluentUI/Controls/FluTimePicker.qml b/src/Qt5/imports/FluentUI/Controls/FluTimePicker.qml index 1edcc3c8..70d79f01 100644 --- a/src/Qt5/imports/FluentUI/Controls/FluTimePicker.qml +++ b/src/Qt5/imports/FluentUI/Controls/FluTimePicker.qml @@ -58,14 +58,14 @@ FluButton { id: divider_1 width: 1 x: isH ? parent.width/3 : parent.width/2 - height: parent.height + height: parent.height - 1 color: dividerColor } Rectangle{ id: divider_2 width: 1 x: parent.width*2/3 - height: parent.height + height: parent.height - 1 color: dividerColor visible: isH } diff --git a/src/Qt6/imports/FluentUI/Controls/FluCalendarPicker.qml b/src/Qt6/imports/FluentUI/Controls/FluCalendarPicker.qml index 15f85925..ab11b054 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluCalendarPicker.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluCalendarPicker.qml @@ -448,7 +448,7 @@ FluButton { DayOfWeekRow { id: dayOfWeekRow locale: FluApp.locale - font.bold: false + font: FluTextStyle.Body delegate: Label { text: model.shortName font: dayOfWeekRow.font diff --git a/src/Qt6/imports/FluentUI/Controls/FluComboBox.qml b/src/Qt6/imports/FluentUI/Controls/FluComboBox.qml index a510b177..7777b2c2 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluComboBox.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluComboBox.qml @@ -68,7 +68,12 @@ T.ComboBox { rightInset:1 background: FluTextBoxBackground{ border.width: 0 - bottomMargin: 0 + bottomMargin: { + if(!control.editable){ + return 0 + } + return contentItem && contentItem.activeFocus ? 2 : 1 + } inputItem: contentItem } Component.onCompleted: { diff --git a/src/Qt6/imports/FluentUI/Controls/FluDatePicker.qml b/src/Qt6/imports/FluentUI/Controls/FluDatePicker.qml index 90adb728..bcd984bc 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluDatePicker.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluDatePicker.qml @@ -41,7 +41,7 @@ FluButton { id:divider_1 width: 1 x: parent.width/3 - height: parent.height + height: parent.height-1 color: control.dividerColor visible: showYear } @@ -49,7 +49,7 @@ FluButton { id:divider_2 width: 1 x: showYear ? parent.width*2/3 : parent.width/2 - height: parent.height + height: parent.height-1 color: control.dividerColor } FluText{ diff --git a/src/Qt6/imports/FluentUI/Controls/FluPivot.qml b/src/Qt6/imports/FluentUI/Controls/FluPivot.qml index 917fd3b2..38a19f04 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluPivot.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluPivot.qml @@ -8,19 +8,18 @@ Page { property alias currentIndex: nav_list.currentIndex property color textNormalColor: FluTheme.dark ? FluColors.Grey120 : FluColors.Grey120 property color textHoverColor: FluTheme.dark ? FluColors.Grey10 : FluColors.Black - property int textSize: 28 - property bool textBold: true property int textSpacing: 10 property int headerSpacing: 20 property int headerHeight: 40 id:control width: 400 height: 300 + font: FluTextStyle.Title implicitHeight: height implicitWidth: width FluObject{ 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{} header:ListView{ @@ -66,10 +65,9 @@ Page { id:item_title text: modelData.title anchors.centerIn: parent - font.pixelSize: control.textSize - font.bold: control.textBold + font: control.font color: { - if(item_button.hovered || nav_list.currentIndex === index) + if(item_button.hovered) return textHoverColor return textNormalColor } diff --git a/src/Qt6/imports/FluentUI/Controls/FluShortcutPicker.qml b/src/Qt6/imports/FluentUI/Controls/FluShortcutPicker.qml index f3a592b8..2dd376f1 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluShortcutPicker.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluShortcutPicker.qml @@ -131,10 +131,9 @@ FluIconButton { width: Math.max(item_text.implicitWidth+12,28) height: Math.max(item_text.implicitHeight,28) radius: 4 - Text{ + FluText{ id:item_text color: FluTheme.dark ? Qt.rgba(0,0,0,1) : Qt.rgba(1,1,1,1) - font.pixelSize: 13 text: keyText anchors.centerIn: parent } diff --git a/src/Qt6/imports/FluentUI/Controls/FluTextBoxBackground.qml b/src/Qt6/imports/FluentUI/Controls/FluTextBoxBackground.qml index 7953fe4d..96bc1c72 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluTextBoxBackground.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluTextBoxBackground.qml @@ -20,12 +20,13 @@ FluControlBackground{ border.width: 1 gradient: Gradient { 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 } } bottomMargin: inputItem && inputItem.activeFocus ? 2 : 1 QtObject{ 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 endColor: { if(!control.enabled){ diff --git a/src/Qt6/imports/FluentUI/Controls/FluTimePicker.qml b/src/Qt6/imports/FluentUI/Controls/FluTimePicker.qml index c54a0cae..e32212b4 100644 --- a/src/Qt6/imports/FluentUI/Controls/FluTimePicker.qml +++ b/src/Qt6/imports/FluentUI/Controls/FluTimePicker.qml @@ -58,14 +58,14 @@ FluButton { id: divider_1 width: 1 x: isH ? parent.width/3 : parent.width/2 - height: parent.height + height: parent.height-1 color: dividerColor } Rectangle{ id: divider_2 width: 1 x: parent.width*2/3 - height: parent.height + height: parent.height-1 color: dividerColor visible: isH }