[Interest] [QtQuick] Interaction with user from C++
Shawn Rutledge
Shawn.Rutledge at qt.io
Tue Apr 26 15:36:10 CEST 2016
> On 26 Apr 2016, at 15:00, Jérôme Godbout <jerome at bodycad.com> wrote:
>
> Hi Dmitry,
> not much problems, except this is a modal way for interacting with the user. I'm not a fan of modal (as matter of fact I hate it, you prevent your user for copy/paste, check something from the real work window), but the Qml Dialog callback make it even worst. It seem ok for a single question for a dual action path, but when thing get a little more complex, this is a code nightmare (not as hard to code, but hard to follow what is going on when not written by you
Yeah modal dialogs are usually bad for usability. But I see, if you have a procedural block and you want to ask “are you sure” somewhere in the middle, that’s a pain to break it up into multiple functions.
Another common usability tip: don’t ask “are you sure” (or, “do you want to save changes” when exiting), because if the user uses your software a lot, answering the dialog in the most common way becomes a reflex, and then maybe he’s going to regret it when the reflex ends up being wrong one time. Instead, make sure that undo/redo works well, and that the user’s work is never lost, so that it can be recovered if he forgot to save. That generally requires the use of the command pattern to remember the list of operations that can be undone/redone. And if you could already organize the steps in an interruptible operation into separate commands, you don’t have the original problem anymore.
The reason we don’t recommend using blocking calls from QML is that you’d be blocking a thread that you don’t own, the same one which is running the JS engine. The behavior might not be consistent from version to version depending on how the engine is implemented.
In a functional language, you could pass lambdas when you invoke the dialog: what to do for each possible outcome. Or, call-with-current-continuation can be used as a way to package up “the rest of the code flow from here on” into a function, without having to give it a name and put it somewhere else. I wonder if we could make that work in JS somehow. It would just give you a way to write the onAccepted/onRejected handlers inline instead of separately. Does anyone know if that sort of thing is possible in any web JS frameworks yet?
More information about the Interest
mailing list