KDDockWidgets API Documentation 2.1
|
LayoutSaver allows to save or restore layouts. More...
#include <LayoutSaver.h>
Public Member Functions | |
LayoutSaver (RestoreOptions options=RestoreOption_None) | |
Constructor. Construction on the stack is suggested. | |
~LayoutSaver () | |
Destructor. | |
Private * | dptr () const |
Vector< Core::DockWidget * > | restoredDockWidgets () const |
returns a list of dock widgets which were restored since the last restoreLayout() or restoreFromFile() | |
bool | restoreFromFile (const QString &jsonFilename) |
restores the layout from a JSON file | |
bool | restoreLayout (const QByteArray &) |
restores the layout from a byte array All MainWindows and DockWidgets should have been created before calling this function. | |
bool | saveToFile (const QString &jsonFilename) |
saves the layout to JSON file | |
QByteArray | serializeLayout () const |
saves the layout into a byte array | |
void | setAffinityNames (const Vector< QString > &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 Vector< QString > | openedDockWidgetsInLayout (const QByteArray &serialized) |
static Vector< QString > | openedDockWidgetsInLayout (const QString &jsonFilename) |
Returns the list of opened dock widgets in the specified layout. | |
static bool | restoreInProgress () |
returns whether a restore (restoreLayout) is in progress | |
static Vector< QString > | sideBarDockWidgetsInLayout (const QByteArray &serialized) |
static Vector< QString > | sideBarDockWidgetsInLayout (const QString &jsonFilename) |
LayoutSaver allows to save or restore layouts.
You can save a layout to a file or to a byte array. JSON is used as the serialized format.
Example: LayoutSaver saver;
// Save to a file: saver.saveToFile(filename);
The counterpart of saveToFile() is restoreFromFile().
You can also save to a QByteArray instead, with serializeLayout(). The counterpart of serializeLayout() is restoreLayout();
Definition at line 55 of file LayoutSaver.h.
|
explicit |
Constructor. Construction on the stack is suggested.
Definition at line 374 of file LayoutSaver.cpp.
LayoutSaver::~LayoutSaver | ( | ) |
Destructor.
Definition at line 380 of file LayoutSaver.cpp.
LayoutSaver::Private * LayoutSaver::dptr | ( | ) | const |
Definition at line 605 of file LayoutSaver.cpp.
Referenced by KDDockWidgets::LayoutSaverInstantiator::affinities().
|
static |
Definition at line 780 of file LayoutSaver.cpp.
References KDToolBox::StlContainerAdaptor::StdVectorAdaptor< T, Args >::reserve().
Returns the list of opened dock widgets in the specified layout.
This operation does not have side-effects, no dock widget will be actually restored.
Definition at line 769 of file LayoutSaver.cpp.
References KDDockWidgets::Core::Platform::instance(), openedDockWidgetsInLayout(), and KDDockWidgets::Core::Platform::readFile().
Referenced by openedDockWidgetsInLayout().
Core::DockWidget::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.
Definition at line 610 of file LayoutSaver.cpp.
References KDDockWidgets::DockRegistry::dockwidgets(), KDToolBox::StlContainerAdaptor::StdVectorAdaptor< T, Args >::reserve(), KDDockWidgets::DockRegistry::self(), and KDToolBox::StlContainerAdaptor::StdVectorAdaptor< T, Args >::size().
bool LayoutSaver::restoreFromFile | ( | const QString & | jsonFilename | ) |
restores the layout from a JSON file
jsonFilename | the filename containing a saved layout |
Definition at line 401 of file LayoutSaver.cpp.
References KDDockWidgets::Core::Platform::instance(), KDDockWidgets::Core::Platform::readFile(), and restoreLayout().
Referenced by KDDockWidgets::Debug::DebugWindow::DebugWindow(), c_KDDockWidgets__LayoutSaver__restoreFromFile_QString(), lint(), and KDDockWidgets::LayoutSaverInstantiator::restoreFromFile().
|
static |
returns whether a restore (restoreLayout) is in progress
Definition at line 739 of file LayoutSaver.cpp.
Referenced by KDDockWidgets::Core::Layout::setLayoutSize().
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()
Definition at line 463 of file LayoutSaver.cpp.
References KDDockWidgets::DockRegistry::ConsultRemapping, KDDockWidgets::Core::DockWidget::deserialize(), QByteArray::isEmpty(), KDDockWidgets::Config::mainWindowFactoryFunc(), KDDockWidgets::DockRegistry::mainwindows(), KDDockWidgets::Maximized, KDDockWidgets::Minimized, KDDockWidgets::None, KDDockWidgets::Config::self(), KDDockWidgets::DockRegistry::self(), and KDDockWidgets::StartsMinimized.
Referenced by restoreFromFile().
bool LayoutSaver::saveToFile | ( | const QString & | jsonFilename | ) |
saves the layout to JSON file
jsonFilename | the filename where the layout will be saved to |
Definition at line 386 of file LayoutSaver.cpp.
References QByteArray::constData(), serializeLayout(), QByteArray::size(), and QString::toStdString().
Referenced by KDDockWidgets::Debug::DebugWindow::DebugWindow(), c_KDDockWidgets__LayoutSaver__saveToFile_QString(), and KDDockWidgets::LayoutSaverInstantiator::saveToFile().
QByteArray LayoutSaver::serializeLayout | ( | ) | const |
saves the layout into a byte array
Definition at line 412 of file LayoutSaver.cpp.
References KDToolBox::StlContainerAdaptor::StdVectorAdaptor< T, Args >::size().
Referenced by main(), and saveToFile().
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
.
Definition at line 596 of file LayoutSaver.cpp.
References KDToolBox::StlContainerAdaptor::StdVectorAdaptor< T, Args >::contains().
Referenced by KDDockWidgets::LayoutSaverInstantiator::setAffinities().
|
static |
Definition at line 813 of file LayoutSaver.cpp.
References KDToolBox::StlContainerAdaptor::StdVectorAdaptor< T, Args >::reserve().
Definition at line 802 of file LayoutSaver.cpp.
References KDDockWidgets::Core::Platform::instance(), KDDockWidgets::Core::Platform::readFile(), and sideBarDockWidgetsInLayout().
Referenced by sideBarDockWidgetsInLayout().