Fix panhelper effect

wilder/Plasma/6.2
Jacopo De Simoi 10 months ago
parent 5012e67258
commit 26a5dd2655
  1. 42
      src/plugins/panhelper/package/contents/code/main.js
  2. 17
      src/plugins/panhelper/package/metadata.desktop
  3. 9
      src/plugins/panhelper/package/metadata.json

@ -18,15 +18,28 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/ *********************************************************************/
/*global effect, effects, animate, animationTime, Effect*/ /*global effect, effects, animate, animationTime, Effect*/
var panHelperEffect = { class panHelperEffect {
duration: animationTime(250), constructor() {
effect.configChanged.connect(this.loadConfig.bind(this));
loadConfig: function () { effects.windowAdded.connect(this.manage.bind(this));
for (const window of effects.stackingOrder) {
this.manage(window);
}
this.loadConfig();
}
loadConfig() {
"use strict"; "use strict";
panHelperEffect.duration = animationTime(250); this.duration = animationTime(250);
}, }
geometryChange: function (window, oldGeometry) { manage(window) {
window.windowFrameGeometryChanged.connect(this.geometryChange.bind(this));
}
geometryChange(window, oldGeometry) {
"use strict"; "use strict";
var newGeometry = window.geometry; var newGeometry = window.geometry;
@ -59,13 +72,13 @@ var panHelperEffect = {
couldRetarget = retarget(window.moveAnimation[0], { couldRetarget = retarget(window.moveAnimation[0], {
value1: newGeometry.width, value1: newGeometry.width,
value2: newGeometry.height value2: newGeometry.height
}, panHelperEffect.duration); }, this.duration);
} }
if (couldRetarget && window.moveAnimation[1]) { if (couldRetarget && window.moveAnimation[1]) {
couldRetarget = retarget(window.moveAnimation[1], { couldRetarget = retarget(window.moveAnimation[1], {
value1: newGeometry.x + newGeometry.width / 2, value1: newGeometry.x + newGeometry.width / 2,
value2: newGeometry.y + newGeometry.height / 2 value2: newGeometry.y + newGeometry.height / 2
}, panHelperEffect.duration); }, this.duration);
} }
if (!couldRetarget) { if (!couldRetarget) {
cancel(window.moveAnimation[0]); cancel(window.moveAnimation[0]);
@ -77,7 +90,7 @@ var panHelperEffect = {
if (!couldRetarget) { if (!couldRetarget) {
window.moveAnimation = animate({ window.moveAnimation = animate({
window: window, window: window,
duration: panHelperEffect.duration, duration: this.duration,
animations: [{ animations: [{
type: Effect.Size, type: Effect.Size,
curve: QEasingCurve.OutCubic, curve: QEasingCurve.OutCubic,
@ -103,12 +116,7 @@ var panHelperEffect = {
}] }]
}); });
} }
},
init: function () {
"use strict";
effect.configChanged.connect(panHelperEffect.loadConfig);
effects.windowGeometryShapeChanged.connect(panHelperEffect.geometryChange);
} }
};
panHelperEffect.init(); }
new panHelperEffect();

@ -1,17 +0,0 @@
[Desktop Entry]
Comment=Pan window helper
Type=Service
X-KDE-ParentApp=
X-KDE-PluginInfo-Author=Marco Martin
X-KDE-PluginInfo-Category=Appearance
X-KDE-PluginInfo-Email=mart@kde.org
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-Name=kwin4_effect_panhelper
X-KDE-PluginInfo-Version=1
X-KDE-PluginInfo-Website=
X-KDE-ServiceTypes=KWin/Effect
X-KDE-PluginInfo-EnabledByDefault=true
X-KDE-Ordering=60
X-Plasma-API=javascript
X-Plasma-MainScript=code/panhelper.js
X-Plasma-RemoteLocation=

@ -8,18 +8,15 @@
} }
], ],
"Category": "Window Pan Animation", "Category": "Window Pan Animation",
"Description": "Make windows smoothly pan when they are moved ", "Description": "Make windows smoothly pan when they are moved (KDE6 version)",
"EnabledByDefault": true, "EnabledByDefault": true,
"Icon": "preferences-system-windows-effect-scale", "Icon": "preferences-system-windows-effect-scale",
"Id": "kwin4_effect_panhelper", "Id": "panhelper",
"License": "GPL", "License": "GPL",
"Name": "Pan Helper", "Name": "Pan Helper",
"Version": "1" "Version": "1"
}, },
"X-KDE-Ordering": "60", "X-KDE-Ordering": "60",
"X-KDE-PluginKeyword": "kwin4_effect_panhelper",
"X-KWin-Config-TranslationDomain": "kwin_effects",
"X-KWin-Exclusive-Category": "toplevel-pan-animation", "X-KWin-Exclusive-Category": "toplevel-pan-animation",
"X-Plasma-API": "javascript", "X-Plasma-API": "javascript"
"X-Plasma-MainScript": "code/panhelper.js"
} }

Loading…
Cancel
Save