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(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 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 _listners; NotificationData _question; NotificationData _notify;