Skip to content

Commit

Permalink
refact: using Item instead of Popup for PanelPopup
Browse files Browse the repository at this point in the history
Popup control could reposition it's geometry, it has a delay, and it depends
window's geometry, but PanelPopup's window is also depends on
PanelPopup, it exists loop bindings.

Issue: linuxdeepin/developer-center#9676
  • Loading branch information
18202781743 committed Jul 24, 2024
1 parent cc915c5 commit 4dbb930
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 30 deletions.
19 changes: 4 additions & 15 deletions frame/qml/PanelPopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.deepin.ds 1.0
Item {
id: control
visible: false
default property alias popupContent: popup.contentChildren
default property alias popupContent: popup.children
property alias popupVisible: popup.visible
property var popupWindow: Panel.popupWindow
property int popupX: 0
Expand Down Expand Up @@ -82,23 +82,12 @@ Item {
}
}

Popup {
Item {
id: popup
padding: 0
visible: readyBinding
width: control.width
height: control.height
width: childrenRect.width
height: childrenRect.height
parent: popupWindow ? popupWindow.contentItem : undefined
onParentChanged: function() {
if (!popupWindow)
return
popupWindow.visibleChanged.connect(function() {
if (popupWindow && !popupWindow.visible)
control.close()
})
}
// TODO dtk's blur causes blurred screen.
background: null
}
Component.onDestruction: {
if (popup.visible)
Expand Down
26 changes: 11 additions & 15 deletions frame/qml/PanelToolTip.qml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import org.deepin.ds 1.0
import org.deepin.dtk.style as DStyle

Item {
id: control

property alias toolTipContent: toolTip.contentChildren
default property alias toolTipContentItem: toolTip.contentItem
property alias text: toolTip.text
property string text
property alias toolTipVisible: toolTip.visible
property var toolTipWindow: Panel.toolTipWindow
property int toolTipX: 0
Expand Down Expand Up @@ -71,25 +71,21 @@ Item {
close()
}

ToolTip {
Control {
id: toolTip
padding: 0
padding: DStyle.Style.toolTip.horizontalPadding
visible: readyBinding
// TODO it's a bug for qt, ToolTip's text color can't change with window's palette changed.
palette.toolTipText: toolTipWindow ? toolTipWindow.palette.toolTipText : undefined
anchors.centerIn: parent
topPadding: 0
bottomPadding: 0
parent: toolTipWindow ? toolTipWindow.contentItem : undefined
onParentChanged: function() {
if (!toolTipWindow)
return
toolTipWindow.visibleChanged.connect(function() {
if (toolTipWindow && !toolTipWindow.visible)
toolTip.close()
})
contentItem: Text {
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
font: toolTip.font
wrapMode: Text.WordWrap
text: control.text
color: toolTip.palette.windowText
}
// TODO dtk's blur causes blurred screen.
background: null
}
}

0 comments on commit 4dbb930

Please sign in to comment.