From 40800a8e8e62f96266d73fc5153a3722f65015ed Mon Sep 17 00:00:00 2001 From: Laurent Constantin Date: Tue, 3 Oct 2023 13:12:47 +0200 Subject: [PATCH 1/2] Add configuration for logs --- Makefile | 2 ++ contents/code/extern/kwin.d.ts | 26 +++++++++++++++++ contents/code/main.ts | 22 ++++++++++++--- contents/config/main.xml | 16 +++++++++++ contents/ui/config.ui | 51 ++++++++++++++++++++++++++++++++++ metadata.json | 1 + 6 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 contents/code/extern/kwin.d.ts create mode 100644 contents/config/main.xml create mode 100644 contents/ui/config.ui diff --git a/Makefile b/Makefile index 25771e4..5688cd1 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,8 @@ lint: clear # Lint build: clear compile # Build package mkdir -p build/contents/code cp -r contents/code build/contents/ + cp -r contents/config build/contents/ + cp -r contents/ui build/contents/ @find "build/" '(' -name "*.ts" ')' -delete @find "build/" -type d -empty -print -delete cp metadata.json build/ diff --git a/contents/code/extern/kwin.d.ts b/contents/code/extern/kwin.d.ts new file mode 100644 index 0000000..3571d9b --- /dev/null +++ b/contents/code/extern/kwin.d.ts @@ -0,0 +1,26 @@ +// Copyright (c) 2018-2019 Eon S. Jeon +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +// API Reference: +// https://techbase.kde.org/Development/Tutorials/KWin/Scripting/API_4.9 + +declare let readConfig: (key: string, defaultValue?: any) => any; + + diff --git a/contents/code/main.ts b/contents/code/main.ts index 5f9048d..457e59e 100644 --- a/contents/code/main.ts +++ b/contents/code/main.ts @@ -12,10 +12,19 @@ enum LogLevel } class Config { - logLevel: LogLevel = LogLevel.NOTICE; - logMaximize: boolean = false; + constructor(debug: boolean = false) { + this.logLevel = debug ? LogLevel.DEBUG: LogLevel.NOTICE; + this.logMaximize = debug + this.logDebugTree = debug + } + + setLogWindowProperties(value: boolean){ + this.logWindowProperties = value; + } + logLevel: LogLevel; + logMaximize: boolean; logWindowProperties: boolean = false; - logDebugTree: boolean = false; + logDebugTree: boolean; logDebugScreens: boolean = false; logEvents: boolean = false; doMaximizeSingleWindow: boolean = true; @@ -540,4 +549,9 @@ class Tiler{ } } -(new Tiler(new Config())); +const isDebug = readConfig("isDebug", false); +const config = new Config(isDebug); +config.setLogWindowProperties(readConfig("logWindowProperties", false)) + +console.log(`Tiling started with debug: ${isDebug}`) +new Tiler(config); diff --git a/contents/config/main.xml b/contents/config/main.xml new file mode 100644 index 0000000..98184ee --- /dev/null +++ b/contents/config/main.xml @@ -0,0 +1,16 @@ + + + + + + false + + + false + + + + diff --git a/contents/ui/config.ui b/contents/ui/config.ui new file mode 100644 index 0000000..d02970e --- /dev/null +++ b/contents/ui/config.ui @@ -0,0 +1,51 @@ + + + KWin::ApiTilingConfigForm + + + + 0 + 0 + 393 + 146 + + + + Kwin-api-tiling settings + + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + + + true + + + Enable debug logs + + + false + + + + + + + Log Window properties + + + + + + + Changes apply only after disabling and re-enabling the script! + + + + + + + + diff --git a/metadata.json b/metadata.json index 0b73df8..815f09f 100644 --- a/metadata.json +++ b/metadata.json @@ -12,6 +12,7 @@ "Version": "0.1", "License": "GPLv3" }, + "X-KDE-ConfigModule": "kwin/effects/configs/kcm_kwin4_genericscripted", "X-Plasma-API": "javascript", "X-Plasma-MainScript": "code/main.js", "KPackageStructure": "KWin/Script" From 1061b67fdbbce6f807227df11f98108d1f7351e7 Mon Sep 17 00:00:00 2001 From: Laurent Constantin Date: Wed, 4 Oct 2023 23:32:26 +0200 Subject: [PATCH 2/2] Bump version to v0.1.1 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 815f09f..d658940 100644 --- a/metadata.json +++ b/metadata.json @@ -9,7 +9,7 @@ } ], "Id": "kde-tiling-on-drag", - "Version": "0.1", + "Version": "v0.1.1", "License": "GPLv3" }, "X-KDE-ConfigModule": "kwin/effects/configs/kcm_kwin4_genericscripted",