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:
@@ -3,6 +3,7 @@
|
||||
#include "common/Channel.hpp"
|
||||
#include "common/FlagsEnum.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "common/WindowDescriptors.hpp"
|
||||
#include "pajlada/settings/settinglistener.hpp"
|
||||
#include "widgets/splits/SplitContainer.hpp"
|
||||
|
||||
@@ -25,7 +26,7 @@ public:
|
||||
WindowManager();
|
||||
|
||||
static void encodeChannel(IndirectChannel channel, QJsonObject &obj);
|
||||
static IndirectChannel decodeChannel(const QJsonObject &obj);
|
||||
static IndirectChannel decodeChannel(const SplitDescriptor &descriptor);
|
||||
|
||||
void showSettingsDialog(
|
||||
SettingsDialogPreference preference = SettingsDialogPreference());
|
||||
@@ -90,6 +91,15 @@ public:
|
||||
private:
|
||||
void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj);
|
||||
|
||||
// Load window layout from the window-layout.json file
|
||||
WindowLayout loadWindowLayoutFromFile() const;
|
||||
|
||||
// Apply a window layout for this window manager.
|
||||
void applyWindowLayout(const WindowLayout &layout);
|
||||
|
||||
// Contains the full path to the window layout file, e.g. /home/pajlada/.local/share/Chatterino/Settings/window-layout.json
|
||||
const QString windowLayoutFilePath;
|
||||
|
||||
bool initialized_ = false;
|
||||
|
||||
QPoint emotePopupPos_;
|
||||
|
||||
Reference in New Issue
Block a user