Multiple dialogs in tasks view

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Multiple dialogs in tasks view

Post by project4 »

Hi all,

What is the convention for the case where I need to add multiple dialogs into the tasks view panel?
How the user should interact with those dialogs?
Prev/Next buttons and OK for the last one?

Lets say I have a multi-stage task that I want to implement using several dialogs in the tasks view.
There are too much information to show it all in one task-dialog.

Every stage in the process is dependent on the previous stage.
Selecting something in stage 1 change the information shown in stage 2 and so on.

Should I have OK/Cancel buttons for every stage?
In that case the user will not be able to go back, he could only cancel the process.
OK will go to the next stage.

Or there should be Prev/Next buttons that will allow to go back as well?
What is the API to change/focus on another dialog in the task view?

Thanks.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Multiple dialogs in tasks view

Post by vocx »

project4 wrote: Sat Oct 03, 2020 5:28 pm ...
Or there should be Prev/Next buttons that will allow to go back as well?
I don't remember off the top of my head a tool that allows you to go forwards and backwards, it's usually only forwards.

Let's see Draft Text; it shows one task panel to set coordinates, then you accept it, and a second task panel shows a dialog to enter the text, and then finish the input. This works okay, I suppose, but if I were to remake this tool, I would probably add the coordinates and the text in the same task panel, maybe in different windows or sections.

This code allows you to load two different interfaces in the "form" variable.

Code: Select all

class CommandTaskPanel:
    def __init__(self):
        one = Gui.PySideUic.loadUi("some1.ui")
        two = Gui.PySideUic.loadUi("some2.ui")
        self.form = [one, two]

ui = CommandTaskPanel()
Gui.Control.showDialog(ui)
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Multiple dialogs in tasks view

Post by project4 »

Thanks.

In my case there are too much information to push them all into one dialog.
And the information is well divided into "logical" blocks, so I prefer to have separate dialogs.

I'm not on the PC where I have the code, will have to check it later if there are several dialogs in the task panel, those are shown as closed "tabs"...
The question is whether the user can just switch ti another "tab" and skip some steps in the process - this will break the logic completely.
chrisb
Veteran
Posts: 54291
Joined: Tue Mar 17, 2015 9:14 am

Re: Multiple dialogs in tasks view

Post by chrisb »

You may have a look at the Path workbench. The operations have different sub tabs, e.g. for heights, depths, etc.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Multiple dialogs in tasks view

Post by vocx »

project4 wrote: Sun Oct 04, 2020 6:20 am ...
The question is whether the user can just switch ti another "tab" and skip some steps in the process - this will break the logic completely.
As chrisb says, also look at the Path Workbench. The tools here often launch a task panel that has many subwindows in various tabs.

It really depends on what your command does; if you have optional values, maybe these should have suitable default values, but if you really need the input from the user, then yes, a sequential display of task panels, like Draft Text does, may be best. This command doesn't handle going back and forth, but I think it should be possible to just a add a few buttons to control this.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Multiple dialogs in tasks view

Post by project4 »

I've tried to add few dialogs to task view, but it looks I'm doing something wrong...
I've expected that calling Gui.Control.showDialog() with different dialog classes will do the trick, but it looks like it does not.
I get "Active task dialog found" for the second call of showDialog.

I found that sketch workbench adds several tasks:
Screenshot from 2020-10-04 19-23-18.png
Screenshot from 2020-10-04 19-23-18.png (43.04 KiB) Viewed 1510 times
But it looks like the UI allows the user to switch to any task he wants and that's not good for my case.

Looks like the only option I have is to close stage1 dialog when user clicks OK button and immediately show stage2 dialog and so on...

Am I missing something?
There is no way to have a multi-stage task?
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Multiple dialogs in tasks view

Post by project4 »

vocx wrote: Sun Oct 04, 2020 4:30 pm It really depends on what your command does; if you have optional values, maybe these should have suitable default values, but if you really need the input from the user, then yes, a sequential display of task panels, like Draft Text does, may be best. This command doesn't handle going back and forth, but I think it should be possible to just a add a few buttons to control this.
I'm not sure I understand how to use that "Draft Text" command to see how it works.
Should I be in a specific workbench? Couldn't find the command in the Draft workbench...
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Multiple dialogs in tasks view

Post by wmayer »

project4 wrote: Sat Oct 03, 2020 5:28 pm What is the convention for the case where I need to add multiple dialogs into the tasks view panel?
How the user should interact with those dialogs?
Prev/Next buttons and OK for the last one?

Lets say I have a multi-stage task that I want to implement using several dialogs in the tasks view.
There are too much information to show it all in one task-dialog.

Every stage in the process is dependent on the previous stage.
Selecting something in stage 1 change the information shown in stage 2 and so on.

Should I have OK/Cancel buttons for every stage?
In that case the user will not be able to go back, he could only cancel the process.
OK will go to the next stage.

Or there should be Prev/Next buttons that will allow to go back as well?
What is the API to change/focus on another dialog in the task view?
You describe the classical use case of a wizard. Qt offers the class QWizard for this. There you can also define for a page whether it allows you to go back.

So, the easiest when embedding a QWizard into a Task dialog is to override the method getStandardButtons() to return QDialogButtonBox::NoButton. This means that the buttons of the wizard are used and therefore the Task dialog doesn't need its own buttons.
project4
Posts: 237
Joined: Fri Jul 12, 2013 12:53 pm

Re: Multiple dialogs in tasks view

Post by project4 »

wmayer wrote: Sun Oct 04, 2020 4:57 pm You describe the classical use case of a wizard. Qt offers the class QWizard for this. There you can also define for a page whether it allows you to go back.

So, the easiest when embedding a QWizard into a Task dialog is to override the method getStandardButtons() to return QDialogButtonBox::NoButton. This means that the buttons of the wizard are used and therefore the Task dialog doesn't need its own buttons.
Thanks.
But in TaskView the buttons are on top, while in the wizard those are on the bottom of the dialog...
It kinda breaks the user experience.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Multiple dialogs in tasks view

Post by wmayer »

project4 wrote: Mon Oct 05, 2020 1:03 pm Thanks.
But in TaskView the buttons are on top, while in the wizard those are on the bottom of the dialog...
It kinda breaks the user experience.
For the moment it's better than nothing. What you can try is to move the push buttons from the QWizard to the QDialogButtonBox

Code: Select all

from PySide import QtGui
wiz=QtGui.QWizard()
box=QtGui.QDialogButtonBox()
pb=wiz.button(wiz.CancelButton)
box.addButton(pb, box.RejectRole)
box.show()
wiz.show()
Post Reply