There was fixed bug

This commit is contained in:
Alex 2023-04-12 11:44:22 +03:00
parent 74ec09bf4a
commit b3ff1cc577
2 changed files with 28 additions and 2 deletions

View File

@ -11,11 +11,13 @@ namespace QmlNotificationService {
NotificationData::NotificationData(const QString &title, NotificationData::NotificationData(const QString &title,
const QString &text, const QString &text,
const QString &img, int type) { const QString &img, int type) {
defImgI = "qrc:/icons/info";
defImgW = "qrc:/icons/warning";
defImgE = "qrc:/icons/error";
_text = text; _text = text;
_title = title; _title = title;
_img = img;
_type = type; _type = type;
_img = getDefaultImage(img, type);
} }
QString NotificationData::text() const { QString NotificationData::text() const {
@ -41,6 +43,25 @@ bool NotificationData::operator !=(const NotificationData &righ) {
return !operator==(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 { int NotificationData::type() const {
return _type; return _type;
} }

View File

@ -71,10 +71,15 @@ public:
bool operator !=(const NotificationData &righ); bool operator !=(const NotificationData &righ);
private: private:
QString getDefaultImage(const QString &img, const int code);
QString _text; QString _text;
QString _img; QString _img;
QString _title; QString _title;
int _type; int _type;
QString defImgI;
QString defImgW;
QString defImgE;
}; };
} }