updated splitheader

This commit is contained in:
fourtf 2018-05-11 13:55:10 +02:00
parent 27cd953c8c
commit 28fb877020
4 changed files with 20 additions and 27 deletions

View file

@ -197,7 +197,9 @@ SOURCES += \
src/controllers/accounts/accountcontroller.cpp \
src/controllers/accounts/accountmodel.cpp \
src/controllers/accounts/account.cpp \
src/widgets/helper/splitoverlay.cpp
src/widgets/helper/splitoverlay.cpp \
src/widgets/helper/dropoverlay.cpp \
src/widgets/helper/splitnode.cpp
HEADERS += \
src/precompiled_header.hpp \
@ -343,7 +345,9 @@ HEADERS += \
src/controllers/accounts/accountmodel.hpp \
src/controllers/accounts/account.hpp \
src/util/sharedptrelementless.hpp \
src/widgets/helper/splitoverlay.hpp
src/widgets/helper/splitoverlay.hpp \
src/widgets/helper/dropoverlay.hpp \
src/widgets/helper/splitnode.hpp
RESOURCES += \
resources/resources.qrc

View file

@ -241,13 +241,13 @@ void SplitHeader::mouseMoveEvent(QMouseEvent *event)
tooltipWidget->show();
}
// if (this->dragging) {
// if (std::abs(this->dragStart.x() - event->pos().x()) > 12 ||
// std::abs(this->dragStart.y() - event->pos().y()) > 12) {
// this->split->drag();
// this->dragging = false;
// }
// }
if (this->dragging) {
if (std::abs(this->dragStart.x() - event->pos().x()) > 12 ||
std::abs(this->dragStart.y() - event->pos().y()) > 12) {
this->split->drag();
this->dragging = false;
}
}
}
void SplitHeader::leaveEvent(QEvent *event)

View file

@ -112,9 +112,9 @@ void SplitOverlay::paintEvent(QPaintEvent *event)
void SplitOverlay::resizeEvent(QResizeEvent *event)
{
float scale = this->getScale();
bool wideEnough = event->size().width() > 150 * scale;
bool highEnough = event->size().height() > 150 * scale;
float _scale = this->getScale();
bool wideEnough = event->size().width() > 150 * _scale;
bool highEnough = event->size().height() > 150 * _scale;
this->_left->setVisible(wideEnough);
this->_right->setVisible(wideEnough);

View file

@ -189,22 +189,11 @@ public:
{
auto &siblings = this->parent->children;
qreal size =
// std::accumulate(this->parent->children.begin(),
// this->parent->children.end(), 0,
// [_direction](qreal val, Node *node) {
// if (toContainerType(_direction) ==
// Type::VerticalContainer) {
// return val + node->geometry.height();
// } else {
// return val + node->geometry.width();
// }
// });
this->parent->geometry.width() / siblings.size();
qreal width = this->parent->geometry.width() / siblings.size();
qreal height = this->parent->geometry.height() / siblings.size();
if (siblings.size() == 1) {
this->geometry = QRect(0, 0, size, size);
this->geometry = QRect(0, 0, width, height);
}
auto it = std::find_if(siblings.begin(), siblings.end(),
@ -216,7 +205,7 @@ public:
}
Node *node = new Node(_split, this->parent);
node->geometry = QRectF(0, 0, size, size);
node->geometry = QRectF(0, 0, width, height);
siblings.insert(it, std::unique_ptr<Node>(node));
}