diff --git a/res/config/main.xml b/res/config/main.xml index 9584ffbd..44c855c3 100644 --- a/res/config/main.xml +++ b/res/config/main.xml @@ -55,6 +55,11 @@ false + + + + + 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 f5091eec..9ce54aa9 100644 --- a/res/ui/config.ui +++ b/res/ui/config.ui @@ -178,11 +178,82 @@ + + + + + + Default: + + + + + + + + Tile Layout + + + + + Monocle Layout + + + + + Three Column Layout + + + + + Spiral Column Layout + + + + + Quarter Layout + + + + + Spread Layout + + + + + Stair Layout + + + + + Floating Layout + + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 20 + 20 + + + + + + - + Qt::Vertical diff --git a/src/config.ts b/src/config.ts index 25d0dba4..03133458 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]); // 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 if (this.kwinApi.KWin.readConfig(configKey, defaultValue))