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 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
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></default>
</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
Empty file modified res/install.sh
100644 → 100755
Empty file.
73 changes: 72 additions & 1 deletion res/ui/config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,82 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Default:</string>
</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>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
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]); // 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))
Expand Down