RibbonTheme,RibbonWindow and example: Add nativeText property and bug fix.

This commit is contained in:
Mentalflow 2024-05-11 09:12:00 +08:00
parent d5101de44c
commit 974268fe9a
Signed by: Mentalflow
GPG Key ID: 5AE68D4401A2EE71
18 changed files with 33 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,6 +27,7 @@ TabButton {
pixelSize: 13
bold: checked
}
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
color: font_color
height: contentHeight
anchors{

View File

@ -29,6 +29,7 @@ Item {
}
color: font_color
height: contentHeight
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
anchors{
horizontalCenter: control.horizontalCenter
bottom: control.bottom

View File

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

View File

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

View File

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

View File

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

View File

@ -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')
{

View File

@ -19,6 +19,7 @@ RibbonTheme::RibbonTheme()
_theme_mode = RibbonThemeType::ThemeMode::System;
_system_theme_mode = current_theme();
modern_style(false);
nativeText(true);
qApp->installEventFilter(this);
}

View File

@ -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();