Skip to content

Commit

Permalink
fix: missing focus box border for some items
Browse files Browse the repository at this point in the history
  • Loading branch information
wineee authored and BLumia committed Apr 24, 2024
1 parent 05b57db commit b4e6f0a
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 19 deletions.
8 changes: 6 additions & 2 deletions qml/windowed/AppListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ Item {
}
}

background: ItemBackground { }
background: ItemBackground {
button: headingBtn
}

MouseArea {
anchors.fill: parent
Expand Down Expand Up @@ -209,7 +211,9 @@ Item {
}
}

background: ItemBackground { }
background: ItemBackground {
button: itemDelegate
}
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions qml/windowed/BottomBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ Control {
ToolButton {
id: shutdownBtn
icon.name: "shutdown"
background: ItemBackground { }
background: ItemBackground {
button: shutdownBtn
}
ToolTip.visible: hovered
ToolTip.delay: 1000
ToolTip.text: qsTr("Power")
Expand Down Expand Up @@ -80,8 +82,11 @@ Control {
}

ToolButton {
id: fullscreenBtn
icon.name: "launcher_fullscreen"
background: ItemBackground { }
background: ItemBackground {
button: fullscreenBtn
}
Accessible.name: "Fullscreen"
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
onClicked: {
Expand Down
1 change: 1 addition & 0 deletions qml/windowed/FreeSortListView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ Item {

background: ItemBackground {
id: bg
button: itemDelegate
}

MouseArea {
Expand Down
4 changes: 3 additions & 1 deletion qml/windowed/IconItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Control {
signal menuTriggered()

contentItem: ToolButton {
id: iconButton
focusPolicy: Qt.NoFocus
contentItem: Column {
anchors.fill: parent
Expand Down Expand Up @@ -63,13 +64,14 @@ Control {
elide: Text.ElideRight
maximumLineCount: singleRow ? 1 : 2
font: DTK.fontManager.t9
}
}
}
ToolTip.text: root.text
ToolTip.delay: 1000
ToolTip.visible: hovered
background: ItemBackground {
radius: 8
button: iconButton
}

onClicked: {
Expand Down
38 changes: 30 additions & 8 deletions qml/windowed/ItemBackground.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ import org.deepin.dtk 1.0 as D
import org.deepin.dtk.style 1.0 as DS

D.BoxPanel {
visible: D.ColorSelector.controlState === D.DTK.HoveredState
outsideBorderColor: null
insideBorderColor: null
implicitWidth: DS.Style.toolButton.width
implicitHeight: DS.Style.toolButton.height

id: control
property Item button
property D.Palette background: D.Palette {
normal {
common: Qt.rgba(0, 0, 0, 0.1)
Expand All @@ -27,6 +23,32 @@ D.BoxPanel {
crystal: Qt.rgba(16.0 / 255, 16.0 / 255, 16.0 / 255, 0.1)
}
}
color1: background
color2: background

implicitWidth: DS.Style.toolButton.width
implicitHeight: DS.Style.toolButton.height
color1: selectValue(background, DS.Style.checkedButton.background, DS.Style.highlightedButton.background1)
color2: selectValue(background, DS.Style.checkedButton.background, DS.Style.highlightedButton.background2)
insideBorderColor: null
outsideBorderColor: null
visible: button.checked || button.highlighted || button.visualFocus || control.D.ColorSelector.controlState === D.DTK.PressedState || control.D.ColorSelector.controlState === D.DTK.HoveredState

function selectValue(normal, checked, highlighted) {
if (button.checked) {
return checked
} else if ((typeof button.highlighted == "boolean") && button.highlighted) {
return highlighted
}

return normal
}

Loader {
anchors.fill: parent
active: button.visualFocus

sourceComponent: D.FocusBoxBorder {
radius: control.radius
color: button.palette.highlight
}
}
}
24 changes: 18 additions & 6 deletions qml/windowed/SideBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ ColumnLayout {
}
}

background: ItemBackground { }
background: ItemBackground {
button: title
}

onClicked: {
const menu = categorizedCom.createObject(this);
Expand All @@ -139,7 +141,9 @@ ColumnLayout {
onClicked: {
DesktopIntegration.showUrl("computer:///")
}
background: ItemBackground { }
background: ItemBackground {
button: computer
}
}

D.ToolButton {
Expand All @@ -155,7 +159,9 @@ ColumnLayout {
onClicked: {
DesktopIntegration.showFolder(StandardPaths.PicturesLocation)
}
background: ItemBackground { }
background: ItemBackground {
button: images
}
}

D.ToolButton {
Expand All @@ -171,7 +177,9 @@ ColumnLayout {
onClicked: {
DesktopIntegration.showFolder(StandardPaths.DocumentsLocation)
}
background: ItemBackground { }
background: ItemBackground {
button: documents
}
}

D.ToolButton {
Expand All @@ -187,7 +195,9 @@ ColumnLayout {
onClicked: {
DesktopIntegration.showFolder(StandardPaths.DesktopLocation)
}
background: ItemBackground { }
background: ItemBackground {
button: desktop
}
}

D.ToolButton {
Expand All @@ -203,7 +213,9 @@ ColumnLayout {
onClicked: {
DesktopIntegration.openSystemSettings();
}
background: ItemBackground { }
background: ItemBackground {
button: setting
}
}

Item {
Expand Down

0 comments on commit b4e6f0a

Please sign in to comment.