Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Add option to select the default layout #117

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
5 changes: 5 additions & 0 deletions res/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
<default>false</default>
</entry>

<entry name="defaultLayout" type="Int">
<label>Change the default layout</label>
<default>Tile Layout</default>
winiciuscota marked this conversation as resolved.
Show resolved Hide resolved
</entry>

<entry name="ignoreActivity" type="String">
<label>Do not apply tiling on some activities(comma-separated list of activity names)</label>
<default></default>
Expand Down
77 changes: 64 additions & 13 deletions res/ui/config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,73 @@
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Default</string>
winiciuscota marked this conversation as resolved.
Show resolved Hide resolved
</property>
</widget>
</item>
<item>
<widget class="KComboBox" name="kcfg_defaultLayout">
<item>
<property name="text">
<string>Tile Layout</string>
</property>
</item>
<item>
<property name="text">
<string>Monocle Layout</string>
</property>
</item>
<item>
<property name="text">
<string>Three Column Layout</string>
</property>
</item>
<item>
<property name="text">
<string>Spiral Column Layout</string>
</property>
</item>
<item>
<property name="text">
<string>Quarter Layout</string>
</property>
</item>
<item>
<property name="text">
<string>Spread Layout</string>
</property>
</item>
<item>
<property name="text">
<string>Stair Layout</string>
</property>
</item>
<item>
<property name="text">
<string>Floating Layout</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="geometryTab">
Expand Down
29 changes: 16 additions & 13 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
winiciuscota marked this conversation as resolved.
Show resolved Hide resolved
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))
Expand Down