Compare commits

...

3 Commits

28 changed files with 215 additions and 68 deletions

View File

@ -22,6 +22,8 @@ RibbonWindow {
Image { Image {
source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png" source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
mipmap: true
autoTransform: true
Layout.preferredHeight: 120 Layout.preferredHeight: 120
Layout.preferredWidth: height Layout.preferredWidth: height
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter

View File

@ -673,6 +673,8 @@ RibbonWindow {
Image { Image {
source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png" source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
mipmap: true
autoTransform: true
Layout.preferredHeight: 300 Layout.preferredHeight: 300
Layout.preferredWidth: height Layout.preferredWidth: height
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
@ -763,12 +765,13 @@ RibbonWindow {
RibbonButton{ RibbonButton{
showBg:false showBg:false
adaptHeight:true adaptHeight:true
iconSource: RibbonIcons.AppStore iconSource: RibbonIcons.StoreMicrosoft
checkable: true checkable: true
tipText: "Test Button 7" tipText: "Test Button 7"
} }
} }
titleBar.titleIconSource: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
titleBar.rightContent:RowLayout{ titleBar.rightContent:RowLayout{
spacing: 1 spacing: 1
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft

View File

@ -23,6 +23,8 @@ RibbonWindow {
Image { Image {
source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png" source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
mipmap: true
autoTransform: true
Layout.preferredHeight: 120 Layout.preferredHeight: 120
Layout.preferredWidth: height Layout.preferredWidth: height
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter

View File

@ -673,6 +673,8 @@ RibbonWindow {
Image { Image {
source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png" source: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
mipmap: true
autoTransform: true
Layout.preferredHeight: 300 Layout.preferredHeight: 300
Layout.preferredWidth: height Layout.preferredWidth: height
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
@ -763,12 +765,13 @@ RibbonWindow {
RibbonButton{ RibbonButton{
showBg:false showBg:false
adaptHeight:true adaptHeight:true
iconSource: RibbonIcons.AppStore iconSource: RibbonIcons.StoreMicrosoft
checkable: true checkable: true
tipText: "Test Button 7" tipText: "Test Button 7"
} }
} }
titleBar.titleIconSource: "qrc:/qt/qml/RibbonUI/resources/imgs/icon.png"
titleBar.rightContent:RowLayout{ titleBar.rightContent:RowLayout{
spacing: 1 spacing: 1
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft

View File

@ -97,7 +97,6 @@ Popup {
text: backText text: backText
font.pixelSize: 30 font.pixelSize: 30
iconSource: RibbonIcons.ArrowCircleLeft iconSource: RibbonIcons.ArrowCircleLeft
implicitWidth: ribbonIcon.width
implicitHeight: ribbonIcon.height implicitHeight: ribbonIcon.height
textColor: RibbonTheme.modernStyle && !RibbonTheme.isDarkMode ? "black" : "white" textColor: RibbonTheme.modernStyle && !RibbonTheme.isDarkMode ? "black" : "white"
ribbonIcon.filled: hovered ribbonIcon.filled: hovered
@ -105,7 +104,7 @@ Popup {
top: parent.top top: parent.top
topMargin: 30 topMargin: 30
left: parent.left left: parent.left
leftMargin: 30 leftMargin: 8
} }
visible: showBackBtn visible: showBackBtn
ribbonIcon.iconSize: 30 ribbonIcon.iconSize: 30
@ -207,7 +206,7 @@ Popup {
id :rib_icon id :rib_icon
iconSource: typeof(model.menu_icon) === "number" ? model.menu_icon : 0 iconSource: typeof(model.menu_icon) === "number" ? model.menu_icon : 0
iconSourceFilled: typeof(model.menu_icon_filled) === "number" ? model.menu_icon_filled : iconSource iconSourceFilled: typeof(model.menu_icon_filled) === "number" ? model.menu_icon_filled : iconSource
iconSize: menu_label.contentHeight iconSize: menu_label.visible ? menu_label.contentHeight : 16
visible: typeof(model.menu_icon) === "number" && model.menu_icon visible: typeof(model.menu_icon) === "number" && model.menu_icon
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
filled: item_bg.view.currentIndex === index && item_bg.isCurrentMenu filled: item_bg.view.currentIndex === index && item_bg.isCurrentMenu
@ -218,7 +217,9 @@ Popup {
source: typeof(model.menu_icon) === "string" ? model.menu_icon : "" source: typeof(model.menu_icon) === "string" ? model.menu_icon : ""
visible: typeof(model.menu_icon) === "string" visible: typeof(model.menu_icon) === "string"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
height: menu_label.contentHeight mipmap: true
autoTransform: true
height: menu_label.visible ? menu_label.contentHeight : 16
width: height width: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
@ -232,6 +233,7 @@ Popup {
elide: Text.ElideRight elide: Text.ElideRight
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
visible: text
Layout.preferredWidth: { Layout.preferredWidth: {
let w = 0 let w = 0
w += rib_icon.visible ? rib_icon.contentWidth : 0 w += rib_icon.visible ? rib_icon.contentWidth : 0

View File

@ -60,6 +60,7 @@ Item {
anchors{ anchors{
left: parent.left left: parent.left
leftMargin: 20 leftMargin: 20
verticalCenter: parent.verticalCenter
} }
} }
@ -71,6 +72,7 @@ Item {
anchors{ anchors{
right: parent.right right: parent.right
rightMargin: 20 rightMargin: 20
verticalCenter: parent.verticalCenter
} }
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft
RibbonButton{ RibbonButton{

View File

@ -36,6 +36,7 @@ Button {
color: bgColor color: bgColor
} }
contentItem: Item{ contentItem: Item{
clip: true
implicitWidth: layout.width + 13 implicitWidth: layout.width + 13
implicitHeight: adaptHeight?root.parent.height>=layout.height?root.parent.height:layout.height:layout.height + 10 implicitHeight: adaptHeight?root.parent.height>=layout.height?root.parent.height:layout.height:layout.height + 10
Rectangle{ Rectangle{
@ -76,7 +77,7 @@ Button {
id :rib_icon id :rib_icon
iconSource: typeof(root.iconSource) === "number" ? root.iconSource : 0 iconSource: typeof(root.iconSource) === "number" ? root.iconSource : 0
iconSourceFilled: typeof(root.iconSourceFilled) === "number" ? root.iconSourceFilled : iconSource iconSourceFilled: typeof(root.iconSourceFilled) === "number" ? root.iconSourceFilled : iconSource
iconSize: label.contentHeight iconSize: label.visible ? label.contentHeight : 16
visible: typeof(root.iconSource) === "number" visible: typeof(root.iconSource) === "number"
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
filled: pressed || checked filled: pressed || checked
@ -98,7 +99,9 @@ Button {
source: typeof(root.iconSource) === "string" ? root.iconSource : "" source: typeof(root.iconSource) === "string" ? root.iconSource : ""
visible: typeof(root.iconSource) === "string" visible: typeof(root.iconSource) === "string"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
height: label.contentHeight mipmap: true
autoTransform: true
height: label.visible ? label.contentHeight : 16
width: height width: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
@ -111,6 +114,7 @@ Button {
font.pixelSize: 12 font.pixelSize: 12
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
visible: text
color: { color: {
if (!showBg && (hovered || checked || pressed) && textColorReverse) if (!showBg && (hovered || checked || pressed) && textColorReverse)
return Qt.lighter(textColor) return Qt.lighter(textColor)

View File

@ -12,13 +12,13 @@ Button {
checkable: true checkable: true
property bool isDarkMode: RibbonTheme.isDarkMode property bool isDarkMode: RibbonTheme.isDarkMode
property int btnSize: 20 property int btnSize: 16
property string borderColor: isDarkMode ? "white" : "black" property string borderColor: isDarkMode ? "white" : "black"
property real borderWidth: 1.4 property real borderWidth: 1.4
property string iconColor: "white" property string iconColor: "white"
property string iconFilledBgColor: "#2143AB" property string iconFilledBgColor: "#2143AB"
property string textColor: isDarkMode ? "white" : "black" property string textColor: isDarkMode ? "white" : "black"
property int textSize: 11 property int textSize: 12
property bool textBold: false property bool textBold: false
property bool textOnLeft: false property bool textOnLeft: false
property bool showTooltip: false property bool showTooltip: false
@ -43,12 +43,12 @@ Button {
color: control.borderColor color: control.borderColor
width: control.borderWidth width: control.borderWidth
} }
radius: 4.5 radius: 0.225 * btnSize
Rectangle{ Rectangle{
id: bg_fill id: bg_fill
anchors.fill: parent anchors.fill: parent
scale: control.hovered || control.pressed ? 0.6 : 1.05 scale: control.hovered || control.pressed ? 0.6 : 1.05
radius: 4.5 radius: 0.225 * btnSize
color: !control.pressed?control.iconFilledBgColor:Qt.darker(control.iconFilledBgColor) color: !control.pressed?control.iconFilledBgColor:Qt.darker(control.iconFilledBgColor)
visible: control.hovered || control.pressed || control.checked visible: control.hovered || control.pressed || control.checked
Behavior on scale{ Behavior on scale{

View File

@ -6,6 +6,7 @@ Text {
property int iconSize: 20 property int iconSize: 20
property bool filled: false property bool filled: false
property int iconSourceFilled property int iconSourceFilled
clip: true
onIconSourceChanged: { onIconSourceChanged: {
if (typeof(iconSourceFilled) === 'undefined' || iconSourceFilled === iconSource) if (typeof(iconSourceFilled) === 'undefined' || iconSourceFilled === iconSource)

View File

@ -68,7 +68,7 @@ MenuItem {
id :rib_icon id :rib_icon
iconSource: typeof(control.iconSource) === "number" ? control.iconSource : 0 iconSource: typeof(control.iconSource) === "number" ? control.iconSource : 0
iconSourceFilled: typeof(control.iconSourceFilled) === "number" ? control.iconSourceFilled : iconSource iconSourceFilled: typeof(control.iconSourceFilled) === "number" ? control.iconSourceFilled : iconSource
iconSize: label.contentHeight iconSize: label.visible ? label.contentHeight : 16
visible: typeof(control.iconSource) === "number" && control.iconSource visible: typeof(control.iconSource) === "number" && control.iconSource
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
filled: pressed || checked filled: pressed || checked
@ -79,7 +79,9 @@ MenuItem {
source: typeof(control.iconSource) === "string" ? control.iconSource : "" source: typeof(control.iconSource) === "string" ? control.iconSource : ""
visible: typeof(control.iconSource) === "string" visible: typeof(control.iconSource) === "string"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
height: label.contentHeight mipmap: true
autoTransform: true
height: label.visible ? label.contentHeight : 16
width: height width: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
@ -93,6 +95,7 @@ MenuItem {
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
color: textColor color: textColor
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
visible: text
Layout.preferredWidth:{ Layout.preferredWidth:{
let w = 0 let w = 0
w += rib_icon.visible ? rib_icon.contentWidth : 0 w += rib_icon.visible ? rib_icon.contentWidth : 0

View File

@ -62,6 +62,8 @@ Item {
source: typeof(root.iconSource) === "string" ? root.iconSource : "" source: typeof(root.iconSource) === "string" ? root.iconSource : ""
visible: typeof(root.iconSource) === "string" visible: typeof(root.iconSource) === "string"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
mipmap: true
autoTransform: true
height: left.height height: left.height
width: height width: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter

View File

@ -48,9 +48,9 @@ RadioButton {
radius: width/2 radius: width/2
color: { color: {
if(control.down) if(control.down)
return Qt.rgba(255,255,255,0.2) return RibbonTheme.isDarkMode ? Qt.rgba(255,255,255,0.2) : Qt.rgba(0,0,0,0.2)
if(control.hovered) if(control.hovered)
return Qt.rgba(255,255,255,0.1) return RibbonTheme.isDarkMode ? Qt.rgba(255,255,255,0.1) : Qt.rgba(0,0,0,0.1)
return 'transparent' return 'transparent'
} }
} }

View File

@ -15,7 +15,7 @@ Button {
property bool showGrabberText: true property bool showGrabberText: true
property string grabberText: control.checked ? qsTr("Open") : qsTr("Close") property string grabberText: control.checked ? qsTr("Open") : qsTr("Close")
property string textColor: isDarkMode ? "white" : "black" property string textColor: isDarkMode ? "white" : "black"
property int textSize: 11 property int textSize: 12
property string grabberCheckedColor: isDarkMode ? "#8AAAEB" : "#2850A4" property string grabberCheckedColor: isDarkMode ? "#8AAAEB" : "#2850A4"
property string grabberUncheckedColor: isDarkMode ? "#292929" : "white" property string grabberUncheckedColor: isDarkMode ? "#292929" : "white"
property string grabberTextCheckedColor: isDarkMode ? "black" : "white" property string grabberTextCheckedColor: isDarkMode ? "black" : "white"

View File

@ -7,7 +7,7 @@ import RibbonUI 1.0
Item { Item {
id: control id: control
height: 30 height: 30
property int minimumWidth: title_text.implicitWidth + Math.max(leftContainer.width, rightContainer.width) * 2 + (Qt.platform.os === "osx" ? 65 : 0) + 20 property int minimumWidth: mid_layout.implicitWidth + Math.max(leftContainer.width, rightContainer.width) * 2 + (Qt.platform.os === "osx" ? 65 : 0) + 20
property string title: Window.window.title property string title: Window.window.title
property bool showStyleSwitch: true property bool showStyleSwitch: true
property bool showDarkmodeBtn: true property bool showDarkmodeBtn: true
@ -16,6 +16,9 @@ Item {
property bool modernStyle: RibbonTheme.modernStyle property bool modernStyle: RibbonTheme.modernStyle
property string titleColor: modernStyle ? "transparent" : isDarkMode ? "#282828" : "#2C59B7" property string titleColor: modernStyle ? "transparent" : isDarkMode ? "#282828" : "#2C59B7"
property string titleTextColor: modernStyle ? isDarkMode ? "white" : "black" : "white" property string titleTextColor: modernStyle ? isDarkMode ? "white" : "black" : "white"
property var titleIconSource
property var titleIconSourceFilled
property var titleIcon: typeof(control.titleIconSource) === "string" ? pic_icon : rib_icon
default property alias content: leftContainer.data default property alias content: leftContainer.data
property alias leftContent: leftContainer.data property alias leftContent: leftContainer.data
property alias rightContent: rightContainer.data property alias rightContent: rightContainer.data
@ -43,17 +46,61 @@ Item {
} }
} }
Text {
id: title_text RowLayout{
id: mid_layout
anchors.centerIn: parent anchors.centerIn: parent
text: control.title RibbonIcon{
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" id :rib_icon
color: titleTextColor iconSource: typeof(control.titleIconSource) === "number" ? control.titleIconSource : 0
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering iconSourceFilled: typeof(control.titleIconSourceFilled) === "number" ? control.titleIconSourceFilled : iconSource
Behavior on color { iconSize: title_text.contentHeight
ColorAnimation { visible: typeof(control.titleIconSource) === "number"
duration: 60 Layout.preferredHeight: title_text.visible ? title_text.contentHeight : 16
easing.type: Easing.OutSine Layout.preferredWidth: Layout.preferredHeight
Layout.alignment: Qt.AlignVCenter
filled: mouse.pressed
color: {
if (mouse.containsMouse || mouse.pressed)
return Qt.lighter(titleTextColor)
else
return titleTextColor
}
Behavior on color {
ColorAnimation {
duration: 60
easing.type: Easing.OutSine
}
}
MouseArea{
id: mouse
hoverEnabled: true
}
}
Image {
id: pic_icon
source: typeof(control.titleIconSource) === "string" ? control.titleIconSource : ""
visible: typeof(control.titleIconSource) === "string"
fillMode:Image.PreserveAspectFit
mipmap: true
autoTransform: true
Layout.preferredHeight: title_text.visible ? title_text.contentHeight : 16
Layout.preferredWidth: Layout.preferredHeight
Layout.alignment: Qt.AlignVCenter
}
Text {
id: title_text
text: control.title
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
color: titleTextColor
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
Layout.alignment: Qt.AlignVCenter
visible: text
Behavior on color {
ColorAnimation {
duration: 60
easing.type: Easing.OutSine
}
} }
} }
} }
@ -65,9 +112,15 @@ Item {
top: parent.top top: parent.top
left: parent.left left: parent.left
bottom: parent.bottom bottom: parent.bottom
leftMargin: Qt.platform.os === "osx" ? 65 : 10 leftMargin: Qt.platform.os === "osx" && Window.window.visibility === Window.Windowed ? 65 : 10
} }
Layout.maximumWidth: (parent.width - title_text.contentWidth) / 2 Behavior on anchors.leftMargin {
NumberAnimation{
duration: 100
easing.type: Easing.OutSine
}
}
Layout.maximumWidth: (parent.width - mid_layout.contentWidth) / 2
} }
RowLayout{ RowLayout{
@ -79,7 +132,7 @@ Item {
bottom: parent.bottom bottom: parent.bottom
rightMargin: 10 rightMargin: 10
} }
Layout.maximumWidth: (parent.width - title_text.contentWidth) / 2 Layout.maximumWidth: (parent.width - mid_layout.contentWidth) / 2
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft
RowLayout{ RowLayout{
visible: Qt.platform.os !== "osx" visible: Qt.platform.os !== "osx"

View File

@ -18,10 +18,10 @@ ToolTip {
background: Rectangle { background: Rectangle {
radius: 3 radius: 3
color: RibbonTheme.isDarkMode ? "#2C2C29" : "#E0E0E2" color: RibbonTheme.modernStyle ? isDarkMode ? "black" : "white" : RibbonTheme.isDarkMode ? "#2C2C29" : "#E0E0E2"
layer.enabled: true layer.enabled: !RibbonTheme.modernStyle
layer.effect: RibbonShadow{} layer.effect: RibbonShadow{}
border.color: isDarkMode ? "#5C5D5D" : "#B5B4B5" border.color: RibbonTheme.modernStyle ? isDarkMode ? "#ADADAD" : "#616161" : isDarkMode ? "#5C5D5D" : "#B5B4B5"
border.width: 1 border.width: 1
} }
} }

View File

@ -46,6 +46,7 @@ Window {
windowAgent.setSystemButton(WindowAgent.Maximize, titleBar.maximizeBtn); windowAgent.setSystemButton(WindowAgent.Maximize, titleBar.maximizeBtn);
windowAgent.setSystemButton(WindowAgent.Close, titleBar.closeBtn); windowAgent.setSystemButton(WindowAgent.Close, titleBar.closeBtn);
} }
windowAgent.setSystemButton(WindowAgent.WindowIcon, titleBar.titleIcon);
windowAgent.setHitTestVisible(titleBar.leftContainer) windowAgent.setHitTestVisible(titleBar.leftContainer)
windowAgent.setHitTestVisible(titleBar.rightContainer) windowAgent.setHitTestVisible(titleBar.rightContainer)
windowAgent.setTitleBar(titleBar) windowAgent.setTitleBar(titleBar)
@ -115,7 +116,7 @@ Window {
return 'transparent' return 'transparent'
} }
border.color: RibbonTheme.isDarkMode ? "#7A7A7A" : "#2C59B7" border.color: RibbonTheme.isDarkMode ? "#7A7A7A" : "#2C59B7"
border.width: RibbonTheme.modernStyle ? 1 : 0 border.width: RibbonTheme.modernStyle && window.visibility === Window.Windowed ? 1 : 0
radius: Qt.platform.os === 'windows' ? RibbonUI.isWin11 ? 7 : 0 : 10 radius: Qt.platform.os === 'windows' ? RibbonUI.isWin11 ? 7 : 0 : 10
visible: RibbonTheme.modernStyle || blurBehindWindow visible: RibbonTheme.modernStyle || blurBehindWindow
} }

View File

@ -97,7 +97,6 @@ Popup {
text: backText text: backText
font.pixelSize: 30 font.pixelSize: 30
iconSource: RibbonIcons.ArrowCircleLeft iconSource: RibbonIcons.ArrowCircleLeft
implicitWidth: ribbonIcon.width
implicitHeight: ribbonIcon.height implicitHeight: ribbonIcon.height
textColor: RibbonTheme.modernStyle && !RibbonTheme.isDarkMode ? "black" : "white" textColor: RibbonTheme.modernStyle && !RibbonTheme.isDarkMode ? "black" : "white"
ribbonIcon.filled: hovered ribbonIcon.filled: hovered
@ -105,7 +104,7 @@ Popup {
top: parent.top top: parent.top
topMargin: 30 topMargin: 30
left: parent.left left: parent.left
leftMargin: 30 leftMargin: 8
} }
visible: showBackBtn visible: showBackBtn
ribbonIcon.iconSize: 30 ribbonIcon.iconSize: 30
@ -207,7 +206,7 @@ Popup {
id :rib_icon id :rib_icon
iconSource: typeof(model.menu_icon) === "number" ? model.menu_icon : 0 iconSource: typeof(model.menu_icon) === "number" ? model.menu_icon : 0
iconSourceFilled: typeof(model.menu_icon_filled) === "number" ? model.menu_icon_filled : iconSource iconSourceFilled: typeof(model.menu_icon_filled) === "number" ? model.menu_icon_filled : iconSource
iconSize: menu_label.contentHeight iconSize: menu_label.visible ? menu_label.contentHeight : 16
visible: typeof(model.menu_icon) === "number" && model.menu_icon visible: typeof(model.menu_icon) === "number" && model.menu_icon
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
filled: item_bg.view.currentIndex === index && item_bg.isCurrentMenu filled: item_bg.view.currentIndex === index && item_bg.isCurrentMenu
@ -218,7 +217,9 @@ Popup {
source: typeof(model.menu_icon) === "string" ? model.menu_icon : "" source: typeof(model.menu_icon) === "string" ? model.menu_icon : ""
visible: typeof(model.menu_icon) === "string" visible: typeof(model.menu_icon) === "string"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
height: menu_label.contentHeight mipmap: true
autoTransform: true
height: menu_label.visible ? menu_label.contentHeight : 16
width: height width: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
@ -232,6 +233,7 @@ Popup {
elide: Text.ElideRight elide: Text.ElideRight
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
visible: text
Layout.preferredWidth: { Layout.preferredWidth: {
let w = 0 let w = 0
w += rib_icon.visible ? rib_icon.contentWidth : 0 w += rib_icon.visible ? rib_icon.contentWidth : 0

View File

@ -60,6 +60,7 @@ Item {
anchors{ anchors{
left: parent.left left: parent.left
leftMargin: 20 leftMargin: 20
verticalCenter: parent.verticalCenter
} }
} }
@ -71,6 +72,7 @@ Item {
anchors{ anchors{
right: parent.right right: parent.right
rightMargin: 20 rightMargin: 20
verticalCenter: parent.verticalCenter
} }
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft
RibbonButton{ RibbonButton{

View File

@ -36,6 +36,7 @@ Button {
color: bgColor color: bgColor
} }
contentItem: Item{ contentItem: Item{
clip: true
implicitWidth: layout.width + 13 implicitWidth: layout.width + 13
implicitHeight: adaptHeight?root.parent.height>=layout.height?root.parent.height:layout.height:layout.height + 10 implicitHeight: adaptHeight?root.parent.height>=layout.height?root.parent.height:layout.height:layout.height + 10
Rectangle{ Rectangle{
@ -76,7 +77,7 @@ Button {
id :rib_icon id :rib_icon
iconSource: typeof(root.iconSource) === "number" ? root.iconSource : 0 iconSource: typeof(root.iconSource) === "number" ? root.iconSource : 0
iconSourceFilled: typeof(root.iconSourceFilled) === "number" ? root.iconSourceFilled : iconSource iconSourceFilled: typeof(root.iconSourceFilled) === "number" ? root.iconSourceFilled : iconSource
iconSize: label.contentHeight iconSize: label.visible ? label.contentHeight : 16
visible: typeof(root.iconSource) === "number" visible: typeof(root.iconSource) === "number"
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
filled: pressed || checked filled: pressed || checked
@ -98,7 +99,9 @@ Button {
source: typeof(root.iconSource) === "string" ? root.iconSource : "" source: typeof(root.iconSource) === "string" ? root.iconSource : ""
visible: typeof(root.iconSource) === "string" visible: typeof(root.iconSource) === "string"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
height: label.contentHeight mipmap: true
autoTransform: true
height: label.visible ? label.contentHeight : 16
width: height width: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
@ -111,6 +114,7 @@ Button {
font.pixelSize: 12 font.pixelSize: 12
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
visible: text
color: { color: {
if (!showBg && (hovered || checked || pressed) && textColorReverse) if (!showBg && (hovered || checked || pressed) && textColorReverse)
return Qt.lighter(textColor) return Qt.lighter(textColor)

View File

@ -12,13 +12,13 @@ Button {
checkable: true checkable: true
property bool isDarkMode: RibbonTheme.isDarkMode property bool isDarkMode: RibbonTheme.isDarkMode
property int btnSize: 20 property int btnSize: 16
property string borderColor: isDarkMode ? "white" : "black" property string borderColor: isDarkMode ? "white" : "black"
property real borderWidth: 1.4 property real borderWidth: 1.4
property string iconColor: "white" property string iconColor: "white"
property string iconFilledBgColor: "#2143AB" property string iconFilledBgColor: "#2143AB"
property string textColor: isDarkMode ? "white" : "black" property string textColor: isDarkMode ? "white" : "black"
property int textSize: 11 property int textSize: 12
property bool textBold: false property bool textBold: false
property bool textOnLeft: false property bool textOnLeft: false
property bool showTooltip: false property bool showTooltip: false
@ -43,12 +43,12 @@ Button {
color: control.borderColor color: control.borderColor
width: control.borderWidth width: control.borderWidth
} }
radius: 4.5 radius: 0.225 * btnSize
Rectangle{ Rectangle{
id: bg_fill id: bg_fill
anchors.fill: parent anchors.fill: parent
scale: control.hovered || control.pressed ? 0.6 : 1.05 scale: control.hovered || control.pressed ? 0.6 : 1.05
radius: 4.5 radius: 0.225 * btnSize
color: !control.pressed?control.iconFilledBgColor:Qt.darker(control.iconFilledBgColor) color: !control.pressed?control.iconFilledBgColor:Qt.darker(control.iconFilledBgColor)
visible: control.hovered || control.pressed || control.checked visible: control.hovered || control.pressed || control.checked
Behavior on scale{ Behavior on scale{

View File

@ -7,6 +7,7 @@ Text {
property int iconSize: 20 property int iconSize: 20
property bool filled: false property bool filled: false
property int iconSourceFilled property int iconSourceFilled
clip: true
onIconSourceChanged: { onIconSourceChanged: {
if (typeof(iconSourceFilled) === 'undefined' || iconSourceFilled === iconSource) if (typeof(iconSourceFilled) === 'undefined' || iconSourceFilled === iconSource)

View File

@ -68,7 +68,7 @@ MenuItem {
id :rib_icon id :rib_icon
iconSource: typeof(control.iconSource) === "number" ? control.iconSource : 0 iconSource: typeof(control.iconSource) === "number" ? control.iconSource : 0
iconSourceFilled: typeof(control.iconSourceFilled) === "number" ? control.iconSourceFilled : iconSource iconSourceFilled: typeof(control.iconSourceFilled) === "number" ? control.iconSourceFilled : iconSource
iconSize: label.contentHeight iconSize: label.visible ? label.contentHeight : 16
visible: typeof(control.iconSource) === "number" && control.iconSource visible: typeof(control.iconSource) === "number" && control.iconSource
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
filled: pressed || checked filled: pressed || checked
@ -79,7 +79,9 @@ MenuItem {
source: typeof(control.iconSource) === "string" ? control.iconSource : "" source: typeof(control.iconSource) === "string" ? control.iconSource : ""
visible: typeof(control.iconSource) === "string" visible: typeof(control.iconSource) === "string"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
height: label.contentHeight mipmap: true
autoTransform: true
height: label.visible ? label.contentHeight : 16
width: height width: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
@ -93,6 +95,7 @@ MenuItem {
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
color: textColor color: textColor
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
visible: text
Layout.preferredWidth:{ Layout.preferredWidth:{
let w = 0 let w = 0
w += rib_icon.visible ? rib_icon.contentWidth : 0 w += rib_icon.visible ? rib_icon.contentWidth : 0

View File

@ -62,6 +62,8 @@ Item {
source: typeof(root.iconSource) === "string" ? root.iconSource : "" source: typeof(root.iconSource) === "string" ? root.iconSource : ""
visible: typeof(root.iconSource) === "string" visible: typeof(root.iconSource) === "string"
fillMode:Image.PreserveAspectFit fillMode:Image.PreserveAspectFit
mipmap: true
autoTransform: true
height: left.height height: left.height
width: height width: height
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter

View File

@ -48,9 +48,9 @@ RadioButton {
radius: width/2 radius: width/2
color: { color: {
if(control.down) if(control.down)
return Qt.rgba(255,255,255,0.2) return RibbonTheme.isDarkMode ? Qt.rgba(255,255,255,0.2) : Qt.rgba(0,0,0,0.2)
if(control.hovered) if(control.hovered)
return Qt.rgba(255,255,255,0.1) return RibbonTheme.isDarkMode ? Qt.rgba(255,255,255,0.1) : Qt.rgba(0,0,0,0.1)
return 'transparent' return 'transparent'
} }
} }

View File

@ -15,7 +15,7 @@ Button {
property bool showGrabberText: true property bool showGrabberText: true
property string grabberText: control.checked ? qsTr("Open") : qsTr("Close") property string grabberText: control.checked ? qsTr("Open") : qsTr("Close")
property string textColor: isDarkMode ? "white" : "black" property string textColor: isDarkMode ? "white" : "black"
property int textSize: 11 property int textSize: 12
property string grabberCheckedColor: isDarkMode ? "#8AAAEB" : "#2850A4" property string grabberCheckedColor: isDarkMode ? "#8AAAEB" : "#2850A4"
property string grabberUncheckedColor: isDarkMode ? "#292929" : "white" property string grabberUncheckedColor: isDarkMode ? "#292929" : "white"
property string grabberTextCheckedColor: isDarkMode ? "black" : "white" property string grabberTextCheckedColor: isDarkMode ? "black" : "white"

View File

@ -1,12 +1,13 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Window
import RibbonUI import RibbonUI
Item { Item {
id: control id: control
height: 30 height: 30
property int minimumWidth: title_text.implicitWidth + Math.max(leftContainer.width, rightContainer.width) * 2 + (Qt.platform.os === "osx" ? 65 : 0) + 20 property int minimumWidth: mid_layout.implicitWidth + Math.max(leftContainer.width, rightContainer.width) * 2 + (Qt.platform.os === "osx" ? 65 : 0) + 20
property string title: Window.window.title property string title: Window.window.title
property bool showStyleSwitch: true property bool showStyleSwitch: true
property bool showDarkmodeBtn: true property bool showDarkmodeBtn: true
@ -15,6 +16,9 @@ Item {
property bool modernStyle: RibbonTheme.modernStyle property bool modernStyle: RibbonTheme.modernStyle
property string titleColor: modernStyle ? "transparent" : isDarkMode ? "#282828" : "#2C59B7" property string titleColor: modernStyle ? "transparent" : isDarkMode ? "#282828" : "#2C59B7"
property string titleTextColor: modernStyle ? isDarkMode ? "white" : "black" : "white" property string titleTextColor: modernStyle ? isDarkMode ? "white" : "black" : "white"
property var titleIconSource
property var titleIconSourceFilled
property var titleIcon: typeof(control.titleIconSource) === "string" ? pic_icon : rib_icon
default property alias content: leftContainer.data default property alias content: leftContainer.data
property alias leftContent: leftContainer.data property alias leftContent: leftContainer.data
property alias rightContent: rightContainer.data property alias rightContent: rightContainer.data
@ -42,17 +46,61 @@ Item {
} }
} }
Text {
id: title_text RowLayout{
id: mid_layout
anchors.centerIn: parent anchors.centerIn: parent
text: control.title RibbonIcon{
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI" id :rib_icon
color: titleTextColor iconSource: typeof(control.titleIconSource) === "number" ? control.titleIconSource : 0
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering iconSourceFilled: typeof(control.titleIconSourceFilled) === "number" ? control.titleIconSourceFilled : iconSource
Behavior on color { iconSize: title_text.contentHeight
ColorAnimation { visible: typeof(control.titleIconSource) === "number"
duration: 60 Layout.preferredHeight: title_text.visible ? title_text.contentHeight : 16
easing.type: Easing.OutSine Layout.preferredWidth: Layout.preferredHeight
Layout.alignment: Qt.AlignVCenter
filled: mouse.pressed
color: {
if (mouse.containsMouse || mouse.pressed)
return Qt.lighter(titleTextColor)
else
return titleTextColor
}
Behavior on color {
ColorAnimation {
duration: 60
easing.type: Easing.OutSine
}
}
MouseArea{
id: mouse
hoverEnabled: true
}
}
Image {
id: pic_icon
source: typeof(control.titleIconSource) === "string" ? control.titleIconSource : ""
visible: typeof(control.titleIconSource) === "string"
fillMode:Image.PreserveAspectFit
mipmap: true
autoTransform: true
Layout.preferredHeight: title_text.visible ? title_text.contentHeight : 16
Layout.preferredWidth: Layout.preferredHeight
Layout.alignment: Qt.AlignVCenter
}
Text {
id: title_text
text: control.title
font.family: Qt.platform.os === "osx" ? "PingFang SC" : "Microsoft YaHei UI"
color: titleTextColor
renderType: RibbonTheme.nativeText ? Text.NativeRendering : Text.QtRendering
Layout.alignment: Qt.AlignVCenter
visible: text
Behavior on color {
ColorAnimation {
duration: 60
easing.type: Easing.OutSine
}
} }
} }
} }
@ -64,9 +112,15 @@ Item {
top: parent.top top: parent.top
left: parent.left left: parent.left
bottom: parent.bottom bottom: parent.bottom
leftMargin: Qt.platform.os === "osx" ? 65 : 10 leftMargin: Qt.platform.os === "osx" && Window.window.visibility === Window.Windowed ? 65 : 10
} }
Layout.maximumWidth: (parent.width - title_text.contentWidth) / 2 Behavior on anchors.leftMargin {
NumberAnimation{
duration: 100
easing.type: Easing.OutSine
}
}
Layout.maximumWidth: (parent.width - mid_layout.contentWidth) / 2
} }
RowLayout{ RowLayout{
@ -78,7 +132,7 @@ Item {
bottom: parent.bottom bottom: parent.bottom
rightMargin: 10 rightMargin: 10
} }
Layout.maximumWidth: (parent.width - title_text.contentWidth) / 2 Layout.maximumWidth: (parent.width - mid_layout.contentWidth) / 2
layoutDirection: Qt.RightToLeft layoutDirection: Qt.RightToLeft
RowLayout{ RowLayout{
visible: Qt.platform.os !== "osx" visible: Qt.platform.os !== "osx"

View File

@ -17,10 +17,10 @@ ToolTip {
background: Rectangle { background: Rectangle {
radius: 3 radius: 3
color: RibbonTheme.isDarkMode ? "#2C2C29" : "#E0E0E2" color: RibbonTheme.modernStyle ? isDarkMode ? "black" : "white" : RibbonTheme.isDarkMode ? "#2C2C29" : "#E0E0E2"
layer.enabled: true layer.enabled: !RibbonTheme.modernStyle
layer.effect: RibbonShadow{} layer.effect: RibbonShadow{}
border.color: isDarkMode ? "#5C5D5D" : "#B5B4B5" border.color: RibbonTheme.modernStyle ? isDarkMode ? "#ADADAD" : "#616161" : isDarkMode ? "#5C5D5D" : "#B5B4B5"
border.width: 1 border.width: 1
} }
} }

View File

@ -45,6 +45,7 @@ Window {
windowAgent.setSystemButton(WindowAgent.Maximize, titleBar.maximizeBtn); windowAgent.setSystemButton(WindowAgent.Maximize, titleBar.maximizeBtn);
windowAgent.setSystemButton(WindowAgent.Close, titleBar.closeBtn); windowAgent.setSystemButton(WindowAgent.Close, titleBar.closeBtn);
} }
windowAgent.setSystemButton(WindowAgent.WindowIcon, titleBar.titleIcon);
windowAgent.setHitTestVisible(titleBar.leftContainer) windowAgent.setHitTestVisible(titleBar.leftContainer)
windowAgent.setHitTestVisible(titleBar.rightContainer) windowAgent.setHitTestVisible(titleBar.rightContainer)
windowAgent.setTitleBar(titleBar) windowAgent.setTitleBar(titleBar)
@ -114,7 +115,7 @@ Window {
return 'transparent' return 'transparent'
} }
border.color: RibbonTheme.isDarkMode ? "#7A7A7A" : "#2C59B7" border.color: RibbonTheme.isDarkMode ? "#7A7A7A" : "#2C59B7"
border.width: RibbonTheme.modernStyle ? 1 : 0 border.width: RibbonTheme.modernStyle && window.visibility === Window.Windowed ? 1 : 0
radius: Qt.platform.os === 'windows' ? RibbonUI.isWin11 ? 7 : 0 : 10 radius: Qt.platform.os === 'windows' ? RibbonUI.isWin11 ? 7 : 0 : 10
visible: RibbonTheme.modernStyle || blurBehindWindow visible: RibbonTheme.modernStyle || blurBehindWindow
} }