KDDockWidgets API Documentation 2.1
|
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some code with the QtQuick implementation, which also derives from MainWindowBase. More...
#include <MainWindow.h>
Public Types | |
typedef Vector< MainWindow * > | List |
Public Member Functions | |
MainWindow (View *view, const QString &uniqueName, MainWindowOptions options) | |
~MainWindow () override | |
void | addDockWidget (KDDockWidgets::Core::DockWidget *dockWidget, KDDockWidgets::Location location, KDDockWidgets::Core::DockWidget *relativeTo=nullptr, const KDDockWidgets::InitialOption &initialOption={}) |
Docks a DockWidget into this main window. | |
void | addDockWidgetAsTab (KDDockWidgets::Core::DockWidget *dockwidget) |
Docks a DockWidget into the central group, tabbed. | |
void | addDockWidgetToSide (KDDockWidgets::Core::DockWidget *dockWidget, KDDockWidgets::Location location, const KDDockWidgets::InitialOption &initialOption={}) |
Vector< QString > | affinities () const |
Returns the list of affinity names. Empty by default. | |
bool | anySideBarIsVisible () const |
Returns whether any side bar is visible. | |
Margins | centerWidgetMargins () const |
void | clearSideBarOverlay (bool deleteGroup=true) |
closes any overlayed dock widget. The sidebar still displays them as button. | |
bool | closeDockWidgets (bool force=false) |
Closes all dock widgets which are docked into this main window This is convenience to calling DockWidget::close() individually If force is true, then the individual dock widgets can't stop the process Returns false if there's at least one dock widget which rejected closing. Returns true if all dock widgets were closed (0 or more) | |
DropArea * | dropArea () const |
void | init (const QString &name) |
bool | isMDI () const |
Returns whether this main window is using an MDI layout. In other words, returns true if MainWindowOption_MDI was passed in the ctor. | |
Layout * | layout () const |
void | layoutEqually () |
layouts all the widgets so they have an equal size within their parent container | |
void | layoutParentContainerEqually (KDDockWidgets::Core::DockWidget *dockWidget) |
like layoutEqually() but starts with the container that has dockWidget . While layoutEqually() starts from the root of the layout tree this function starts on a sub-tree. | |
MDILayout * | mdiLayout () const |
void | moveToSideBar (KDDockWidgets::Core::DockWidget *dw) |
Moves the dock widget into one of the MainWindow's sidebar. Means the dock widget is removed from the layout, and the sidebar shows a button that if pressed will toggle the dock widget's visibility as an overlay over the layout. This is the auto-hide functionality. | |
void | moveToSideBar (KDDockWidgets::Core::DockWidget *dw, KDDockWidgets::SideBarLocation location) |
overload that allows to specify which sidebar to use, instead of using heuristics. | |
DropArea * | multiSplitter () const |
MainWindowOptions | options () const |
Returns the main window options that were passed via constructor. | |
Core::DockWidget * | overlayedDockWidget () const |
returns the dock widget which is currently overlayed. nullptr if none. This is only relevant when using the auto-hide and side-bar feature. | |
int | overlayMargin () const |
Returns the margin used by overlay docks. Default: 1. | |
void | overlayOnSideBar (KDDockWidgets::Core::DockWidget *dw) |
Shows the dock widget overlayed on top of the main window, placed next to the sidebar. | |
std::shared_ptr< View > | persistentCentralView () const |
void | restoreFromSideBar (KDDockWidgets::Core::DockWidget *dw) |
Removes the dock widget from the sidebar and docks it into the main window again. | |
void | setAffinities (const Vector< QString > &names) |
Sets the affinities names. Dock widgets can only dock into main windows of the same affinity. | |
void | setContentsMargins (int l, int t, int r, int b) |
Sets the content's margins. | |
void | setOverlayMargin (int margin) |
Sets the margin used by overlay docks. Does not modify currently overlayed docks. | |
void | setPersistentCentralView (std::shared_ptr< View > widget) |
Sets a persistent central widget. It can't be detached. | |
Core::SideBar * | sideBar (SideBarLocation location) const |
Returns the side bar at the specified location. | |
KDDockWidgets::Core::SideBar * | sideBarForDockWidget (const KDDockWidgets::Core::DockWidget *dw) const |
Returns the sidebar this dockwidget is in. nullptr if not in any. | |
bool | sideBarIsVisible (KDDockWidgets::SideBarLocation location) const |
Returns whether the specified sidebar is visible. | |
void | toggleOverlayOnSideBar (KDDockWidgets::Core::DockWidget *dw) |
Shows or hides an overlay. It's assumed the dock widget is already in a side-bar. | |
QString | uniqueName () const |
Returns the unique name that was passed via constructor. Used internally by the save/restore mechanism. | |
Public Member Functions inherited from KDDockWidgets::Core::Controller | |
Controller (ViewType type, View *) | |
virtual | ~Controller () |
bool | close () |
void | destroyLater () |
Controller::Private * | dptr () const |
Rect | geometry () const |
int | height () const |
bool | inDtor () const |
bool | is (ViewType) const |
Returns whether this controller is of the specified type. | |
bool | isFixedHeight () const |
bool | isFixedWidth () const |
bool | isVisible () const |
Point | mapToGlobal (Point) const |
Point | pos () const |
Rect | rect () const |
void | setParentView (View *parent) |
void | setVisible (bool) |
void | show () const |
Size | size () const |
ViewType | type () const |
Returns the type of this controller. | |
View * | view () const |
Returns the view associated with this controller, if any. | |
int | width () const |
std::shared_ptr< View > | window () const |
int | x () const |
int | y () const |
Protected Member Functions | |
Rect | centralAreaGeometry () const |
void | setUniqueName (const QString &uniqueName) |
Protected Member Functions inherited from KDDockWidgets::Core::Controller | |
virtual void | setParentView_impl (View *parent) |
Additional Inherited Members | |
Protected Attributes inherited from KDDockWidgets::Core::Controller | |
bool | m_inDtor = false |
The MainWindow base-class. MainWindow and MainWindowBase are only split in two so we can share some code with the QtQuick implementation, which also derives from MainWindowBase.
Do not use instantiate directly in user code. Use MainWindow instead.
Definition at line 61 of file core/MainWindow.h.
Definition at line 65 of file core/MainWindow.h.
|
explicit |
|
override |
void KDDockWidgets::Core::MainWindow::addDockWidget | ( | KDDockWidgets::Core::DockWidget * | dockWidget, |
KDDockWidgets::Location | location, | ||
KDDockWidgets::Core::DockWidget * | relativeTo = nullptr , |
||
const KDDockWidgets::InitialOption & | initialOption = {} |
||
) |
Docks a DockWidget into this main window.
dockWidget | The dock widget to add into this MainWindow |
location | the location where to dock |
relativeTo | In case we're docking in relation to another dock widget |
initialOption | Allows to specify an InitialOption. Which is useful to add the dock widget as hidden, recording only a placeholder in the tab. So it's restored to tabbed when eventually shown. |
Referenced by KDDockWidgets::Core::MainWindowViewInterface::addDockWidget(), KDDockWidgets::Core::MainWindowViewInterface::addDockWidget(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::addDockWidget(), KDDockWidgets::MainWindowInstantiator::addDockWidget(), and c_KDDockWidgets__Core__MainWindow__addDockWidget_DockWidget_Location_DockWidget_InitialOption().
void KDDockWidgets::Core::MainWindow::addDockWidgetAsTab | ( | KDDockWidgets::Core::DockWidget * | dockwidget | ) |
Docks a DockWidget into the central group, tabbed.
dockwidget | The dockwidget to dock. |
Referenced by KDDockWidgets::Core::MainWindowViewInterface::addDockWidgetAsTab(), KDDockWidgets::Core::MainWindowViewInterface::addDockWidgetAsTab(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::addDockWidgetAsTab(), KDDockWidgets::MainWindowInstantiator::addDockWidgetAsTab(), and c_KDDockWidgets__Core__MainWindow__addDockWidgetAsTab_DockWidget().
void KDDockWidgets::Core::MainWindow::addDockWidgetToSide | ( | KDDockWidgets::Core::DockWidget * | dockWidget, |
KDDockWidgets::Location | location, | ||
const KDDockWidgets::InitialOption & | initialOption = {} |
||
) |
Docks a DockWidget into this main window at the specified side. To be used only with MainWindowOption_HasCentralWidget or MainWindowOption_HasCentralFrame. This is to mimic old QDockWidget system where there were 4 sides around the central widget (not infinite nesting).
Example: Adding dock widget D1 to Right results in: +------—+–+ | central |D1| +------—+–+ but adding D2 to Right as well will result in +------—+–+ | |D1| | central +–+ | |D2| +------—+–+ which is actually equivalent to addDockWidget(D2, Location_onBottom, /relativeTo=/D1);
Referenced by KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::addDockWidgetToSide(), and c_KDDockWidgets__Core__MainWindow__addDockWidgetToSide_DockWidget_Location_InitialOption().
Returns the list of affinity names. Empty by default.
Referenced by KDDockWidgets::Core::MainWindowViewInterface::affinities(), KDDockWidgets::MainWindowInstantiator::affinities(), and KDDockWidgets::MainWindowMDIInstantiator::affinities().
bool KDDockWidgets::Core::MainWindow::anySideBarIsVisible | ( | ) | const |
Returns whether any side bar is visible.
Referenced by KDDockWidgets::Core::MainWindowViewInterface::anySideBarIsVisible(), and c_KDDockWidgets__Core__MainWindow__anySideBarIsVisible().
Margins KDDockWidgets::Core::MainWindow::centerWidgetMargins | ( | ) | const |
Referenced by c_KDDockWidgets__Core__MainWindow__centerWidgetMargins().
|
protected |
void KDDockWidgets::Core::MainWindow::clearSideBarOverlay | ( | bool | deleteGroup = true | ) |
closes any overlayed dock widget. The sidebar still displays them as button.
Referenced by c_KDDockWidgets__Core__MainWindow__clearSideBarOverlay_bool(), KDDockWidgets::Core::MainWindowViewInterface::clearSideBarOverlay(), KDDockWidgets::MainWindowInstantiator::clearSideBarOverlay(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::clearSideBarOverlay().
bool KDDockWidgets::Core::MainWindow::closeDockWidgets | ( | bool | force = false | ) |
Closes all dock widgets which are docked into this main window This is convenience to calling DockWidget::close() individually If force is true, then the individual dock widgets can't stop the process Returns false if there's at least one dock widget which rejected closing. Returns true if all dock widgets were closed (0 or more)
Referenced by c_KDDockWidgets__Core__MainWindow__closeDockWidgets_bool(), KDDockWidgets::Core::MainWindowViewInterface::closeDockWidgets(), KDDockWidgets::MainWindowInstantiator::closeDockWidgets(), and KDDockWidgets::MainWindowMDIInstantiator::closeDockWidgets().
DropArea * KDDockWidgets::Core::MainWindow::dropArea | ( | ) | const |
Referenced by c_KDDockWidgets__Core__MainWindow__dropArea().
void KDDockWidgets::Core::MainWindow::init | ( | const QString & | name | ) |
bool KDDockWidgets::Core::MainWindow::isMDI | ( | ) | const |
Returns whether this main window is using an MDI layout. In other words, returns true if MainWindowOption_MDI was passed in the ctor.
Referenced by c_KDDockWidgets__Core__MainWindow__isMDI(), KDDockWidgets::Core::MainWindowViewInterface::isMDI(), and KDDockWidgets::MainWindowInstantiator::isMDI().
Layout * KDDockWidgets::Core::MainWindow::layout | ( | ) | const |
Referenced by c_KDDockWidgets__Core__MainWindow__layout().
void KDDockWidgets::Core::MainWindow::layoutEqually | ( | ) |
layouts all the widgets so they have an equal size within their parent container
Note that the layout is a tree of nested horizontal and vertical container layouts. The nodes closer to the root will have more space.
min/max constraints will still be honoured.
Referenced by c_KDDockWidgets__Core__MainWindow__layoutEqually(), KDDockWidgets::Core::MainWindowViewInterface::layoutEqually(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::layoutEqually(), and KDDockWidgets::MainWindowInstantiator::layoutEqually().
void KDDockWidgets::Core::MainWindow::layoutParentContainerEqually | ( | KDDockWidgets::Core::DockWidget * | dockWidget | ) |
like layoutEqually() but starts with the container that has dockWidget
. While layoutEqually() starts from the root of the layout tree this function starts on a sub-tree.
Referenced by c_KDDockWidgets__Core__MainWindow__layoutParentContainerEqually_DockWidget(), KDDockWidgets::Core::MainWindowViewInterface::layoutParentContainerEqually(), KDDockWidgets::Core::MainWindowViewInterface::layoutParentContainerEqually(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::layoutParentContainerEqually(), and KDDockWidgets::MainWindowInstantiator::layoutParentContainerEqually().
MDILayout * KDDockWidgets::Core::MainWindow::mdiLayout | ( | ) | const |
Referenced by KDDockWidgets::MainWindowMDIInstantiator::addDockWidget().
void KDDockWidgets::Core::MainWindow::moveToSideBar | ( | KDDockWidgets::Core::DockWidget * | dw | ) |
Moves the dock widget into one of the MainWindow's sidebar. Means the dock widget is removed from the layout, and the sidebar shows a button that if pressed will toggle the dock widget's visibility as an overlay over the layout. This is the auto-hide functionality.
The chosen side bar will depend on some heuristics, mostly proximity.
Referenced by c_KDDockWidgets__Core__MainWindow__moveToSideBar_DockWidget(), KDDockWidgets::Core::MainWindowViewInterface::moveToSideBar(), KDDockWidgets::Core::MainWindowViewInterface::moveToSideBar(), KDDockWidgets::Core::MainWindowViewInterface::moveToSideBar(), KDDockWidgets::Core::MainWindowViewInterface::moveToSideBar(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::moveToSideBar(), KDDockWidgets::MainWindowInstantiator::moveToSideBar(), and KDDockWidgets::MainWindowInstantiator::moveToSideBar().
void KDDockWidgets::Core::MainWindow::moveToSideBar | ( | KDDockWidgets::Core::DockWidget * | dw, |
KDDockWidgets::SideBarLocation | location | ||
) |
overload that allows to specify which sidebar to use, instead of using heuristics.
DropArea * KDDockWidgets::Core::MainWindow::multiSplitter | ( | ) | const |
Referenced by c_KDDockWidgets__Core__MainWindow__multiSplitter().
MainWindowOptions KDDockWidgets::Core::MainWindow::options | ( | ) | const |
Returns the main window options that were passed via constructor.
Referenced by c_KDDockWidgets__Core__MainWindow__options(), from_json(), and KDDockWidgets::Core::MainWindowViewInterface::options().
Core::DockWidget * KDDockWidgets::Core::MainWindow::overlayedDockWidget | ( | ) | const |
returns the dock widget which is currently overlayed. nullptr if none. This is only relevant when using the auto-hide and side-bar feature.
Referenced by c_KDDockWidgets__Core__MainWindow__overlayedDockWidget().
int KDDockWidgets::Core::MainWindow::overlayMargin | ( | ) | const |
Returns the margin used by overlay docks. Default: 1.
Referenced by c_KDDockWidgets__Core__MainWindow__overlayMargin().
void KDDockWidgets::Core::MainWindow::overlayOnSideBar | ( | KDDockWidgets::Core::DockWidget * | dw | ) |
Shows the dock widget overlayed on top of the main window, placed next to the sidebar.
Referenced by c_KDDockWidgets__Core__MainWindow__overlayOnSideBar_DockWidget(), KDDockWidgets::Core::MainWindowViewInterface::overlayOnSideBar(), KDDockWidgets::Core::MainWindowViewInterface::overlayOnSideBar(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::overlayOnSideBar(), and KDDockWidgets::MainWindowInstantiator::overlayOnSideBar().
std::shared_ptr< View > KDDockWidgets::Core::MainWindow::persistentCentralView | ( | ) | const |
void KDDockWidgets::Core::MainWindow::restoreFromSideBar | ( | KDDockWidgets::Core::DockWidget * | dw | ) |
Removes the dock widget from the sidebar and docks it into the main window again.
Referenced by c_KDDockWidgets__Core__MainWindow__restoreFromSideBar_DockWidget(), KDDockWidgets::Core::TitleBar::onAutoHideClicked(), KDDockWidgets::Core::MainWindowViewInterface::restoreFromSideBar(), KDDockWidgets::Core::MainWindowViewInterface::restoreFromSideBar(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::restoreFromSideBar(), and KDDockWidgets::MainWindowInstantiator::restoreFromSideBar().
Sets the affinities names. Dock widgets can only dock into main windows of the same affinity.
By default the affinity is empty and a dock widget can dock into any main window. Usually you won't ever need to call this function, unless you have requirements where certain dock widgets can only dock into certain main windows.
Note: Call this function right after creating your main window, before docking any dock widgets into a main window and before restoring any layout.
Note: Currently you can only call this function once, to keep the code simple and avoid edge cases. This will only be changed if a good use case comes up that requires changing affinities multiple times.
name
The affinity names.
Referenced by KDDockWidgets::MainWindowInstantiator::componentComplete(), and KDDockWidgets::Core::MainWindowViewInterface::setAffinities().
void KDDockWidgets::Core::MainWindow::setContentsMargins | ( | int | l, |
int | t, | ||
int | r, | ||
int | b | ||
) |
Sets the content's margins.
Referenced by c_KDDockWidgets__Core__MainWindow__setContentsMargins_int_int_int_int(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::setContentsMargins().
void KDDockWidgets::Core::MainWindow::setOverlayMargin | ( | int | margin | ) |
Sets the margin used by overlay docks. Does not modify currently overlayed docks.
Referenced by c_KDDockWidgets__Core__MainWindow__setOverlayMargin_int(), and KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::setOverlayMargin().
void KDDockWidgets::Core::MainWindow::setPersistentCentralView | ( | std::shared_ptr< View > | widget | ) |
Sets a persistent central widget. It can't be detached.
Requires passing MainWindowOption_HasCentralWidget in the CTOR. This is similar to the central group concept of MainWindowOption_HasCentralFrame, with the difference that it won't show a tabs.
Example: examples/qtwidgets_dockwidgets –central-widget
Referenced by KDDockWidgets::Core::MainWindowViewInterface::setPersistentCentralView().
|
protected |
Core::SideBar * KDDockWidgets::Core::MainWindow::sideBar | ( | SideBarLocation | location | ) | const |
Returns the side bar at the specified location.
KDDockWidgets::Core::SideBar * KDDockWidgets::Core::MainWindow::sideBarForDockWidget | ( | const KDDockWidgets::Core::DockWidget * | dw | ) | const |
Returns the sidebar this dockwidget is in. nullptr if not in any.
Referenced by c_KDDockWidgets__Core__MainWindow__sideBarForDockWidget_DockWidget().
bool KDDockWidgets::Core::MainWindow::sideBarIsVisible | ( | KDDockWidgets::SideBarLocation | location | ) | const |
Returns whether the specified sidebar is visible.
Referenced by KDDockWidgets::Core::MainWindowViewInterface::sideBarIsVisible(), and KDDockWidgets::MainWindowInstantiator::sideBarIsVisible().
void KDDockWidgets::Core::MainWindow::toggleOverlayOnSideBar | ( | KDDockWidgets::Core::DockWidget * | dw | ) |
Shows or hides an overlay. It's assumed the dock widget is already in a side-bar.
Referenced by c_KDDockWidgets__Core__MainWindow__toggleOverlayOnSideBar_DockWidget(), KDDockWidgets::Core::SideBar::toggleOverlay(), KDDockWidgets::Core::MainWindowViewInterface::toggleOverlayOnSideBar(), KDDockWidgets::Core::MainWindowViewInterface::toggleOverlayOnSideBar(), KDDockWidgetsBindings_wrappersNS::KDDWBindingsCore::MainWindow_wrapper::toggleOverlayOnSideBar(), and KDDockWidgets::MainWindowInstantiator::toggleOverlayOnSideBar().
QString KDDockWidgets::Core::MainWindow::uniqueName | ( | ) | const |
Returns the unique name that was passed via constructor. Used internally by the save/restore mechanism.
Referenced by c_KDDockWidgets__Core__MainWindow__uniqueName(), KDDockWidgets::DockRegistry::registerMainWindow(), and KDDockWidgets::Core::MainWindowViewInterface::uniqueName().