Skip to content
  • Laurent Valentin Jospin's avatar
    Allow the user to change the active unit in the KisDoubleParseUnitSpinBoxes. · 74e30085
    Laurent Valentin Jospin authored
    I'm not sure it's worth merging now, but I want to get sure the design I choosed is not problematic.
    
    Ref T1621
    
    Summary:
    The main change, is the new class KisSpinBoxUnitManager. This is an abstract interface to let the spinboxes use different sorts of units from KoUnit, but also document relative lenght units (vw, vh), angle units and time units.
    
    This force some little tricks in the design, since the spinboxes must stay in the widget library, but a lot of needed info for relative units can't be acessed from this library.
    
    So the idea is to subclass the KisSpinBoxUnitManager where it can acess thoses datas, then send a pointer to the spinboxes. With polymorphism we can make all of this work.
    
    So now it's possible to change the unit by writing the symbol of this unit at the end of a KisDoubleParseUnitSpinBox.
    
    There's a few problem left, for example in some places the spinbox is destroyed and rebuilt everytime the user want to use it, so the active unit is not kept.
    
    There's also a few refactoring needed in a lot of places that use simple parse spinboxes with a suffix rather than unit spinbox.
    
    Test Plan:
    Activate all Karbon tool in your kritarc (not needed, But I've checked it works with them too).
    
    Launch krita
    
    Create a new document
    
    Create a new vector layer (the unit spinbox is used essentially for Karbon tools for the moment).
    
    You can try the freehand path and draw path karbon tool, set a size in any unit you want and start to draw.
    
    Then you can use the default tool (moving, resizing objects, setting a shadow). In all thoses steps you can use units like mm, cm, pt, ... but also px, vw, vh).
    
    Finally open the add shape and shape propeties docker. Add a few shapes and try to change the properties. deselect the shape reselect if, you'll found that the unit is reset to px (the spin box has been destroyed, then recreated).
    (I had a lots of problem with this docker, it needs a few refactoring to work with the new spinboxes).
    
    Close krita and check there's not segfault caused by the patch (I had this problem a few time, and had to find way to prevent it).
    
    Reviewers: #krita, dkazakov
    
    Subscribers: rempt
    
    Differential Revision: https://phabricator.kde.org/D2771
    74e30085