#pragma once
#include "configlist.hpp"
#include "configobject.hpp"
#include <QStringList>

namespace ZShell::config {

class BatteryThresholdEntry : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CFG_PROPERTY(QString, icon)
	CFG_PROPERTY(QString, message)
	CFG_PROPERTY(QString, name)
	CFG_PROPERTY(int, perc)

	public:
	explicit BatteryThresholdEntry(QObject* parent = nullptr)
		: ConfigObject(parent) {}

	[[nodiscard]] QStringList identityKeys() const override {
		return {QStringLiteral("perc")};
	}
};

CONFIG_LIST_TYPE(BatteryThresholdEntry, BatteryThresholdList)

class IdleTimeoutEntry : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CFG_PROPERTY(QString, idleAction)
	CFG_PROPERTY(QString, name)
	CFG_PROPERTY(int, timeout)

	public:
	explicit IdleTimeoutEntry(QObject* parent = nullptr)
		: ConfigObject(parent) {}

	[[nodiscard]] QStringList identityKeys() const override {
		return {QStringLiteral("name")};
	}
};

CONFIG_LIST_TYPE(IdleTimeoutEntry, IdleTimeoutList)

class Apps : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CFG_PROPERTY(QStringList, archiver, {QStringLiteral("ark")})
	CFG_PROPERTY(QStringList, audio, {QStringLiteral("pavucontrol")})
	CFG_PROPERTY(QStringList, document, {QStringLiteral("libreoffice")})
	CFG_PROPERTY(QStringList, editor, {QStringLiteral("kate")})
	CFG_PROPERTY(QStringList, explorer, {QStringLiteral("dolphin")})
	CFG_PROPERTY(QStringList, image, {QStringLiteral("imv")})
	CFG_PROPERTY(QStringList, playback, {QStringLiteral("vlc")})
	CFG_PROPERTY(QStringList, terminal, {QStringLiteral("wezterm")})

	public:
	explicit Apps(QObject* parent = nullptr) : ConfigObject(parent) {}
};

class Battery : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CFG_PROPERTY(int, critPerc, 5)
	CONFIG_LIST(
		BatteryThresholdList,
		popupThresholds,
		{
			vmap(
				{{"icon", "battery_android_frame_2"},
				 {"message", "Battery low"},
				 {"name", "Low battery"},
				 {"perc", 20}}),
			vmap(
				{{"icon", "battery_android_frame_2"},
				 {"message", "Battery lower"},
				 {"name", "Low battery"},
				 {"perc", 15}}),
			vmap(
				{{"icon", "battery_android_frame_2"},
				 {"message", "Battery lowest"},
				 {"name", "Low battery"},
				 {"perc", 10}}),
		})

	public:
	explicit Battery(QObject* parent = nullptr) : ConfigObject(parent) {}
};

class Idle : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CONFIG_LIST(
		IdleTimeoutList,
		timeouts,
		{
			vmap(
				{{"idleAction", QStringLiteral("lock")},
				 {"name", QStringLiteral("Lock")},
				 {"timeout", 180}}),
		})

	public:
	explicit Idle(QObject* parent = nullptr) : ConfigObject(parent) {}
};

class General : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CONFIG_SUBOBJECT(Apps, apps)
	CONFIG_SUBOBJECT(Battery, battery)
	CFG_PROPERTY(QString, dateFormat, QStringLiteral("ddd d MMM - hh:mm:ss"))
	CFG_PROPERTY(bool, desktopIcons, true)
	CONFIG_SUBOBJECT(Idle, idle)
	CFG_PROPERTY(QString, logo, QString())
	CFG_PROPERTY(bool, showOverFullscreen, true)
	CFG_PROPERTY(
		QString,
		wallpaperPath,
		QStringLiteral("/mnt/IronWolf/SDImages/SWWW_Wals/"))

	public:
	explicit General(QObject* parent = nullptr)
		: ConfigObject(parent)
		, m_apps(new Apps(this))
		, m_battery(new Battery(this))
		, m_idle(new Idle(this)) {}
};

} // namespace ZShell::config
