D21312: [Places] Draw 2px rectangle disk capacity bar underneath mount points

Chris Holland noreply at phabricator.kde.org
Mon May 20 21:51:43 BST 2019


Zren created this revision.
Herald added a project: Dolphin.
Herald added a subscriber: kfm-devel.
Zren requested review of this revision.

REVISION SUMMARY
  F6840096: 2019-05-20___16-13-35.png <https://phabricator.kde.org/F6840096> F6840099: 2019-05-20___16-15-58.png <https://phabricator.kde.org/F6840099>
  
  https://www.youtube.com/watch?v=7BF9JXI7xvg#t=2m40
  
  Elementary (and other file managers) show the capacity bar in the sidebar as well: https://i.stack.imgur.com/4l7YS.png
  
  -----
  
  - This patch is based on the KIO's `KFilePlacesView`. We're not using the KIO class as there's a significant amount of work needed to support Dolphin's "open in new tab/window" (https://phabricator.kde.org/T9795#178086).
    - https://github.com/KDE/kio/blob/master/src/filewidgets/kfileplacesview.h
    - https://github.com/KDE/kio/blob/master/src/filewidgets/kfileplacesview.cpp#L218
  
  - We're not using the `KCapacityBar` itself either since we can't easily make space for a 8px tall capacitybar + padding as mentioned in the next point.
    - https://github.com/KDE/kwidgetsaddons/blob/master/src/kcapacitybar.cpp#L180
  
  - This patch draws overtop the text that's goes below the baseline like `gj_`.
    - It's fairly difficult to add extra space below the text as the places view is a "details" view. That means the text is vertically centered in the widget's "row".
    - We can make the PlacesItemWidget 8px taller, adding 4px above and below so there's adequate room for the capacitybar, but that wastes 4px for each mount point. Add padding above/below:
      - We add a `PlacesItemListWidgetInformant` inheriting `KStandardItemListWidgetInformant`. We overload, `PlacesItemListWidgetInformant::calculateItemSizeHints(...)` so we can change the height of each `PlacesItemWidget`.
      - We then need to check if the current `PlacesItemWidget` is a mount point, and share that boolean with the `KStandardItemListWidgetInformant`. I'm not 100% sure how to do this.
    - Ideally we'd use the "compact" view, which displays the text/size/etc in a column beside the icon. However the compact view was not designed a file to take up the entire width of the viewport. It's also designed to handle vertical overflow with a horizontal scrollbar.
  
  -----
  
  Performance (TODO)
  ------------------
  
  I originally wanted to draw these capacity bars in the main file view (like Windows's "This PC"), but that would probably slow down loading folders with millions of files. So while D10453 <https://phabricator.kde.org/D10453> was a nice hack, it was dead in the water for merging upstream.
  
  This current patch might affect the startup speed, as the places panel is visible on load. I need to determine if this code is blocking or if it's lazy loaded. We don't want to make the startup slower.
  
  KIO's File Selector only shows the capacity bars on hover?
  
  -----
  
  `QT_SCALE_FACTOR=2 build/bin/dolphin`
  
  F6840090: 2019-05-20___16-08-45.png <https://phabricator.kde.org/F6840090>

TEST PLAN
  - Check if an unmounted drive does not shows a capacity bar at startup.
  - Check if an unmounted drive shows a capacity bar after mounting.
  
  -----
  
  - Confirm various color schemes look okay with the breeze widget style.
  - Confirm the kvantum widget style looks okay.
  - Confirm it looks okay with various screen scaling.
    - 2x HiDPI `QT_SCALE_FACTOR=2 build/bin/dolphin`
    - 1.5x `QT_SCALE_FACTOR=1.5 build/bin/dolphin`

REPOSITORY
  R318 Dolphin

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

AFFECTED FILES
  src/kitemviews/kstandarditemlistwidget.h
  src/panels/places/placesitemlistwidget.cpp
  src/panels/places/placesitemlistwidget.h

To: Zren
Cc: kfm-devel, alexde, feverfew, meven, spoorun, navarromorales, firef, andrebarros, emmanuelp, mikesomov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20190520/69add732/attachment.htm>


More information about the kfm-devel mailing list