From f63a0f1564d05d4994ac477e542688975952218b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Win=C3=ADcius=20Iago=20Vieira=20Cota?= Date: Sun, 21 Mar 2021 23:22:28 -0300 Subject: [PATCH] Add option to select the default layout --- res/config.ui | 80 +++++++++++++++++++++++++++++------ res/config.xml | 5 +++ src/driver/kwin/kwinconfig.ts | 10 +++-- 3 files changed, 79 insertions(+), 16 deletions(-) diff --git a/res/config.ui b/res/config.ui index 6d69a1f..daece1f 100644 --- a/res/config.ui +++ b/res/config.ui @@ -178,22 +178,76 @@ + + + + Qt::Vertical + + + + 20 + 5 + + + + + + + + Default + + + + + + + Change the default layout + + + + Tile Layout + + + + + Monocle Layout + + + + + Three Column Layout + + + + + Spiral Layout + + + + + Quarter Layout + + + + + Spread Layout + + + + + Stair Layout + + + + + Floating Layout + + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - diff --git a/res/config.xml b/res/config.xml index cae197b..69087ed 100644 --- a/res/config.xml +++ b/res/config.xml @@ -51,6 +51,11 @@ false + + + Tile Layout + + diff --git a/src/driver/kwin/kwinconfig.ts b/src/driver/kwin/kwinconfig.ts index 99fc86b..a2ee364 100644 --- a/src/driver/kwin/kwinconfig.ts +++ b/src/driver/kwin/kwinconfig.ts @@ -20,6 +20,7 @@ class KWinConfig implements IConfig { //#region Layout + public defaultLayout: number; public layoutOrder: string[]; public layoutFactories: {[key: string]: () => ILayout}; public maximizeSoleTile: boolean; @@ -78,9 +79,10 @@ class KWinConfig implements IConfig { DEBUG.enabled = DEBUG.enabled || KWin.readConfig("debug", false); + this.defaultLayout = KWin.readConfig("defaultLayout", 0); this.layoutOrder = []; this.layoutFactories = {}; - ([ + const layouts = ([ ["enableTileLayout" , true , TileLayout ], ["enableMonocleLayout" , true , MonocleLayout ], ["enableThreeColumnLayout", true , ThreeColumnLayout], @@ -90,8 +92,10 @@ class KWinConfig implements IConfig { ["enableQuarterLayout" , false, QuarterLayout ], ["enableFloatingLayout" , false, FloatingLayout ], ["enableCascadeLayout" , false, CascadeLayout ], // TODO: add config - ] as Array<[string, boolean, ILayoutClass]>) - .forEach(([configKey, defaultValue, layoutClass]) => { + ] as Array<[string, boolean, ILayoutClass]>); + + layouts.unshift(layouts.splice(this.defaultLayout, 1)[0]); + layouts.forEach(([configKey, defaultValue, layoutClass]) => { if (KWin.readConfig(configKey, defaultValue)) this.layoutOrder.push(layoutClass.id); this.layoutFactories[layoutClass.id] = (() => new layoutClass());