KDDockWidgets API Documentation 1.7
|
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 <MainWindowBase.h>
Public Types | |
typedef QVector< MainWindowBase * > | List |
Public Types inherited from QMainWindow | |
enum | DockOption |
Public Types inherited from QWidget | |
enum | RenderFlag |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric |
Signals | |
void | frameCountChanged (int) |
emitted when the number of docked frames changes Note that we're using the "Frame" nomenculature instead of "DockWidget" here, as DockWidgets can be tabbed together, in which case this signal isn't emitted. | |
void | overlayMarginChanged (int) |
void | uniqueNameChanged () |
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 52 of file MainWindowBase.h.
Definition at line 64 of file MainWindowBase.h.
|
explicit |
Definition at line 119 of file MainWindowBase.cpp.
References QObject::connect(), frameCountChanged(), setUniqueName(), and uniqueName.
|
override |
Definition at line 130 of file MainWindowBase.cpp.
void MainWindowBase::addDockWidget | ( | KDDockWidgets::DockWidgetBase * | dockWidget, |
KDDockWidgets::Location | location, | ||
KDDockWidgets::DockWidgetBase * | relativeTo = nullptr , |
||
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. |
Definition at line 168 of file MainWindowBase.cpp.
References dropArea(), isMDI, KDDockWidgets::DockWidgetBase::Option_NotDockable, and QObject::qobject_cast().
Referenced by KDDockWidgets::DockWidgetBase::addDockWidgetToContainingWindow().
void MainWindowBase::addDockWidgetAsTab | ( | KDDockWidgets::DockWidgetBase * | dockwidget | ) |
Docks a DockWidget into the central frame, tabbed.
dockwidget | The dockwidget to dock. |
Definition at line 136 of file MainWindowBase.cpp.
References KDDockWidgets::DockWidgetBase::affinities(), affinities, dropArea(), isMDI, KDDockWidgets::DockWidgetBase::Option_NotDockable, KDDockWidgets::DockWidgetBase::options, and QObject::qobject_cast().
QStringList MainWindowBase::affinities | ( | ) | const |
Returns the list of affinity names. Empty by default.
Definition at line 233 of file MainWindowBase.cpp.
bool MainWindowBase::anySideBarIsVisible | ( | ) | const |
Returns whether any side bar is visible.
Definition at line 630 of file MainWindowBase.cpp.
References KDDockWidgets::East, KDDockWidgets::North, QObject::qobject_cast(), sideBarIsVisible(), KDDockWidgets::South, and KDDockWidgets::West.
Implemented in KDDockWidgets::MainWindow.
Reimplemented in KDDockWidgets::MainWindow.
Definition at line 245 of file MainWindowBase.h.
closes any overlayed dock widget. The sidebar still displays them as button.
Definition at line 575 of file MainWindowBase.cpp.
References QObject::Q_EMIT(), and QObject::qobject_cast().
Referenced by overlayOnSideBar(), restoreFromSideBar(), and toggleOverlayOnSideBar().
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)
Definition at line 646 of file MainWindowBase.cpp.
References QObject::qobject_cast().
DropAreaWithCentralFrame * MainWindowBase::dropArea | ( | ) | const |
Definition at line 195 of file MainWindowBase.cpp.
References QObject::qobject_cast().
Referenced by addDockWidget(), addDockWidgetAsTab(), layoutEqually(), layoutParentContainerEqually(), and multiSplitter().
emitted when the number of docked frames changes Note that we're using the "Frame" nomenculature instead of "DockWidget" here, as DockWidgets can be tabbed together, in which case this signal isn't emitted.
Referenced by MainWindowBase().
bool MainWindowBase::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.
Definition at line 641 of file MainWindowBase.cpp.
References KDDockWidgets::MainWindowOption_MDI.
void MainWindowBase::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.
Definition at line 238 of file MainWindowBase.cpp.
References dropArea().
void MainWindowBase::layoutParentContainerEqually | ( | KDDockWidgets::DockWidgetBase * | 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.
Definition at line 243 of file MainWindowBase.cpp.
References dropArea(), and QObject::qobject_cast().
LayoutWidget * MainWindowBase::layoutWidget | ( | ) | const |
Definition at line 205 of file MainWindowBase.cpp.
Referenced by KDDockWidgets::MainWindow::MainWindow(), KDDockWidgets::MainWindowMDI::addDockWidget(), and mdiLayoutWidget().
MDILayoutWidget * MainWindowBase::mdiLayoutWidget | ( | ) | const |
Definition at line 210 of file MainWindowBase.cpp.
References layoutWidget(), and QObject::qobject_cast().
void MainWindowBase::moveToSideBar | ( | KDDockWidgets::DockWidgetBase * | 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.
Definition at line 496 of file MainWindowBase.cpp.
References moveToSideBar(), and QObject::qobject_cast().
Referenced by moveToSideBar().
void MainWindowBase::moveToSideBar | ( | KDDockWidgets::DockWidgetBase * | dw, |
KDDockWidgets::SideBarLocation | location | ||
) |
overload that allows to specify which sidebar to use, instead of using heuristics.
Definition at line 501 of file MainWindowBase.cpp.
References QObject::qobject_cast(), and sideBar().
MultiSplitter * MainWindowBase::multiSplitter | ( | ) | const |
Definition at line 200 of file MainWindowBase.cpp.
References dropArea().
|
protected |
Definition at line 814 of file MainWindowBase.cpp.
References QObject::qobject_cast().
Referenced by KDDockWidgets::MainWindow::closeEvent().
|
protected |
Definition at line 690 of file MainWindowBase.cpp.
Referenced by KDDockWidgets::MainWindow::resizeEvent().
MainWindowOptions MainWindowBase::options | ( | ) | const |
Returns the main window options that were passed via constructor.
Definition at line 190 of file MainWindowBase.cpp.
DockWidgetBase * MainWindowBase::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.
Definition at line 616 of file MainWindowBase.cpp.
int MainWindowBase::overlayMargin | ( | ) | const |
Returns the margin used by overlay docks. Default: 1.
Definition at line 776 of file MainWindowBase.cpp.
Referenced by setOverlayMargin().
void MainWindowBase::overlayOnSideBar | ( | KDDockWidgets::DockWidgetBase * | dw | ) |
Shows the dock widget overlayed on top of the main window, placed next to the sidebar.
Definition at line 533 of file MainWindowBase.cpp.
References clearSideBarOverlay(), QObject::connect(), KDDockWidgets::FrameworkWidgetFactory::createFrame(), KDDockWidgets::FrameOption_IsOverlayed, KDDockWidgets::Config::frameworkWidgetFactory(), QObject::Q_EMIT(), QObject::qobject_cast(), KDDockWidgets::Config::self(), and sideBarForDockWidget().
Referenced by toggleOverlayOnSideBar().
QWidgetOrQuick * MainWindowBase::persistentCentralWidget | ( | ) | const |
Definition at line 806 of file MainWindowBase.cpp.
References QObject::qobject_cast().
void MainWindowBase::restoreFromSideBar | ( | KDDockWidgets::DockWidgetBase * | dw | ) |
Removes the dock widget from the sidebar and docks it into the main window again.
Definition at line 516 of file MainWindowBase.cpp.
References clearSideBarOverlay(), QObject::qobject_cast(), and sideBarForDockWidget().
void MainWindowBase::setAffinities | ( | const QStringList & | names | ) |
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.
Definition at line 215 of file MainWindowBase.cpp.
References affinities, QObject::qobject_cast(), and QList::removeAll().
Sets the margin used by overlay docks. Does not modify currently overlayed docks.
Definition at line 781 of file MainWindowBase.cpp.
References overlayMarginChanged(), and QObject::Q_EMIT().
void MainWindowBase::setPersistentCentralWidget | ( | KDDockWidgets::QWidgetOrQuick * | widget | ) |
Sets a persistent central widget. It can't be detached.
Requires passing MainWindowOption_HasCentralWidget in the CTOR. This is similar to the central frame concept of MainWindowOption_HasCentralFrame, with the difference that it won't show a tabs.
widget | The QWidget (or QQuickItem if built with QtQuick support) that you want to set. |
Example: kddockwidgets_example –central-widget
Definition at line 791 of file MainWindowBase.cpp.
References QObject::qobject_cast().
Definition at line 676 of file MainWindowBase.cpp.
References QString::isEmpty(), QObject::Q_EMIT(), QObject::qobject_cast(), uniqueName, and uniqueNameChanged().
Referenced by MainWindowBase().
|
protectedpure virtual |
Implemented in KDDockWidgets::MainWindow.
Referenced by moveToSideBar(), sideBarForDockWidget(), and sideBarIsVisible().
SideBar * MainWindowBase::sideBarForDockWidget | ( | const KDDockWidgets::DockWidgetBase * | dw | ) | const |
Returns the sidebar this dockwidget is in. nullptr if not in any.
Definition at line 602 of file MainWindowBase.cpp.
References KDDockWidgets::East, KDDockWidgets::North, QObject::qobject_cast(), sideBar(), KDDockWidgets::South, and KDDockWidgets::West.
Referenced by overlayOnSideBar(), and restoreFromSideBar().
bool MainWindowBase::sideBarIsVisible | ( | KDDockWidgets::SideBarLocation | loc | ) | const |
Returns whether the specified sidebar is visible.
Definition at line 621 of file MainWindowBase.cpp.
References QObject::qobject_cast(), and sideBar().
Referenced by anySideBarIsVisible().
void MainWindowBase::toggleOverlayOnSideBar | ( | KDDockWidgets::DockWidgetBase * | dw | ) |
Shows or hides an overlay. It's assumed the dock widget is already in a side-bar.
Definition at line 566 of file MainWindowBase.cpp.
References clearSideBarOverlay(), overlayOnSideBar(), and QObject::qobject_cast().
QString MainWindowBase::uniqueName | ( | ) | const |
Returns the unique name that was passed via constructor. Used internally by the save/restore mechanism.
Definition at line 185 of file MainWindowBase.cpp.
|
signal |
Referenced by setUniqueName().
QRect MainWindowBase::windowGeometry | ( | ) | const |
Returns the window geometry This is usually the same as MainWindowBase::geometry() But fixes the following special cases:
Definition at line 768 of file MainWindowBase.cpp.
References QWidget::geometry, QWidget::window(), and QWidget::windowHandle().
|
read |
Definition at line 58 of file MainWindowBase.h.
Referenced by addDockWidgetAsTab(), KDDockWidgets::LayoutSaver::restoreLayout(), and setAffinities().
|
read |
Definition at line 61 of file MainWindowBase.h.
Referenced by addDockWidget(), and addDockWidgetAsTab().
|
read |
Definition at line 60 of file MainWindowBase.h.
|
readwrite |
Definition at line 62 of file MainWindowBase.h.
|
read |
Definition at line 59 of file MainWindowBase.h.
Referenced by MainWindowBase(), and setUniqueName().