Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Make HalfLayout split ratio configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
laloch committed Apr 24, 2019
1 parent 95a575d commit e3d8b95
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
9 changes: 5 additions & 4 deletions contents/code/halflayout.js
Expand Up @@ -30,7 +30,8 @@ function HalfLayout(screenRectangle) {
} catch(err) {
print(err, "in HalfLayout");
}
this.firstWidth = this.screenRectangle.width / 2;
this.masterRatio = 100 / KWin.readConfig("halfLayoutMasterRatio", 50);
this.firstWidth = this.screenRectangle.width / this.masterRatio;
this.master = 0;
this.masterCount = 1;
};
Expand All @@ -57,7 +58,7 @@ HalfLayout.prototype.addTile = function() {
var newWidth = this.screenRectangle.width / (this.tiles.length + 1);
var newSWidth = newWidth;
} else {
this.firstWidth = this.screenRectangle.width / 2;
this.firstWidth = this.screenRectangle.width / this.masterRatio;
var newWidth = this.firstWidth / (this.tiles.length);
var newSWidth = this.screenRectangle.width - this.firstWidth;
}
Expand Down Expand Up @@ -253,7 +254,7 @@ HalfLayout.prototype.decrementMaster = function() {
var newSWidth = this.screenRectangle.width - (newMWidth * newC);
var newSHeight = this.screenRectangle.height / (this.tiles.length - newC);
} else if (this.tiles.length == oldC) {
var newMWidth = (this.screenRectangle.width / 2) / newC ;
var newMWidth = (this.screenRectangle.width / this.masterRatio) / newC ;
var newSWidth = this.screenRectangle.width - (newMWidth * newC);
var newSHeight = this.screenRectangle.height / (this.tiles.length - newC);
} else {
Expand All @@ -277,6 +278,6 @@ HalfLayout.prototype.decrementMaster = function() {
if(newC != 0) {
this.firstWidth = this.getMasterWidth();
} else {
this.firstWidth = this.screenRectangle.width / 2;
this.firstWidth = this.screenRectangle.width / this.masterRatio;
}
};
4 changes: 4 additions & 0 deletions contents/config/main.xml
Expand Up @@ -69,5 +69,9 @@
<label>Remove empty desktops</label>
<default>false</default>
</entry>
<entry name="halfLayoutMasterRatio" type="int">
<label>Default Half Layout master ratio</label>
<default>50</default>
</entry>
</group>
</kcfg>
56 changes: 56 additions & 0 deletions contents/ui/config.ui
Expand Up @@ -210,6 +210,62 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="halfLayoutTab">
<attribute name="title">
<string>Half Layout</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="verticalSpacer">
<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 row="0" column="1">
<widget class="QSpinBox" name="kcfg_halfLayoutMasterRatio">
<property name="suffix">
<string notr="true">%</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>90</number>
</property>
<property name="value">
<number>50</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Default master width</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
Expand Down

0 comments on commit e3d8b95

Please sign in to comment.