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

namespace ZShell::config {

class LauncherActionEntry : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CFG_PROPERTY(QVariantList, command)
	CFG_PROPERTY(bool, dangerous, false)
	CFG_PROPERTY(QString, description)
	CFG_PROPERTY(bool, enabled, true)
	CFG_PROPERTY(QString, icon)
	CFG_PROPERTY(QString, name)

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

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

CONFIG_LIST_TYPE(LauncherActionEntry, LauncherActionList)

class LauncherSizes : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CFG_PROPERTY(int, itemHeight, 50)
	CFG_PROPERTY(int, itemWidth, 600)
	CFG_PROPERTY(int, wallpaperHeight, 200)
	CFG_PROPERTY(int, wallpaperWidth, 280)

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

class UseFuzzy : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CFG_PROPERTY(bool, actions, true)
	CFG_PROPERTY(bool, apps, true)
	CFG_PROPERTY(bool, schemes, true)
	CFG_PROPERTY(bool, variants, true)
	CFG_PROPERTY(bool, wallpapers, true)

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

class Launcher : public ConfigObject {
	Q_OBJECT
	QML_ANONYMOUS

	CFG_PROPERTY(QString, actionPrefix, QStringLiteral("<"))
	CONFIG_LIST(
		LauncherActionList,
		actions,
		{
			vmap(
				{{"command", QVariantList{"autocomplete", "calc"}},
				 {"dangerous", false},
				 {"description", "Do simple math equations"},
				 {"enabled", true},
				 {"icon", "calculate"},
				 {"name", "Calculator"}}),
			vmap(
				{{"command", QVariantList{"setMode", "light"}},
				 {"dangerous", false},
				 {"description", "Change to light mode"},
				 {"enabled", true},
				 {"icon", "light_mode"},
				 {"name", "Light"}}),
			vmap(
				{{"command", QVariantList{"setMode", "dark"}},
				 {"dangerous", false},
				 {"description", "Change to dark mode"},
				 {"enabled", true},
				 {"icon", "dark_mode"},
				 {"name", "Dark"}}),
			vmap(
				{{"command", QVariantList{"autocomplete", "wallpaper"}},
				 {"dangerous", false},
				 {"description", "Change the current wallpaper"},
				 {"enabled", true},
				 {"icon", "image"},
				 {"name", "Wallpaper"}}),
			vmap(
				{{"command", QVariantList{"autocomplete", "variant"}},
				 {"dangerous", false},
				 {"description", "Change the current scheme variant"},
				 {"enabled", true},
				 {"icon", "colors"},
				 {"name", "Variant"}}),
			vmap(
				{{"command", QVariantList{"systemctl", "poweroff"}},
				 {"dangerous", true},
				 {"description", "Shutdown the system"},
				 {"enabled", true},
				 {"icon", "power_settings_new"},
				 {"name", "Shutdown"}}),
			vmap(
				{{"command", QVariantList{"systemctl", "reboot"}},
				 {"dangerous", true},
				 {"description", "Reboot the system"},
				 {"enabled", true},
				 {"icon", "cached"},
				 {"name", "Reboot"}}),
			vmap(
				{{"command", QVariantList{"loginctl", "terminate-user", ""}},
				 {"dangerous", true},
				 {"description", "Log out of the current session"},
				 {"enabled", true},
				 {"icon", "logout"},
				 {"name", "Logout"}}),
			vmap(
				{{"command", QVariantList{"loginctl", "lock-session"}},
				 {"dangerous", false},
				 {"description", "Lock the current session"},
				 {"enabled", true},
				 {"icon", "lock"},
				 {"name", "Lock"}}),
			vmap(
				{{"command",
				  QVariantList{"systemctl", "suspend-then-hibernate"}},
				 {"dangerous", false},
				 {"description", "Suspend then hibernate"},
				 {"enabled", true},
				 {"icon", "bedtime"},
				 {"name", "Sleep"}}),
		})
	CFG_PROPERTY(int, dragThreshold, 150)
	CFG_PROPERTY(bool, enableDangerousActions, true)
	CFG_PROPERTY(bool, enabled, true)
	CFG_PROPERTY(
		QStringList,
		favoriteApps,
		{QStringLiteral("Balatro"),
		 QStringLiteral("Slay the Spire 2"),
		 QStringLiteral("com.obsproject.Studio")})
	CFG_PROPERTY(
		QStringList,
		hiddenApps,
		{QStringLiteral("zellij"),
		 QStringLiteral("vim"),
		 QStringLiteral("jshell-java-openjdk"),
		 QStringLiteral("jconsole-java-openjdk"),
		 QStringLiteral("jshell-java21-openjdk"),
		 QStringLiteral("jconsole-java21-openjdk"),
		 QStringLiteral("jshell-java17-openjdk"),
		 QStringLiteral("jconsole-java17-openjdk"),
		 QStringLiteral("org.neovim.nvim"),
		 QStringLiteral("avahi-discover"),
		 QStringLiteral("bvnc"),
		 QStringLiteral("bssh"),
		 QStringLiteral("nm-connection-editor")})
	CFG_PROPERTY(int, maxAppsShown, 18)
	CFG_PROPERTY(int, maxWallpapers, 7)
	CONFIG_SUBOBJECT(LauncherSizes, sizes)
	CFG_PROPERTY(QString, specialPrefix, QStringLiteral("@"))
	CONFIG_SUBOBJECT(UseFuzzy, useFuzzy)
	CFG_PROPERTY(bool, uwsm, true)

	public:
	explicit Launcher(QObject* parent = nullptr)
		: ConfigObject(parent)
		, m_sizes(new LauncherSizes(this))
		, m_useFuzzy(new UseFuzzy(this)) {}
};

} // namespace ZShell::config
