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
22 changes: 22 additions & 0 deletions frame/qml/PanelToolTip.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Item {
property var toolTipWindow: Panel.toolTipWindow
property int toolTipX: 0
property int toolTipY: 0
// Set to 0 when the tooltip producer already handles the delay.
property int showDelay: 300
readonly property bool readyBinding: !!toolTipWindow && toolTipWindow.currentItem === control
property bool openPending: false
// WM_NAME, used for kwin.
Expand Down Expand Up @@ -46,6 +48,19 @@ Item {
}

function open()
{
if (!toolTipWindow)
return

if (showDelay > 0) {
toolTipShowTimer.start()
} else {
toolTipShowTimer.stop()
showToolTip()
}
}

function showToolTip()
{
if (!toolTipWindow)
return
Expand All @@ -59,6 +74,7 @@ Item {

function close()
{
toolTipShowTimer.stop()
openPending = false
if (!readyBinding)
return
Expand Down Expand Up @@ -88,6 +104,12 @@ Item {
}
Component.onDestruction: close()

Timer {
id: toolTipShowTimer
interval: control.showDelay
onTriggered: control.showToolTip()
}

Connections {
target: control.Window.window
function onVisibleChanged() {
Expand Down
2 changes: 2 additions & 0 deletions panels/dock/cardleft/package/CardLeftDockArea.qml
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ AppletDockItem {
PanelToolTip {
Accessible.id: "CardLeftDockArea_Pane_4"
id: cardToolTip
// tray-loader already delays tooltip creation for card plugins.
showDelay: 0

property alias shellSurface: cardToolTipContent.shellSurface

Expand Down
18 changes: 3 additions & 15 deletions panels/dock/multitaskview/package/multitaskview.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,6 @@ AppletDockItem {
sourceSize: Qt.size(Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE, Dock.MAX_DOCK_TASKMANAGER_ICON_SIZE)
}

Timer {
id: toolTipShowTimer
interval: 50
onTriggered: {
var point = toggleworkspace.mapToItem(null, toggleworkspace.width / 2, toggleworkspace.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
}
}

TapHandler {
id: tapHandler
acceptedButtons: Qt.LeftButton | Qt.RightButton
Expand All @@ -68,12 +58,10 @@ AppletDockItem {
HoverHandler {
onHoveredChanged: {
if (hovered) {
toolTipShowTimer.start()
var point = toggleworkspace.mapToItem(null, toggleworkspace.width / 2, toggleworkspace.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
} else {
if (toolTipShowTimer.running) {
toolTipShowTimer.stop()
}

toolTip.close()
}
}
Expand Down
30 changes: 9 additions & 21 deletions panels/dock/taskmanager/package/AppItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ Item {

Timer {
id: previewTimer
interval: 500
interval: 350
running: false
repeat: false
property int xOffset: 0
Expand All @@ -559,7 +559,12 @@ Item {

function onEntered() {
if (windows.length === 0) {
toolTipShowTimer.start()
toolTip.text = root.itemId === "dde-trash" ? root.name + "-" + taskmanager.Applet.getTrashTipText() : root.name
const point = icon.mapToItem(null, icon.width / 2, icon.height / 2)
icon.DockPanelPositioner.bounding = Qt.rect(point.x, point.y,
toolTip.width, toolTip.height)
icon.DockPanelPositioner.updatePosition()
toolTip.open()
return
}

Expand All @@ -570,16 +575,13 @@ Item {
}

function onExited() {
if (toolTipShowTimer.running) {
toolTipShowTimer.stop()
}
toolTip.close()

if (previewTimer.running) {
previewTimer.stop()
}

if (windows.length === 0) {
toolTip.close()
return
}
closeItemPreview()
Expand Down Expand Up @@ -687,19 +689,6 @@ Item {
toolTipY: icon.DockPanelPositioner.y
visible: false
}

Timer {
id: toolTipShowTimer
interval: 50
onTriggered: {
toolTip.text = root.itemId === "dde-trash" ? root.name + "-" + taskmanager.Applet.getTrashTipText() : root.name
const point = icon.mapToItem(null, icon.width / 2, icon.height / 2)
icon.DockPanelPositioner.bounding = Qt.rect(point.x, point.y,
toolTip.width, toolTip.height)
icon.DockPanelPositioner.updatePosition()
toolTip.open()
}
}
}

Timer {
Expand Down Expand Up @@ -743,7 +732,7 @@ Item {
onWindowsChanged: {
updateWindowIconGeometryTimer.start()
// Close tooltip when window appears
if (windows.length > 0 && toolTip.toolTipVisible) {
if (windows.length > 0) {
toolTip.close()
}
}
Expand All @@ -764,7 +753,6 @@ Item {

onVisibleChanged: {
if (!visible) {
toolTipShowTimer.stop()
toolTip.close()
if (hoverHandler.hovered || previewTimer.running)
closeItemPreview()
Expand Down
16 changes: 3 additions & 13 deletions panels/dock/taskmanager/package/TaskOverflowButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ Item {
}

function togglePopup() {
toolTipShowTimer.stop()
toolTip.close()

if (root.overflowCount <= 0) {
Expand Down Expand Up @@ -198,9 +197,10 @@ Item {
id: overflowHoverHandler
onHoveredChanged: {
if (hovered && !overflowPopup.popupVisible) {
toolTipShowTimer.start()
var point = root.mapToItem(null, root.width / 2, root.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
} else {
toolTipShowTimer.stop()
toolTip.close()
}
}
Expand All @@ -213,16 +213,6 @@ Item {
toolTipY: DockPanelPositioner.y
}

Timer {
id: toolTipShowTimer
interval: 50
onTriggered: {
var point = root.mapToItem(null, root.width / 2, root.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
}
}

PanelPopup {
id: overflowPopup
width: popupContentLoader.item ? popupContentLoader.item.implicitWidth : 0
Expand Down
2 changes: 2 additions & 0 deletions panels/dock/tray/SurfacePopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Item {
Accessible.role: Accessible.ToolTip
Accessible.id: "ToolTip"
id: toolTip
// tray-loader already delays tooltip creation.
showDelay: 0
onToolTipVisibleChanged: function (visible) {
if (visible && menuWindow.visible)
menuWindow.close()
Expand Down
2 changes: 2 additions & 0 deletions panels/dock/tray/TrayItemSurfacePopup.qml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ Item {
Accessible.id: "TrayItemSurfacePopup_Pane_7"
Accessible.role: Accessible.ToolTip
id: toolTip
// tray-loader already delays tooltip creation.
showDelay: 0
property alias shellSurface: toolTipContent.shellSurface
toolTipX: DockPanelPositioner.x
toolTipY: DockPanelPositioner.y
Expand Down
22 changes: 4 additions & 18 deletions panels/dock/tray/package/ActionShowStashDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ AppletItemButton {
// 用户主动点击打开:后续拖拽结束不应自动关闭面板
stashedPopup.wasOpenBeforeDrag = true
}
if (toolTipShowTimer.running) {
toolTipShowTimer.stop()
}
toolTip.close()
}

Expand All @@ -122,28 +119,17 @@ AppletItemButton {
toolTipX: DockPanelPositioner.x
toolTipY: DockPanelPositioner.y
}
Timer {
id: toolTipShowTimer
interval: 200
onTriggered: {
var point = root.mapToItem(null, root.width / 2, root.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
}
}


onHoveredChanged: {
if (stashedPopup.popupVisible) {
return
}

if (hovered) {
toolTipShowTimer.start()
var point = root.mapToItem(null, root.width / 2, root.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
} else {
if (toolTipShowTimer.running) {
toolTipShowTimer.stop()
}

toolTip.close()
}
}
Expand Down
18 changes: 3 additions & 15 deletions panels/dock/tray/package/ActionToggleCollapseDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,13 @@ AppletItemButton {
toolTipX: DockPanelPositioner.x
toolTipY: DockPanelPositioner.y
}
Timer {
id: toolTipShowTimer
interval: 200
onTriggered: {
var point = root.mapToItem(null, root.width / 2, root.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
}
}


onHoveredChanged: {
if (hovered) {
toolTipShowTimer.start()
var point = root.mapToItem(null, root.width / 2, root.height / 2)
toolTip.DockPanelPositioner.bounding = Qt.rect(point.x, point.y, toolTip.width, toolTip.height)
toolTip.open()
} else {
if (toolTipShowTimer.running) {
toolTipShowTimer.stop()
}

toolTip.close()
}
}
Expand Down
Loading