Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions qt6/src/qml/Button.qml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ T.Button {
opacity: D.ColorSelector.controlState === D.DTK.DisabledState ? 0.4 : 1
D.DciIcon.mode: D.ColorSelector.controlState
D.DciIcon.theme: D.ColorSelector.controlTheme
D.DciIcon.palette: D.DTK.makeIconPalette(palette)
palette.windowText: D.ColorSelector.textColor
D.DciIcon.palette: D.DTK.makeIconPaletteWithForeground(palette, D.ColorSelector.textColor)
icon {
width: DS.Style.button.iconSize
height: DS.Style.button.iconSize
Expand Down
2 changes: 1 addition & 1 deletion qt6/src/qml/ButtonIndicator.qml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Rectangle {
width: DS.Style.buttonIndicator.iconSize
}
name: "arrow_ordinary_down"
palette: control.D.DTK.makeIconPalette(control.palette)
palette: control.D.DTK.makeIconPaletteWithForeground(control.palette, control.D.ColorSelector.textColor)
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
fallbackToQIcon: false
Expand Down
2 changes: 1 addition & 1 deletion qt6/src/qml/IconButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Button {
contentItem: D.DciIcon {
smooth: control.smooth
name: control.icon.name
palette: D.DTK.makeIconPalette(control.palette)
palette: D.DTK.makeIconPaletteWithForeground(control.palette, control.D.ColorSelector.textColor)
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
sourceSize: Qt.size(control.icon.width, control.icon.height)
Expand Down
14 changes: 7 additions & 7 deletions qt6/src/qml/ItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ T.ItemDelegate {
property bool contentFlow
property Component content
property D.Palette checkedTextColor: DS.Style.checkedButton.text
readonly property color resolvedTextColor: {
let undraged = D.DTK.hasAnimation ? control.backgroundVisible && !dragActive : true
return checked && !control.cascadeSelected && undraged ? D.ColorSelector.checkedTextColor : control.palette.windowText
}
property int corners: D.RoundRectangle.TopLeftCorner | D.RoundRectangle.TopRightCorner | D.RoundRectangle.BottomLeftCorner | D.RoundRectangle.BottomRightCorner
property bool dragActive: false
// drag
Expand All @@ -43,14 +47,10 @@ T.ItemDelegate {
spacing: DS.Style.control.spacing
checkable: true
autoExclusive: true
palette.windowText: {
let undraged = D.DTK.hasAnimation ? control.backgroundVisible && !dragActive : true
return checked && !control.cascadeSelected && undraged ? D.ColorSelector.checkedTextColor : undefined
}

D.DciIcon.mode: D.ColorSelector.controlState
D.DciIcon.theme: D.ColorSelector.controlTheme
D.DciIcon.palette: D.DTK.makeIconPalette(palette)
D.DciIcon.palette: D.DTK.makeIconPaletteWithForeground(palette, control.resolvedTextColor)
icon {
width: DS.Style.itemDelegate.iconSize
height: DS.Style.itemDelegate.iconSize
Expand All @@ -65,7 +65,7 @@ T.ItemDelegate {

sourceComponent: D.DciIcon {
smooth: control.smooth
palette: D.DTK.makeIconPalette(control.palette)
palette: D.DTK.makeIconPaletteWithForeground(control.palette, control.resolvedTextColor)
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
fallbackToQIcon: false
Expand All @@ -84,7 +84,7 @@ T.ItemDelegate {
? Qt.AlignCenter : Qt.AlignLeft | Qt.AlignVCenter
text: control.text
font: control.font
color: control.palette.windowText
color: control.resolvedTextColor
icon: D.DTK.makeIcon(control.icon, control.D.DciIcon)
Layout.fillWidth: !control.contentFlow
}
Expand Down
5 changes: 2 additions & 3 deletions qt6/src/qml/MenuItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ T.MenuItem {
: DS.Style.menu.itemText
property D.Palette subMenuBackgroundColor: DS.Style.menu.subMenuOpenedBackground

palette.windowText: D.ColorSelector.textColor
D.DciIcon.mode: D.ColorSelector.controlState
D.DciIcon.theme: D.ColorSelector.controlTheme
D.DciIcon.palette: D.DTK.makeIconPalette(palette)
D.DciIcon.palette: D.DTK.makeIconPaletteWithForeground(palette, D.ColorSelector.textColor)
contentItem: D.IconLabel {
readonly property real arrowPadding: control.subMenu && control.arrow ? control.arrow.width + control.spacing : 0
readonly property real indicatorPadding: control.useIndicatorPadding && control.indicator ? control.indicator.width + control.spacing : 0
Expand All @@ -44,7 +43,7 @@ T.MenuItem {
alignment: Qt.AlignLeft
text: control.text
font: control.font
color: control.palette.windowText
color: control.D.ColorSelector.textColor
Behavior on color {
enabled: D.DTK.hasAnimation
ColorAnimation { duration: control.hovered ? 100 : 0; }
Expand Down
2 changes: 1 addition & 1 deletion qt6/src/qml/WindowButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ D.IconButton {
smooth: control.smooth
name: control.icon.name
asynchronous: false
palette: D.DTK.makeIconPalette(control.palette)
palette: D.DTK.makeIconPaletteWithForeground(control.palette, control.D.ColorSelector.textColor)
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
sourceSize: Qt.size(control.icon.width, control.icon.height)
Expand Down
9 changes: 9 additions & 0 deletions src/private/dqmlglobalobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,15 @@ DDciIconPalette DQMLGlobalObject::makeIconPalette(const QQuickPalette *palette)
iconPalette.setHighlightForeground(palette->highlightedText());
return iconPalette;
}

// 在 makeIconPalette 基础上,显式设置前景色(用于状态相关图标的颜色渲染)
DDciIconPalette DQMLGlobalObject::makeIconPaletteWithForeground(const QQuickPalette *palette, const QColor &foreground)
{
DDciIconPalette iconPalette = makeIconPalette(palette);
if (foreground.isValid())
iconPalette.setForeground(foreground);
return iconPalette;
}
#endif

bool DQMLGlobalObject::sendMessage(QObject *target, const QString &content, const QString &iconName, int duration, const QString &msgId)
Expand Down
1 change: 1 addition & 0 deletions src/private/dqmlglobalobject_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ class DQMLGlobalObject : public QObject, public DTK_CORE_NAMESPACE::DObject
Q_INVOKABLE DTK_GUI_NAMESPACE::DDciIconPalette makeIconPalette(const QPalette &palette);
#else
Q_INVOKABLE DTK_GUI_NAMESPACE::DDciIconPalette makeIconPalette(const QQuickPalette *palette);
Q_INVOKABLE DTK_GUI_NAMESPACE::DDciIconPalette makeIconPaletteWithForeground(const QQuickPalette *palette, const QColor &foreground);
#endif

Q_INVOKABLE bool sendMessage(QObject *target, const QString &content, const QString &iconName = QString(), int duration = 4000, const QString &msgId = QString());
Expand Down
Loading