#ifndef MESSAGEITEM_H
#define MESSAGEITEM_H

#include <QMessageBox>
#include <QSoundEffect>

#include "item.h"

class MessageItem : public Item
{
	Q_OBJECT
private:

	QString message_;
	QMessageBox* messageBox_ = nullptr;
	QString alertSoundFileName = "";
	QSoundEffect alertSound;

private slots:
	void closeMessageBox();

protected:
	virtual void enactValue(uint8_t value) override;

public:

	MessageItem(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0,
	            QObject *parent = nullptr);
	MessageItem(const ItemData& itemData,  QObject *parent = nullptr);
	~MessageItem();

	void setMessage(const QString& in);
	QString getMessage();
	void setAlert(const QString& in);
	QString getAlert();

	virtual void store(QJsonObject& json) override;
	virtual void load(const QJsonObject& json, const bool preserve = false) override;
};

#endif // MESSAGEITEM_H
