4
0
mirror of https://github.com/QuasarApp/SimpleQmlNotify.git synced 2025-05-05 09:49:35 +00:00

There were fixed issues

This commit is contained in:
Alex 2023-04-11 12:06:21 +03:00
parent 84702f4835
commit 0830ddfc0d
4 changed files with 51 additions and 40 deletions

@ -58,6 +58,7 @@ Popup {
width: parent.width
height: parent.height * 0.9
clip: true
spacing: 5
model: historyModel
anchors {
top: toolbar.bottom
@ -88,7 +89,6 @@ Popup {
value: true
}
NumberAnimation {
target: swipeDelegate
property: "height"
@ -97,7 +97,6 @@ Popup {
easing.type: Easing.InOutQuad
}
PropertyAction {
target: swipeDelegate;
property: "ListView.delayRemove"
@ -105,41 +104,47 @@ Popup {
}
}
Image {
id: notificationIcon
width: notificationIcon.sourceSize.width * 0.25
height: notificationIcon.sourceSize.height * 0.25
source: model.icon
fillMode: Image.PreserveAspectFit
anchors {
left: parent.left
leftMargin: parent.width * 0.1
verticalCenter: parent.verticalCenter
}
}
contentItem: Row {
width: parent.width
spacing: width * 0.35
Column {
id: column
width: parent.width * 0.25
anchors {
horizontalCenter: parent.horizontalCenter
verticalCenter: parent.verticalCenter
Image {
id: notificationIcon
width: notificationIcon.sourceSize.width * 0.15
height: notificationIcon.sourceSize.height * 0.15
source: model.icon
fillMode: Image.PreserveAspectFit
anchors {
verticalCenter: parent.verticalCenter
}
}
Label {
id: notificationTitle
text: qsTr(model.title)
font.pointSize: 12
clip: true
}
Column {
id: column
width: parent.width - notificationIcon.width * 0.2
anchors {
verticalCenter: parent.verticalCenter
}
Label {
id: notificationText
text: qsTr(model.text)
font.pointSize: 12
wrapMode: Text.WordWrap
clip: true
linkColor: Material.accent
Label {
id: notificationTitle
width: parent.width
text: qsTr(model.title)
font.pointSize: 12
elide: Label.ElideRight
}
Label {
id: notificationText
width: parent.width
text: qsTr(model.text)
font.pointSize: 12
elide: {
console.log(notificationText.width, parent.width, notificationText.width < parent.width)
Label.ElideRight
}
linkColor: Material.accent
}
}
}
@ -152,11 +157,10 @@ Popup {
height: parent.height
anchors.right: parent.right
SwipeDelegate.onClicked: notificationLV.model.removeNotificationItemAtIndex(index)
background: Rectangle {
color: deleteLabel.SwipeDelegate.pressed? "red" : "gray"
color: "red"
}
}
}

@ -76,7 +76,7 @@ Item {
NotificationHistoryView {
id: history
width: parent.width * 0.6
width: parent.width * 0.8
height: parent.height * 0.5
anchors.centerIn: parent
}

@ -13,8 +13,12 @@ namespace QmlNotificationService {
NotificationService::NotificationService(QObject * ptr): QObject (ptr) {
qRegisterMetaType<NotificationData>("NotificationData");
qRegisterMetaType<QList<NotificationData>> ("QList<NotificationData>");
qRegisterMetaType<QSharedPointer<HistoryNotificationsModel>>("QSharedPointer<HistoryNotificationsModel>");
setNotify("Test", "Test");
_history = new HistoryNotificationsModel();
QQmlEngine::setObjectOwnership(_history, QQmlEngine::CppOwnership);
}
NotificationService::~NotificationService() {
delete _history;
}
NotificationData NotificationService::notify() const {
@ -106,7 +110,7 @@ NotificationService *NotificationService::getService() {
}
QObject *NotificationService::history() const{
return _history.data();
return _history;
}
}

@ -7,6 +7,7 @@
#include <QHash>
#include <QObject>
#include <QSharedPointer>
#include <QQmlEngine>
namespace QmlNotificationService {
@ -121,6 +122,8 @@ public:
*/
QObject* history() const;
~NotificationService();
signals:
/**
* @brief notifyChanged This signal emited whet the notificator (Ths object) received a new notification message.
@ -147,7 +150,7 @@ private:
QHash<int, Listner> _listners;
NotificationData _question;
NotificationData _notify;
QSharedPointer<HistoryNotificationsModel> _history;
HistoryNotificationsModel* _history = nullptr;
};
}