diff --git a/example/example.qml b/example/example.qml index 2270d1f..1c8c87a 100644 --- a/example/example.qml +++ b/example/example.qml @@ -33,8 +33,10 @@ RibbonWindow { text: qsTr("Vertical/Horizental sliders with/without buttons."), target: slider_layout, enter_func: ()=>{ + tab_bar.setPage(0) slider_with_btn.value = 70 slider_without_btn.value = 70 + tour.refresh(500) }, exit_func: ()=>{ slider_with_btn.value = 50 @@ -555,6 +557,15 @@ RibbonWindow { text: "Test Text (Read Only)" view_only: true } + RibbonSwitchButton{ + text: "Render" + grabber_text: RibbonTheme.nativeText ? "native" : "Qt" + checked: true + Layout.alignment: Qt.AlignHCenter + onClicked: { + RibbonTheme.nativeText = checked + } + } } } } diff --git a/lib_source/qml/RibbonButton.qml b/lib_source/qml/RibbonButton.qml index 5779fce..1c8cec7 100644 --- a/lib_source/qml/RibbonButton.qml +++ b/lib_source/qml/RibbonButton.qml @@ -110,6 +110,7 @@ Button { verticalAlignment: Text.AlignVCenter font.pixelSize: 12 font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering color: { if (!show_bg && (hovered || checked || pressed) && text_color_reverse) return Qt.lighter(text_color) diff --git a/lib_source/qml/RibbonCheckBox.qml b/lib_source/qml/RibbonCheckBox.qml index e063c4e..3de419e 100644 --- a/lib_source/qml/RibbonCheckBox.qml +++ b/lib_source/qml/RibbonCheckBox.qml @@ -82,6 +82,7 @@ Button { pixelSize: control.text_size bold: control.text_bold } + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering color: text_color visible: text } diff --git a/lib_source/qml/RibbonIcon.qml b/lib_source/qml/RibbonIcon.qml index 89a7faf..9a7e4aa 100644 --- a/lib_source/qml/RibbonIcon.qml +++ b/lib_source/qml/RibbonIcon.qml @@ -19,6 +19,7 @@ Text { font.pixelSize: icon_size horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering text: (String.fromCharCode(filled ? icon_source_filled : icon_source).toString(16)) FontLoader{ diff --git a/lib_source/qml/RibbonLineEdit.qml b/lib_source/qml/RibbonLineEdit.qml index 25235e0..3e909f4 100644 --- a/lib_source/qml/RibbonLineEdit.qml +++ b/lib_source/qml/RibbonLineEdit.qml @@ -26,6 +26,7 @@ TextField{ width:150 height:20 onCommit: cursorVisible = false + renderType: RibbonTheme.nativeText ? TextField.NativeRendering : TextField.QtRendering background: Rectangle{ radius: 4 implicitHeight: 20 diff --git a/lib_source/qml/RibbonMenuItem.qml b/lib_source/qml/RibbonMenuItem.qml index 0742b91..8da55fb 100644 --- a/lib_source/qml/RibbonMenuItem.qml +++ b/lib_source/qml/RibbonMenuItem.qml @@ -92,6 +92,7 @@ MenuItem { elide: Text.ElideRight font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" color: text_color + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering Layout.preferredWidth:{ let w = 0 w += rib_icon.visible ? rib_icon.contentWidth : 0 diff --git a/lib_source/qml/RibbonPushButton.qml b/lib_source/qml/RibbonPushButton.qml index 48f7646..5ba9974 100644 --- a/lib_source/qml/RibbonPushButton.qml +++ b/lib_source/qml/RibbonPushButton.qml @@ -120,6 +120,7 @@ Item { verticalAlignment: Text.AlignVCenter font.pixelSize: 12 font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering color: text_color } diff --git a/lib_source/qml/RibbonSwitchButton.qml b/lib_source/qml/RibbonSwitchButton.qml index a528b82..f0e2d78 100644 --- a/lib_source/qml/RibbonSwitchButton.qml +++ b/lib_source/qml/RibbonSwitchButton.qml @@ -128,6 +128,7 @@ Button { text: control.grabber_text anchors.verticalCenter: parent.verticalCenter anchors.margins: 4 + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering visible: control.show_grabber_text x: control.checked ? grabber.x - anchors.margins - contentWidth : grabber.x + grabber.width + anchors.margins z: 0 @@ -192,6 +193,7 @@ Button { id:label text:control.text Layout.alignment: Qt.AlignVCenter + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering font{ family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" pixelSize: control.text_size diff --git a/lib_source/qml/RibbonTabBar.qml b/lib_source/qml/RibbonTabBar.qml index 66b78d0..988be9c 100644 --- a/lib_source/qml/RibbonTabBar.qml +++ b/lib_source/qml/RibbonTabBar.qml @@ -96,12 +96,6 @@ Item{ } height: bar_layout.height z:1 - ScrollBar.horizontal: RibbonScrollBar{ - anchors.bottom: bar_view.bottom - anchors.horizontalCenter: bar_view.horizontalCenter - width: bar_view.width - 10 - height: 5 - } RowLayout { id: bar_layout diff --git a/lib_source/qml/RibbonTabButton.qml b/lib_source/qml/RibbonTabButton.qml index 6af224f..cc8afdb 100644 --- a/lib_source/qml/RibbonTabButton.qml +++ b/lib_source/qml/RibbonTabButton.qml @@ -27,6 +27,7 @@ TabButton { pixelSize: 13 bold: checked } + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering color: font_color height: contentHeight anchors{ diff --git a/lib_source/qml/RibbonTabGroup.qml b/lib_source/qml/RibbonTabGroup.qml index 72e009a..009bc3b 100644 --- a/lib_source/qml/RibbonTabGroup.qml +++ b/lib_source/qml/RibbonTabGroup.qml @@ -29,6 +29,7 @@ Item { } color: font_color height: contentHeight + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering anchors{ horizontalCenter: control.horizontalCenter bottom: control.bottom diff --git a/lib_source/qml/RibbonText.qml b/lib_source/qml/RibbonText.qml index 5b4fd0c..bab783f 100644 --- a/lib_source/qml/RibbonText.qml +++ b/lib_source/qml/RibbonText.qml @@ -19,6 +19,12 @@ TextEdit { wrapMode: TextEdit.WrapAnywhere enabled: !view_only font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" + renderType: RibbonTheme.nativeText ? TextEdit.NativeRendering : TextEdit.QtRendering + onRenderTypeChanged: { + selectAll() + deselect() + } + MouseArea{ anchors.fill: parent cursorShape: Qt.IBeamCursor diff --git a/lib_source/qml/RibbonTextEdit.qml b/lib_source/qml/RibbonTextEdit.qml index c41c823..3fd08a4 100644 --- a/lib_source/qml/RibbonTextEdit.qml +++ b/lib_source/qml/RibbonTextEdit.qml @@ -42,6 +42,7 @@ Item{ selectionColor: dark_mode ? "#4F5E7F" : "#BECDE8" selectedTextColor: dark_mode ? "white" : "black" wrapMode: Text.WrapAnywhere + renderType: RibbonTheme.nativeText ? TextArea.NativeRendering : TextArea.QtRendering opacity: enabled ? 1.0 : 0.3 signal commit() diff --git a/lib_source/qml/RibbonTitleBar.qml b/lib_source/qml/RibbonTitleBar.qml index e1c012f..b031b21 100644 --- a/lib_source/qml/RibbonTitleBar.qml +++ b/lib_source/qml/RibbonTitleBar.qml @@ -48,6 +48,7 @@ Item { text: control.title font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" color: title_text_color + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering Behavior on color { ColorAnimation { duration: 60 diff --git a/lib_source/qml/RibbonToolTip.qml b/lib_source/qml/RibbonToolTip.qml index f61fece..7502c5a 100644 --- a/lib_source/qml/RibbonToolTip.qml +++ b/lib_source/qml/RibbonToolTip.qml @@ -12,6 +12,7 @@ ToolTip { text: control.text font: control.font color: RibbonTheme.dark_mode ? "white" : "black" + renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering } background: Rectangle { diff --git a/lib_source/qml/RibbonWindow.qml b/lib_source/qml/RibbonWindow.qml index 6c794ab..c519147 100644 --- a/lib_source/qml/RibbonWindow.qml +++ b/lib_source/qml/RibbonWindow.qml @@ -48,6 +48,7 @@ Window { windowAgent.setTitleBar(titleBar) window.visible = true windowAgent.centralize() + raise() windowAgent.setWindowAttribute("dark-mode", RibbonTheme.dark_mode) if (Qt.platform.os === 'windows') { diff --git a/lib_source/ribbontheme.cpp b/lib_source/ribbontheme.cpp index c16f66b..39cf0a0 100644 --- a/lib_source/ribbontheme.cpp +++ b/lib_source/ribbontheme.cpp @@ -19,6 +19,7 @@ RibbonTheme::RibbonTheme() _theme_mode = RibbonThemeType::ThemeMode::System; _system_theme_mode = current_theme(); modern_style(false); + nativeText(true); qApp->installEventFilter(this); } diff --git a/lib_source/ribbontheme.h b/lib_source/ribbontheme.h index e10a771..cf7cee1 100644 --- a/lib_source/ribbontheme.h +++ b/lib_source/ribbontheme.h @@ -14,6 +14,7 @@ class RibbonTheme : public QQuickItem Q_PROPERTY(bool dark_mode READ dark_mode() NOTIFY dark_modeChanged FINAL) Q_PROPERTY_RW(RibbonThemeType::ThemeMode,theme_mode) Q_PROPERTY_RW(bool,modern_style) + Q_PROPERTY_RW(bool,nativeText) public: static RibbonTheme* create(QQmlEngine *qmlEngine, QJSEngine *jsEngine){return instance();} static RibbonTheme* instance();