diff --git a/app-carousel/AppConfig.qml b/app-carousel/AppConfig.qml index 318bffe..a59c26e 100644 --- a/app-carousel/AppConfig.qml +++ b/app-carousel/AppConfig.qml @@ -14,39 +14,42 @@ Item { watchChanges: true onFileChanged: configFile.reload() onLoaded: { - let parsed = JSON.parse(configFile.text()); - if (!Array.isArray(parsed)) { - throw new Error(`Invalid app config: expected a JSON array, got ${typeof parsed}`); + const logPrefix = 'Invalid app config: '; + const testIt = (cond, error) => { + if (!cond) { + throw new Error(`${logPrefix} ${error}`) + } } - for (const elm of parsed) { - if (!(typeof elm.name == 'string')) { - throw new Error(`Invalid app config: expected name to be a string, got ${typeof elm.name}`); - } - if (!(typeof elm.image == 'string')) { - throw new Error(`Invalid app config: expected image to be a string, got ${typeof elm.image}`); - } - if (elm.isIcon !== undefined && typeof elm.isIcon !== 'boolean') { - throw new Error(`Invalid app config: expected isIcon to be a boolean, got ${typeof elm.isIcon}`); + const isOf = (typeName) => (name, elm, iffDefined = false) => { + if (!iffDefined || (iffDefined && elm !== undefined)) { + testIt(typeof elm === typeName, `expected ${name} to be a ${typeName}, got ${typeof elm}`) } + } + const isBoolean = isOf('boolean') + const isString = isOf('string') + let parsed = JSON.parse(configFile.text()); + let apps = parsed.apps; + if (!Array.isArray(apps)) { + throw new Error(`Invalid app config: expected a JSON array, got ${typeof apps}`); + } + isBoolean('autoStart', parsed.autoStart, true) + for (const elm of apps) { + isString('name', elm.name) + isString('image', elm.image) + isBoolean('isIcon', elm.isIcon, true) if (elm.dims !== undefined) { - if (!elm.isIcon) { - throw new Error(`Invalid app config: dims is only allowed when isIcon is true`); - } + testIt(elm.isIcon, 'dims is only allowed when isIcon is true') if (!Array.isArray(elm.dims) || elm.dims.length !== 2 || !elm.dims.every(n => Number.isInteger(n))) { - throw new Error(`Invalid app config: expected dims to be a tuple of 2 ints`); + throw new Error(`${logPrefix} expected dims to be a tuple of 2 ints`); } } else { elm.dims = [100, 100]; } - if (!Array.isArray(elm.exec) || elm.exec.length === 0) { - throw new Error(`Invalid app config: expected exec to be a non-empty array, got ${typeof elm.exec}`); - } - if (!elm.exec.every(arg => typeof arg === 'string')) { - throw new Error(`Invalid app config: expected all exec entries to be strings`); - } + testIt(Array.isArray(elm.exec) && elm.exec.length > 0, `expected exec to be a non-empty array, got ${elm.exec}`) + testIt(elm.exec.every(arg => typeof arg === 'string'), 'expected all exec entries to be strings') } console.log("Loaded Config", configFile.__data); - root.appConfig = parsed; + root.appConfig = apps; } } } diff --git a/app-carousel/Theme.qml b/app-carousel/Theme.qml index e262b88..3d1ec87 100644 --- a/app-carousel/Theme.qml +++ b/app-carousel/Theme.qml @@ -6,10 +6,10 @@ QtObject { readonly property color selectedBorder: "#7aa2f7" readonly property color textColor: "#ffffff" readonly property color labelBg: "#99000000" - readonly property real cornerRadius: 10 - readonly property real cardWidth: 240 - readonly property real cardHeight: 240 - readonly property real cardPadding: 10 + readonly property real cornerRadius: 20 + readonly property real cardWidth: 480 + readonly property real cardHeight: 480 + readonly property real cardPadding: 50 readonly property real cardSpacing: 40 readonly property real fontSize: 24 diff --git a/example.json b/example.json index 62af3a4..be3920d 100644 --- a/example.json +++ b/example.json @@ -1,30 +1,22 @@ -[ - { - "name": "Chromium", - "image": "chromium", - "isIcon": true, - "exec": [ - "chromium" - ] - }, - { - "name": "Netflix", - "image": "https://assets.nflxext.com/us/ffe/siteui/common/icons/nficon2023.ico", - "exec": [ - "chromium", - "--app=https://www.netflix.com" - ] - }, - { - "name": "Settings", - "image": "system-settings", - "isIcon": true, - "exec": [ - "dms", - "ipc", - "call", - "settings", - "toggle" - ] - } -] \ No newline at end of file +{ + "autoStart": true, + "apps": [ + { + "name": "Chromium", + "image": "chromium", + "isIcon": true, + "exec": ["chromium"] + }, + { + "name": "Netflix", + "image": "https://assets.nflxext.com/us/ffe/siteui/common/icons/nficon2023.ico", + "exec": ["chromium", "--app=https://www.netflix.com"] + }, + { + "name": "Settings", + "image": "system-settings", + "isIcon": true, + "exec": ["dms", "ipc", "call", "settings", "toggle"] + } + ] +} diff --git a/webpreview/shell.qml b/webpreview/shell.qml deleted file mode 100644 index e06ef0f..0000000 --- a/webpreview/shell.qml +++ /dev/null @@ -1,33 +0,0 @@ -import QtQuick -import QtWebEngine -import Quickshell - -ShellRoot { - // Ensure the WebEngine is initialized - Component.onCompleted: WebEngine.initialize() - - PanelWindow { - id: webWindow - width: 800 - height: 600 - - // Background container - Rectangle { - anchors.fill: parent - color: "#1e1e2e" // Match your desktop theme - - // The embedded Web Page Component - WebEngineView { - anchors.fill: parent - url: "https://quickshell.org" // The URL you want to embed - - // Optional: Handle loading status - onLoadingChanged: (loadingInfo) => { - if (loadingInfo.status === WebEngineView.LoadFailedStatus) { - console.log("Failed to load page: " + loadingInfo.errorString); - } - } - } - } - } -} \ No newline at end of file