File tree 3 files changed +24
-4
lines changed
3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -258,14 +258,15 @@ bool LayoutSaver::restoreLayout(const QByteArray &data)
258
258
}
259
259
260
260
// 2. Restore FloatingWindows
261
- for (const LayoutSaver::FloatingWindow &fw : qAsConst ( layout.floatingWindows ) ) {
261
+ for (LayoutSaver::FloatingWindow &fw : layout.floatingWindows ) {
262
262
if (!d->matchesAffinity (fw.affinities ))
263
263
continue ;
264
264
265
265
MainWindowBase *parent = fw.parentIndex == -1 ? nullptr
266
266
: DockRegistry::self ()->mainwindows ().at (fw.parentIndex );
267
267
268
268
auto floatingWindow = Config::self ().frameworkWidgetFactory ()->createFloatingWindow (parent);
269
+ fw.floatingWindowInstance = floatingWindow;
269
270
d->deserializeWindowGeometry (fw, floatingWindow);
270
271
if (!floatingWindow->deserialize (fw)) {
271
272
qWarning () << Q_FUNC_INFO << " Failed to deserialize floating window" ;
@@ -471,6 +472,19 @@ LayoutSaver::MainWindow LayoutSaver::Layout::mainWindowForIndex(int index) const
471
472
return mainWindows.at (index );
472
473
}
473
474
475
+ LayoutSaver::FloatingWindow LayoutSaver::Layout::floatingWindowForIndex (int index) const
476
+ {
477
+ if (index < 0 || index >= floatingWindows.size ())
478
+ return {};
479
+
480
+ return floatingWindows.at (index );
481
+ }
482
+
483
+ FloatingWindow *LayoutSaver::Layout::floatingWindowInstanceForIndex (int index) const
484
+ {
485
+ return floatingWindowForIndex (index ).floatingWindowInstance ;
486
+ }
487
+
474
488
QStringList LayoutSaver::Layout::mainWindowNames () const
475
489
{
476
490
QStringList names;
Original file line number Diff line number Diff line change 36
36
37
37
namespace KDDockWidgets {
38
38
39
+ class FloatingWindow ;
40
+
39
41
template <typename T>
40
42
typename T::List fromVariantList (const QVariantList &listV)
41
43
{
@@ -233,6 +235,9 @@ struct LayoutSaver::FloatingWindow
233
235
int screenIndex;
234
236
QSize screenSize; // for relative-size restoring
235
237
bool isVisible = true ;
238
+
239
+ // The instance that was created during a restore:
240
+ KDDockWidgets::FloatingWindow *floatingWindowInstance = nullptr ;
236
241
};
237
242
238
243
struct LayoutSaver ::MainWindow
@@ -313,6 +318,8 @@ struct LayoutSaver::Layout
313
318
static LayoutSaver::Layout* s_currentLayoutBeingRestored;
314
319
315
320
LayoutSaver::MainWindow mainWindowForIndex (int index) const ;
321
+ LayoutSaver::FloatingWindow floatingWindowForIndex (int index) const ;
322
+ KDDockWidgets::FloatingWindow* floatingWindowInstanceForIndex (int index) const ;
316
323
317
324
QStringList mainWindowNames () const ;
318
325
QStringList dockWidgetNames () const ;
Original file line number Diff line number Diff line change @@ -126,9 +126,8 @@ void Position::deserialize(const LayoutSaver::Position &lp)
126
126
if (index == -1 ) {
127
127
continue ; // Skip
128
128
} else {
129
- const auto floatingWindows = DockRegistry::self ()->floatingWindows ();
130
- if (index >= 0 && index < floatingWindows.size ()) {
131
- FloatingWindow *fw = floatingWindows.at (index );
129
+ FloatingWindow *fw = LayoutSaver::Layout::s_currentLayoutBeingRestored->floatingWindowInstanceForIndex (index );
130
+ if (fw) {
132
131
layout = fw->multiSplitter ();
133
132
} else {
134
133
qWarning () << " Invalid floating window position to restore" << index ;
You can’t perform that action at this time.
0 commit comments