From 07c4de7e91da041d269ec0ff9ec2cb7cddf2f23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Win=C3=ADcius=20Iago=20Vieira=20Cota?= Date: Mon, 18 Oct 2021 04:28:24 -0300 Subject: [PATCH 1/4] Add option to select the default layout --- res/config/main.xml | 5 +++ res/ui/config.ui | 84 ++++++++++++++++++++++++++++++++++++++------- src/config.ts | 29 +++++++++------- 3 files changed, 92 insertions(+), 26 deletions(-) diff --git a/res/config/main.xml b/res/config/main.xml index 9584ffbd..6a4549d9 100644 --- a/res/config/main.xml +++ b/res/config/main.xml @@ -55,6 +55,11 @@ false + + + Tile Layout + + diff --git a/res/ui/config.ui b/res/ui/config.ui index f5091eec..da588de2 100644 --- a/res/ui/config.ui +++ b/res/ui/config.ui @@ -178,22 +178,73 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Default + + + + + + + + Tile Layout + + + + + Monocle Layout + + + + + Three Column Layout + + + + + Spiral Column Layout + + + + + Quarter Layout + + + + + Spread Layout + + + + + Stair Layout + + + + + Floating Layout + + + + - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -649,6 +700,13 @@ + + + KComboBox + QComboBox +
kcombobox.h
+
+
diff --git a/src/config.ts b/src/config.ts index 25d0dba4..a6ffc460 100644 --- a/src/config.ts +++ b/src/config.ts @@ -76,6 +76,7 @@ type LayoutFactories = { [key: string]: () => WindowsLayout }; export class ConfigImpl implements Config { //#region Layout + public defaultLayout: number; public layoutOrder: string[]; public layoutFactories: LayoutFactories; public maximizeSoleTile: boolean; @@ -142,20 +143,22 @@ export class ConfigImpl implements Config { // TODO: Refactor this: config should not create factories. It is not its responsibility this.layoutOrder = []; + this.defaultLayout = this.kwinApi.KWin.readConfig("defaultLayout", 0); this.layoutFactories = {}; - ( - [ - ["enableTileLayout", true, TileLayout], - ["enableMonocleLayout", true, MonocleLayout], - ["enableThreeColumnLayout", true, ThreeColumnLayout], - ["enableSpreadLayout", true, SpreadLayout], - ["enableStairLayout", true, StairLayout], - ["enableSpiralLayout", true, SpiralLayout], - ["enableQuarterLayout", false, QuarterLayout], - ["enableFloatingLayout", false, FloatingLayout], - ["enableCascadeLayout", false, CascadeLayout], // TODO: add config - ] as Array<[string, boolean, WindowsLayoutClass]> - ).forEach(([configKey, defaultValue, layoutClass]) => { + const layouts = [ + ["enableTileLayout", true, TileLayout], + ["enableMonocleLayout", true, MonocleLayout], + ["enableThreeColumnLayout", true, ThreeColumnLayout], + ["enableSpreadLayout", true, SpreadLayout], + ["enableStairLayout", true, StairLayout], + ["enableSpiralLayout", true, SpiralLayout], + ["enableQuarterLayout", false, QuarterLayout], + ["enableFloatingLayout", false, FloatingLayout], + ["enableCascadeLayout", false, CascadeLayout], // TODO: add config + ] as Array<[string, boolean, WindowsLayoutClass]>; + + layouts.unshift(layouts.splice(this.defaultLayout, 1)[0]); + layouts.forEach(([configKey, defaultValue, layoutClass]) => { // For some reason if we put the curly brackets here script breaks // This will be dealt with, when this facility will be refactored out if (this.kwinApi.KWin.readConfig(configKey, defaultValue)) From c9db7d7cd8ca2c434880857c21dc27de3fa4905e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Win=C3=ADcius=20Iago=20Vieira=20Cota?= Date: Mon, 18 Oct 2021 04:54:42 -0300 Subject: [PATCH 2/4] Remove unecessary code from res/ui/config.ui --- res/ui/config.ui | 7 ------- 1 file changed, 7 deletions(-) diff --git a/res/ui/config.ui b/res/ui/config.ui index da588de2..cdf9bf1b 100644 --- a/res/ui/config.ui +++ b/res/ui/config.ui @@ -700,13 +700,6 @@ - - - KComboBox - QComboBox -
kcombobox.h
-
-
From b49c4a105dc8dde5ea2abb2531f40dcae6d272f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Win=C3=ADcius=20Iago=20Vieira=20Cota?= Date: Tue, 19 Oct 2021 02:10:07 -0300 Subject: [PATCH 3/4] Minor layout adjusment --- res/install.sh | 0 res/ui/config.ui | 132 +++++++++++++++++++++++++++-------------------- src/config.ts | 4 +- 3 files changed, 78 insertions(+), 58 deletions(-) mode change 100644 => 100755 res/install.sh diff --git a/res/install.sh b/res/install.sh old mode 100644 new mode 100755 diff --git a/res/ui/config.ui b/res/ui/config.ui index cdf9bf1b..9ce54aa9 100644 --- a/res/ui/config.ui +++ b/res/ui/config.ui @@ -179,72 +179,92 @@ - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Default - - - - - - - - Tile Layout - - - - - Monocle Layout - - - - - Three Column Layout - - + - - Spiral Column Layout - - - - - Quarter Layout - - - - - Spread Layout - + + + Default: + + - - Stair Layout - + + + + Tile Layout + + + + + Monocle Layout + + + + + Three Column Layout + + + + + Spiral Column Layout + + + + + Quarter Layout + + + + + Spread Layout + + + + + Stair Layout + + + + + Floating Layout + + + - - Floating Layout - + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + - + + + + + Qt::Vertical + + + + 20 + 40 + + + + diff --git a/src/config.ts b/src/config.ts index a6ffc460..03133458 100644 --- a/src/config.ts +++ b/src/config.ts @@ -156,8 +156,8 @@ export class ConfigImpl implements Config { ["enableFloatingLayout", false, FloatingLayout], ["enableCascadeLayout", false, CascadeLayout], // TODO: add config ] as Array<[string, boolean, WindowsLayoutClass]>; - - layouts.unshift(layouts.splice(this.defaultLayout, 1)[0]); + + layouts.unshift(layouts.splice(this.defaultLayout, 1)[0]); // place the default layout at the top of the list layouts.forEach(([configKey, defaultValue, layoutClass]) => { // For some reason if we put the curly brackets here script breaks // This will be dealt with, when this facility will be refactored out From 996c0a8992057539f829d28a31941f0fe090a466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Win=C3=ADcius=20Iago=20Vieira=20Cota?= Date: Tue, 19 Oct 2021 02:17:24 -0300 Subject: [PATCH 4/4] Remove invalid default value --- res/config/main.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/config/main.xml b/res/config/main.xml index 6a4549d9..44c855c3 100644 --- a/res/config/main.xml +++ b/res/config/main.xml @@ -57,7 +57,7 @@ - Tile Layout +