There were fixed bugs

This commit is contained in:
Alex 2023-04-13 15:46:01 +03:00
parent b3ff1cc577
commit 7491594379
7 changed files with 55 additions and 24 deletions

View File

@ -62,7 +62,7 @@ BasePopUp {
}
ToolButton {
text: "History"
text: String.fromCharCode(0x2630)
font.pointSize: 10
onClicked: {
history.open()

View File

@ -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
}

View File

@ -80,4 +80,11 @@ Item {
height: parent.height * 0.5
anchors.centerIn: parent
}
Connections {
target: model
function onSigShowHistory() {
history.open()
}
}
}

View File

@ -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 "";
}
}

View File

@ -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;
};
}

View File

@ -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();
}
}

View File

@ -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;