mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fixed style issues
This commit is contained in:
parent
835b6d80da
commit
16c57045ed
1 changed files with 29 additions and 25 deletions
|
@ -31,10 +31,10 @@ Split *SplitContainer::draggingSplit = nullptr;
|
||||||
|
|
||||||
SplitContainer::SplitContainer(Notebook *parent)
|
SplitContainer::SplitContainer(Notebook *parent)
|
||||||
: BaseWidget(parent)
|
: BaseWidget(parent)
|
||||||
, tab(nullptr)
|
|
||||||
, dropPreview(this)
|
, dropPreview(this)
|
||||||
, mouseOverPoint(-10000, -10000)
|
|
||||||
, overlay(this)
|
, overlay(this)
|
||||||
|
, mouseOverPoint(-10000, -10000)
|
||||||
|
, tab(nullptr)
|
||||||
{
|
{
|
||||||
this->refreshTabTitle();
|
this->refreshTabTitle();
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void SplitContainer::appendSplit(Split *split)
|
||||||
|
|
||||||
void SplitContainer::insertSplit(Split *split, const Position &position)
|
void SplitContainer::insertSplit(Split *split, const Position &position)
|
||||||
{
|
{
|
||||||
this->insertSplit(split, position.direction, (Node *)position.relativeNode);
|
this->insertSplit(split, position.direction, reinterpret_cast<Node *>(position.relativeNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitContainer::insertSplit(Split *split, Direction direction, Split *relativeTo)
|
void SplitContainer::insertSplit(Split *split, Direction direction, Split *relativeTo)
|
||||||
|
@ -677,7 +677,7 @@ qreal SplitContainer::Node::getSize(bool isVertical)
|
||||||
qreal SplitContainer::Node::getChildrensTotalFlex(bool isVertical)
|
qreal SplitContainer::Node::getChildrensTotalFlex(bool isVertical)
|
||||||
{
|
{
|
||||||
return std::accumulate(
|
return std::accumulate(
|
||||||
this->children.begin(), this->children.end(), (qreal)0,
|
this->children.begin(), this->children.end(), qreal(0),
|
||||||
[=](qreal val, std::unique_ptr<Node> &node) { return val + node->getFlex(isVertical); });
|
[=](qreal val, std::unique_ptr<Node> &node) { return val + node->getFlex(isVertical); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,11 +701,11 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, std::vector<Dro
|
||||||
bool isVertical = this->type == Node::VerticalContainer;
|
bool isVertical = this->type == Node::VerticalContainer;
|
||||||
|
|
||||||
// vars
|
// vars
|
||||||
qreal minSize = 48 * _scale;
|
qreal minSize = qreal(48 * _scale);
|
||||||
|
|
||||||
qreal totalFlex = this->getChildrensTotalFlex(isVertical);
|
qreal totalFlex = this->getChildrensTotalFlex(isVertical);
|
||||||
qreal totalSize = std::accumulate(
|
qreal totalSize = std::accumulate(
|
||||||
this->children.begin(), this->children.end(), (qreal)0,
|
this->children.begin(), this->children.end(), qreal(0),
|
||||||
[=](int val, std::unique_ptr<Node> &node) {
|
[=](int val, std::unique_ptr<Node> &node) {
|
||||||
return val + std::max<qreal>(this->getSize(isVertical) / totalFlex *
|
return val + std::max<qreal>(this->getSize(isVertical) / totalFlex *
|
||||||
node->getFlex(isVertical),
|
node->getFlex(isVertical),
|
||||||
|
@ -717,25 +717,29 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, std::vector<Dro
|
||||||
|
|
||||||
// add spacing if reqested
|
// add spacing if reqested
|
||||||
if (addSpacing) {
|
if (addSpacing) {
|
||||||
qreal offset = std::min<qreal>(this->getSize(!isVertical) * 0.1, _scale * 24);
|
qreal offset =
|
||||||
|
std::min<qreal>(this->getSize(!isVertical) * 0.1, qreal(_scale * 24));
|
||||||
|
|
||||||
// droprect left / above
|
// droprect left / above
|
||||||
dropRects.emplace_back(
|
dropRects.emplace_back(
|
||||||
QRect(this->geometry.left(), this->geometry.top(),
|
QRectF(this->geometry.left(), this->geometry.top(),
|
||||||
isVertical ? offset : this->geometry.width(),
|
isVertical ? offset : this->geometry.width(),
|
||||||
isVertical ? this->geometry.height() : offset),
|
isVertical ? this->geometry.height() : offset)
|
||||||
|
.toRect(),
|
||||||
Position(this, isVertical ? Direction::Left : Direction::Above));
|
Position(this, isVertical ? Direction::Left : Direction::Above));
|
||||||
|
|
||||||
// droprect right / below
|
// droprect right / below
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
dropRects.emplace_back(
|
dropRects.emplace_back(
|
||||||
QRect(this->geometry.right() - offset, this->geometry.top(), offset,
|
QRectF(this->geometry.right() - offset, this->geometry.top(), offset,
|
||||||
this->geometry.height()),
|
this->geometry.height())
|
||||||
|
.toRect(),
|
||||||
Position(this, Direction::Right));
|
Position(this, Direction::Right));
|
||||||
} else {
|
} else {
|
||||||
dropRects.emplace_back(
|
dropRects.emplace_back(
|
||||||
QRect(this->geometry.left(), this->geometry.bottom() - offset,
|
QRectF(this->geometry.left(), this->geometry.bottom() - offset,
|
||||||
this->geometry.width(), offset),
|
this->geometry.width(), offset)
|
||||||
|
.toRect(),
|
||||||
Position(this, Direction::Below));
|
Position(this, Direction::Below));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -774,11 +778,11 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, std::vector<Dro
|
||||||
|
|
||||||
// add resize rect
|
// add resize rect
|
||||||
if (child != this->children.front()) {
|
if (child != this->children.front()) {
|
||||||
QRect r = isVertical ? QRect(this->geometry.left(), child->geometry.top() - 4,
|
QRectF r = isVertical ? QRectF(this->geometry.left(), child->geometry.top() - 4,
|
||||||
this->geometry.width(), 8)
|
this->geometry.width(), 8)
|
||||||
: QRect(child->geometry.left() - 4, this->geometry.top(),
|
: QRectF(child->geometry.left() - 4, this->geometry.top(),
|
||||||
8, this->geometry.height());
|
8, this->geometry.height());
|
||||||
resizeRects.push_back(ResizeRect(r, child.get(), isVertical));
|
resizeRects.push_back(ResizeRect(r.toRect(), child.get(), isVertical));
|
||||||
}
|
}
|
||||||
|
|
||||||
// normalize flex
|
// normalize flex
|
||||||
|
@ -856,7 +860,7 @@ void SplitContainer::DropOverlay::dragMoveEvent(QDragMoveEvent *event)
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitContainer::DropOverlay::dragLeaveEvent(QDragLeaveEvent *event)
|
void SplitContainer::DropOverlay::dragLeaveEvent(QDragLeaveEvent *)
|
||||||
{
|
{
|
||||||
this->mouseOverPoint = QPoint(-10000, -10000);
|
this->mouseOverPoint = QPoint(-10000, -10000);
|
||||||
this->close();
|
this->close();
|
||||||
|
@ -900,19 +904,19 @@ SplitContainer::ResizeHandle::ResizeHandle(SplitContainer *_parent)
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitContainer::ResizeHandle::paintEvent(QPaintEvent *event)
|
void SplitContainer::ResizeHandle::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
|
|
||||||
painter.fillRect(this->rect(), "#999");
|
painter.fillRect(this->rect(), "#999");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitContainer::ResizeHandle::mousePressEvent(QMouseEvent *event)
|
void SplitContainer::ResizeHandle::mousePressEvent(QMouseEvent *)
|
||||||
{
|
{
|
||||||
this->isMouseDown = true;
|
this->isMouseDown = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitContainer::ResizeHandle::mouseReleaseEvent(QMouseEvent *event)
|
void SplitContainer::ResizeHandle::mouseReleaseEvent(QMouseEvent *)
|
||||||
{
|
{
|
||||||
this->isMouseDown = false;
|
this->isMouseDown = false;
|
||||||
}
|
}
|
||||||
|
@ -955,7 +959,7 @@ void SplitContainer::ResizeHandle::mouseMoveEvent(QMouseEvent *event)
|
||||||
this->parent->layout();
|
this->parent->layout();
|
||||||
|
|
||||||
// move handle
|
// move handle
|
||||||
this->move(this->x(), (int)before->geometry.bottom() - 4);
|
this->move(this->x(), int(before->geometry.bottom() - 4));
|
||||||
} else {
|
} else {
|
||||||
qreal totalFlexH = this->node->flexH + before->flexH;
|
qreal totalFlexH = this->node->flexH + before->flexH;
|
||||||
before->flexH =
|
before->flexH =
|
||||||
|
@ -965,7 +969,7 @@ void SplitContainer::ResizeHandle::mouseMoveEvent(QMouseEvent *event)
|
||||||
this->parent->layout();
|
this->parent->layout();
|
||||||
|
|
||||||
// move handle
|
// move handle
|
||||||
this->move((int)before->geometry.right() - 4, this->y());
|
this->move(int(before->geometry.right() - 4), this->y());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue