KDDockWidgets API Documentation
1.5
|
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. More... | |
~LayoutSaver () | |
Destructor. More... | |
Private * | dptr () const |
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 More... | |
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 . More... | |
Static Public Member Functions | |
static bool | restoreInProgress () |
returns whether a restore (restoreLayout) is in progress More... | |
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 54 of file LayoutSaver.h.
|
explicit |
Constructor. Construction on the stack is suggested.
Definition at line 99 of file LayoutSaver.cpp.
LayoutSaver::~LayoutSaver | ( | ) |
Destructor.
Definition at line 104 of file LayoutSaver.cpp.
LayoutSaver::Private * LayoutSaver::dptr | ( | ) | const |
Definition at line 310 of file LayoutSaver.cpp.
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.
Definition at line 315 of file LayoutSaver.cpp.
References QVector::push_back(), QVector::reserve(), and QVector::size().
bool LayoutSaver::restoreFromFile | ( | const QString & | jsonFilename | ) |
restores the layout from a JSON file
jsonFilename | the filename containing a saved layout |
Definition at line 123 of file LayoutSaver.cpp.
References QIODevice::errorString(), QFile::open(), QIODevice::readAll(), QIODevice::ReadOnly, and restoreLayout().
Referenced by lint().
|
static |
returns whether a restore (restoreLayout) is in progress
Definition at line 419 of file LayoutSaver.cpp.
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 187 of file LayoutSaver.cpp.
References KDDockWidgets::MainWindowBase::affinities, KDDockWidgets::FrameworkWidgetFactory::createFloatingWindow(), KDDockWidgets::Config::frameworkWidgetFactory(), QByteArray::isEmpty(), KDDockWidgets::Config::self(), QWidget::window(), QWidget::windowHandle(), and Qt::WindowNoState.
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 109 of file LayoutSaver.cpp.
References QIODevice::errorString(), QFile::open(), serializeLayout(), QIODevice::write(), and QIODevice::WriteOnly.
QByteArray LayoutSaver::serializeLayout | ( | ) | const |
saves the layout into a byte array
Definition at line 137 of file LayoutSaver.cpp.
References QVector::size().
Referenced by saveToFile().
void LayoutSaver::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
.
Definition at line 301 of file LayoutSaver.cpp.
References QStringList::contains().