SplitContainer refactor (#4261)
* Remove unused include util/Helpers.hpp * SplitContainer::setTag fix parameter naming * autofy/constify where possible * More const auto ptr magicifying * Make SplitNode::Type an enum class * Move QuickSwitcherPopup includes from header to source file * Remove unused DropRegion code * use empty() instead of size() == 0 * Add curly braces everywhere * Remove useless reinterpret_cast It was casting Node* to Node* * Clarify that the connect is QObject::connect * SplitContainer::setSelected fix parameter naming * Rename function variables to remove unneccesary underscore Also move addSpacing parameter out of the layout function * emplace_back where possible * Name parameters * Remove ineffective const from return type * Make node getters const * Flatten Node::releaseSplit * Rename in-function variable to match code style * [ACTUAL CODE CHANGE/MOVE] Move clamp logic to its own function * name params * applyFromDescriptorRecursively: rename node param to baseNode * [ACTUAL CODE CHANGE/MOVE] Remove the many overloads for append/insertSplit This utilizes the C++20 designed initializers aggregate initialization feature * Remove unused includes * [ACTUAL CODE CHANGE] Clean up dragging logic There's no need to keep a pointer around to which split is being dragged, it's already stored in the QDropEvent source() * UNRELATED .clang-tidy: Only suggest UPPER_CASE for constant global variables * Remove unused SplitContainer::getSplitCount function * Use std::max in Node's clamp function * Remove test code * DraggedSplit.hpp: remove unused include * Split `setDraggingSplit` into two functions, `startDraggingSplit` and `stopDraggingSplit`
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#include "widgets/helper/NotebookButton.hpp"
|
||||
|
||||
#include "common/QLogging.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "widgets/helper/Button.hpp"
|
||||
#include "widgets/Notebook.hpp"
|
||||
#include "widgets/splits/DraggedSplit.hpp"
|
||||
#include "widgets/splits/Split.hpp"
|
||||
#include "widgets/splits/SplitContainer.hpp"
|
||||
|
||||
@@ -67,7 +69,7 @@ void NotebookButton::paintEvent(QPaintEvent *event)
|
||||
case Plus: {
|
||||
painter.setPen([&] {
|
||||
QColor tmp = foreground;
|
||||
if (SplitContainer::isDraggingSplit)
|
||||
if (isDraggingSplit())
|
||||
{
|
||||
tmp = this->theme->tabs.selected.line.regular;
|
||||
}
|
||||
@@ -181,22 +183,30 @@ void NotebookButton::dragLeaveEvent(QDragLeaveEvent *)
|
||||
|
||||
void NotebookButton::dropEvent(QDropEvent *event)
|
||||
{
|
||||
if (SplitContainer::isDraggingSplit)
|
||||
auto *draggedSplit = dynamic_cast<Split *>(event->source());
|
||||
if (!draggedSplit)
|
||||
{
|
||||
event->acceptProposedAction();
|
||||
|
||||
Notebook *notebook = dynamic_cast<Notebook *>(this->parentWidget());
|
||||
|
||||
if (notebook != nuuls)
|
||||
{
|
||||
SplitContainer *page = new SplitContainer(notebook);
|
||||
auto *tab = notebook->addPage(page);
|
||||
page->setTab(tab);
|
||||
|
||||
SplitContainer::draggingSplit->setParent(page);
|
||||
page->appendSplit(SplitContainer::draggingSplit);
|
||||
}
|
||||
qCDebug(chatterinoWidget)
|
||||
<< "Dropped something that wasn't a split onto a notebook button";
|
||||
return;
|
||||
}
|
||||
|
||||
auto *notebook = dynamic_cast<Notebook *>(this->parentWidget());
|
||||
if (!notebook)
|
||||
{
|
||||
qCDebug(chatterinoWidget) << "Dropped a split onto a notebook button "
|
||||
"without a parent notebook";
|
||||
return;
|
||||
}
|
||||
|
||||
event->acceptProposedAction();
|
||||
|
||||
auto *page = new SplitContainer(notebook);
|
||||
auto *tab = notebook->addPage(page);
|
||||
page->setTab(tab);
|
||||
|
||||
draggedSplit->setParent(page);
|
||||
page->insertSplit(draggedSplit);
|
||||
}
|
||||
|
||||
void NotebookButton::hideEvent(QHideEvent *)
|
||||
|
||||
Reference in New Issue
Block a user