Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config panel #8

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
26 changes: 26 additions & 0 deletions contents/code/extern/kwin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2018-2019 Eon S. Jeon <esjeon@hyunmu.am>
//
// 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;


22 changes: 18 additions & 4 deletions contents/code/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
16 changes: 16 additions & 0 deletions contents/config/main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="">
<entry name="isDebug" type="bool">
<default>false</default>
</entry>
<entry name="logWindowProperties" type="bool">
<default>false</default>
</entry>
</group>

</kcfg>
51 changes: 51 additions & 0 deletions contents/ui/config.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWin::ApiTilingConfigForm</class>
<widget class="QWidget" name="KWin::ApiTilingConfigForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>393</width>
<height>146</height>
</rect>
</property>
<property name="windowTitle">
<string>Kwin-api-tiling settings</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="labelAlignment">
<set>Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing</set>
</property>
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_isDebug">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Enable debug logs</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="kcfg_logWindowProperties">
<property name="text">
<string>Log Window properties</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label" >
<property name="text">
<string>Changes apply only after disabling and re-enabling the script!</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
3 changes: 2 additions & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
}
],
"Id": "kde-tiling-on-drag",
"Version": "0.1",
"Version": "v0.1.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"
Expand Down
Loading