[Plasma folderview] Replace "Up" button with "Back" button in listview mode
ClosedPublic

Authored by chinmoyr on Jan 3 2017, 8:09 AM.

Details

Summary

Replaces "Up" button with "Back" button and use history when going back.

Diff Detail

Repository
R119 Plasma Desktop
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
chinmoyr updated this revision to Diff 9628.Jan 3 2017, 8:09 AM
chinmoyr retitled this revision from to [Plasma folderview] Change behaviour of FolderModel::up.
chinmoyr updated this object.
chinmoyr edited the test plan for this revision. (Show Details)
chinmoyr added reviewers: hein, Plasma.
chinmoyr set the repository for this revision to R119 Plasma Desktop.
Restricted Application added a project: Plasma. · View Herald TranscriptJan 3 2017, 8:09 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
hein requested changes to this revision.Jan 3 2017, 8:17 AM
hein edited edge metadata.

(a) I don't like accumulating data in a cache that's never evicted and never changed for correctness. What if the hierarchy changes in the meantime? This is like a subtle bug trap.

(b) It's "Up", not "Back". If there's no way up from a location then there's no way up. Maybe for links we should make it "Back", and just keep the previous URL around.

This revision now requires changes to proceed.Jan 3 2017, 8:17 AM
chinmoyr updated this revision to Diff 9687.Jan 4 2017, 6:59 AM
chinmoyr retitled this revision from [Plasma folderview] Change behaviour of FolderModel::up to [Plasma folderview] Introduce "Back to Desktop" option in listview mode.
chinmoyr updated this object.
chinmoyr edited edge metadata.
hein added a comment.Jan 4 2017, 7:07 AM

Why is this specific to the desktop? What about other links?

In D3931#73809, @hein wrote:

Why is this specific to the desktop? What about other links?

The default behaviour is to treat desktop links as folder and for normal links dolphin (or the associated program) is launched.
It's just i only focused on desktop links. But this can be changed as well.

hein added a comment.Jan 4 2017, 7:19 AM

I'm referring to links to folders outside of a parent. .desktop links to folders are sort of similar to symlinks.

In D3931#73814, @hein wrote:

I'm referring to links to folders outside of a parent. .desktop links to folders are sort of similar to symlinks.

May be we can treat them as folders but then i guess we'll have to drop the "Up" button and introduce dolphin like behaviour.
To be honest I didn't bothered looking into this. So i can't say for sure.

IMO limiting this behaviour only to desktop will keep things simple.

hein added a comment.Jan 4 2017, 7:34 AM

I don't follow you at all there, sorry - my original request to use Up normally and Back for links, and you ended up special-casing desktop for some reason with no explanation :)

hein added a comment.Jan 4 2017, 7:39 AM

No, hardcoding magic behavior based on special URLs and inconsistent behavior depending on URL is not "simple".

In D3931#73817, @hein wrote:
my original request to use Up normally and Back for links, and you ended up special-casing desktop for some reason with no explanation :)

I "special cased" desktop because links were treated as folder only when folder view's location was set to "Desktop Folder".

Can you please elaborate "Up normally and Back for links". I am afraid i still don't get you.
Do you mean as we go down show "Up" but when a link (.desktop or symlink) to folder is clicked change directory but show "Back" , keep the previous dir's url around and carry on doing the same?
If so do you want this to be the case for Location="desktop:/" or for all locations?

hein added a comment.Jan 4 2017, 8:10 AM

I "special cased" desktop because links were treated as folder only when folder view's location was set to "Desktop Folder".

Ah!

Actually, on further thought, I don't really having two different modes, and maybe having an "Up" in concert with the decision to follow links in general. How about we rename it to "Back" and keep a stack of previous URLs, put on the stack on every cd and make back pop it off? This seems more in line with what users probably want rather than ever jumping to a new hierarchy context and going "Up" or having the action change name.

chinmoyr updated this revision to Diff 9698.Jan 4 2017, 12:27 PM
chinmoyr retitled this revision from [Plasma folderview] Introduce "Back to Desktop" option in listview mode to [Plasma folderview] Replace "Up" button with "Back" button in listview mode.
chinmoyr updated this object.
chinmoyr edited edge metadata.
hein requested changes to this revision.Jan 5 2017, 5:59 AM
hein edited edge metadata.

I'm not entirely happy with the way this works, I think the history may need to be kept on the QML side instead, then:

(a) You can properly evict the history when the URL in the config changes
(b) Tie the visibility of the Back button to whether the history is empty or not

So basically before QML runs FolderModel::cd write down the URL, then when back is pressed pop it off.

FolderModel can't know when to evict the history because it can't distinguish between setUrl coming from cd() or from a config change, only the applet code can.

Having history functionality in FolderModel is otherwise attractive, so this is a bit of a dilemma. Putting the history into QML however keeps FolderModel "dumber" in the sense that it doesn't have to reason about intent and just does what it's told, and the higher level situation is captured on the side of the user of the model instead.

containments/desktop/plugins/folder/foldermodel.cpp
487

For future reference: This can be simplified to takeLast().

This revision now requires changes to proceed.Jan 5 2017, 5:59 AM
chinmoyr updated this revision to Diff 9753.Jan 5 2017, 10:57 AM
chinmoyr edited edge metadata.

Added properties location(which will store folder view's location) and historyAvailable
Removed prop url and renamed prop resolvedUrl to currentUrl
Bind Back button's visibility to historyAvailable
For the logic; folder view must reset to location whenever plasmoid.expanded changes, added method goToLocation.

hein requested changes to this revision.Jan 6 2017, 5:29 AM
hein edited edge metadata.

I don't want two props in the model - I want it to remain simple and simply provide data for one location. It should be oblivious to the configuration concerns of its user. This is in line with KDirModel, too. Please implement in the suggested way.

This revision now requires changes to proceed.Jan 6 2017, 5:29 AM

So only the 'historyAvailable' prop and no 'location' prop and stuffs?

hein added a comment.Jan 6 2017, 5:44 AM

You don't neeed any changes to the C++ side - do it in QML.

chinmoyr updated this revision to Diff 9811.Jan 7 2017, 5:30 AM
chinmoyr updated this object.
chinmoyr edited edge metadata.

Added history functionality to the qml side for use use with back button.

hein requested changes to this revision.Jan 9 2017, 7:01 AM
hein edited edge metadata.
  • Leave FolderModel::up unchanged
  • There's no need for a FolderModel::back, it just duplicates setUrl
  • I don't understand the need for updateHistory, please explain
This revision now requires changes to proceed.Jan 9 2017, 7:01 AM

Push and pop methods were not updating the property might be they were working on another copy of "history". Due to this I used "history=history" so as to update it explicitly.

hein added a comment.Jan 9 2017, 8:38 AM

Thanks for the explanation. Thoughts:

  • Can you try { new Array() } or something instead of []? There's some confusion in QML between "QML list" and "JavaScript array", perhaps the prop notification works with an explicity array.
  • If this doesn't work either, please add a code comment explaining why updateHistory exists.
  • Perhaps instead of length = 0 assignments and calling updateHistory, just assigning a new Array would be cleaner?
hein added a comment.Jan 9 2017, 8:40 AM

Looks like it will be the code comment route:

‎[17:38] ‎<‎Sho_‎>‎ btw
‎[17:39] ‎<‎Sho_‎>‎ i have a dev on phab who claims push/pop on a [] held in a var-type prop doesn't notify
‎[17:39] ‎<‎Sho_‎>‎ anyone run into this?
‎[17:39] ‎<‎kbroulik‎>‎ yup
‎[17:39] ‎<‎kbroulik‎>‎ that's by design™
‎[17:39] ‎<‎kbroulik‎>‎ QML can't detect that
‎[17:39] ‎<‎Sho_‎>‎ even for a JS array?
‎[17:39] ‎<‎kbroulik‎>‎ yup
‎[17:39] ‎<‎Sho_‎>‎ or is this just with QML lists
‎[17:39] ‎<‎kbroulik‎>‎ also for JS objects
‎[17:39] ‎<‎Sho_‎>‎ ok ...
‎[17:39] ‎<‎Sho_‎>‎ what did you do to work around?
‎[17:39] ‎<‎kbroulik‎>‎ var foo = prop
‎[17:39] ‎<‎kbroulik‎>‎ foo.push(bar)
‎[17:39] ‎<‎kbroulik‎>‎ prop = foo
‎[17:40] ‎<‎Sho_‎>‎ how aful

chinmoyr updated this revision to Diff 9900.Jan 9 2017, 10:41 AM
chinmoyr edited edge metadata.

Minor changes

hein accepted this revision.Jan 9 2017, 11:04 AM
hein edited edge metadata.
This revision is now accepted and ready to land.Jan 9 2017, 11:04 AM
This revision was automatically updated to reflect the committed changes.