From 1c6e7f06bcd4e8d178932cf4b0cfc5c67168dd2e Mon Sep 17 00:00:00 2001 From: master <master@Ubuntu20.04.6.myguest.virtualbox.org> Date: Wed, 5 Apr 2023 15:23:46 +0300 Subject: [PATCH 01/21] There were added historynotificationsmodel and historynotificationsview --- NotifyModule.qrc | 1 + NotifyModule/NotificationForm.qml | 12 +- NotifyModule/NotificationHistoryView.qml | 171 +++++++++++++++++++++++ NotifyModule/NotificationServiceView.qml | 7 + historynotificationsmodel.cpp | 59 ++++++++ historynotificationsmodel.h | 40 ++++++ notificationservice.cpp | 13 +- notificationservice.h | 7 +- 8 files changed, 298 insertions(+), 12 deletions(-) create mode 100644 NotifyModule/NotificationHistoryView.qml create mode 100644 historynotificationsmodel.cpp create mode 100644 historynotificationsmodel.h diff --git a/NotifyModule.qrc b/NotifyModule.qrc index 68a69a8..ab6d6ac 100644 --- a/NotifyModule.qrc +++ b/NotifyModule.qrc @@ -16,6 +16,7 @@ <file>qmlNotify_languages/fr.qm</file> <file>qmlNotify_languages/de.qm</file> <file>qmlNotify_languages/zh.qm</file> + <file>NotifyModule/NotificationHistoryView.qml</file> </qresource> <qresource prefix="/icons"> <file alias="warning">icons/Warning.png</file> diff --git a/NotifyModule/NotificationForm.qml b/NotifyModule/NotificationForm.qml index fc56a2f..86ff02b 100644 --- a/NotifyModule/NotificationForm.qml +++ b/NotifyModule/NotificationForm.qml @@ -61,6 +61,15 @@ BasePopUp { Layout.fillWidth: true } + ToolButton { + text: "History" + font.pointSize: 10 + onClicked: { + history.open() + popup.close() + } + } + ToolButton { text: "X" onClicked: { @@ -151,10 +160,9 @@ BasePopUp { } - - } } + title: titleText } diff --git a/NotifyModule/NotificationHistoryView.qml b/NotifyModule/NotificationHistoryView.qml new file mode 100644 index 0000000..00b535c --- /dev/null +++ b/NotifyModule/NotificationHistoryView.qml @@ -0,0 +1,171 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Controls.Material 2.15 + +Popup { + id: root + + readonly property var historyModel: historyNotificationsModel + + ToolBar { + id: toolbar + width: parent.width + height: parent.height * 0.1 + anchors { + top: parent.top + left: parent.left + right: parent.right + } + + ToolButton { + id: clearAllButton + text: qsTr("Clear All") + height: parent.height + font.pointSize: 10 + anchors { + left: parent.left + verticalCenter: parent.verticalCenter + } + + onClicked: historyModel.clearAllHistory() + } + + Label { + id: toolbarTitle + text: qsTr("Notification history") + font.pointSize: 12 + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + } + + ToolButton { + id: closePopupButton + text: "X" + font.pointSize: 12 + anchors { + right: parent.right + verticalCenter: parent.verticalCenter + } + + onClicked: root.close() + } + } + + ListView { + id: notificationLV + width: parent.width + height: parent.height * 0.9 + clip: true + model: historyModel + anchors { + top: toolbar.bottom + horizontalCenter: parent.horizontalCenter + } + + ScrollBar.vertical: ScrollBar { + hoverEnabled: true + active: hovered || pressed + anchors { + top: notificationLV.top + right: notificationLV.right + bottom: notificationLV.bottom + } + } + + delegate: SwipeDelegate { + id: swipeDelegate + text: model.notificationValue + width: notificationLV.width + height: notificationLV.height * 0.15 + + ListView.onRemove: SequentialAnimation { + + PropertyAction { + target: swipeDelegate + property: "ListView.delayRemove" + value: true + } + + + NumberAnimation { + target: swipeDelegate + property: "height" + to: 0 + duration: 20 + easing.type: Easing.InOutQuad + } + + + PropertyAction { + target: swipeDelegate; + property: "ListView.delayRemove" + value: false + } + } + + 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 + } + } + + Column { + id: column + width: parent.width * 0.25 + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + + Label { + id: notificationTitle + text: qsTr(model.title) + font.pointSize: 12 + clip: true + } + + Label { + id: notificationText + text: qsTr(model.text) + font.pointSize: 12 + wrapMode: Text.WordWrap + clip: true + linkColor: Material.accent + } + } + + swipe.right: Label { + id: deleteLabel + text: qsTr("Delete") + color: "white" + verticalAlignment: Label.AlignVCenter + padding: 12 + height: parent.height + anchors.right: parent.right + + + SwipeDelegate.onClicked: notificationLV.model.removeNotificationItemAtIndex(index) + + background: Rectangle { + color: deleteLabel.SwipeDelegate.pressed? "red" : "gray" + } + } + } + } + + Connections { + target: historyModel + function onDataInserted() { + console.log(Object.keys(historyModel)) + } + } +} diff --git a/NotifyModule/NotificationServiceView.qml b/NotifyModule/NotificationServiceView.qml index 82ff844..27dd1c7 100644 --- a/NotifyModule/NotificationServiceView.qml +++ b/NotifyModule/NotificationServiceView.qml @@ -73,4 +73,11 @@ Item { questionMsgBox._show(); } } + + NotificationHistoryView { + id: history + width: parent.width * 0.6 + height: parent.height * 0.5 + anchors.centerIn: parent + } } diff --git a/historynotificationsmodel.cpp b/historynotificationsmodel.cpp new file mode 100644 index 0000000..b1d5eb2 --- /dev/null +++ b/historynotificationsmodel.cpp @@ -0,0 +1,59 @@ +#include "historynotificationsmodel.h" +#include <QDebug> +HistoryNotificationsModel::HistoryNotificationsModel(QObject *parent) + : QAbstractListModel{parent} { +} + +int HistoryNotificationsModel::rowCount(const QModelIndex &parent) const { + Q_UNUSED(parent); + return notificationsList.count(); +} + +QVariant HistoryNotificationsModel::data(const QModelIndex &index, int role) const { + if(index.row() < 0 || index.row() >= notificationsList.count()) + return QVariant(); + + switch (role) { + case Icon: + return notificationsList.at(index.row()).img(); + case Title: + return notificationsList.at(index.row()).title(); + case Message: + return notificationsList.at(index.row()).text(); + case Type: + return notificationsList.at(index.row()).type(); + default: + break; + } + return QVariant(); +} + +QHash<int, QByteArray> HistoryNotificationsModel::roleNames() const { + QHash<int, QByteArray> roles; + roles[Icon] = "icon"; + roles[Title] = "title"; + roles[Message] = "text"; + roles[Type] = "type"; + return roles; +} + + +void HistoryNotificationsModel::setHistory(const QmlNotificationService::NotificationData ¬ificationData) { + beginResetModel(); + notificationsList.push_back(notificationData); + endResetModel(); + emit dataInserted(); +} + +void HistoryNotificationsModel::clearAllHistory() { + beginResetModel(); + notificationsList.clear(); + endResetModel(); +} + +void HistoryNotificationsModel::removeNotificationItemAtIndex(const int elementIndex) { + beginResetModel(); + notificationsList.removeAt(elementIndex); + endResetModel(); +} + diff --git a/historynotificationsmodel.h b/historynotificationsmodel.h new file mode 100644 index 0000000..66432ae --- /dev/null +++ b/historynotificationsmodel.h @@ -0,0 +1,40 @@ +#ifndef HISTORYNOTIFICATIONMODEL_H +#define HISTORYNOTIFICATIONMODEL_H + +#include <QAbstractListModel> +#include "notificationdata.h" + +class HistoryNotificationsModel : public QAbstractListModel +{ + Q_OBJECT + + enum Roles { + Icon = Qt::UserRole + 1, + Title, + Message, + Type + }; + + Q_PROPERTY(int notificationsCount READ getNotificationsCount WRITE setNotificationsCount NOTIFY notificationsCountChanged) + +public: + explicit HistoryNotificationsModel(QObject *parent = nullptr); + + int rowCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; + QHash<int, QByteArray> roleNames() const override; + void setHistory(const QmlNotificationService::NotificationData ¬ificationData); + Q_INVOKABLE void clearAllHistory(); + + Q_INVOKABLE void removeNotificationItemAtIndex(const int index); + + +signals: + void dataInserted(); + +private: + QList<QmlNotificationService::NotificationData> notificationsList; + int m_notificationsCount; +}; + +#endif // HISTORYNOTIFICATIONMODEL_H diff --git a/notificationservice.cpp b/notificationservice.cpp index c461c8e..2f7430d 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -13,7 +13,6 @@ namespace QmlNotificationService { NotificationService::NotificationService(QObject * ptr): QObject (ptr) { qRegisterMetaType<NotificationData>("NotificationData"); qRegisterMetaType<QList<NotificationData>> ("QList<NotificationData>"); - } NotificationData NotificationService::notify() const { @@ -25,9 +24,9 @@ NotificationData NotificationService::question() const { } void NotificationService::setNotify(const NotificationData& notify) { - if (_notify != notify) - _history.push_back(_notify); - + if (_notify != notify) { + _history.setHistory(notify); + } _notify = notify; emit notifyChanged(); @@ -104,8 +103,8 @@ NotificationService *NotificationService::getService() { return service; } -const QList<NotificationData> &NotificationService::history() const { - return _history; -} +//const QList<NotificationData> &NotificationService::history() const { +// return _history; +//} } diff --git a/notificationservice.h b/notificationservice.h index d6b0a7e..4eabdbb 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -2,6 +2,7 @@ #define NOTIFICATIONSERVICE_H #include "notificationdata.h" +#include "historynotificationsmodel.h" #include <QHash> #include <QObject> @@ -23,7 +24,7 @@ class NOTIFYSERVICESHARED_EXPORT NotificationService: public QObject Q_PROPERTY(NotificationData notify READ notify NOTIFY notifyChanged) Q_PROPERTY(NotificationData question READ question NOTIFY questionChanged) - Q_PROPERTY(QList<NotificationData> history READ history NOTIFY notifyChanged) + //Q_PROPERTY(HistoryNotificationModel history READ history NOTIFY notifyChanged) public: /** @@ -117,7 +118,7 @@ public: * @brief history - This method used for return notify list. * @return list of all notify. */ - const QList<NotificationData> & history() const; + // const HistoryNotificationModel & history() const; signals: /** @@ -145,7 +146,7 @@ private: QHash<int, Listner> _listners; NotificationData _question; NotificationData _notify; - QList<NotificationData> _history; + HistoryNotificationsModel _history; }; } From 45edd8236813cb02e532cd52f64e4959e420de16 Mon Sep 17 00:00:00 2001 From: master <master@Ubuntu20.04.6.myguest.virtualbox.org> Date: Wed, 5 Apr 2023 15:33:24 +0300 Subject: [PATCH 02/21] There was register HistoryNotificationsModel in qml --- qmlnotifyservice.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qmlnotifyservice.cpp b/qmlnotifyservice.cpp index 37a234d..f68d245 100644 --- a/qmlnotifyservice.cpp +++ b/qmlnotifyservice.cpp @@ -7,6 +7,7 @@ #include "notificationservice.h" #include "qmlnotifyservice.h" +#include "historynotificationsmodel.h" #include <QQmlApplicationEngine> #include <QQmlContext> @@ -22,10 +23,12 @@ bool init(QQmlApplicationEngine *engine) { return false; initSNotufyResources(); + QPointer<HistoryNotificationsModel> historyModel = new HistoryNotificationsModel(); engine->addImportPath(":/"); root->setContextProperty("notificationService", NotificationService::getService()); + root->setContextProperty("historyNotificationsModel", historyModel); return true; } } From 95eb3eca16741e33dcb510d6756a26b4006d500d Mon Sep 17 00:00:00 2001 From: master <master@Ubuntu20.04.6.myguest.virtualbox.org> Date: Thu, 6 Apr 2023 16:13:59 +0300 Subject: [PATCH 03/21] There was refactored code --- historynotificationsmodel.cpp | 8 ++++---- historynotificationsmodel.h | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/historynotificationsmodel.cpp b/historynotificationsmodel.cpp index b1d5eb2..8e45794 100644 --- a/historynotificationsmodel.cpp +++ b/historynotificationsmodel.cpp @@ -39,10 +39,10 @@ QHash<int, QByteArray> HistoryNotificationsModel::roleNames() const { void HistoryNotificationsModel::setHistory(const QmlNotificationService::NotificationData ¬ificationData) { - beginResetModel(); - notificationsList.push_back(notificationData); - endResetModel(); - emit dataInserted(); + const int index = notificationsList.count() > 0? notificationsList.count() - 1 : notificationsList.count(); + beginInsertRows(QModelIndex(), index, index); + notificationsList.insert(index, notificationData); + endInsertRows(); } void HistoryNotificationsModel::clearAllHistory() { diff --git a/historynotificationsmodel.h b/historynotificationsmodel.h index 66432ae..d0e4247 100644 --- a/historynotificationsmodel.h +++ b/historynotificationsmodel.h @@ -15,8 +15,6 @@ class HistoryNotificationsModel : public QAbstractListModel Type }; - Q_PROPERTY(int notificationsCount READ getNotificationsCount WRITE setNotificationsCount NOTIFY notificationsCountChanged) - public: explicit HistoryNotificationsModel(QObject *parent = nullptr); @@ -34,7 +32,6 @@ signals: private: QList<QmlNotificationService::NotificationData> notificationsList; - int m_notificationsCount; }; #endif // HISTORYNOTIFICATIONMODEL_H From 43ea5822c76a4bcd3f49303e19d6aa29f9881fad Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Thu, 6 Apr 2023 16:20:39 +0300 Subject: [PATCH 04/21] There was refactored code --- historynotificationsmodel.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/historynotificationsmodel.cpp b/historynotificationsmodel.cpp index 8e45794..04388cf 100644 --- a/historynotificationsmodel.cpp +++ b/historynotificationsmodel.cpp @@ -39,10 +39,9 @@ QHash<int, QByteArray> HistoryNotificationsModel::roleNames() const { void HistoryNotificationsModel::setHistory(const QmlNotificationService::NotificationData ¬ificationData) { - const int index = notificationsList.count() > 0? notificationsList.count() - 1 : notificationsList.count(); - beginInsertRows(QModelIndex(), index, index); - notificationsList.insert(index, notificationData); - endInsertRows(); + beginResetModel(); + notificationsList.push_back(notificationData); + endResetModel(); } void HistoryNotificationsModel::clearAllHistory() { From 592f8463f1172084ea4d564ac9344e7adcbc08ec Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Mon, 10 Apr 2023 14:59:27 +0300 Subject: [PATCH 05/21] There were fixed issues --- NotifyModule/NotificationHistoryView.qml | 9 +-------- historynotificationsmodel.cpp | 22 +++++++++++++++------- historynotificationsmodel.h | 8 ++------ notificationservice.cpp | 10 ++++++---- notificationservice.h | 9 +++++---- qmlnotifyservice.cpp | 3 --- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/NotifyModule/NotificationHistoryView.qml b/NotifyModule/NotificationHistoryView.qml index 00b535c..2cfe7ee 100644 --- a/NotifyModule/NotificationHistoryView.qml +++ b/NotifyModule/NotificationHistoryView.qml @@ -5,7 +5,7 @@ import QtQuick.Controls.Material 2.15 Popup { id: root - readonly property var historyModel: historyNotificationsModel + readonly property var historyModel: notificationService.history ToolBar { id: toolbar @@ -161,11 +161,4 @@ Popup { } } } - - Connections { - target: historyModel - function onDataInserted() { - console.log(Object.keys(historyModel)) - } - } } diff --git a/historynotificationsmodel.cpp b/historynotificationsmodel.cpp index 04388cf..1049dd5 100644 --- a/historynotificationsmodel.cpp +++ b/historynotificationsmodel.cpp @@ -15,7 +15,7 @@ QVariant HistoryNotificationsModel::data(const QModelIndex &index, int role) con switch (role) { case Icon: - return notificationsList.at(index.row()).img(); + return notificationsList.at(index.row()).img(); case Title: return notificationsList.at(index.row()).title(); case Message: @@ -38,10 +38,15 @@ QHash<int, QByteArray> HistoryNotificationsModel::roleNames() const { } -void HistoryNotificationsModel::setHistory(const QmlNotificationService::NotificationData ¬ificationData) { - beginResetModel(); - notificationsList.push_back(notificationData); - endResetModel(); +void HistoryNotificationsModel::addHistoryObject(const QmlNotificationService::NotificationData ¬ificationData) { + beginInsertRows({}, rowCount({}), rowCount({})); + notificationsList.append(notificationData); + endInsertRows(); +} + +void HistoryNotificationsModel::setHistory(const QList<QmlNotificationService::NotificationData> &historyList) +{ + notificationsList = std::move(historyList); } void HistoryNotificationsModel::clearAllHistory() { @@ -51,8 +56,11 @@ void HistoryNotificationsModel::clearAllHistory() { } void HistoryNotificationsModel::removeNotificationItemAtIndex(const int elementIndex) { - beginResetModel(); + beginRemoveRows({}, elementIndex, elementIndex); notificationsList.removeAt(elementIndex); - endResetModel(); + endRemoveRows(); } + + + diff --git a/historynotificationsmodel.h b/historynotificationsmodel.h index d0e4247..3ba7bbd 100644 --- a/historynotificationsmodel.h +++ b/historynotificationsmodel.h @@ -21,15 +21,11 @@ public: int rowCount(const QModelIndex &parent) const override; QVariant data(const QModelIndex &index, int role) const override; QHash<int, QByteArray> roleNames() const override; - void setHistory(const QmlNotificationService::NotificationData ¬ificationData); + void addHistoryObject(const QmlNotificationService::NotificationData ¬ificationData); + void setHistory(const QList<QmlNotificationService::NotificationData> &historyList); Q_INVOKABLE void clearAllHistory(); - Q_INVOKABLE void removeNotificationItemAtIndex(const int index); - -signals: - void dataInserted(); - private: QList<QmlNotificationService::NotificationData> notificationsList; }; diff --git a/notificationservice.cpp b/notificationservice.cpp index 2f7430d..ce5812f 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -7,12 +7,14 @@ #include "notificationservice.h" -#include <QSharedPointer> + namespace QmlNotificationService { NotificationService::NotificationService(QObject * ptr): QObject (ptr) { qRegisterMetaType<NotificationData>("NotificationData"); qRegisterMetaType<QList<NotificationData>> ("QList<NotificationData>"); + qRegisterMetaType<QSharedPointer<HistoryNotificationsModel>>("QSharedPointer<HistoryNotificationsModel>"); + setNotify("Test", "Test"); } NotificationData NotificationService::notify() const { @@ -25,7 +27,7 @@ NotificationData NotificationService::question() const { void NotificationService::setNotify(const NotificationData& notify) { if (_notify != notify) { - _history.setHistory(notify); + _history.addHistoryObject(notify); } _notify = notify; @@ -103,8 +105,8 @@ NotificationService *NotificationService::getService() { return service; } -//const QList<NotificationData> &NotificationService::history() const { -// return _history; +//QObject *NotificationService::history() const{ +// return _history.data(); //} } diff --git a/notificationservice.h b/notificationservice.h index 4eabdbb..3b04ff1 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -6,6 +6,7 @@ #include <QHash> #include <QObject> +#include <QSharedPointer> namespace QmlNotificationService { @@ -24,7 +25,7 @@ class NOTIFYSERVICESHARED_EXPORT NotificationService: public QObject Q_PROPERTY(NotificationData notify READ notify NOTIFY notifyChanged) Q_PROPERTY(NotificationData question READ question NOTIFY questionChanged) - //Q_PROPERTY(HistoryNotificationModel history READ history NOTIFY notifyChanged) + // Q_PROPERTY(QObject* history READ history NOTIFY notifyChanged) public: /** @@ -115,10 +116,10 @@ public: static NotificationService* getService(); /** - * @brief history - This method used for return notify list. - * @return list of all notify. + * @brief history - This method used for return notify history model. + * @return history model of all notify. */ - // const HistoryNotificationModel & history() const; + // QObject* history() const; signals: /** diff --git a/qmlnotifyservice.cpp b/qmlnotifyservice.cpp index f68d245..37a234d 100644 --- a/qmlnotifyservice.cpp +++ b/qmlnotifyservice.cpp @@ -7,7 +7,6 @@ #include "notificationservice.h" #include "qmlnotifyservice.h" -#include "historynotificationsmodel.h" #include <QQmlApplicationEngine> #include <QQmlContext> @@ -23,12 +22,10 @@ bool init(QQmlApplicationEngine *engine) { return false; initSNotufyResources(); - QPointer<HistoryNotificationsModel> historyModel = new HistoryNotificationsModel(); engine->addImportPath(":/"); root->setContextProperty("notificationService", NotificationService::getService()); - root->setContextProperty("historyNotificationsModel", historyModel); return true; } } From 84702f48356c2a6f1ee9d64e25a22168403116d1 Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Mon, 10 Apr 2023 15:06:06 +0300 Subject: [PATCH 06/21] There was added original code version --- notificationservice.cpp | 8 ++++---- notificationservice.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/notificationservice.cpp b/notificationservice.cpp index ce5812f..e98236a 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -27,7 +27,7 @@ NotificationData NotificationService::question() const { void NotificationService::setNotify(const NotificationData& notify) { if (_notify != notify) { - _history.addHistoryObject(notify); + _history->addHistoryObject(notify); } _notify = notify; @@ -105,8 +105,8 @@ NotificationService *NotificationService::getService() { return service; } -//QObject *NotificationService::history() const{ -// return _history.data(); -//} +QObject *NotificationService::history() const{ + return _history.data(); +} } diff --git a/notificationservice.h b/notificationservice.h index 3b04ff1..5c152c8 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -25,7 +25,7 @@ class NOTIFYSERVICESHARED_EXPORT NotificationService: public QObject Q_PROPERTY(NotificationData notify READ notify NOTIFY notifyChanged) Q_PROPERTY(NotificationData question READ question NOTIFY questionChanged) - // Q_PROPERTY(QObject* history READ history NOTIFY notifyChanged) + Q_PROPERTY(QObject* history READ history NOTIFY notifyChanged) public: /** @@ -119,7 +119,7 @@ public: * @brief history - This method used for return notify history model. * @return history model of all notify. */ - // QObject* history() const; + QObject* history() const; signals: /** @@ -147,7 +147,7 @@ private: QHash<int, Listner> _listners; NotificationData _question; NotificationData _notify; - HistoryNotificationsModel _history; + QSharedPointer<HistoryNotificationsModel> _history; }; } From 0830ddfc0d037e03a4d051536e0f1b839f76b9eb Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Tue, 11 Apr 2023 12:06:21 +0300 Subject: [PATCH 07/21] There were fixed issues --- NotifyModule/NotificationHistoryView.qml | 74 +++++++++++++----------- NotifyModule/NotificationServiceView.qml | 2 +- notificationservice.cpp | 10 +++- notificationservice.h | 5 +- 4 files changed, 51 insertions(+), 40 deletions(-) diff --git a/NotifyModule/NotificationHistoryView.qml b/NotifyModule/NotificationHistoryView.qml index 2cfe7ee..1c46682 100644 --- a/NotifyModule/NotificationHistoryView.qml +++ b/NotifyModule/NotificationHistoryView.qml @@ -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" } } } diff --git a/NotifyModule/NotificationServiceView.qml b/NotifyModule/NotificationServiceView.qml index 27dd1c7..aa7397f 100644 --- a/NotifyModule/NotificationServiceView.qml +++ b/NotifyModule/NotificationServiceView.qml @@ -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 } diff --git a/notificationservice.cpp b/notificationservice.cpp index e98236a..f5d3ac5 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -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; } } diff --git a/notificationservice.h b/notificationservice.h index 5c152c8..da9729f 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -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; }; } From 74ec09bf4ae6e0317fe7a09e3e500769ac59c7ec Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Tue, 11 Apr 2023 12:08:28 +0300 Subject: [PATCH 08/21] There was fixed typos --- NotifyModule/NotificationHistoryView.qml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/NotifyModule/NotificationHistoryView.qml b/NotifyModule/NotificationHistoryView.qml index 1c46682..b13b354 100644 --- a/NotifyModule/NotificationHistoryView.qml +++ b/NotifyModule/NotificationHistoryView.qml @@ -139,10 +139,7 @@ Popup { width: parent.width text: qsTr(model.text) font.pointSize: 12 - elide: { - console.log(notificationText.width, parent.width, notificationText.width < parent.width) - Label.ElideRight - } + elide: Label.ElideRight linkColor: Material.accent } } From b3ff1cc57708fd1fe1bcfaa8389831fdd6ccbdad Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Wed, 12 Apr 2023 11:44:22 +0300 Subject: [PATCH 09/21] There was fixed bug --- notificationdata.cpp | 25 +++++++++++++++++++++++-- notificationdata.h | 5 +++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/notificationdata.cpp b/notificationdata.cpp index c01a286..5f6e0f6 100644 --- a/notificationdata.cpp +++ b/notificationdata.cpp @@ -11,11 +11,13 @@ namespace QmlNotificationService { NotificationData::NotificationData(const QString &title, const QString &text, const QString &img, int type) { - + defImgI = "qrc:/icons/info"; + defImgW = "qrc:/icons/warning"; + defImgE = "qrc:/icons/error"; _text = text; _title = title; - _img = img; _type = type; + _img = getDefaultImage(img, type); } QString NotificationData::text() const { @@ -41,6 +43,25 @@ bool NotificationData::operator !=(const NotificationData &righ) { return !operator==(righ); } +QString NotificationData::getDefaultImage(const QString &img, const int code) +{ + if(img != "") + return img; + + const auto notificationType = static_cast<NotificationData::Type>(code); + + switch (notificationType) { + case NotificationData::Type::Normal: + return defImgI; + case NotificationData::Type::Warning: + return defImgW; + case NotificationData::Type::Error: + return defImgE; + default: + return defImgI; + } +} + int NotificationData::type() const { return _type; } diff --git a/notificationdata.h b/notificationdata.h index 047fd11..9f9d930 100644 --- a/notificationdata.h +++ b/notificationdata.h @@ -71,10 +71,15 @@ public: bool operator !=(const NotificationData &righ); private: + QString getDefaultImage(const QString &img, const int code); + QString _text; QString _img; QString _title; int _type; + QString defImgI; + QString defImgW; + QString defImgE; }; } From 7491594379aee3f1721826b2e23543c35b02461e Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Thu, 13 Apr 2023 15:46:01 +0300 Subject: [PATCH 10/21] There were fixed bugs --- NotifyModule/NotificationForm.qml | 2 +- NotifyModule/NotificationHistoryView.qml | 8 +++---- NotifyModule/NotificationServiceView.qml | 7 ++++++ notificationdata.cpp | 27 ++++++++++++++---------- notificationdata.h | 12 +++++++---- notificationservice.cpp | 10 ++++++--- notificationservice.h | 13 +++++++++++- 7 files changed, 55 insertions(+), 24 deletions(-) diff --git a/NotifyModule/NotificationForm.qml b/NotifyModule/NotificationForm.qml index 86ff02b..854686b 100644 --- a/NotifyModule/NotificationForm.qml +++ b/NotifyModule/NotificationForm.qml @@ -62,7 +62,7 @@ BasePopUp { } ToolButton { - text: "History" + text: String.fromCharCode(0x2630) font.pointSize: 10 onClicked: { history.open() diff --git a/NotifyModule/NotificationHistoryView.qml b/NotifyModule/NotificationHistoryView.qml index b13b354..b4b8974 100644 --- a/NotifyModule/NotificationHistoryView.qml +++ b/NotifyModule/NotificationHistoryView.qml @@ -106,12 +106,12 @@ Popup { contentItem: Row { width: parent.width - spacing: width * 0.35 + spacing: width * 0.2 Image { id: notificationIcon - width: notificationIcon.sourceSize.width * 0.15 - height: notificationIcon.sourceSize.height * 0.15 + width: notificationIcon.sourceSize.width * 0.2 + height: notificationIcon.sourceSize.height * 0.2 source: model.icon fillMode: Image.PreserveAspectFit anchors { @@ -121,7 +121,7 @@ Popup { Column { id: column - width: parent.width - notificationIcon.width * 0.2 + width: parent.width - notificationIcon.width - parent.spacing anchors { verticalCenter: parent.verticalCenter } diff --git a/NotifyModule/NotificationServiceView.qml b/NotifyModule/NotificationServiceView.qml index aa7397f..3a23658 100644 --- a/NotifyModule/NotificationServiceView.qml +++ b/NotifyModule/NotificationServiceView.qml @@ -80,4 +80,11 @@ Item { height: parent.height * 0.5 anchors.centerIn: parent } + + Connections { + target: model + function onSigShowHistory() { + history.open() + } + } } diff --git a/notificationdata.cpp b/notificationdata.cpp index 5f6e0f6..bed8df2 100644 --- a/notificationdata.cpp +++ b/notificationdata.cpp @@ -11,13 +11,11 @@ namespace QmlNotificationService { NotificationData::NotificationData(const QString &title, const QString &text, const QString &img, int type) { - defImgI = "qrc:/icons/info"; - defImgW = "qrc:/icons/warning"; - defImgE = "qrc:/icons/error"; + _text = text; _title = title; + _img = img; _type = type; - _img = getDefaultImage(img, type); } QString NotificationData::text() const { @@ -25,6 +23,15 @@ QString NotificationData::text() const { } QString NotificationData::img() const { + const QString imageSrc = imgSrc(); + if(imageSrc != "") + return imageSrc; + else + return this->getDefaultImage(_type); +} + +QString NotificationData::imgSrc() const +{ return _img; } @@ -43,22 +50,20 @@ bool NotificationData::operator !=(const NotificationData &righ) { return !operator==(righ); } -QString NotificationData::getDefaultImage(const QString &img, const int code) +QString NotificationData::getDefaultImage(const int code) const { - if(img != "") - return img; const auto notificationType = static_cast<NotificationData::Type>(code); switch (notificationType) { case NotificationData::Type::Normal: - return defImgI; + return "qrc:/icons/info"; case NotificationData::Type::Warning: - return defImgW; + return "qrc:/icons/warning"; case NotificationData::Type::Error: - return defImgE; + return "qrc:/icons/error"; default: - return defImgI; + return ""; } } diff --git a/notificationdata.h b/notificationdata.h index 9f9d930..a77557d 100644 --- a/notificationdata.h +++ b/notificationdata.h @@ -43,6 +43,13 @@ public: */ Q_INVOKABLE QString img() const; + + /** + * @brief imgSrc This method return url to image of a question/notification object. + * @return url of image. + */ + QString imgSrc() const; + /** * @brief title This method return title of a question/notification object. * @return title of a question/notification object. @@ -71,15 +78,12 @@ public: bool operator !=(const NotificationData &righ); private: - QString getDefaultImage(const QString &img, const int code); + QString getDefaultImage(const int code) const; QString _text; QString _img; QString _title; int _type; - QString defImgI; - QString defImgW; - QString defImgE; }; } diff --git a/notificationservice.cpp b/notificationservice.cpp index f5d3ac5..ec5b4e6 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -6,8 +6,7 @@ */ #include "notificationservice.h" - - +#include <QDebug> namespace QmlNotificationService { NotificationService::NotificationService(QObject * ptr): QObject (ptr) { @@ -109,8 +108,13 @@ NotificationService *NotificationService::getService() { return service; } -QObject *NotificationService::history() const{ +QObject *NotificationService::history() const { return _history; } +void NotificationService::showHistory() +{ + emit sigShowHistory(); +} + } diff --git a/notificationservice.h b/notificationservice.h index da9729f..87ddc14 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -122,9 +122,15 @@ public: */ QObject* history() const; + /** + * @brief showHistory - This method used for emit signal by which show notification menu. + */ + + Q_INVOKABLE void showHistory(); + ~NotificationService(); -signals: + signals: /** * @brief notifyChanged This signal emited whet the notificator (Ths object) received a new notification message. */ @@ -143,10 +149,15 @@ signals: */ void questionCompleted(bool accepted, int questionCode); + void historyListChanged(); + + void sigShowHistory(); + private: explicit NotificationService(QObject *ptr = nullptr); + QHash<int, Listner> _listners; NotificationData _question; NotificationData _notify; From 7b5ec8f63fd8cb1fa9bd91cb1ad4a7bed0c64955 Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Thu, 13 Apr 2023 16:21:36 +0300 Subject: [PATCH 11/21] There were fixed typos --- historynotificationsmodel.cpp | 3 +-- notificationdata.cpp | 8 ++++---- notificationdata.h | 4 ++-- notificationservice.h | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/historynotificationsmodel.cpp b/historynotificationsmodel.cpp index 1049dd5..3c63e59 100644 --- a/historynotificationsmodel.cpp +++ b/historynotificationsmodel.cpp @@ -44,8 +44,7 @@ void HistoryNotificationsModel::addHistoryObject(const QmlNotificationService::N endInsertRows(); } -void HistoryNotificationsModel::setHistory(const QList<QmlNotificationService::NotificationData> &historyList) -{ +void HistoryNotificationsModel::setHistory(const QList<QmlNotificationService::NotificationData> &historyList) { notificationsList = std::move(historyList); } diff --git a/notificationdata.cpp b/notificationdata.cpp index bed8df2..072e368 100644 --- a/notificationdata.cpp +++ b/notificationdata.cpp @@ -1,4 +1,4 @@ -/* + /* * Copyright (C) 2018-2023 QuasarApp. * Distributed under the lgplv3 software license, see the accompanying * Everyone is permitted to copy and distribute verbatim copies @@ -24,10 +24,10 @@ QString NotificationData::text() const { QString NotificationData::img() const { const QString imageSrc = imgSrc(); - if(imageSrc != "") + if(imageSrc.size()) return imageSrc; - else - return this->getDefaultImage(_type); + + return this->getDefaultImage(_type); } QString NotificationData::imgSrc() const diff --git a/notificationdata.h b/notificationdata.h index a77557d..996eb15 100644 --- a/notificationdata.h +++ b/notificationdata.h @@ -38,8 +38,8 @@ public: Q_INVOKABLE QString text() const; /** - * @brief img This method return url to image of a question/notification object. - * @return url of image. + * @brief img This method return url to image of a question/notification object if it exisis or return url of default question/notification image. + * @return url of image or url of default image. */ Q_INVOKABLE QString img() const; diff --git a/notificationservice.h b/notificationservice.h index 87ddc14..af7320f 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -6,7 +6,6 @@ #include <QHash> #include <QObject> -#include <QSharedPointer> #include <QQmlEngine> namespace QmlNotificationService { From e18cea31b7f65121c448a21eb737a10e4d90eb15 Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Thu, 13 Apr 2023 16:24:56 +0300 Subject: [PATCH 12/21] There was fixed typos --- notificationdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notificationdata.h b/notificationdata.h index 996eb15..2f954e5 100644 --- a/notificationdata.h +++ b/notificationdata.h @@ -38,7 +38,7 @@ public: Q_INVOKABLE QString text() const; /** - * @brief img This method return url to image of a question/notification object if it exisis or return url of default question/notification image. + * @brief img This method return url to image of a question/notification object if it exists or return url of default question/notification image. * @return url of image or url of default image. */ Q_INVOKABLE QString img() const; From 71b99da2d7d84cfa9fd245b78f26da5dd2176225 Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Thu, 13 Apr 2023 16:32:25 +0300 Subject: [PATCH 13/21] There was fixed typos --- notificationdata.cpp | 6 ++---- notificationservice.cpp | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/notificationdata.cpp b/notificationdata.cpp index 072e368..5b8b4c9 100644 --- a/notificationdata.cpp +++ b/notificationdata.cpp @@ -30,8 +30,7 @@ QString NotificationData::img() const { return this->getDefaultImage(_type); } -QString NotificationData::imgSrc() const -{ +QString NotificationData::imgSrc() const { return _img; } @@ -50,8 +49,7 @@ bool NotificationData::operator !=(const NotificationData &righ) { return !operator==(righ); } -QString NotificationData::getDefaultImage(const int code) const -{ +QString NotificationData::getDefaultImage(const int code) const { const auto notificationType = static_cast<NotificationData::Type>(code); diff --git a/notificationservice.cpp b/notificationservice.cpp index ec5b4e6..d1bf6df 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -112,8 +112,7 @@ QObject *NotificationService::history() const { return _history; } -void NotificationService::showHistory() -{ +void NotificationService::showHistory() { emit sigShowHistory(); } From 8fe1d46df8e89cd53b19c26594741f1e00e1844c Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Thu, 13 Apr 2023 16:37:56 +0300 Subject: [PATCH 14/21] There was fixed typos --- notificationdata.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notificationdata.h b/notificationdata.h index 2f954e5..1d98f5c 100644 --- a/notificationdata.h +++ b/notificationdata.h @@ -38,7 +38,7 @@ public: Q_INVOKABLE QString text() const; /** - * @brief img This method return url to image of a question/notification object if it exists or return url of default question/notification image. + * @brief img This method return url to image of a question/notification object if url is empty then return default question/notification image. * @return url of image or url of default image. */ Q_INVOKABLE QString img() const; From a5d21cb35088167a5a5b330000b663916bb21d0b Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Fri, 14 Apr 2023 19:13:49 +0300 Subject: [PATCH 15/21] There was added notifications count method --- notificationservice.cpp | 6 +++++- notificationservice.h | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/notificationservice.cpp b/notificationservice.cpp index d1bf6df..dd588a1 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -6,7 +6,7 @@ */ #include "notificationservice.h" -#include <QDebug> + namespace QmlNotificationService { NotificationService::NotificationService(QObject * ptr): QObject (ptr) { @@ -116,4 +116,8 @@ void NotificationService::showHistory() { emit sigShowHistory(); } +int NotificationService::notificationsCount() const { + return _history->rowCount({}); +} + } diff --git a/notificationservice.h b/notificationservice.h index af7320f..53de8a4 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -127,6 +127,12 @@ public: Q_INVOKABLE void showHistory(); + /** + * @brief notificationsCount - This method used for return count of history notifications. + * @return count of history notifications. + */ + Q_INVOKABLE int notificationsCount() const; + ~NotificationService(); signals: From 50bc65df29be0158130c915781fefc47c5102f9c Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Sat, 15 Apr 2023 16:13:27 +0300 Subject: [PATCH 16/21] There were added countNotificationsChanged signal and connect with HistoryNotificationsModel --- notificationservice.cpp | 4 ++++ notificationservice.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/notificationservice.cpp b/notificationservice.cpp index dd588a1..2fce1df 100644 --- a/notificationservice.cpp +++ b/notificationservice.cpp @@ -14,6 +14,10 @@ NotificationService::NotificationService(QObject * ptr): QObject (ptr) { qRegisterMetaType<QList<NotificationData>> ("QList<NotificationData>"); _history = new HistoryNotificationsModel(); QQmlEngine::setObjectOwnership(_history, QQmlEngine::CppOwnership); + + connect(_history, &HistoryNotificationsModel::rowsInserted, this, &NotificationService::countNotificationsChanged); + connect(_history, &HistoryNotificationsModel::rowsRemoved, this, &NotificationService::countNotificationsChanged); + connect(_history, &HistoryNotificationsModel::modelReset, this, &NotificationService::countNotificationsChanged); } NotificationService::~NotificationService() { diff --git a/notificationservice.h b/notificationservice.h index 53de8a4..73bf389 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -158,6 +158,8 @@ public: void sigShowHistory(); + void countNotificationsChanged(); + private: explicit NotificationService(QObject *ptr = nullptr); From 4ce8a6282f0225f004e551ce77990daf9f23ccc0 Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Sun, 16 Apr 2023 10:37:35 +0300 Subject: [PATCH 17/21] There was added notificationsCount property --- notificationservice.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notificationservice.h b/notificationservice.h index 73bf389..d329523 100644 --- a/notificationservice.h +++ b/notificationservice.h @@ -27,6 +27,8 @@ class NOTIFYSERVICESHARED_EXPORT NotificationService: public QObject Q_PROPERTY(QObject* history READ history NOTIFY notifyChanged) + Q_PROPERTY(int notificationsCount READ notificationsCount NOTIFY countNotificationsChanged) + public: /** * @brief Notify This method return data of the last notify message. From aa87ba422328f52b66195c5bd8a6bf32546f2708 Mon Sep 17 00:00:00 2001 From: EndrII <endriimail@gmail.com> Date: Sun, 16 Apr 2023 11:21:42 +0200 Subject: [PATCH 18/21] some gui fixes: 1. Move to Layouts 2. Dynamic dialog sizes 3. Move to Dialog instand popup 4. New remove animations 5. Using default sizes of text and another controls --- NotifyModule/NotificationHistoryView.qml | 91 ++++++------------------ NotifyModule/NotificationServiceView.qml | 5 +- qmlNotify_languages/de.ts | 15 ++++ qmlNotify_languages/en.ts | 15 ++++ qmlNotify_languages/es.ts | 15 ++++ qmlNotify_languages/fr.ts | 15 ++++ qmlNotify_languages/ja.ts | 15 ++++ qmlNotify_languages/pl.ts | 15 ++++ qmlNotify_languages/ru.ts | 15 ++++ qmlNotify_languages/tr.ts | 15 ++++ qmlNotify_languages/uk.ts | 15 ++++ qmlNotify_languages/zh.ts | 15 ++++ 12 files changed, 176 insertions(+), 70 deletions(-) diff --git a/NotifyModule/NotificationHistoryView.qml b/NotifyModule/NotificationHistoryView.qml index b4b8974..4fcf5d6 100644 --- a/NotifyModule/NotificationHistoryView.qml +++ b/NotifyModule/NotificationHistoryView.qml @@ -1,27 +1,20 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Controls.Material 2.15 +import QtQuick.Layouts 1.3 -Popup { +Dialog { id: root readonly property var historyModel: notificationService.history - ToolBar { + header: ToolBar { id: toolbar - width: parent.width - height: parent.height * 0.1 - anchors { - top: parent.top - left: parent.left - right: parent.right - } ToolButton { id: clearAllButton - text: qsTr("Clear All") + text: qsTr("clear") height: parent.height - font.pointSize: 10 anchors { left: parent.left verticalCenter: parent.verticalCenter @@ -33,53 +26,25 @@ Popup { Label { id: toolbarTitle text: qsTr("Notification history") - font.pointSize: 12 anchors { horizontalCenter: parent.horizontalCenter verticalCenter: parent.verticalCenter } } - - ToolButton { - id: closePopupButton - text: "X" - font.pointSize: 12 - anchors { - right: parent.right - verticalCenter: parent.verticalCenter - } - - onClicked: root.close() - } } - ListView { + contentItem: ListView { id: notificationLV - width: parent.width - height: parent.height * 0.9 clip: true - spacing: 5 + spacing: 10 model: historyModel - anchors { - top: toolbar.bottom - horizontalCenter: parent.horizontalCenter - } - ScrollBar.vertical: ScrollBar { - hoverEnabled: true - active: hovered || pressed - anchors { - top: notificationLV.top - right: notificationLV.right - bottom: notificationLV.bottom - } - } + ScrollBar.vertical: ScrollBar {} delegate: SwipeDelegate { id: swipeDelegate text: model.notificationValue width: notificationLV.width - height: notificationLV.height * 0.15 ListView.onRemove: SequentialAnimation { @@ -91,9 +56,9 @@ Popup { NumberAnimation { target: swipeDelegate - property: "height" - to: 0 - duration: 20 + property: "x" + to: -swipeDelegate.width + duration: 200 easing.type: Easing.InOutQuad } @@ -104,43 +69,33 @@ Popup { } } - contentItem: Row { - width: parent.width - spacing: width * 0.2 + contentItem: RowLayout { Image { - id: notificationIcon - width: notificationIcon.sourceSize.width * 0.2 - height: notificationIcon.sourceSize.height * 0.2 + id: image + Layout.preferredWidth: toolbar.height; + Layout.preferredHeight: toolbar.height; + Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter + + fillMode: Image.PreserveAspectCrop + clip: true source: model.icon - fillMode: Image.PreserveAspectFit - anchors { - verticalCenter: parent.verticalCenter - } } - Column { - id: column - width: parent.width - notificationIcon.width - parent.spacing - anchors { - verticalCenter: parent.verticalCenter - } - + ColumnLayout { Label { id: notificationTitle - width: parent.width - text: qsTr(model.title) - font.pointSize: 12 + text: model.title elide: Label.ElideRight } Label { id: notificationText - width: parent.width - text: qsTr(model.text) - font.pointSize: 12 + text: model.text elide: Label.ElideRight linkColor: Material.accent + wrapMode: Text.WordWrap + Layout.fillWidth: true } } } diff --git a/NotifyModule/NotificationServiceView.qml b/NotifyModule/NotificationServiceView.qml index 3a23658..27a1262 100644 --- a/NotifyModule/NotificationServiceView.qml +++ b/NotifyModule/NotificationServiceView.qml @@ -76,8 +76,9 @@ Item { NotificationHistoryView { id: history - width: parent.width * 0.8 - height: parent.height * 0.5 + width: Math.min(Math.max(Math.min(parent.width * 0.6, 1024 ), 320), parent.width) + height: Math.min(Math.max(Math.min(parent.height * 0.6, 720), 240), parent.height) + anchors.centerIn: parent } diff --git a/qmlNotify_languages/de.ts b/qmlNotify_languages/de.ts index b918166..5f635ac 100644 --- a/qmlNotify_languages/de.ts +++ b/qmlNotify_languages/de.ts @@ -8,4 +8,19 @@ <translation>Botschaft</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/en.ts b/qmlNotify_languages/en.ts index 9d8f17e..d53a1e0 100644 --- a/qmlNotify_languages/en.ts +++ b/qmlNotify_languages/en.ts @@ -8,4 +8,19 @@ <translation>Message</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/es.ts b/qmlNotify_languages/es.ts index ffb535e..ebefb5f 100644 --- a/qmlNotify_languages/es.ts +++ b/qmlNotify_languages/es.ts @@ -8,4 +8,19 @@ <translation>Mensaje</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/fr.ts b/qmlNotify_languages/fr.ts index b1d0e30..9ce777a 100644 --- a/qmlNotify_languages/fr.ts +++ b/qmlNotify_languages/fr.ts @@ -8,4 +8,19 @@ <translation>Un message</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/ja.ts b/qmlNotify_languages/ja.ts index 84649da..2a2dd2c 100644 --- a/qmlNotify_languages/ja.ts +++ b/qmlNotify_languages/ja.ts @@ -8,4 +8,19 @@ <translation>メッセージ</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/pl.ts b/qmlNotify_languages/pl.ts index 5d17eaf..f517a72 100644 --- a/qmlNotify_languages/pl.ts +++ b/qmlNotify_languages/pl.ts @@ -8,4 +8,19 @@ <translation>Wiadomość</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/ru.ts b/qmlNotify_languages/ru.ts index 2e44356..5a676a6 100644 --- a/qmlNotify_languages/ru.ts +++ b/qmlNotify_languages/ru.ts @@ -8,4 +8,19 @@ <translation>Cообщение</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/tr.ts b/qmlNotify_languages/tr.ts index aefaa8f..c19218f 100644 --- a/qmlNotify_languages/tr.ts +++ b/qmlNotify_languages/tr.ts @@ -8,4 +8,19 @@ <translation>İleti</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/uk.ts b/qmlNotify_languages/uk.ts index 04fd4ff..0226e27 100644 --- a/qmlNotify_languages/uk.ts +++ b/qmlNotify_languages/uk.ts @@ -8,4 +8,19 @@ <translation>Повідомлення</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> diff --git a/qmlNotify_languages/zh.ts b/qmlNotify_languages/zh.ts index db5c2bf..e4a644f 100644 --- a/qmlNotify_languages/zh.ts +++ b/qmlNotify_languages/zh.ts @@ -8,4 +8,19 @@ <translation>信息</translation> </message> </context> +<context> + <name>NotificationHistoryView</name> + <message> + <source>Notification history</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>Delete</source> + <translation type="unfinished"></translation> + </message> + <message> + <source>clear</source> + <translation type="unfinished"></translation> + </message> +</context> </TS> From 667c309076a907009dae9a49b8676a4b0eb288c5 Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Mon, 17 Apr 2023 12:23:06 +0300 Subject: [PATCH 19/21] There were added translations --- qmlNotify_languages/de.ts | 6 +++--- qmlNotify_languages/en.ts | 6 +++--- qmlNotify_languages/es.ts | 6 +++--- qmlNotify_languages/fr.ts | 6 +++--- qmlNotify_languages/ja.ts | 6 +++--- qmlNotify_languages/pl.ts | 6 +++--- qmlNotify_languages/ru.ts | 6 +++--- qmlNotify_languages/tr.ts | 6 +++--- qmlNotify_languages/uk.ts | 6 +++--- qmlNotify_languages/zh.ts | 6 +++--- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/qmlNotify_languages/de.ts b/qmlNotify_languages/de.ts index 5f635ac..29e0807 100644 --- a/qmlNotify_languages/de.ts +++ b/qmlNotify_languages/de.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>Benachrichtigungsverlauf</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>Löschen</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>klare</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/en.ts b/qmlNotify_languages/en.ts index d53a1e0..20c40d5 100644 --- a/qmlNotify_languages/en.ts +++ b/qmlNotify_languages/en.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>Notification history</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>Delete</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>clear</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/es.ts b/qmlNotify_languages/es.ts index ebefb5f..5172abc 100644 --- a/qmlNotify_languages/es.ts +++ b/qmlNotify_languages/es.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>Historial de notificaciones</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>Borrar</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>borrar</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/fr.ts b/qmlNotify_languages/fr.ts index 9ce777a..744f4e6 100644 --- a/qmlNotify_languages/fr.ts +++ b/qmlNotify_languages/fr.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>Historique des notifications</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>Supprimer</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>claire</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/ja.ts b/qmlNotify_languages/ja.ts index 2a2dd2c..9acfcbc 100644 --- a/qmlNotify_languages/ja.ts +++ b/qmlNotify_languages/ja.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>通知履歴</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>消去</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>クリア通知</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/pl.ts b/qmlNotify_languages/pl.ts index f517a72..6debc86 100644 --- a/qmlNotify_languages/pl.ts +++ b/qmlNotify_languages/pl.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>Historia powiadomień</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>Usuwać</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>wyczyść</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/ru.ts b/qmlNotify_languages/ru.ts index 5a676a6..28c99d4 100644 --- a/qmlNotify_languages/ru.ts +++ b/qmlNotify_languages/ru.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>История уведомлений</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>Удалить</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>очистить</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/tr.ts b/qmlNotify_languages/tr.ts index c19218f..edfaae5 100644 --- a/qmlNotify_languages/tr.ts +++ b/qmlNotify_languages/tr.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>Bildirim geçmişi</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>Silmek</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>temizle</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/uk.ts b/qmlNotify_languages/uk.ts index 0226e27..03e5c76 100644 --- a/qmlNotify_languages/uk.ts +++ b/qmlNotify_languages/uk.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>Історія сповіщень</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>Видалити</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>очистити</translation> </message> </context> </TS> diff --git a/qmlNotify_languages/zh.ts b/qmlNotify_languages/zh.ts index e4a644f..f3f3f66 100644 --- a/qmlNotify_languages/zh.ts +++ b/qmlNotify_languages/zh.ts @@ -12,15 +12,15 @@ <name>NotificationHistoryView</name> <message> <source>Notification history</source> - <translation type="unfinished"></translation> + <translation>通知履歷</translation> </message> <message> <source>Delete</source> - <translation type="unfinished"></translation> + <translation>刪除</translation> </message> <message> <source>clear</source> - <translation type="unfinished"></translation> + <translation>清除</translation> </message> </context> </TS> From ecdd89876f1b7b43d4893595d34d98f4190df958 Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Mon, 17 Apr 2023 12:38:01 +0300 Subject: [PATCH 20/21] There was fixed font size for clear button --- NotifyModule/NotificationHistoryView.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/NotifyModule/NotificationHistoryView.qml b/NotifyModule/NotificationHistoryView.qml index 4fcf5d6..bb4a700 100644 --- a/NotifyModule/NotificationHistoryView.qml +++ b/NotifyModule/NotificationHistoryView.qml @@ -14,6 +14,7 @@ Dialog { ToolButton { id: clearAllButton text: qsTr("clear") + font.pointSize: 10 height: parent.height anchors { left: parent.left From 58e5b35880c62ed3bf3ae54d0488cbd84368e26c Mon Sep 17 00:00:00 2001 From: Alex <Alex> Date: Mon, 17 Apr 2023 13:08:53 +0300 Subject: [PATCH 21/21] There were fixed font size and translations --- NotifyModule/NotificationHistoryView.qml | 3 +-- qmlNotify_languages/de.ts | 4 ++-- qmlNotify_languages/en.ts | 4 ++-- qmlNotify_languages/es.ts | 4 ++-- qmlNotify_languages/fr.ts | 4 ++-- qmlNotify_languages/ja.ts | 4 ++-- qmlNotify_languages/pl.ts | 4 ++-- qmlNotify_languages/ru.ts | 4 ++-- qmlNotify_languages/tr.ts | 4 ++-- qmlNotify_languages/uk.ts | 4 ++-- qmlNotify_languages/zh.ts | 4 ++-- 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/NotifyModule/NotificationHistoryView.qml b/NotifyModule/NotificationHistoryView.qml index bb4a700..a28fb3e 100644 --- a/NotifyModule/NotificationHistoryView.qml +++ b/NotifyModule/NotificationHistoryView.qml @@ -14,7 +14,6 @@ Dialog { ToolButton { id: clearAllButton text: qsTr("clear") - font.pointSize: 10 height: parent.height anchors { left: parent.left @@ -26,7 +25,7 @@ Dialog { Label { id: toolbarTitle - text: qsTr("Notification history") + text: qsTr("Notifications") anchors { horizontalCenter: parent.horizontalCenter verticalCenter: parent.verticalCenter diff --git a/qmlNotify_languages/de.ts b/qmlNotify_languages/de.ts index 29e0807..0e7f05e 100644 --- a/qmlNotify_languages/de.ts +++ b/qmlNotify_languages/de.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>Benachrichtigungsverlauf</translation> + <source>Notifications</source> + <translation>Benachrichtigungen</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/en.ts b/qmlNotify_languages/en.ts index 20c40d5..377807e 100644 --- a/qmlNotify_languages/en.ts +++ b/qmlNotify_languages/en.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>Notification history</translation> + <source>Notifications</source> + <translation>Notifications</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/es.ts b/qmlNotify_languages/es.ts index 5172abc..515fd49 100644 --- a/qmlNotify_languages/es.ts +++ b/qmlNotify_languages/es.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>Historial de notificaciones</translation> + <source>Notifications</source> + <translation>Notificaciones</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/fr.ts b/qmlNotify_languages/fr.ts index 744f4e6..d691a8b 100644 --- a/qmlNotify_languages/fr.ts +++ b/qmlNotify_languages/fr.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>Historique des notifications</translation> + <source>Notifications</source> + <translation>Avis</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/ja.ts b/qmlNotify_languages/ja.ts index 9acfcbc..bc73d29 100644 --- a/qmlNotify_languages/ja.ts +++ b/qmlNotify_languages/ja.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>通知履歴</translation> + <source>Notifications</source> + <translation>通知</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/pl.ts b/qmlNotify_languages/pl.ts index 6debc86..dd6f341 100644 --- a/qmlNotify_languages/pl.ts +++ b/qmlNotify_languages/pl.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>Historia powiadomień</translation> + <source>Notifications</source> + <translation>Powiadomienia</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/ru.ts b/qmlNotify_languages/ru.ts index 28c99d4..90258c2 100644 --- a/qmlNotify_languages/ru.ts +++ b/qmlNotify_languages/ru.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>История уведомлений</translation> + <source>Notifications</source> + <translation>Уведомления</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/tr.ts b/qmlNotify_languages/tr.ts index edfaae5..65683cb 100644 --- a/qmlNotify_languages/tr.ts +++ b/qmlNotify_languages/tr.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>Bildirim geçmişi</translation> + <source>Notifications</source> + <translation>Bildirimler</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/uk.ts b/qmlNotify_languages/uk.ts index 03e5c76..f05e2a2 100644 --- a/qmlNotify_languages/uk.ts +++ b/qmlNotify_languages/uk.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>Історія сповіщень</translation> + <source>Notifications</source> + <translation>Повідомлення</translation> </message> <message> <source>Delete</source> diff --git a/qmlNotify_languages/zh.ts b/qmlNotify_languages/zh.ts index f3f3f66..c5c5bb0 100644 --- a/qmlNotify_languages/zh.ts +++ b/qmlNotify_languages/zh.ts @@ -11,8 +11,8 @@ <context> <name>NotificationHistoryView</name> <message> - <source>Notification history</source> - <translation>通知履歷</translation> + <source>Notifications</source> + <translation>通知</translation> </message> <message> <source>Delete</source>