From d7ecbf2e776be7305287509403aaca54eed894b2 Mon Sep 17 00:00:00 2001 From: Ye ShanShan Date: Thu, 14 Nov 2024 14:32:09 +0800 Subject: [PATCH] fix: incomplete display of time for notification ContentItem's height is not large enough. Bug: https://pms.uniontech.com/bug-view-283509.html --- panels/notification/center/CMakeLists.txt | 5 +++++ panels/notification/center/NormalNotify.qml | 2 +- .../notification/center/NotifyItemContent.qml | 19 ++++++++++++++++--- panels/notification/center/NotifyStyle.qml | 16 ++++++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 panels/notification/center/NotifyStyle.qml diff --git a/panels/notification/center/CMakeLists.txt b/panels/notification/center/CMakeLists.txt index 9ebce40e6..ab86f257e 100644 --- a/panels/notification/center/CMakeLists.txt +++ b/panels/notification/center/CMakeLists.txt @@ -2,12 +2,17 @@ # # SPDX-License-Identifier: GPL-3.0-or-later +set_source_files_properties(NotifyStyle.qml PROPERTIES + QT_QML_SINGLETON_TYPE TRUE +) + qt_add_qml_module(notificationcenterpanel PLUGIN_TARGET notificationcenterpanelplugin URI org.deepin.ds.notificationcenter VERSION 1.0 QML_FILES NotifyCenter.qml + NotifyStyle.qml NotifyStaging.qml NotifyHeader.qml NotifyView.qml diff --git a/panels/notification/center/NormalNotify.qml b/panels/notification/center/NormalNotify.qml index 9203d028f..b91dad713 100644 --- a/panels/notification/center/NormalNotify.qml +++ b/panels/notification/center/NormalNotify.qml @@ -32,7 +32,7 @@ NotifyItem { } contentItem: NotifyItemContent { - + width: parent.width appName: root.appName iconName: root.iconName content: root.content diff --git a/panels/notification/center/NotifyItemContent.qml b/panels/notification/center/NotifyItemContent.qml index 4e6b4cc50..051ba56dd 100644 --- a/panels/notification/center/NotifyItemContent.qml +++ b/panels/notification/center/NotifyItemContent.qml @@ -6,12 +6,17 @@ import QtQuick import QtQuick.Controls import QtQuick.Layouts import org.deepin.dtk 1.0 +import org.deepin.dtk.style 1.0 as DStyle import org.deepin.ds.notificationcenter NotifyItem { id: root + implicitHeight:Math.max(DStyle.Style.control.implicitHeight(root), + actionPlaceHolder.active ? root.miniContentHeight + actionPlaceHolder.height : 0) property bool closeVisible: root.hovered || root.activeFocus + property int miniContentHeight: NotifyStyle.contentItem.miniHeight + // placeHolder to receive MouseEvent Control { id: closePlaceHolder @@ -111,6 +116,12 @@ NotifyItem { contentItem: RowLayout { spacing: 0 + Binding { + target: root + property: "miniContentHeight" + value: 26 + NotifyStyle.contentItem.topMargin + NotifyStyle.contentItem.bottomMargin + } + DciIcon { name: root.iconName sourceSize: Qt.size(24, 24) @@ -127,13 +138,14 @@ NotifyItem { Layout.alignment: Qt.AlignLeft | Qt.AlignTop Layout.rightMargin: 10 Layout.leftMargin: 10 - Layout.topMargin: 4 - Layout.bottomMargin: 8 + Layout.topMargin: NotifyStyle.contentItem.topMargin + Layout.bottomMargin: NotifyStyle.contentItem.bottomMargin Layout.fillWidth: true Layout.fillHeight: true - Layout.minimumHeight: 40 + Layout.minimumHeight: NotifyStyle.contentItem.miniHeight Layout.maximumHeight: 240 RowLayout { + id: firstLine spacing: 0 Layout.fillWidth: true Layout.preferredHeight: 24 @@ -213,6 +225,7 @@ NotifyItem { Layout.minimumHeight: 16 Layout.alignment: Qt.AlignRight active: root.contentIcon !== "" + visible: active // TODO DciIcon's bounding can't be limit by maximumWidth. sourceComponent: Image { anchors.fill: parent diff --git a/panels/notification/center/NotifyStyle.qml b/panels/notification/center/NotifyStyle.qml new file mode 100644 index 000000000..c434a33c3 --- /dev/null +++ b/panels/notification/center/NotifyStyle.qml @@ -0,0 +1,16 @@ +// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +import QtQuick +pragma Singleton + +QtObject { + id: root + + property QtObject contentItem: QtObject { + property int topMargin: 4 + property int bottomMargin: 8 + property int miniHeight: 40 + } +}