Skip to content

Commit 4e28f2e

Browse files
committed
feat: improve dock popup and tray integration
Improve popup handling and tray integration for the dock. Align popup geometry and tray behavior with the fashion mode workflow.
1 parent 66744c6 commit 4e28f2e

54 files changed

Lines changed: 4041 additions & 459 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,52 @@ if(Qt${QT_VERSION_MAJOR}_VERSION VERSION_GREATER_EQUAL 6.10)
5757
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS WaylandClientPrivate WaylandCompositorPrivate REQUIRED)
5858
endif()
5959
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui)
60+
set(ICU_USE_STATIC_LIBS OFF)
6061
find_package(ICU 74.2 REQUIRED COMPONENTS uc i18n io)
62+
63+
get_filename_component(DS_ICU_PREFIX "${ICU_INCLUDE_DIR}" DIRECTORY)
64+
function(ds_resolve_icu_shared_library output_var library_basename)
65+
set(search_roots
66+
"${DS_ICU_PREFIX}/lib"
67+
"${DS_ICU_PREFIX}/lib/*"
68+
"/usr/local/lib"
69+
"/usr/local/lib/*"
70+
"/usr/lib"
71+
"/usr/lib/*"
72+
"/lib"
73+
"/lib/*"
74+
)
75+
76+
foreach(search_root IN LISTS search_roots)
77+
file(GLOB versioned_candidates LIST_DIRECTORIES false "${search_root}/${library_basename}.so.*")
78+
list(SORT versioned_candidates)
79+
list(REVERSE versioned_candidates)
80+
81+
foreach(candidate IN LISTS versioned_candidates)
82+
get_filename_component(resolved_library "${candidate}" REALPATH)
83+
if (EXISTS "${resolved_library}")
84+
set(${output_var} "${resolved_library}" PARENT_SCOPE)
85+
return()
86+
endif()
87+
endforeach()
88+
89+
file(GLOB soname_candidates LIST_DIRECTORIES false "${search_root}/${library_basename}.so")
90+
foreach(candidate IN LISTS soname_candidates)
91+
get_filename_component(resolved_library "${candidate}" REALPATH)
92+
if (EXISTS "${resolved_library}")
93+
set(${output_var} "${resolved_library}" PARENT_SCOPE)
94+
return()
95+
endif()
96+
endforeach()
97+
endforeach()
98+
99+
message(FATAL_ERROR "Could not resolve an existing ICU shared library for ${library_basename}")
100+
endfunction()
101+
102+
ds_resolve_icu_shared_library(DS_ICU_UC_LIBRARY libicuuc)
103+
ds_resolve_icu_shared_library(DS_ICU_I18N_LIBRARY libicui18n)
104+
ds_resolve_icu_shared_library(DS_ICU_IO_LIBRARY libicuio)
105+
61106
find_package(WaylandProtocols REQUIRED)
62107
find_package(PkgConfig REQUIRED)
63108

cmake/DDEShellPackageMacros.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ function(ds_handle_package_translation)
7979
)
8080

8181
set(package_dirs ${PROJECT_BINARY_DIR}/packages/${_config_PACKAGE}/)
82+
set(translation_lupdate_target ${_config_PACKAGE}_translation_lupdate)
83+
set(translation_lrelease_target ${_config_PACKAGE}_translation_lrelease)
8284

8385
# FIXME: not working on Qt 6.7
8486
# set_source_files_properties(${TRANSLATION_FILES}
@@ -93,10 +95,14 @@ function(ds_handle_package_translation)
9395
TS_FILES ${TRANSLATION_FILES}
9496
SOURCES ${_config_QML_FILES} ${_config_SOURCE_FILES}
9597
QM_FILES_OUTPUT_VARIABLE TRANSLATED_FILES
98+
LUPDATE_TARGET ${translation_lupdate_target}
99+
LRELEASE_TARGET ${translation_lrelease_target}
96100
LUPDATE_OPTIONS -no-obsolete -no-ui-lines -locations none
97101
IMMEDIATE_CALL
98102
)
99103

104+
add_dependencies(${_config_PACKAGE}_translation ${translation_lrelease_target})
105+
100106
# /usr/share/dde-shell/org.deepin.xxx/translations/org.deepin.xxx.qm
101107
install(FILES ${TRANSLATED_FILES} DESTINATION ${DDE_SHELL_TRANSLATION_INSTALL_DIR}/${_config_PACKAGE}/translations)
102108
endfunction()

frame/qml/PanelPopupWindow.qml

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,20 @@ PopupWindow {
1313

1414
property real xOffset: 0
1515
property real yOffset: 0
16+
property real positionXOffset: xOffset
17+
property real positionYOffset: yOffset
1618
property int margins: 10
1719
property int windowThemeType: D.ApplicationHelper.LightType
1820
readonly property bool darkTheme: root.windowThemeType === D.ApplicationHelper.DarkType
1921
property Item currentItem
20-
property int requestedWidth: 10
21-
property int requestedHeight: 10
22+
property bool geometryUpdatePending: false
2223
signal requestUpdateGeometry()
2324
signal updateGeometryFinished()
2425

2526
// order to update screen and (x,y)
2627
property var updateGeometryer : function updateGeometry()
2728
{
28-
if (root.requestedWidth <= 10 || root.requestedHeight <= 10) {
29-
root.width = root.requestedWidth;
30-
root.height = root.requestedHeight;
29+
if (root.width <= 10 || root.height <= 10) {
3130
return;
3231
}
3332
if (!root.transientParent)
@@ -38,12 +37,10 @@ PopupWindow {
3837

3938
let bounding = Qt.rect(root.screen.virtualX + margins, root.screen.virtualY + margins,
4039
root.screen.width - margins * 2, root.screen.height - margins * 2)
41-
let pos = Qt.point(transientParent ? transientParent.x + xOffset : xOffset,
42-
transientParent ? transientParent.y + yOffset : yOffset)
43-
let newX = selectValue(pos.x, bounding.left, bounding.right - root.requestedWidth)
44-
let newY = selectValue(pos.y, bounding.top, bounding.bottom - root.requestedHeight)
45-
46-
root.setWindowGeometry(newX, newY, root.requestedWidth, root.requestedHeight)
40+
let pos = Qt.point(transientParent ? transientParent.x + positionXOffset : positionXOffset,
41+
transientParent ? transientParent.y + positionYOffset : positionYOffset)
42+
x = selectValue(pos.x, bounding.left, bounding.right - root.width)
43+
y = selectValue(pos.y, bounding.top, bounding.bottom - root.height)
4744
}
4845

4946
function selectValue(value, min, max) {
@@ -93,8 +90,6 @@ PopupWindow {
9390
if(root.visible)
9491
return
9592
currentItem = null
96-
root.requestedWidth = 10
97-
root.requestedHeight = 10
9893
root.width = 10
9994
root.height = 10
10095
DS.closeChildrenWindows(root)
@@ -128,18 +123,20 @@ PopupWindow {
128123
}
129124
}
130125

131-
onRequestedHeightChanged: {
132-
requestUpdateGeometry()
133-
}
134-
onRequestedWidthChanged: {
135-
requestUpdateGeometry()
136-
}
137-
onXOffsetChanged: requestUpdateGeometry()
138-
onYOffsetChanged: requestUpdateGeometry()
126+
onHeightChanged: requestUpdateGeometry()
127+
onWidthChanged: requestUpdateGeometry()
128+
onPositionXOffsetChanged: requestUpdateGeometry()
129+
onPositionYOffsetChanged: requestUpdateGeometry()
139130

140131
onRequestUpdateGeometry: {
141132
if (updateGeometryer) {
133+
if (geometryUpdatePending) {
134+
return
135+
}
136+
137+
geometryUpdatePending = true
142138
Qt.callLater(function () {
139+
geometryUpdatePending = false
143140
updateGeometryer()
144141
updateGeometryFinished()
145142
})

frame/qml/PanelToolTip.qml

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Item {
1818
property int toolTipX: 0
1919
property int toolTipY: 0
2020
property bool readyBinding: false
21+
property int closeGraceInterval: 90
2122
readonly property int toolTipTopFrameInset: 1
2223
// WM_NAME, used for kwin.
2324
property string windowTitle: "dde-shell/paneltooltip"
@@ -52,11 +53,19 @@ Item {
5253
if (!toolTipWindow)
5354
return
5455

56+
closeTimer.stop()
5557
readyBinding = Qt.binding(function () {
5658
return toolTipWindow && toolTipWindow.currentItem === control
5759
})
5860

5961
toolTipWindow.currentItem = control
62+
if (toolTipWindow.visible) {
63+
toolTipWindow.title = windowTitle
64+
if ("showAnimated" in toolTipWindow) {
65+
toolTipWindow.showAnimated()
66+
}
67+
return
68+
}
6069
timer.start()
6170
}
6271

@@ -71,7 +80,11 @@ Item {
7180
return
7281

7382
toolTipWindow.title = windowTitle
74-
toolTipWindow.show()
83+
if ("showAnimated" in toolTipWindow) {
84+
toolTipWindow.showAnimated()
85+
} else {
86+
toolTipWindow.show()
87+
}
7588
}
7689
}
7790

@@ -83,14 +96,45 @@ Item {
8396
if (!readyBinding)
8497
return
8598

86-
toolTipWindow.close()
87-
toolTipWindow.currentItem = null
99+
if (closeGraceInterval > 0 && toolTipWindow.visible) {
100+
closeTimer.restart()
101+
return
102+
}
103+
104+
if (toolTipWindow.currentItem !== control) {
105+
return
106+
}
107+
108+
if ("closeAnimated" in toolTipWindow) {
109+
toolTipWindow.closeAnimated()
110+
} else {
111+
toolTipWindow.close()
112+
toolTipWindow.currentItem = null
113+
}
88114
}
89115
function hide()
90116
{
91117
close()
92118
}
93119

120+
Timer {
121+
id: closeTimer
122+
interval: control.closeGraceInterval
123+
repeat: false
124+
onTriggered: {
125+
if (!toolTipWindow || toolTipWindow.currentItem !== control) {
126+
return
127+
}
128+
129+
if ("closeAnimated" in toolTipWindow) {
130+
toolTipWindow.closeAnimated()
131+
} else {
132+
toolTipWindow.close()
133+
toolTipWindow.currentItem = null
134+
}
135+
}
136+
}
137+
94138
Control {
95139
id: toolTip
96140
visible: readyBinding

0 commit comments

Comments
 (0)