konstantinshtepa added a comment.

  A detailed explanation of bugs, fixes and mechanics changes
  ===========================================================
  
  Before anything else I'd like to explain why I need this patch. At winter 
holidays I had a free time and decided to rewrite plasma-simplemonitor(maded by 
dhabyx) - port it to plasma5 and improve it. As one of new features I added 
"skins" - posibility to change UI looks. Let's describe one skin as "row" and 
other as "column". Skins had different default sizes and different minimum 
sizes. As behaviour it sugges that when user change one skin to another 
plasmoid size supposed to change to default size of new skin. In plasma5 there 
is no resize function in plasmoid anymore. Instead docs pointed to use Layout 
properties. And so I tried to set maximum sizes in Layout. It doesn't work. 
When researching this problem it was occurred that there is no such 
functionality in plasmoids despite that plasmoid already uses Layout minimum 
sizes. And so I made this patch to fix that. When debugging this patch I found 
other bugs and fixed them alongside.
  
  **To read next you should understand QML and Qt/C++. Especially what is 
QPropertyAnimation, how it works and behave over object properties.**
  I would mention bugs in order of it's difficulties and their involvement in 
patch. From easy to hard.
  
  1. Bug 375349 (Plasmoid can't be resized to declared minimumWidth).
  
  This bug was because of mess in size relationship. Because of it plasmoid 
wouldn't get smaller than Layout.minimumWidth + 2 * handleWidth. Bug was in 
appletItem minimumWidth calculation and in AppletHandler.qml resize 
calculation(resizeHandle.onPositionChanged) .
  
  2. Bug 375307 (Sometimes Plasmoid doesn't free all his space in 
LayoutManager),
  
  Bug happens because of appletItem size animations. Let's see how bug 
happening. User is done resizing appletItem, after that appletItem would be 
resized and positioned in layoutManager to fit cell politics, result sizes and 
position would be locked in layoutManager as area which used by this plasmoid. 
Now will start animation over applet height, width, x and y. Guess what would 
happend if somebody tried to move plasmoid or resize it in exact that moment? 
Yup. appletItem would try to release area in layoutManager with current(still 
animated) properties which != end properies. And it would lead to some area in 
layoutManager to not release properly.
  I did many things(for example tried to implement and use "end" properties) to 
patch this but I think that it should be fully patched with implemtation of 
appletItem.floating property and functions positionItem and releasePosition 
which now handle all operations over layoutManager to lock\unlock area.
  
  3. Bug 375308 (Plasmoid applet doesn't have maximum size handlers)
  
  When implementing this patch I encountered several questions:
  
  - What to do in case of minimum > maximum size?
  
  I think that when this happened the other restrictive size should be changed 
to match new one. So I added this behaviour to all changes handlers of 
restrictive sizes. It also broke normal qml binding of restrictive sizes, but I 
solved it with using of QML Binding Items.
  
  - What to do with qreal -> int convertation for maxinum size?
  
  Default maxsize is Number.POSITIVE_INFINITY and that it would be 
autoconverted into int.NEGATIVE_MAX_VALUE which is not good. So I added simple 
check to see if qreal value would be too much to handle in int. And if it so to 
change it to 1000000. I don't have any better idea how to handle this.
  
  - What to do when appletItem size set by layoutManager would be > than 
maximumSize?
  
  I created "innerAppletItem" in face of mouseListener. To handle all of 
animations I created additional properties like endHeight, endX, etc. "End" - 
because they symbolise what height, x, and other would be at end of animation. 
With these additional properties current end values always known and using them 
"innerAppletItem" can handle all kind of size and position changes even when it 
animations are running.
  
  - What to do when plasmoid is moved to new place and animations is on?
  
  Because of this I just can not write in "innerAppletItem"(mouseListener) 
"anchors.centerIn: parent". So I implemented x and y change handlers in 
appletItem which would move position of "innerAppletItem" to place of old 
center(where it was according to appletItem.parent coordinates) and then play 
animation of move to a new place.

REPOSITORY
  R119 Plasma Desktop

REVISION DETAIL
  https://phabricator.kde.org/D4204

EMAIL PREFERENCES
  https://phabricator.kde.org/settings/panel/emailpreferences/

To: konstantinshtepa, #plasma
Cc: davidedmundson, plasma-devel, lesliezhai, ali-mohamed, jensreuterberg, 
abetts, sebas

Reply via email to