Skip to content
Merged
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: 2 additions & 1 deletion qt6/src/qml/TitleBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ Item {
palette.windowText: D.ColorSelector.textColor

HoverHandler {
enabled: __isFullScreen && autoHideOnFullscreen
id: hoverHandler
// reset it's parent to disable HoverHandler
parent: __isFullScreen && autoHideOnFullscreen ? control : null
}
Comment on lines 54 to 58
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Clarify using 'parent' to disable HoverHandler

Using the parent assignment as a means to conditionally disable the HoverHandler is non-standard. It might be clearer and more maintainable to bind the 'enabled' property directly to the condition.

Suggested change
HoverHandler {
enabled: __isFullScreen && autoHideOnFullscreen
id: hoverHandler
// reset it's parent to disable HoverHandler
parent: __isFullScreen && autoHideOnFullscreen ? control : null
}
HoverHandler {
id: hoverHandler
enabled: __isFullScreen && autoHideOnFullscreen
}

TapHandler {
acceptedButtons: Qt.RightButton | Qt.LeftButton
Expand Down
63 changes: 41 additions & 22 deletions qt6/src/qml/WindowButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,53 @@ import QtQuick
import org.deepin.dtk 1.0 as D
import org.deepin.dtk.style 1.0 as DS

Control {
D.IconButton {
id: control
property alias icon: iconLoader
readonly property bool pressed: mouseArea.pressed
signal clicked(var mouse)
property D.Palette textColor: DS.Style.button.text
property D.Palette backgroundColor: DS.Style.windowButton.background

palette.windowText: D.ColorSelector.textColor
hoverEnabled: true
contentItem: D.DciIcon {
id: iconLoader
palette: D.DTK.makeIconPalette(control.palette)
sourceSize {
width: DS.Style.windowButton.width
height: DS.Style.windowButton.height
property int topRightRadius: (Window.window.visibility !== Window.Maximized &&
Window.window.visibility !== Window.FullScreen &&
isOnRightEdgeOfWindow) ? D.DTK.platformTheme.windowRadius : 0
readonly property bool isOnRightEdgeOfWindow: __itemGlobalPoint.x + control.width >= Window.window.width

readonly property var __itemGlobalPoint: {
var a = control
var x = 0, y = 0
while(a.parent) {
x += a.x
y += a.y
a = a.parent
}
mode: control.D.ColorSelector.controlState
theme: control.D.ColorSelector.controlTheme
return Qt.point(x, y)
}
MouseArea {
id: mouseArea
anchors.fill: parent
Component.onCompleted: clicked.connect(control.clicked)

topPadding: 0
bottomPadding: 0
leftPadding: 0
rightPadding: 0
icon {
width: DS.Style.windowButton.width
height: DS.Style.windowButton.height
}
background: Rectangle {
background: D.BoxPanel {
implicitWidth: DS.Style.windowButton.width
implicitHeight: DS.Style.windowButton.height
color: control.D.ColorSelector.backgroundColor
insideBorderColor: null
outsideBorderColor: null
color1: DS.Style.windowButton.background
color2: color1
radius: 0

Loader {
anchors.fill: parent
active: control.visualFocus
sourceComponent: Rectangle {
topRightRadius: control.topRightRadius
color: "transparent"
border {
width: DS.Style.control.focusBorderWidth
color: control.palette.highlight
}
}
}
}
}