Move notificationswapper to common, change defaul wrap mode
This commit is contained in:
@@ -8,12 +8,18 @@ import qs.Services
|
||||
import qs.Widgets
|
||||
import qs.Common.Styled
|
||||
import qs.Common
|
||||
import QtQuick.Window
|
||||
import Quickshell.Wayland
|
||||
|
||||
PopupWindow {
|
||||
PanelWindow {
|
||||
id: notificationRoot
|
||||
|
||||
anchor.item: root
|
||||
anchors {
|
||||
left: true
|
||||
bottom: true
|
||||
right: true
|
||||
top: true
|
||||
}
|
||||
|
||||
implicitWidth: screen.width
|
||||
// implicitWidth: 400
|
||||
implicitHeight: screen.height
|
||||
@@ -21,6 +27,14 @@ PopupWindow {
|
||||
visible: true
|
||||
signal clear
|
||||
|
||||
WlrLayershell.keyboardFocus: WlrKeyboardFocus.OnDemand
|
||||
|
||||
contentItem {
|
||||
focus: true
|
||||
Keys.onPressed: event => {
|
||||
if (event.key == Qt.Key_Escape) notificationRoot.clear();
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: notificationRoot.clear()
|
||||
@@ -32,7 +46,6 @@ PopupWindow {
|
||||
anchors{
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
topMargin: 40
|
||||
}
|
||||
border.width: 1
|
||||
color: Theme.color2
|
||||
@@ -60,7 +73,7 @@ PopupWindow {
|
||||
}
|
||||
}
|
||||
StyledText {
|
||||
anchors.centerIn: parent
|
||||
anchors.fill: parent
|
||||
text: "NOTIFICAÇÕES"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
import Quickshell
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell.Widgets
|
||||
import qs.Common.Styled
|
||||
|
||||
BackgroundRectangle {
|
||||
id: notificationWrapper
|
||||
|
||||
signal dismissed
|
||||
signal timedout
|
||||
|
||||
property bool hasImage: notification?.image ? true : false
|
||||
property bool clicked: false
|
||||
property var notification: null
|
||||
property bool startTimer: false
|
||||
property int timerDuration: 2000
|
||||
property bool firstTime: true
|
||||
|
||||
property string image: {
|
||||
if (hasImage) {
|
||||
return notification?.image;
|
||||
}
|
||||
if (notification?.appIcon === "") {
|
||||
return "";
|
||||
}
|
||||
return Quickshell.iconPath(notification?.appIcon);
|
||||
}
|
||||
property real targetHeight: notifLayout.implicitHeight + 20
|
||||
|
||||
implicitWidth: 400
|
||||
implicitHeight: 0
|
||||
// implicitHeight: Math.max(notifLayout.implicitHeight, 100)
|
||||
|
||||
Component.onCompleted: {
|
||||
notificationWrapper.implicitHeight = targetHeight
|
||||
}
|
||||
clip: true
|
||||
|
||||
Behavior on implicitHeight {
|
||||
SequentialAnimation {
|
||||
NumberAnimation {
|
||||
duration: 150
|
||||
easing.type: Easing.OutCubic
|
||||
}
|
||||
ScriptAction {
|
||||
script: {
|
||||
if(clicked) notificationWrapper.dismissed()
|
||||
if(notificationWrapper.implicitHeight === 0) notificationWrapper.timedout()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
notificationWrapper.clicked = true
|
||||
notificationWrapper.implicitHeight = 0
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: notifTimer
|
||||
|
||||
interval: timerDuration
|
||||
running: notificationWrapper.startTimer
|
||||
|
||||
onTriggered: {
|
||||
notificationWrapper.implicitHeight = 0;
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
id: notifLayout
|
||||
|
||||
implicitHeight: Math.max(iconImage.implicitHeight, gridRoot.implicitHeight)
|
||||
|
||||
anchors {
|
||||
fill: parent
|
||||
}
|
||||
|
||||
IconImage {
|
||||
id: iconImage
|
||||
|
||||
Layout.alignment: Qt.AlignLeft| Qt.AlignVCenter
|
||||
Layout.leftMargin: 10
|
||||
implicitSize: 80
|
||||
visible: notificationWrapper.image? true: false
|
||||
source: notificationWrapper.image
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: gridRoot
|
||||
|
||||
Layout.leftMargin: 10
|
||||
Layout.rightMargin: 10
|
||||
implicitHeight: summaryRectangle.implicitHeight + bodyRectangle.implicitHeight
|
||||
|
||||
spacing: 5
|
||||
|
||||
ForegroundRectangle {
|
||||
id: summaryRectangle
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
||||
implicitHeight: summaryText.implicitHeight + 10
|
||||
|
||||
visible: summaryText.text ? true : false
|
||||
|
||||
StyledText {
|
||||
id: summaryText
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
text: notificationWrapper.notification? notificationWrapper.notification.summary : ""
|
||||
}
|
||||
}
|
||||
|
||||
ForegroundRectangle {
|
||||
id: bodyRectangle
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.columnSpan: 5
|
||||
|
||||
implicitHeight: bodyText.implicitHeight + 10
|
||||
|
||||
visible: bodyText.text ? true : false
|
||||
|
||||
StyledText {
|
||||
id: bodyText
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
text: notificationWrapper.notification? notificationWrapper.notification.body : ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user