How to implement a callback interface to go for example from Main Menu screen to start period screen when pressing start period button and return to Main menu screen when pressing main menu button in start period screen.
Main Menu screen image
Start period screen image
You can use DataFX and its Flow mechanism. If you prefer not to use an external library you can do one of the following:
Use a single controller for UI, have a reference to all your UI "screens" which are essentially some type of containers, like BorderPane, VBox, etc. When button start is clicked, you change the root of the Scene to period UI. Having same controller class means all references are in the same place, so when go back button is pressed, you change the root back to main UI.
If your code is rather big, you can use controllers for each UI, but then you will need to implement some basic global event system. When a change in the Scene's root is required you fire an event, say CHANGE_SCENE, and attach some info, like the reference to the UI root. Once the event is caught, change the Scene root to the one you received by the event system.
Related
I have a QT application, which creates a dialog which has a bunch of tab pages, which each have a lot of Widgets.
I know there isn't going to be a way to get around how long it takes to load the widgets in as there are quite a few.
I've thought about after the main window being initialized, if there is something I can do to load the dialog in the background, so when show is clicked it is a faster experience.
Are there any techniques to preload dialogs, perhaps after the main window has loaded? When I say preload, I mean the 'new QDialog(..)...' process. That seems to be where the latency is as then that constructor begins laying out all the components and so on. the .show() isn't the issue as that runs instantly.
QCustomDialog * customDialog = new QCustomDialog(); // the latency
customDialog->show(); //not the latency
class QCustomDialog {
QCustomDialog::QCustomDialog() {
//creation of many nesscary widgets and added to the dialog
QLabel * lab = new QLabel("Label 1");
...
};
};
If you just need to let the user know the application is starting, and it takes a few seconds before the main window loads, you could use QSplashScreen.
This allows you to display an image while the main window loads. If the application takes more than a few seconds, and it makes sense for your application, you can also use QSplashScreen::message() to display messages as different parts of the app are loading.
I am trying to implement a terminal in my application.
Currently, class Terminal inherits from QMainWindow, and all of its contents are lost if the close button is triggered. This does not affect the main application though.
I want the contents to stay and be accessible by the rest of the application. How can I achieve that?
I am working on a Touchscreen application.
For this I Need to Change the current window if user clicks on the Screen (Position doesn't matter).
For this I Need a to make my button (which is currently the same size as the current window) invisble, so user can see the Labels etc.
Any idea how to make Buttons invisible in PyQt4?
I recommend you not use a button to do this. Instead, either put an event filter on the QApplication instance, so any widgets in your window get events only if you determine they should; OR put a transparent panel widget over the touch area, with a mouse click event handler for that panel. Either method supports arbitrary complexity of widgets inside your touch area (labels and tables to display information etc). Main disadvantage with event filter approach is that all application events (from all threads) will be filtered. This could affect performance (you'd have to test, may not be any noticeable differenc), but it is simpler to implement than the transparent panel.
I have an Flex 4 application (not AIR) which has some floating windows that act essentially as modeless dialogs.
Right now, if two of these are open at once they function as siblings which are both active and whose controls are enabled for user interaction.
I now need to maintain some notion of which one is "active" in the application. I don't want to /disable/ the non-active ones so as to blur them or prevent input on their controls.
I basically want to replicate basic OS window management: when you click or type into a control in one window it comes to the front and its title bar looks "active" and the others then look "inactive". Just like with a bunch of explorers in Windows.
Can anyone clue me in on an approach?
Assuming that your pop up windows extend UIComponent, you should be able to listen to the FocusIn event to make your window active and the focusOut to make your window inactive.
Now containers do not usually dispatch the focus events; however children of the containers will. And since the focus event bubble, you can listen for them as part of your popup.
Personally I would handle this with what we call a Mediator... essentially a singleton UI controller, along with a slightly custom component and custom skin. On Popup, each window registers itself with the Mediator, so the mediator knows all the windows that are open, on close each de-registers itself, OnFocusIn on each component it notifies the mediator of this event, the mediator calls a method on every other panel to does the blurring or whatever.
The custom component can extend TitleWindow and add a property IsActiveWindow, then the custom skin can change it's appearance based on this property.
For pro points use RobotLegs to to inject the reference to the mediator into the components.
Good luck!
Functionnaly :
On one of my components of my application, I have an editing/lock system. When a user starts editing, he locks the file so other users cannot edit it.
Problem scenario : When the user activates "edition mode" and leaves screen, I would like to show a alert with two options : save changes, or discard changes.
There are different ways to exit screen :
There is a List on the left side containing other possible editabel data. A click changes the data in my component.
There is a menubar on top leading to other screens.
The edition component is embedded in a Tab navigator. When changing tabs, the alert has to show.
Closing browser.
Do I have to catch all of these events and plug at all those places?
Is there any kind of focusout mecanism?
The answer to the first question is: YES.
You need to watch all possible exit events that could harm the currently edited data.
Well, the problem is now how to manage this properly. Using an MVC framework you would trigger the appropriate commands from your components:
CHANGE_LIST_ITEM (new item)
CHANGE_TAB (new tab)
CHANGE_SCREEN (new screen)
Each command then checks if the currently edited tab has been saved or not. If not, it displays the Alert. Else, if there are no changes, it allows the list, the screen chooser and the tab bar to continue.
So your components (list, screens, tabs) need to implement some kind of rollback or preventDefault mechanism. Generally, changing their state must be allowed by a central validator (in MVC the command).
In the case of the list: I would suggest that the list is not selectable by mouse click but only programmatically. You set a listener on the list item click event. If the command allows setting of a new item it will notify the list. In MVC usually by sending an async message that gets received by the list's mediator. [[And even more correct: The command would set some model properties (e.g. currentListItem) and the model than sends an async message.]]
Edit: For the browser close event, you need to call a JavaScript expert.