Main application window for plugins of BPS Workplace. More...
#include <bpsapplicationwindow.h>
Inheritance diagram for BpsApplicationWindow:Public Slots | |
| void | setWindowModified (bool aModified=true) |
| Overloaded version of QMainWindow::setWindowModified, which sends out the signal modifiedChanged. | |
Signals | |
| void | resetLayoutRequested () |
| This signal is emitted when a layout reset was requested through the popup menu. | |
| void | windowModified (bool aModified) |
| Signal emitted whenever the window modification status changes. | |
Public Member Functions | |
| BpsApplicationWindow (QWidget *aParent=0, Qt::WindowFlags aFlags=0) | |
| Constructor. | |
| void | enableChangeIconSize (bool aEnable) |
| Enable or disable the change icon size option. | |
| void | enableChangeIconText (bool aEnable) |
| Enable or disable the change icon text option. | |
| void | enableResetLayout (bool aEnable) |
| Enable or disable the reset layout option. | |
| virtual void | init () |
| Do initializations immediately before showing of the window. | |
| bool | isChangeIconSizeEnabled () const |
| bool | isChangeIconTextEnabled () const |
| bool | isResetLayoutEnabled () const |
| bool | restoreDockedState (bool aDockingEnabled, const QByteArray &aState, int aVersion=0) |
| Replacement for restoreState(), where docking window features can be enabled. | |
Main application window for plugins of BPS Workplace.
Typically an application window is derived from this class and implements a customized init function. This class extends the popup menu of QMainWindow with action groups to select toolbar button styles and sizes, and an action to reset the layout.
A signal is emitted when a layout reset is requested, and the application must implement a slot to connect it to. Status of the icon text and size must be saved and restored by the application.
Examples status save:
settings.setValue("icontext", toolButtonStyle()); settings.setValue("iconsize", iconSize().height());
Examples status restore:
int style = settings.value("icontext", Qt::ToolButtonIconOnly).toInt(); if (style < Qt::ToolButtonIconOnly || style > Qt::ToolButtonTextUnderIcon) style = Qt::ToolButtonIconOnly; setToolButtonStyle(static_cast<Qt::ToolButtonStyle>(style)); int size = settings.value("iconsize", 24).toInt(); if (size != 16 && size != 32) size = 24; setIconSize(QSize(size, size));
The application should also add the popup menu to the menu bar for convenience of touchscreen users. This should happen after all toolbars and dock windows are created and attached to the main window:
menuBar()->addMenu(createPopupMenu()); // submenu automatically reparented to application window
Icon action groups as well as the reset layout action can be disabled for special purpose; for example when the application has no tool bars at all or appearance must stay fixed. This should be done before createPopupMenu() is used.
The application window may receive a close request from the workplace. This request has to be handled in a close event handler, in case closing could have to be denied because of unsaved data or because a modal dialog is open. Here is an example for such an event handler:
void ADesignerWindow::closeEvent(QCloseEvent* aEvent) { bool modalChild = false; foreach (QWidget* widget, findChildren<QWidget*>()) if (widget->isVisible() && widget->isModal()) { modalChild = true; break; } // if if (!modalChild && mWorkspaceView->closeAllReports()) { writeSettings(); aEvent->accept(); } else aEvent->ignore(); } // closeEvent
| BpsApplicationWindow::BpsApplicationWindow | ( | QWidget * | aParent = 0, |
| Qt::WindowFlags | aFlags = 0 |
||
| ) |
Constructor.
| [in] | aParent | Parent widget. |
| [in] | aFlags | Main window flags. |
| void BpsApplicationWindow::enableChangeIconSize | ( | bool | aEnable | ) |
Enable or disable the change icon size option.
This should be done before createPopupMenu() is used. By default the option is enabled.
| [in] | aEnable | The new enable state. |
| void BpsApplicationWindow::enableChangeIconText | ( | bool | aEnable | ) |
Enable or disable the change icon text option.
This should be done before createPopupMenu() is used. By default the option is enabled.
| [in] | aEnable | The new enable state. |
| void BpsApplicationWindow::enableResetLayout | ( | bool | aEnable | ) |
Enable or disable the reset layout option.
This should be done before createPopupMenu() is used. By default the option is enabled.
| [in] | aEnable | The new enable state. |
| virtual void BpsApplicationWindow::init | ( | ) | [virtual] |
Do initializations immediately before showing of the window.
The default implementation does nothing.
| bool BpsApplicationWindow::isChangeIconSizeEnabled | ( | ) | const |
| bool BpsApplicationWindow::isChangeIconTextEnabled | ( | ) | const |
| bool BpsApplicationWindow::isResetLayoutEnabled | ( | ) | const |
| void BpsApplicationWindow::resetLayoutRequested | ( | ) | [signal] |
This signal is emitted when a layout reset was requested through the popup menu.
Connect this signal to the custom application slot resetting the layout to defaults.
| bool BpsApplicationWindow::restoreDockedState | ( | bool | aDockingEnabled, |
| const QByteArray & | aState, | ||
| int | aVersion = 0 |
||
| ) |
Replacement for restoreState(), where docking window features can be enabled.
| [in] | aDockingEnabled | True for docking enabled, false for docking disabled. |
| [in] | aState | The state to restore |
| [in] | aVersion | The version number of the state. |
| void BpsApplicationWindow::setWindowModified | ( | bool | aModified = true | ) | [slot] |
Overloaded version of QMainWindow::setWindowModified, which sends out the signal modifiedChanged.
| [in] | aModified | New modification status. |
| void BpsApplicationWindow::windowModified | ( | bool | aModified | ) | [signal] |
Signal emitted whenever the window modification status changes.
| [in] | aModified | New modification status. |