Skip to content

Commit e5ff176

Browse files
committed
fix: adjust ui for notification
Using OverlapIndicator to display overlap for notification. Drop NotifyItemBackground's blur(it can't work), and adjust it's opacity to from 0.7 to 1. Drop blur of NotificationCenter. Drop window's blur, and window is transparent. pms: BUG-284903
1 parent 964cf2f commit e5ff176

File tree

12 files changed

+174
-162
lines changed

12 files changed

+174
-162
lines changed

panels/notification/bubble/package/Bubble.qml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import QtQuick.Controls 2.15
88
import org.deepin.ds 1.0
99
import org.deepin.dtk 1.0 as D
1010

11-
D.Control {
11+
Control {
1212
id: control
13+
height: loader.height
1314
property var bubble
1415
onHoveredChanged: function () {
1516
if (control.hovered) {
@@ -19,7 +20,9 @@ D.Control {
1920
}
2021
}
2122

22-
contentItem: Loader {
23+
Loader {
24+
id: loader
25+
width: control.width
2326
sourceComponent: bubble.level <= 1 ? normalCom : overlayCom
2427
}
2528
Component {
@@ -34,8 +37,4 @@ D.Control {
3437
bubble: control.bubble
3538
}
3639
}
37-
38-
z: bubble.level <= 1 ? 0 : 1 - bubble.level
39-
40-
// background: D.FloatingPanel { }
4140
}

panels/notification/bubble/package/NormalBubble.qml

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,40 +9,26 @@ import org.deepin.ds 1.0
99
import org.deepin.ds.notification 1.0
1010
import org.deepin.dtk 1.0 as D
1111

12-
D.Control {
12+
NotifyItemContent {
1313
id: control
1414
property var bubble
1515

16-
contentItem: NotifyItemContent {
17-
width: 360
18-
appName: bubble.appName
19-
iconName: bubble.iconName
20-
date: bubble.timeTip
21-
actions: bubble.actions
22-
title: bubble.summary
23-
content: bubble.body
24-
strongInteractive: bubble.urgency === 2
25-
contentIcon: bubble.bodyImagePath
26-
onRemove: function () {
27-
console.log("remove notify", bubble.appName)
28-
Applet.close(bubble.index)
29-
}
30-
onActionInvoked: function (actionId) {
31-
console.log("action notify", bubble.appName, actionId)
32-
Applet.invokeAction(bubble.index, actionId)
33-
}
16+
width: 360
17+
appName: bubble.appName
18+
iconName: bubble.iconName
19+
date: bubble.timeTip
20+
actions: bubble.actions
21+
title: bubble.summary
22+
content: bubble.body
23+
strongInteractive: bubble.urgency === 2
24+
contentIcon: bubble.bodyImagePath
25+
onRemove: function () {
26+
console.log("remove notify", bubble.appName)
27+
Applet.close(bubble.index)
3428
}
35-
36-
z: bubble.level <= 1 ? 0 : 1 - bubble.level
37-
38-
background: Rectangle {
39-
width: 360
40-
radius: 12
41-
opacity: {
42-
if (bubble.level === 1)
43-
return 0.8
44-
return 1
45-
}
29+
onActionInvoked: function (actionId) {
30+
console.log("action notify", bubble.appName, actionId)
31+
Applet.invokeAction(bubble.index, actionId)
4632
}
4733

4834
MouseArea {

panels/notification/bubble/package/OverlayBubble.qml

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,35 @@ import QtQuick.Controls 2.15
77
import QtQuick.Layouts 1.15
88

99
import org.deepin.ds 1.0
10+
import org.deepin.ds.notification 1.0
1011
import org.deepin.dtk 1.0 as D
1112

12-
D.Control {
13+
Item {
1314
id: control
1415
property var bubble
1516
readonly property int radius: 12
1617

17-
contentItem: ColumnLayout {
18-
spacing: 0
19-
Rectangle {
20-
visible: bubble.level > 2
21-
Layout.bottomMargin: -34
22-
Layout.alignment: Qt.AlignHCenter
23-
Layout.preferredWidth: bubbleContent.width - 2 * control.radius
24-
Layout.preferredHeight: 40
25-
radius: control.radius
26-
opacity: 0.8
27-
z: control.z + control.z + 1
28-
}
29-
30-
Rectangle {
31-
Layout.bottomMargin: -34
32-
Layout.alignment: Qt.AlignHCenter
33-
Layout.preferredWidth: bubbleContent.width - control.radius
34-
Layout.preferredHeight: 40
35-
radius: control.radius
36-
opacity: 0.8
37-
z: control.z + control.z + 1
38-
}
39-
40-
NormalBubble {
41-
id: bubbleContent
42-
Layout.fillWidth: true
43-
Layout.maximumWidth: 360
44-
bubble: control.bubble
18+
height: bubbleContent.height + indicator.height
19+
OverlapIndicator {
20+
id: indicator
21+
width: parent.width
22+
count: bubble.level - 1
23+
revert: true
24+
anchors {
25+
top: parent.top
26+
left: parent.left
27+
leftMargin: radius
28+
right: parent.right
29+
rightMargin: radius
4530
}
4631
}
4732

48-
z: bubble.level <= 1 ? 0 : 1 - bubble.level
49-
50-
background: Rectangle {
51-
implicitWidth: 200
52-
radius: control.radius
53-
opacity: 1
54-
color: "transparent"
33+
NormalBubble {
34+
id: bubbleContent
35+
width: parent.width
36+
bubble: control.bubble
37+
anchors {
38+
top: indicator.bottom
39+
}
5540
}
5641
}

panels/notification/bubble/package/main.qml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ Window {
4040
DLayerShellWindow.bottomMargin: windowMargin(2)
4141
palette: DTK.palette
4242
ColorSelector.family: Palette.CrystalColor
43-
DWindow.enabled: true
4443
DWindow.windowEffect: PlatformHandle.EffectNoBorder | PlatformHandle.EffectNoShadow
4544
color: "transparent"
4645
DWindow.windowRadius: 0
46+
DWindow.enabled: false
4747
// DWindow.enableBlurWindow: true
4848
screen: Qt.application.screens[0]
4949
// TODO `Qt.application.screens[0]` maybe invalid, why screen is changed.
@@ -58,6 +58,7 @@ Window {
5858
anchors {
5959
centerIn: parent
6060
margins: 10
61+
topMargin: 15
6162
}
6263

6364
spacing: 10

panels/notification/center/Main.qml

Lines changed: 0 additions & 41 deletions
This file was deleted.

panels/notification/center/OverlapNotify.qml

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,28 +82,4 @@ NotifyItem {
8282
}
8383
Keys.onEnterPressed: root.expand()
8484
Keys.onReturnPressed: root.expand()
85-
86-
component OverlapIndicator: Control {
87-
id: overlap
88-
89-
required property var count
90-
91-
contentItem: ColumnLayout {
92-
spacing: 0
93-
Repeater {
94-
model: overlap.count
95-
96-
delegate: NotifyItemBackground {
97-
Layout.topMargin: -overlapItemRadius
98-
Layout.alignment: Qt.AlignHCenter
99-
Layout.preferredWidth: overlap.width - (index) * overlapItemRadius *2
100-
Layout.preferredHeight: overlapItemRadius * 2
101-
radius: overlapItemRadius
102-
z: -index
103-
}
104-
}
105-
}
106-
107-
background: BoundingRectangle {}
108-
}
10985
}

panels/notification/center/package/main.qml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,14 @@ Window {
4242
DLayerShellWindow.bottomMargin: windowMargin(2) + 10
4343
palette: DTK.palette
4444
ColorSelector.family: Palette.CrystalColor
45-
DWindow.enabled: true
4645
DWindow.windowEffect: PlatformHandle.EffectNoBorder | PlatformHandle.EffectNoShadow
47-
DWindow.windowRadius: DTK.platformTheme.windowRadius
46+
// DWindow.windowRadius: DTK.platformTheme.windowRadius
4847
// DWindow.enableSystemResize: false
4948
// DWindow.enableSystemMove: false
49+
DWindow.windowRadius: 0
50+
DWindow.enabled: false
5051
color: "transparent"
51-
DWindow.enableBlurWindow: true
52+
// DWindow.enableBlurWindow: true
5253
screen: Qt.application.screens[0]
5354
// TODO `Qt.application.screens[0]` maybe invalid, why screen is changed.
5455
onScreenChanged: {

panels/notification/plugin/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ qt_add_qml_module(notificationplugin
1717
NotifyItemContent.qml
1818
NotifyAction.qml
1919
SettingActionButton.qml
20+
OverlapIndicator.qml
2021
OUTPUT_DIRECTORY
2122
${PROJECT_BINARY_DIR}/plugins/org/deepin/ds/notification/
2223
)

panels/notification/plugin/NotifyAction.qml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ Control {
7575
actionInvoked(actionData.id)
7676
}
7777

78+
Loader {
79+
anchors.fill: parent
80+
active: actionButton.activeFocus
81+
82+
sourceComponent: FocusBoxBorder {
83+
radius: 6
84+
color: palette.highlight
85+
}
86+
}
87+
7888
background: NotifyItemBackground {
7989
implicitHeight: 30
8090
implicitWidth: 50

panels/notification/plugin/NotifyItemBackground.qml

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@ import QtQuick
66
import org.deepin.dtk 1.0
77
import org.deepin.ds.notification
88

9-
FloatingPanel {
10-
id: root
11-
radius: 12
12-
backgroundColor: Palette {
9+
Control {
10+
id: control
11+
12+
padding: radius / 2
13+
14+
property int radius: 12
15+
property Palette backgroundColor: Palette {
1316
normal {
1417
common: ("transparent")
15-
crystal: Qt.rgba(240 / 255.0, 240 / 255.0, 240 / 255.0, 0.7)
18+
crystal: Qt.rgba(240 / 255.0, 240 / 255.0, 240 / 255.0, 1)
1619
}
1720
normalDark {
18-
crystal: Qt.rgba(24 / 255.0, 24 / 255.0, 24 / 255.0, 0.7)
21+
crystal: Qt.rgba(24 / 255.0, 24 / 255.0, 24 / 255.0, 1)
1922
}
2023
}
21-
insideBorderColor: Palette {
24+
property Palette insideBorderColor: Palette {
2225
normal {
2326
common: ("transparent")
2427
crystal: Qt.rgba(255 / 255.0, 255 / 255.0, 255 / 255.0, 0.2)
@@ -27,7 +30,7 @@ FloatingPanel {
2730
crystal: Qt.rgba(255 / 255.0, 255 / 255.0, 255 / 255.0, 0.1)
2831
}
2932
}
30-
outsideBorderColor: Palette {
33+
property Palette outsideBorderColor: Palette {
3134
normal {
3235
common: ("transparent")
3336
crystal: Qt.rgba(0, 0, 0, 0.1)
@@ -36,7 +39,7 @@ FloatingPanel {
3639
crystal: Qt.rgba(0, 0, 0, 0.6)
3740
}
3841
}
39-
dropShadowColor: Palette {
42+
property Palette dropShadowColor: Palette {
4043
normal {
4144
common: ("transparent")
4245
crystal: Qt.rgba(0, 0, 0, 0.2)
@@ -45,4 +48,49 @@ FloatingPanel {
4548
crystal: Qt.rgba(0, 0, 0, 0.4)
4649
}
4750
}
51+
52+
background: Item {
53+
id: blur
54+
implicitWidth: 180
55+
implicitHeight: 40
56+
57+
Loader {
58+
anchors.fill: backgroundRect
59+
active: control.dropShadowColor
60+
sourceComponent: BoxShadow {
61+
shadowOffsetX: 0
62+
shadowOffsetY: 6
63+
shadowColor: control.ColorSelector.dropShadowColor
64+
shadowBlur: 20
65+
cornerRadius: backgroundRect.radius
66+
spread: 0
67+
hollow: true
68+
}
69+
}
70+
71+
Rectangle {
72+
id: backgroundRect
73+
anchors.fill: parent
74+
radius: control.radius
75+
color: control.ColorSelector.backgroundColor
76+
}
77+
78+
Loader {
79+
anchors.fill: backgroundRect
80+
active: control.insideBorderColor && control.ColorSelector.controlTheme === ApplicationHelper.DarkType
81+
sourceComponent: InsideBoxBorder {
82+
radius: backgroundRect.radius
83+
color: control.ColorSelector.insideBorderColor
84+
}
85+
}
86+
87+
Loader {
88+
anchors.fill: backgroundRect
89+
active: control.outsideBorderColor
90+
sourceComponent: OutsideBoxBorder {
91+
radius: backgroundRect.radius
92+
color: control.ColorSelector.outsideBorderColor
93+
}
94+
}
95+
}
4896
}

0 commit comments

Comments
 (0)