Split up Window Layout loading into a loading and application stage (#1964)

* Split up Window Layout loading into a loading and application stage

Previously, we were creating UI elements at while we were reading the window-layout.json file.
We now read the window-layout.json file fully first, which results in a
WindowLayout struct which is built up of a list of windows with a list
of tabs with a root node which contains containers and splits.
This WindowLayout can then be applied.

This will enable PRs like #1940 to start Chatterino with Window Layouts
that aren't defined in a json file.

This commit has deprecated loading of v1 window layouts (we're now on v2). If a v1 window layout is there, it will just be ignored and Chatterino will boot up as if it did not have a window layout at all, and on save that old window layout will be gone.

* Fix compile error for mac
This commit is contained in:
pajlada
2020-09-19 11:14:10 -04:00
committed by GitHub
parent 7eabba959b
commit 913193f8b5
8 changed files with 484 additions and 191 deletions
+6 -3
View File
@@ -1,5 +1,6 @@
#pragma once
#include "common/WindowDescriptors.hpp"
#include "widgets/BaseWidget.hpp"
#include <QDragEnterEvent>
@@ -184,8 +185,6 @@ public:
void selectNextSplit(Direction direction);
void setSelected(Split *selected_);
void decodeFromJson(QJsonObject &obj);
int getSplitCount();
const std::vector<Split *> getSplits() const;
@@ -201,6 +200,8 @@ public:
static bool isDraggingSplit;
static Split *draggingSplit;
void applyFromDescriptor(const NodeDescriptor &rootNode);
protected:
void paintEvent(QPaintEvent *event) override;
@@ -214,6 +215,9 @@ protected:
void resizeEvent(QResizeEvent *event) override;
private:
void applyFromDescriptorRecursively(const NodeDescriptor &rootNode,
Node *node);
void layout();
void selectSplitRecursive(Node *node, Direction direction);
void focusSplitRecursive(Node *node);
@@ -221,7 +225,6 @@ private:
void addSplit(Split *split);
void decodeNodeRecusively(QJsonObject &obj, Node *node);
Split *getTopRightSplit(Node &node);
void refreshTabTitle();