From 04b47b4a0367ba58bc95795db81b73e1cd3d1f6b Mon Sep 17 00:00:00 2001 From: Fabian Homborg <FHomborg@gmail.com> Date: Tue, 15 Oct 2013 12:20:30 +0200 Subject: [PATCH] Enable configuration through UI. This needs a couple of workarounds: - Qt won't convert a QStringList to an Array, instead giving an utterly useless QVariant(QStringList) (without any methods and presumably only containing the pointer) - The config group _needs_ to be empty, else it's not accessible from the javascript side --- commentary.org | 5 +++-- contents/code/tests.js | 14 ++++++++++++++ contents/code/tilelist.js | 13 ++++++++++--- contents/config/main.xml | 5 +++-- contents/ui/config.ui | 21 ++++++++++++++------- metadata.desktop | 6 +++--- 6 files changed, 47 insertions(+), 17 deletions(-) diff --git a/commentary.org b/commentary.org index c89554b..c0c3d22 100644 --- a/commentary.org +++ b/commentary.org @@ -1,6 +1,5 @@ * TODO Make rules for tiling -** HACK Ignore yakuake and menus/dialogs for tiling - Waiting for KDE 4.11 which allows configuration for kwin scripts +** DONE HACK Ignore yakuake and menus/dialogs for tiling ** DONE Add useractionsmenu * DONE Resize tiles Hacked for Spirallayout, working for Halflayout @@ -22,6 +21,8 @@ ** This was the result of removing an element from an array and afterwards accessing it by index * DONE Retile on minimize +* TODO Avoid struts + Never noticed because I set the panel to autohide * TODO Testing ** Weird apps (mplayer, gimp) ** Weird configurations diff --git a/contents/code/tests.js b/contents/code/tests.js index 00d3aee..ef7735a 100644 --- a/contents/code/tests.js +++ b/contents/code/tests.js @@ -40,3 +40,17 @@ success2 = false; testSignal.disconnect(testSlot2); testSignal.emit(1, 2, "test"); print("Signal test 2: " + (success1 && !success2 ? "SUCCESS" : "FAILURE")); + +var isConfig = function(name, defaultValue) { + print("Reading", name); + c = readConfig(name, defaultValue); + print("Read", name); + if (c == null) { + print("Configuration option", name, "not defined"); + } else { + print("Configuration option", name, ": ", c); + } +} + +print("Testing configuration"); +isConfig("floaters", ""); diff --git a/contents/code/tilelist.js b/contents/code/tilelist.js index dd5a329..ad9fa96 100644 --- a/contents/code/tilelist.js +++ b/contents/code/tilelist.js @@ -125,6 +125,7 @@ TileList.prototype.addClient = function(client) { this.tiles[tileIndex].clients.push(client); } } else { + print("Adding client",client.resourceClass.toString(), "to a new tile"); // If not, create a new tile this._addTile(client); } @@ -252,10 +253,16 @@ TileList.prototype._identifyNewTiles = function() { * all, e.g. the panel. */ TileList._isIgnored = function(client) { - // NOTE: Application workarounds should be put here - // TODO: Hook this up to the rules - var floaters = Array("yakuake", "krunner", "Plasma", "Plasma-desktop", "plasma-desktop", "Plugin-container", "plugin-container"); + // Application workarounds should be put here + // Qt gives us a method-less QVariant(QStringList) if we ask for an array + // Ask for a string instead (which can and should still be a StringList for the UI) + var fl = "yakuake,krunner,Plasma,Plasma-desktop,plasma-desktop,Plugin-container,plugin-container,Wine"; + // TODO: This could break if an entry contains whitespace or a comma - it needs to be validated on the qt side + var floaters = String(readConfig("floaters", fl)).replace(/ /g,"").split(","); + print("Floaters: ",floaters); + print(client.resourceClass.toString()); if (floaters.indexOf(client.resourceClass.toString()) > -1) { + print("Client floating"); client.syncTabGroupFor("kwin_tiling_floats", true); return true; } diff --git a/contents/config/main.xml b/contents/config/main.xml index 626a7f0..12a8f8a 100644 --- a/contents/config/main.xml +++ b/contents/config/main.xml @@ -5,8 +5,9 @@ http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > <kcfgfile name=""/> <group name=""> - <entry name="FadeToBlack" type="Bool"> - <default>false</default> + <entry name="floaters" type="StringList"> + <label>The windows (by class) that should float</label> + <default>yakuake,Plasma,Plasma-desktop,krunner,plugin-container</default> </entry> </group> </kcfg> diff --git a/contents/ui/config.ui b/contents/ui/config.ui index 93e500d..b685b09 100644 --- a/contents/ui/config.ui +++ b/contents/ui/config.ui @@ -11,13 +11,6 @@ </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QCheckBox" name="kcfg_FadeToBlack"> - <property name="text"> - <string>Fade to black (fullscreen splash screens only)</string> - </property> - </widget> - </item> <item> <spacer name="verticalSpacer"> <property name="orientation"> @@ -31,8 +24,22 @@ </property> </spacer> </item> + <item> + <widget class="KEditListBox" name="kcfg_floaters"> + <property name="buttons"> + <set>KEditListBox::Add|KEditListBox::Remove</set> + </property> + </widget> + </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>KEditListBox</class> + <extends>QGroupBox</extends> + <header>keditlistbox.h</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> diff --git a/metadata.desktop b/metadata.desktop index 264d904..f159c00 100644 --- a/metadata.desktop +++ b/metadata.desktop @@ -8,9 +8,9 @@ X-KWin-Exclude-Listing=false X-KDE-PluginInfo-Author=Fabian Homborg X-KDE-PluginInfo-Email=FHomborg@gmail.com -X-KDE-PluginInfo-Name=tiling -X-KDE-PluginKeyword=tiling -X-KDE-ParentComponents=tiling +X-KDE-PluginInfo-Name=kwin-script-tiling +X-KDE-PluginKeyword=kwin-script-tiling +X-KDE-ParentComponents=kwin-script-tiling X-KDE-PluginInfo-Version=0.2 X-KDE-PluginInfo-Depends= -- GitLab