Skip to content

Commit

Permalink
fix size of splits not loading properly (#2554)
Browse files Browse the repository at this point in the history
  • Loading branch information
fourtf authored Apr 17, 2021
1 parent ed7d1a8 commit 58017a7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Major: Added custom FrankerFaceZ VIP Badges. (#2628)
- Minor: Added `in:<channels>` search filter to find messages sent in specific channels. (#2299, #2634)
- Minor: Allow for built-in Chatterino commands to be used in custom commands. (#2632)
- Bugfix: Size of splits not saved properly (#2362, #2548)
- Bugfix: Fix crash that could occur when the user changed the "Custom stream player URI Scheme" setting if the user had closed down and splits in the application runtime. (#2592)

## 2.3.0
Expand Down
6 changes: 3 additions & 3 deletions src/singletons/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,6 @@ void WindowManager::encodeNodeRecursively(SplitNode *node, QJsonObject &obj)
QJsonArray filters;
encodeFilters(node->getSplit(), filters);
obj.insert("filters", filters);

obj.insert("flexh", node->getHorizontalFlex());
obj.insert("flexv", node->getVerticalFlex());
}
break;
case SplitNode::HorizontalContainer:
Expand All @@ -524,6 +521,9 @@ void WindowManager::encodeNodeRecursively(SplitNode *node, QJsonObject &obj)
}
break;
}

obj.insert("flexh", node->getHorizontalFlex());
obj.insert("flexv", node->getVerticalFlex());
}

void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
Expand Down
15 changes: 15 additions & 0 deletions src/widgets/splits/SplitContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,11 @@ Split *SplitContainer::getTopRightSplit(Node &node)

void SplitContainer::layout()
{
if (this->disableLayouting_)
{
return;
}

// update top right split
auto topRight = this->getTopRightSplit(this->baseNode_);
if (this->topRight_)
Expand Down Expand Up @@ -702,7 +707,10 @@ void SplitContainer::applyFromDescriptor(const NodeDescriptor &rootNode)
{
assert(this->baseNode_.type_ == Node::EmptyRoot);

this->disableLayouting_ = true;
this->applyFromDescriptorRecursively(rootNode, &this->baseNode_);
this->disableLayouting_ = false;
this->layout();
}

void SplitContainer::applyFromDescriptorRecursively(
Expand Down Expand Up @@ -769,6 +777,13 @@ void SplitContainer::applyFromDescriptorRecursively(
{
Node *_node = new Node();
_node->parent_ = node;

if (auto *n = std::get_if<ContainerNodeDescriptor>(&item))
{
_node->flexH_ = n->flexH_;
_node->flexV_ = n->flexV_;
}

node->children_.emplace_back(_node);
this->applyFromDescriptorRecursively(item, _node);
}
Expand Down
1 change: 1 addition & 0 deletions src/widgets/splits/SplitContainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ class SplitContainer final : public BaseWidget, pajlada::Signals::SignalHolder
Node baseNode_;
Split *selected_{};
Split *topRight_{};
bool disableLayouting_{};

NotebookTab *tab_;
std::vector<Split *> splits_;
Expand Down

0 comments on commit 58017a7

Please sign in to comment.