ToolWindowManager
Qt based tool window manager.
|
The QToolWindowManager class provides docking tool behavior. More...
Inherits QWidget.
Public Types | |
enum | AreaType { LastUsedArea, NewFloatingArea, EmptySpaceArea, NoArea } |
enum | ReferenceType { ReferenceAddTo, ReferenceLeftOf, ReferenceRightOf, ReferenceTopOf, ReferenceBottomOf } |
Signals | |
void | toolWindowVisibilityChanged (QWidget *toolWindow, bool visible) |
void | suggestionSwitchIntervalChanged (int suggestionSwitchInterval) |
void | borderSensitivityChanged (int borderSensitivity) |
void | rubberBandLineWidthChanged (int rubberBandLineWidth) |
Public Member Functions | |
QToolWindowManager (QWidget *parent=0) | |
Creates a manager with given parent. | |
~QToolWindowManager () | |
Destroys the widget. Additionally all tool windows and all floating windows created by this widget are destroyed. | |
void | addToolWindow (QWidget *toolWindow, AreaType area=LastUsedArea) |
void | addToolWindow (QWidget *toolWindow, ReferenceType reference, QAbstractToolWindowManagerArea *area) |
void | addToolWindows (const QWidgetList &toolWindows, AreaType area=LastUsedArea) |
Adds toolWindows to the manager and moves it to the position specified in area. The manager takes ownership of the tool windows and will delete them upon destruction. More... | |
void | addToolWindows (const QWidgetList &toolWindows, ReferenceType reference, QAbstractToolWindowManagerArea *area) |
void | moveToolWindow (QWidget *toolWindow, AreaType area=LastUsedArea) |
Moves toolWindow to the position specified in area. More... | |
void | moveToolWindow (QWidget *toolWindow, ReferenceType reference, QAbstractToolWindowManagerArea *area) |
Moves toolWindow to the position specified by a reference relative to area. More... | |
void | moveToolWindows (const QWidgetList &toolWindows, AreaType area=LastUsedArea) |
Moves toolWindows to the position specified in area. More... | |
void | moveToolWindows (const QWidgetList &toolWindows, ReferenceType reference, QAbstractToolWindowManagerArea *area) |
Moves toolWindows to the position specified by a reference relative to area. More... | |
QAbstractToolWindowManagerArea * | areaFor (QWidget *toolWindow) const |
void | removeToolWindow (QWidget *toolWindow) |
Removes toolWindow from the manager. toolWindow becomes a hidden top level widget. The ownership of toolWindow is returned to the caller. | |
QWidgetList | toolWindows () const |
Returns all tool window added to the manager. | |
void | hideToolWindow (QWidget *toolWindow) |
QVariant | saveState () const |
void | restoreState (const QVariant &data) |
int | suggestionSwitchInterval () const |
void | setSuggestionSwitchInterval (int msec) |
int | borderSensitivity () const |
void | setBorderSensitivity (int pixels) |
int | rubberBandLineWidth () const |
void | setRubberBandLineWidth (int pixels) |
QRubberBand * | rectRubberBand () const |
QRubberBand * | lineRubberBand () const |
Protected Member Functions | |
virtual QSplitter * | createSplitter () |
virtual QAbstractToolWindowManagerArea * | createArea () |
virtual QPixmap | generateDragPixmap (const QWidgetList &toolWindows) |
bool | event (QEvent *e) |
Properties | |
int | suggestionSwitchInterval |
The delay between showing the next suggestion of drop location in milliseconds. More... | |
int | borderSensitivity |
Maximal distance in pixels between mouse position and area border that allows to display a suggestion. More... | |
int | rubberBandLineWidth |
Visible width of rubber band line that is used to display drop suggestions. More... | |
Friends | |
class | QToolWindowManagerWrapper |
class | QAbstractToolWindowManagerArea |
The QToolWindowManager class provides docking tool behavior.
QtWidgets
The behavior provided by QToolWindowManager is similar to tool windows mechanism in Visual Studio or Eclipse. User can arrange tool windows in tabs, dock it to any border, split with vertical and horizontal splitters, tabify them together and detach to floating windows. QToolWindowManager can be used to implement ability for user to setup an environment with customized tool windows layout.
QToolWindowManager is in many ways similar to QMainWindow that also provides ability to pin dock widgets and toolbars to its borders, tabify or detach them. However, QToolWindowManager has extended abilities to manage tool windows. It has no canonic central area. Each and every area can be used to tabify several tool windows. Each area can be divided to display many tool windows at once. Dropping tool windows is not limited to the borders of QToolWindowManager. A tool window can be dropped at any border between areas. These features also applies to the floating areas. They can be split up and/or contain tabified tool windows.
QToolWindowManager also provides API to setup an arbitrary environment programmatically. This can be used to create presets of environments for quick start.
Each tool window can be dragged individually by pressing left mouse button at its tab button at the tab bar and dragging away. Each area containing multiple tabified tool window can be dragged as a whole by pressing left mouse button at the empty space at the tab bar and dragging away. When an item is dragged and mouse is over a suitable drop area (i.e. QToolWindowManager itself or one of the floating windows created by it), a drop suggestion appears indicating where the item will be put to if it's dropped. It can be either a line indicating that the item will be inserted between its neighbor areas, or a rectangle indicating that the dragged tool window(s) will be added to the highlighted area as tabs. When an item is dropped to space that is not managed by the QToolWindowManager, it becomes a floating window.
Describes where to place a tool window.
LastUsedArea The area tool windows has been added to most recently. NewFloatingArea New area in a detached window. EmptySpaceArea Area inside the manager widget (only available when there is no tool windows in it). NoArea Tool window is hidden.
Describes where to place a tool window relative to an existing area.
ReferenceAddTo Add to existing QToolWindowManagerArea as new tab. ReferenceLeftOf Add to new area to the left of the QToolWindowManagerArea. ReferenceRightOf Add to new area to the right of the QToolWindowManagerArea. ReferenceTopOf Add to new area to the top of the QToolWindowManagerArea. ReferenceBottomOf Add to new area to the bottom of the QToolWindowManagerArea.
void QToolWindowManager::addToolWindow | ( | QWidget * | toolWindow, |
QToolWindowManager::AreaType | area = LastUsedArea |
||
) |
Adds toolWindow to the manager and moves it to the position specified in area. This function is a shortcut for QToolWindowManager::addToolWindows.
void QToolWindowManager::addToolWindow | ( | QWidget * | toolWindow, |
QToolWindowManager::ReferenceType | reference, | ||
QAbstractToolWindowManagerArea * | area | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Adds toolWindow to the manager and moves it to the position specified by a reference relative to area. This function is a shortcut for QToolWindowManager::addToolWindows.
void QToolWindowManager::addToolWindows | ( | const QWidgetList & | toolWindows, |
QToolWindowManager::AreaType | area = LastUsedArea |
||
) |
Adds toolWindows to the manager and moves it to the position specified in area. The manager takes ownership of the tool windows and will delete them upon destruction.
toolWindow->windowIcon() and toolWindow->windowTitle() will be used as the icon and title of the tab that represents the tool window.
If you intend to use QToolWindowManager::saveState and QToolWindowManager::restoreState functions, you must set objectName() of each added tool window to a non-empty unique string.
void QToolWindowManager::addToolWindows | ( | const QWidgetList & | toolWindows, |
QToolWindowManager::ReferenceType | reference, | ||
QAbstractToolWindowManagerArea * | area | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Adds toolWindows to the manager and moves it to the position specified by a reference relative to area.
QAbstractToolWindowManagerArea * QToolWindowManager::areaFor | ( | QWidget * | toolWindow | ) | const |
Returns the area that contains toolWindow, or 0 if toolWindow is hidden.
|
protectedvirtual |
Create an area object. Reimplement this function if you want to use your own area subclass.
|
protectedvirtual |
Create a splitter. Reimplement this function if you want to use your own splitter subclass.
|
protected |
|
protectedvirtual |
Generates a pixmap for toolWindows that is used to represent the data in a drag and drop operation near the mouse cursor. You may reimplement this function to use different pixmaps.
void QToolWindowManager::hideToolWindow | ( | QWidget * | toolWindow | ) |
Hides toolWindow.
toolWindow must be added to the manager prior to calling this function.
QRubberBand * QToolWindowManager::lineRubberBand | ( | ) | const |
Returns the widget that is used to display line drop suggestions.
void QToolWindowManager::moveToolWindow | ( | QWidget * | toolWindow, |
QToolWindowManager::AreaType | area = LastUsedArea |
||
) |
Moves toolWindow to the position specified in area.
toolWindow must be added to the manager prior to calling this function.
void QToolWindowManager::moveToolWindow | ( | QWidget * | toolWindow, |
QToolWindowManager::ReferenceType | reference, | ||
QAbstractToolWindowManagerArea * | area | ||
) |
Moves toolWindow to the position specified by a reference relative to area.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void QToolWindowManager::moveToolWindows | ( | const QWidgetList & | toolWindows, |
QToolWindowManager::AreaType | area = LastUsedArea |
||
) |
Moves toolWindows to the position specified in area.
toolWindows must be added to the manager prior to calling this function.
void QToolWindowManager::moveToolWindows | ( | const QWidgetList & | toolWindows, |
QToolWindowManager::ReferenceType | reference, | ||
QAbstractToolWindowManagerArea * | area | ||
) |
Moves toolWindows to the position specified by a reference relative to area.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
QRubberBand * QToolWindowManager::rectRubberBand | ( | ) | const |
Returns the widget that is used to display rectangular drop suggestions.
void QToolWindowManager::restoreState | ( | const QVariant & | data | ) |
Restores state and position of tool windows stored in data.
QVariant QToolWindowManager::saveState | ( | ) | const |
Dumps the state and position of all tool windows to a variable. It can be stored in application settings using QSettings. Stored state can be restored by calling QToolWindowManager::restoreState with the same value.
|
signal |
This signal is emitted when toolWindow may be hidden or shown. visible indicates new visibility state of the tool window.
|
readwrite |
Maximal distance in pixels between mouse position and area border that allows to display a suggestion.
Default value is 12.
|
readwrite |
Visible width of rubber band line that is used to display drop suggestions.
Default value is the same as QSplitter::handleWidth default value on current platform.
|
readwrite |
The delay between showing the next suggestion of drop location in milliseconds.
When user starts a tool window drag and moves mouse pointer to a position, there can be an ambiguity in new position of the tool window. If user holds the left mouse button and stops mouse movements, all possible suggestions will be indicated periodically, one at a time.
Default value is 1000 (i.e. 1 second).