diff --git a/modules/utilities/cards/Toggles.qml b/modules/utilities/cards/Toggles.qml index b2e14567..9cdf4291 100644 --- a/modules/utilities/cards/Toggles.qml +++ b/modules/utilities/cards/Toggles.qml @@ -19,7 +19,7 @@ StyledRect { const seenIds = new Set(); return Config.utilities.quickToggles.filter(item => { - if (!item.enabled) + if (!(item.enabled ?? true)) return false; if (seenIds.has(item.id)) { diff --git a/plugin/src/Caelestia/Config/barconfig.hpp b/plugin/src/Caelestia/Config/barconfig.hpp index 6397064f..43d43205 100644 --- a/plugin/src/Caelestia/Config/barconfig.hpp +++ b/plugin/src/Caelestia/Config/barconfig.hpp @@ -8,6 +8,8 @@ namespace caelestia::config { +using Qt::StringLiterals::operator""_s; + class BarScrollActions : public ConfigObject { Q_OBJECT QML_ANONYMOUS @@ -46,12 +48,16 @@ class BarWorkspaces : public ConfigObject { CONFIG_PROPERTY(int, maxWindowIcons, 5) CONFIG_PROPERTY(bool, activeTrail, false) CONFIG_GLOBAL_PROPERTY(bool, perMonitorWorkspaces, true) - CONFIG_PROPERTY(QString, label, QStringLiteral(" ")) - CONFIG_PROPERTY(QString, occupiedLabel, QStringLiteral("\U000f06af")) - CONFIG_PROPERTY(QString, activeLabel, QStringLiteral("\U000f06af")) - CONFIG_PROPERTY(QString, capitalisation, QStringLiteral("preserve")) + CONFIG_PROPERTY(QString, label, u" "_s) + CONFIG_PROPERTY(QString, occupiedLabel, u"󰮯"_s) + CONFIG_PROPERTY(QString, activeLabel, u"󰮯"_s) + CONFIG_PROPERTY(QString, capitalisation, u"preserve"_s) CONFIG_GLOBAL_PROPERTY(QVariantList, specialWorkspaceIcons) - CONFIG_GLOBAL_PROPERTY(QVariantList, windowIcons) + CONFIG_GLOBAL_PROPERTY(QVariantList, windowIcons, + { vmap({ + { u"regex"_s, u"steam(_app_(default|[0-9]+))?"_s }, + { u"icon"_s, u"sports_esports"_s }, + }) }) public: explicit BarWorkspaces(QObject* parent = nullptr) @@ -131,7 +137,18 @@ class BarConfig : public ConfigObject { CONFIG_SUBOBJECT(BarTray, tray) CONFIG_SUBOBJECT(BarStatus, status) CONFIG_SUBOBJECT(BarClock, clock) - CONFIG_PROPERTY(QVariantList, entries) + CONFIG_PROPERTY(QVariantList, entries, + { + vmap({ { u"id"_s, u"logo"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"workspaces"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"spacer"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"activeWindow"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"spacer"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"tray"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"clock"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"statusIcons"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"power"_s }, { u"enabled"_s, true } }), + }) CONFIG_PROPERTY(QStringList, excludedScreens) public: diff --git a/plugin/src/Caelestia/Config/configobject.hpp b/plugin/src/Caelestia/Config/configobject.hpp index c35d812c..c4f4428b 100644 --- a/plugin/src/Caelestia/Config/configobject.hpp +++ b/plugin/src/Caelestia/Config/configobject.hpp @@ -9,6 +9,17 @@ #include #include +namespace caelestia::config { + +inline QVariantMap vmap(std::initializer_list> entries) { + QVariantMap map; + for (const auto& [key, value] : entries) + map.insert(std::move(key), std::move(value)); + return map; +} + +} // namespace caelestia::config + // Declares a serialized config property with getter, setter (change-detected), signal, and member. #define CONFIG_PROPERTY(Type, name, ...) \ Q_PROPERTY(Type name READ name WRITE set_##name NOTIFY name##Changed) \ diff --git a/plugin/src/Caelestia/Config/generalconfig.hpp b/plugin/src/Caelestia/Config/generalconfig.hpp index f84cfa34..73a4915d 100644 --- a/plugin/src/Caelestia/Config/generalconfig.hpp +++ b/plugin/src/Caelestia/Config/generalconfig.hpp @@ -8,14 +8,16 @@ namespace caelestia::config { +using Qt::StringLiterals::operator""_s; + class GeneralApps : public ConfigObject { Q_OBJECT QML_ANONYMOUS - CONFIG_GLOBAL_PROPERTY(QStringList, terminal, { QStringLiteral("foot") }) - CONFIG_GLOBAL_PROPERTY(QStringList, audio, { QStringLiteral("pavucontrol") }) - CONFIG_GLOBAL_PROPERTY(QStringList, playback, { QStringLiteral("mpv") }) - CONFIG_GLOBAL_PROPERTY(QStringList, explorer, { QStringLiteral("thunar") }) + CONFIG_GLOBAL_PROPERTY(QStringList, terminal, { u"foot"_s }) + CONFIG_GLOBAL_PROPERTY(QStringList, audio, { u"pavucontrol"_s }) + CONFIG_GLOBAL_PROPERTY(QStringList, playback, { u"mpv"_s }) + CONFIG_GLOBAL_PROPERTY(QStringList, explorer, { u"thunar"_s }) public: explicit GeneralApps(QObject* parent = nullptr) @@ -28,7 +30,22 @@ class GeneralIdle : public ConfigObject { CONFIG_GLOBAL_PROPERTY(bool, lockBeforeSleep, true) CONFIG_GLOBAL_PROPERTY(bool, inhibitWhenAudio, true) - CONFIG_GLOBAL_PROPERTY(QVariantList, timeouts) + CONFIG_GLOBAL_PROPERTY(QVariantList, timeouts, + { + vmap({ + { u"timeout"_s, 180 }, + { u"idleAction"_s, u"lock"_s }, + }), + vmap({ + { u"timeout"_s, 300 }, + { u"idleAction"_s, u"dpms off"_s }, + { u"returnAction"_s, u"dpms on"_s }, + }), + vmap({ + { u"timeout"_s, 600 }, + { u"idleAction"_s, QStringList{ u"systemctl"_s, u"suspend-then-hibernate"_s } }, + }), + }) public: explicit GeneralIdle(QObject* parent = nullptr) @@ -39,7 +56,28 @@ class GeneralBattery : public ConfigObject { Q_OBJECT QML_ANONYMOUS - CONFIG_GLOBAL_PROPERTY(QVariantList, warnLevels) + CONFIG_GLOBAL_PROPERTY(QVariantList, warnLevels, + { + vmap({ + { u"level"_s, 20 }, + { u"title"_s, u"Low battery"_s }, + { u"message"_s, u"You might want to plug in a charger"_s }, + { u"icon"_s, u"battery_android_frame_2"_s }, + }), + vmap({ + { u"level"_s, 10 }, + { u"title"_s, u"Did you see the previous message?"_s }, + { u"message"_s, u"You should probably plug in a charger now"_s }, + { u"icon"_s, u"battery_android_frame_1"_s }, + }), + vmap({ + { u"level"_s, 5 }, + { u"title"_s, u"Critical battery level"_s }, + { u"message"_s, u"PLUG THE CHARGER RIGHT NOW!!"_s }, + { u"icon"_s, u"battery_android_alert"_s }, + { u"critical"_s, true }, + }), + }) CONFIG_GLOBAL_PROPERTY(int, criticalLevel, 3) public: diff --git a/plugin/src/Caelestia/Config/launcherconfig.hpp b/plugin/src/Caelestia/Config/launcherconfig.hpp index b0c8d06b..049e213a 100644 --- a/plugin/src/Caelestia/Config/launcherconfig.hpp +++ b/plugin/src/Caelestia/Config/launcherconfig.hpp @@ -8,6 +8,8 @@ namespace caelestia::config { +using Qt::StringLiterals::operator""_s; + class LauncherUseFuzzy : public ConfigObject { Q_OBJECT QML_ANONYMOUS @@ -31,15 +33,98 @@ class LauncherConfig : public ConfigObject { CONFIG_PROPERTY(bool, showOnHover, false) CONFIG_PROPERTY(int, maxShown, 7) CONFIG_PROPERTY(int, maxWallpapers, 9) - CONFIG_GLOBAL_PROPERTY(QString, specialPrefix, QStringLiteral("@")) - CONFIG_GLOBAL_PROPERTY(QString, actionPrefix, QStringLiteral(">")) + CONFIG_GLOBAL_PROPERTY(QString, specialPrefix, u"@"_s) + CONFIG_GLOBAL_PROPERTY(QString, actionPrefix, u">"_s) CONFIG_GLOBAL_PROPERTY(bool, enableDangerousActions, false) CONFIG_PROPERTY(int, dragThreshold, 50) CONFIG_GLOBAL_PROPERTY(bool, vimKeybinds, false) CONFIG_GLOBAL_PROPERTY(QStringList, favouriteApps) CONFIG_GLOBAL_PROPERTY(QStringList, hiddenApps) CONFIG_SUBOBJECT(LauncherUseFuzzy, useFuzzy) - CONFIG_GLOBAL_PROPERTY(QVariantList, actions) + CONFIG_GLOBAL_PROPERTY(QVariantList, actions, + { + vmap({ + { u"name"_s, u"Calculator"_s }, + { u"icon"_s, u"calculate"_s }, + { u"description"_s, u"Do simple math equations (powered by Qalc)"_s }, + { u"command"_s, QStringList{ u"autocomplete"_s, u"calc"_s } }, + }), + vmap({ + { u"name"_s, u"Scheme"_s }, + { u"icon"_s, u"palette"_s }, + { u"description"_s, u"Change the current colour scheme"_s }, + { u"command"_s, QStringList{ u"autocomplete"_s, u"scheme"_s } }, + }), + vmap({ + { u"name"_s, u"Wallpaper"_s }, + { u"icon"_s, u"image"_s }, + { u"description"_s, u"Change the current wallpaper"_s }, + { u"command"_s, QStringList{ u"autocomplete"_s, u"wallpaper"_s } }, + }), + vmap({ + { u"name"_s, u"Variant"_s }, + { u"icon"_s, u"colors"_s }, + { u"description"_s, u"Change the current scheme variant"_s }, + { u"command"_s, QStringList{ u"autocomplete"_s, u"variant"_s } }, + }), + vmap({ + { u"name"_s, u"Random"_s }, + { u"icon"_s, u"casino"_s }, + { u"description"_s, u"Switch to a random wallpaper"_s }, + { u"command"_s, QStringList{ u"caelestia"_s, u"wallpaper"_s, u"-r"_s } }, + }), + vmap({ + { u"name"_s, u"Light"_s }, + { u"icon"_s, u"light_mode"_s }, + { u"description"_s, u"Change the scheme to light mode"_s }, + { u"command"_s, QStringList{ u"setMode"_s, u"light"_s } }, + }), + vmap({ + { u"name"_s, u"Dark"_s }, + { u"icon"_s, u"dark_mode"_s }, + { u"description"_s, u"Change the scheme to dark mode"_s }, + { u"command"_s, QStringList{ u"setMode"_s, u"dark"_s } }, + }), + vmap({ + { u"name"_s, u"Shutdown"_s }, + { u"icon"_s, u"power_settings_new"_s }, + { u"description"_s, u"Shutdown the system"_s }, + { u"command"_s, QStringList{ u"systemctl"_s, u"poweroff"_s } }, + { u"dangerous"_s, true }, + }), + vmap({ + { u"name"_s, u"Reboot"_s }, + { u"icon"_s, u"cached"_s }, + { u"description"_s, u"Reboot the system"_s }, + { u"command"_s, QStringList{ u"systemctl"_s, u"reboot"_s } }, + { u"dangerous"_s, true }, + }), + vmap({ + { u"name"_s, u"Logout"_s }, + { u"icon"_s, u"exit_to_app"_s }, + { u"description"_s, u"Log out of the current session"_s }, + { u"command"_s, QStringList{ u"loginctl"_s, u"terminate-user"_s, u""_s } }, + { u"dangerous"_s, true }, + }), + vmap({ + { u"name"_s, u"Lock"_s }, + { u"icon"_s, u"lock"_s }, + { u"description"_s, u"Lock the current session"_s }, + { u"command"_s, QStringList{ u"loginctl"_s, u"lock-session"_s } }, + }), + vmap({ + { u"name"_s, u"Sleep"_s }, + { u"icon"_s, u"bedtime"_s }, + { u"description"_s, u"Suspend then hibernate"_s }, + { u"command"_s, QStringList{ u"systemctl"_s, u"suspend-then-hibernate"_s } }, + }), + vmap({ + { u"name"_s, u"Settings"_s }, + { u"icon"_s, u"settings"_s }, + { u"description"_s, u"Configure the shell"_s }, + { u"command"_s, QStringList{ u"caelestia"_s, u"shell"_s, u"controlCenter"_s, u"open"_s } }, + }), + }) public: explicit LauncherConfig(QObject* parent = nullptr) diff --git a/plugin/src/Caelestia/Config/serviceconfig.hpp b/plugin/src/Caelestia/Config/serviceconfig.hpp index 439092af..b97c69c1 100644 --- a/plugin/src/Caelestia/Config/serviceconfig.hpp +++ b/plugin/src/Caelestia/Config/serviceconfig.hpp @@ -7,24 +7,33 @@ namespace caelestia::config { +using Qt::StringLiterals::operator""_s; + class ServiceConfig : public ConfigObject { Q_OBJECT QML_ANONYMOUS CONFIG_GLOBAL_PROPERTY(QString, weatherLocation) - CONFIG_GLOBAL_PROPERTY(bool, useFahrenheit, false) + // Guess based on locale + CONFIG_GLOBAL_PROPERTY(bool, useFahrenheit, + QLocale().measurementSystem() == QLocale::ImperialUSSystem || + QLocale().measurementSystem() == QLocale::ImperialUKSystem) + // This is always false by default cause apparently even imperial system users don't use it for perf temps? CONFIG_GLOBAL_PROPERTY(bool, useFahrenheitPerformance, false) - CONFIG_GLOBAL_PROPERTY(bool, useTwelveHourClock, false) + // Attempt to guess based on locale + CONFIG_GLOBAL_PROPERTY( + bool, useTwelveHourClock, QLocale().timeFormat(QLocale::ShortFormat).toLower().contains(u"a"_s)) CONFIG_GLOBAL_PROPERTY(QString, gpuType) CONFIG_GLOBAL_PROPERTY(int, visualiserBars, 45) CONFIG_GLOBAL_PROPERTY(qreal, audioIncrement, 0.1) CONFIG_GLOBAL_PROPERTY(qreal, brightnessIncrement, 0.1) CONFIG_GLOBAL_PROPERTY(qreal, maxVolume, 1.0) CONFIG_GLOBAL_PROPERTY(bool, smartScheme, true) - CONFIG_GLOBAL_PROPERTY(QString, defaultPlayer, QStringLiteral("Spotify")) - CONFIG_GLOBAL_PROPERTY(QVariantList, playerAliases) + CONFIG_GLOBAL_PROPERTY(QString, defaultPlayer, u"Spotify"_s) + CONFIG_GLOBAL_PROPERTY(QVariantList, playerAliases, + { vmap({ { u"from"_s, u"com.github.th_ch.youtube_music"_s }, { u"to"_s, u"YT Music"_s } }) }) CONFIG_GLOBAL_PROPERTY(bool, showLyrics, false) - CONFIG_GLOBAL_PROPERTY(QString, lyricsBackend, QStringLiteral("Auto")) + CONFIG_GLOBAL_PROPERTY(QString, lyricsBackend, u"Auto"_s) public: explicit ServiceConfig(QObject* parent = nullptr) diff --git a/plugin/src/Caelestia/Config/sessionconfig.hpp b/plugin/src/Caelestia/Config/sessionconfig.hpp index 629b3b6e..7e7548f1 100644 --- a/plugin/src/Caelestia/Config/sessionconfig.hpp +++ b/plugin/src/Caelestia/Config/sessionconfig.hpp @@ -7,14 +7,16 @@ namespace caelestia::config { +using Qt::StringLiterals::operator""_s; + class SessionIcons : public ConfigObject { Q_OBJECT QML_ANONYMOUS - CONFIG_PROPERTY(QString, logout, QStringLiteral("logout")) - CONFIG_PROPERTY(QString, shutdown, QStringLiteral("power_settings_new")) - CONFIG_PROPERTY(QString, hibernate, QStringLiteral("downloading")) - CONFIG_PROPERTY(QString, reboot, QStringLiteral("cached")) + CONFIG_PROPERTY(QString, logout, u"logout"_s) + CONFIG_PROPERTY(QString, shutdown, u"power_settings_new"_s) + CONFIG_PROPERTY(QString, hibernate, u"downloading"_s) + CONFIG_PROPERTY(QString, reboot, u"cached"_s) public: explicit SessionIcons(QObject* parent = nullptr) @@ -25,10 +27,10 @@ class SessionCommands : public ConfigObject { Q_OBJECT QML_ANONYMOUS - CONFIG_PROPERTY(QStringList, logout, { QStringLiteral("loginctl"), QStringLiteral("terminate-user"), QString() }) - CONFIG_PROPERTY(QStringList, shutdown, { QStringLiteral("systemctl"), QStringLiteral("poweroff") }) - CONFIG_PROPERTY(QStringList, hibernate, { QStringLiteral("systemctl"), QStringLiteral("hibernate") }) - CONFIG_PROPERTY(QStringList, reboot, { QStringLiteral("systemctl"), QStringLiteral("reboot") }) + CONFIG_PROPERTY(QStringList, logout, { u"loginctl"_s, u"terminate-user"_s, u""_s }) + CONFIG_PROPERTY(QStringList, shutdown, { u"systemctl"_s, u"poweroff"_s }) + CONFIG_PROPERTY(QStringList, hibernate, { u"systemctl"_s, u"hibernate"_s }) + CONFIG_PROPERTY(QStringList, reboot, { u"systemctl"_s, u"reboot"_s }) public: explicit SessionCommands(QObject* parent = nullptr) diff --git a/plugin/src/Caelestia/Config/userpaths.hpp b/plugin/src/Caelestia/Config/userpaths.hpp index f0d0fb2e..da6973a7 100644 --- a/plugin/src/Caelestia/Config/userpaths.hpp +++ b/plugin/src/Caelestia/Config/userpaths.hpp @@ -8,17 +8,19 @@ namespace caelestia::config { +using Qt::StringLiterals::operator""_s; + class UserPaths : public ConfigObject { Q_OBJECT QML_ANONYMOUS - CONFIG_GLOBAL_PROPERTY(QString, wallpaperDir, - QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + QStringLiteral("/Wallpapers")) - CONFIG_GLOBAL_PROPERTY(QString, lyricsDir, QDir::homePath() + QStringLiteral("/Music/lyrics/")) - CONFIG_PROPERTY(QString, sessionGif, QStringLiteral("root:/assets/kurukuru.gif")) - CONFIG_PROPERTY(QString, mediaGif, QStringLiteral("root:/assets/bongocat.gif")) - CONFIG_PROPERTY(QString, noNotifsPic, QStringLiteral("root:/assets/dino.png")) - CONFIG_PROPERTY(QString, lockNoNotifsPic, QStringLiteral("root:/assets/dino.png")) + CONFIG_GLOBAL_PROPERTY( + QString, wallpaperDir, QStandardPaths::writableLocation(QStandardPaths::PicturesLocation) + u"/Wallpapers"_s) + CONFIG_GLOBAL_PROPERTY(QString, lyricsDir, QDir::homePath() + u"/Music/lyrics/"_s) + CONFIG_PROPERTY(QString, sessionGif, u"root:/assets/kurukuru.gif"_s) + CONFIG_PROPERTY(QString, mediaGif, u"root:/assets/bongocat.gif"_s) + CONFIG_PROPERTY(QString, noNotifsPic, u"root:/assets/dino.png"_s) + CONFIG_PROPERTY(QString, lockNoNotifsPic, u"root:/assets/dino.png"_s) public: explicit UserPaths(QObject* parent = nullptr) diff --git a/plugin/src/Caelestia/Config/utilitiesconfig.hpp b/plugin/src/Caelestia/Config/utilitiesconfig.hpp index cabb877e..3e5625bb 100644 --- a/plugin/src/Caelestia/Config/utilitiesconfig.hpp +++ b/plugin/src/Caelestia/Config/utilitiesconfig.hpp @@ -7,11 +7,13 @@ namespace caelestia::config { +using Qt::StringLiterals::operator""_s; + class UtilitiesToasts : public ConfigObject { Q_OBJECT QML_ANONYMOUS - CONFIG_PROPERTY(QString, fullscreen, QStringLiteral("off")) + CONFIG_PROPERTY(QString, fullscreen, u"off"_s) CONFIG_GLOBAL_PROPERTY(bool, configLoaded, true) CONFIG_GLOBAL_PROPERTY(bool, chargingChanged, true) CONFIG_GLOBAL_PROPERTY(bool, gameModeChanged, true) @@ -50,7 +52,16 @@ class UtilitiesConfig : public ConfigObject { CONFIG_PROPERTY(int, maxToasts, 4) CONFIG_SUBOBJECT(UtilitiesToasts, toasts) CONFIG_SUBOBJECT(UtilitiesVpn, vpn) - CONFIG_PROPERTY(QVariantList, quickToggles) + CONFIG_PROPERTY(QVariantList, quickToggles, + { + vmap({ { u"id"_s, u"wifi"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"bluetooth"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"mic"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"settings"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"gameMode"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"dnd"_s }, { u"enabled"_s, true } }), + vmap({ { u"id"_s, u"vpn"_s }, { u"enabled"_s, false } }), + }) public: explicit UtilitiesConfig(QObject* parent = nullptr)