What's the best way to chain Dialogs in QT? - qt

In my app, I have a project features but it needs a chain of dialogs to work.
At start, the user must either open an existing project or create a new one and when creating a new project, the user must specify a folder.
So there is a first dialog for the choice between new or existing project and another one opens to select a folder in the case of a new project.
Right now, I call the exec_() method on the first one, and do everything inside (creating the second dialog, using it, ect). the direct consequence : it is messy as it uses side effects.
So the question is : It is possible to cleanly chain dialogs in QT ?

Take a look at QWizard clas:
A wizard (also called an assistant on Mac OS X) is a special type of
input dialog that consists of a sequence of pages. A wizard's purpose
is to guide the user through a process step by step. Wizards are
useful for complex or infrequent tasks that users may find difficult
to learn.

Sounds to me like "state machine" is your friend.
http://www.drdobbs.com/cpp/state-machine-design-in-c/184401236
https://en.wikipedia.org/wiki/Automata-based_programming
In your case, you'd start your state machine from an initial state that runs dialog 1.
You run dialog 1, and when it returns from exec(), determine and
update your machine to a new state.
Then run the appropriate dialog for the new state. And so on, until you get to a state that is the end of your dialog chain.
This allows you to have the flexibility in your dialog chain where the next dialog is conditional to what the user selects in the previous dialog, while keeping the logic of the states outside of the dialogs and in a central location.
It's basically a switch statement in a while loop, but a very useful one for managing non-linear / conditional flow in your program.
Hope this helps.

Related

Create an auhtentication popUp

With Robot Framework I automatizate a connexion to a website.
To do this, I used Dialogs Library to ask for a username and a password with the command "Get Value From User". The thing is, the library let the user enter only one by one value (a first popup where robot ask Username then a second where it ask the password). Dialogs Library do not support to ask several values in the same popup or window. But is there a way to do it ? (I do not find anything, and I almost never learn python to creat my own library (it is in my plan to do it asap)). Thank you for help !
Possible, yes. If you need to ask, not easy.
Dialogs uses tkinter toolkit, when you call a keyword from dialogs keyword library, library will create a temporary gui element and runs the event loop until its either dismissed or value is provided.
You can make similar keyword that creates tkinter dialog with multiple ui elements, process the event loop until user has indicated that all is fine, exit the event loop and return the field values to the caller.

gnome-shell-extensions drag and drop

While trying to add D&D support to a gnome-shell-extension that I'm writing I ran into a bit of trouble. I can create drop targets to any open window, but that's all I've managed to pull off.
I can't differentiate between the windows. I tried to use global.get_stage().get_actor_at_pos(Clutter.PickMode.ALL, x, y).get_parent().get_parent().get_meta_window().get_wm_class(), but half the time it gives me the wrong window and every now and again it just returns null. Also I'm not sure how to drop the information into the target.
All I'm trying to do is drop a file URI into a browser window or the file into a file manager.
Is it even possible in gnome-shell-extensions and how would I pull it off? Any advice would be welcome!
Here is the current available shell code about DND between windows: https://github.com/GNOME/gnome-shell/blob/master/js/ui/xdndHandler.js You can do practically nothing with it.
In Mutter, there are more than one procedure to handled a drag and drop in a window, because there are one implementation for X11-windows and another implementation for Wayland-windows.
To be honest, i don't know if there are a way on Wayland and how will be.
I can tell you that in gnome-shell (Mutter to be specific) there are not a fully implementation of this ability on X11. Most you can know, it's if a drag and drop occurs from a window to the shell and the position of the dragged actor, but the shell dosen't provide any api to create an internal drag and drop from the shell to a particular window.
The shell drag and drop that you can fully used, it's only an internal (just the shell) drag and drop from and to the shell (only for clutter actors) and not an external one between different windows.
In X11, the drag and drop process occurs between windows only. One window provide the dragged object and the information that it's associate to that object. The another window (could be the same) will accept the drop of the object, taking on account the information that the first window provide.
As there are not way in the shell to be possible setting the requiered information to the target-window and like your GUI is inside a big top window (The window that represent the shell global stage: https://github.com/GNOME/mutter/blob/6c18bae83cd27a7397a1ed0c1c0c81b282f1b44e/src/compositor/meta-dnd.c#L152) and like you don't have access to this big internal window, finally you can not do anything to interact directly with other windows.
Here (https://github.com/swayfreeda/blender-2.77a/tree/5969d704f44952ea8cbecba2ba4150fb4a48e6de/extern/xdnd) you can find a fully implementation of drag and drop on X11, you will need to modify the code to be adapted to the Mutter workflow and then add this code to Mutter. After that you will have support, but you will need to create the corresponding procedured to then invoked the functionalities, provide information and recive usefull events from the shell to the window, to be possible finally control it in gjs, but it will be only for X11, not for Wayland. I suppose you will need to do something similar if you want support on Wayland.
Good loock.

Communication between multiple dialogs in Qt, using signals and slots or references

Im developing a Qt GUI application, with multiple QDialog's open at any given time.
These dialogs need to communicate and notify with each other when special data is received on a separate network thread.
Usually a dialog will hold a reference to at least one other dialog, and thus can communicate using this.
My question is whether to use this reference to call a function in a another dialog, or emit a signal and absorb that signal in a slot in another dialog? Im aware that this might be a preference - but I would still like to get some input on this.
I suggest you start by looking at Qt's Model View Programming. Based on the Model View Controller design pattern, you would be better off separating data (the model) and the view of that data.
If you follow Qt's Model View Programming, you'll find that when the model containing your data changes, the view(s) are notified and react accordingly. You shouldn't need to message from one dialog to another.

QTP command repository dependancy

When open the HP Quick Test Professional we gets Add-in Manager window for select add-ins we wants,
By selecting a Add-in from that menu, is it only effect for identify objects from the window we try to automate or Is that commands(Click, DoubleClick, etc.) also arrange according to the above selection?
eg- By only selecting WEB add-in from the manager and Try to Scroll the browser pane up
window("abc").Scrollup
but only selecting Java add-in from the manager, I dont able to find that Scrollup,
Is that commands depend on what we selected add-in from the Add-in Manager or Is it a QTP commands
It is not really clear what you are asking.
Click is a test object´s method.
The object repository (OR) contains test objects, or at least info that allows QTP to create (instantiate) test objects when you reference them using TestobjectClass ("TOName").
During recording, QTP creates playback statements (calls to test object methods) that reference test objects in the OR, and creates those test objects there.
What kind (class) of test object it creates indeed is determined by the currently active add-ins.
For example, if you record a Java application, but deactivate the Java add-in, you won´t see Java objects in your OR after recording.
That means .Click calls might still be recorded, but for lower-level objects, like Window.
The layout in the OR is just the parent/child relationship (in a simplified way, since in the OR, there usually are less hierarchy levels than in the GUI -- a listbox in a groupbox in a groupbox in a Tab in a frame in a dialog is stored as a listbox in a dialog).

Notes and remarks over the GUI

I am developing a flex application for collaborative data analysis. To present the data my application uses standard and custom components (grids, charts etc.).
I want to deliver the feature that allows users making notes over the GUI of my application. So, other users will see they notes late on.
At the moment my question is: How can be implemented mechanism that allows making notes over the GUI? All suggestions and examples are welcome?
There are a lot of ways to approach this. ( Check out Buzzword, MS Word, and Acrobat all for slightly different approaches of note taking on a document--I assume an application GUI could use any of the same approaches ).
I'd start by saying that the click event bubbles:
http://livedocs.adobe.com/flex/3/langref/flash/display/InteractiveObject.html#event:click
So, listen for the click event on every child of your main application file. When you receive that click event you can provide some business logic as to whether or not you want to add a comment /note on the component that was clicked. Then you just some "note" component for collecting and displaying the note data. You an position them based on the x, y values of the click event.
So, actually my problem is much easier then I expected (thank for great design of Flex).
I decided to utilize PopUpManager functionality for my task. It does everything I need at the moment.

Resources