KDDockWidgets API Documentation  1.0.1
Classes | Public Member Functions | Static Public Member Functions | List of all members
KDDockWidgets::LayoutSaver Class Reference

Classes

struct  DockWidget
 
struct  FloatingWindow
 
struct  Frame
 
struct  Layout
 
struct  MainWindow
 
struct  MultiSplitter
 
struct  Placeholder
 
struct  Position
 
struct  ScalingInfo
 contains info about how a main window is scaled. Used for RestoreOption_RelativeToMainWindow More...
 
struct  ScreenInfo
 we serialize some info about screens, so eventually we can make restore smarter when switching screens Not used currently, but nice to have in the json already More...
 

Public Member Functions

 LayoutSaver (RestoreOptions options=RestoreOption_None)
 Constructor. Construction on the stack is suggested.
 
 ~LayoutSaver ()
 Destructor.
 
QVector< DockWidgetBase * > restoredDockWidgets () const
 returns a list of dock widgets which were restored since the last restoreLayout() or restoreFromFile() More...
 
bool restoreFromFile (const QString &jsonFilename)
 restores the layout from a JSON file More...
 
bool restoreLayout (const QByteArray &)
 restores the layout from a byte array All MainWindows and DockWidgets should have been created before calling this function. More...
 
bool saveToFile (const QString &jsonFilename)
 saves the layout to JSON file More...
 
QByteArray serializeLayout () const
 saves the layout into a byte array
 
void setAffinityNames (const QStringList &affinityNames)
 Sets the list of affinity names for which restore and save will be applied on. Allows to save/restore only a subset of the windows. Empty by default, all windows are subject to save/restore. Any window with empty affinity will also be subject to save/restore, regardless of affinityNames.
 

Static Public Member Functions

static bool restoreInProgress ()
 returns whether a restore (restoreLayout) is in progress
 

Member Function Documentation

DockWidgetBase::List LayoutSaver::restoredDockWidgets ( ) const

returns a list of dock widgets which were restored since the last restoreLayout() or restoreFromFile()

Useful since some dock widgets can be new, and hence not be included in the last saved layout.

bool LayoutSaver::restoreFromFile ( const QString jsonFilename)

restores the layout from a JSON file

Parameters
jsonFilenamethe filename containing a saved layout
Returns
true on success
bool LayoutSaver::restoreLayout ( const QByteArray data)

restores the layout from a byte array All MainWindows and DockWidgets should have been created before calling this function.

If not all DockWidgets can be created beforehand then make sure to set a DockWidget factory via Config::setDockWidgetFactoryFunc()

See also
Config::setDockWidgetFactoryFunc()
Returns
true on success
bool LayoutSaver::saveToFile ( const QString jsonFilename)

saves the layout to JSON file

Parameters
jsonFilenamethe filename where the layout will be saved to
Returns
true on success

Klarälvdalens Datakonsult AB (KDAB)
"The Qt Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/