Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to select the default layout #160

Open
wants to merge 1 commit 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
80 changes: 67 additions & 13 deletions res/config.ui
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,76 @@
</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>5</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Default</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="kcfg_defaultLayout">
<property name="toolTip">
<string>Change the default layout</string>
</property>
<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 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
5 changes: 5 additions & 0 deletions res/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<default>false</default>
</entry>

<entry name="defaultLayout" type="Int">
<label>Change the default layout</label>
<default>Tile Layout</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
10 changes: 7 additions & 3 deletions src/driver/kwin/kwinconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

class KWinConfig implements IConfig {
//#region Layout
public defaultLayout: number;
public layoutOrder: string[];
public layoutFactories: {[key: string]: () => ILayout};
public maximizeSoleTile: boolean;
Expand Down Expand Up @@ -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],
Expand All @@ -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());
Expand Down