fixed the add button not wrapping the notebook

This commit is contained in:
fourtf 2018-06-01 14:46:41 +02:00
parent 3a78068810
commit bba82ac912
6 changed files with 39 additions and 16 deletions

View file

@ -45,12 +45,20 @@ void NotebookButton::paintEvent(QPaintEvent *)
float h = height(), w = width();
if (icon == IconPlus) {
painter.fillRect(
QRectF((h / 12) * 2 + 1, (h / 12) * 5 + 1, w - ((h / 12) * 5), (h / 12) * 1),
foreground);
painter.fillRect(
QRectF((h / 12) * 5 + 1, (h / 12) * 2 + 1, (h / 12) * 1, w - ((h / 12) * 5)),
foreground);
painter.setPen([&] {
QColor tmp = foreground;
if (!this->mouseOver) {
tmp.setAlpha(180);
}
return tmp;
}());
QRect rect = this->rect();
int s = h * 4 / 9;
painter.drawLine(rect.left() + rect.width() / 2 - (s / 2), rect.top() + rect.height() / 2,
rect.left() + rect.width() / 2 + (s / 2), rect.top() + rect.height() / 2);
painter.drawLine(rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 - (s / 2),
rect.left() + rect.width() / 2, rect.top() + rect.height() / 2 + (s / 2));
} else if (icon == IconUser) {
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);

View file

@ -90,7 +90,7 @@ void Notebook::removePage(QWidget *page)
}
}
this->performLayout();
this->performLayout(true);
}
void Notebook::removeCurrentPage()
@ -262,7 +262,7 @@ void Notebook::rearrangePage(QWidget *page, int index)
{
this->items.move(this->indexOf(page), index);
this->performLayout();
this->performLayout(true);
}
bool Notebook::getAllowUserTabManagement() const
@ -307,7 +307,7 @@ void Notebook::performLayout(bool animated)
{
auto app = getApp();
int xStart = (int)(2 * this->getScale());
int xStart = int(2 * this->getScale());
int x = xStart, y = 0;
float scale = this->getScale();
@ -349,12 +349,12 @@ void Notebook::performLayout(bool animated)
for (auto i = this->items.begin(); i != this->items.end(); i++) {
// int yOffset = i->tab->isSelected() ? 0 : 1;
if (!first &&
(i == this->items.end() && this->showAddButton ? tabHeight : 0) + x + i->tab->width() >
width()) //
{
bool wrap =
!first && (((i + 1 == this->items.end() && this->showAddButton) ? tabHeight : 0) + x +
i->tab->width()) > width();
if (wrap) {
y += i->tab->height();
// y += 20;
i->tab->moveAnimated(QPoint(xStart, y), animated);
x = i->tab->width() + xStart;
} else {
@ -376,7 +376,7 @@ void Notebook::performLayout(bool animated)
this->update();
}
y += (int)(3 * scale);
y += int(3 * scale);
for (auto &i : this->items) {
i.tab->raise();

View file

@ -45,7 +45,7 @@ public:
bool getShowAddButton() const;
void setShowAddButton(bool value);
void performLayout(bool animate = true);
void performLayout(bool animate = false);
protected:
virtual void scaleChangedEvent(float scale) override;

View file

@ -311,6 +311,10 @@ void Split::enterEvent(QEvent *event)
if (modifierStatus == showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/) {
this->overlay->show();
}
if (this->container != nullptr) {
this->container->resetMouseStatus();
}
}
void Split::leaveEvent(QEvent *event)

View file

@ -97,6 +97,12 @@ void SplitContainer::hideResizeHandles()
}
}
void SplitContainer::resetMouseStatus()
{
this->mouseOverPoint = QPoint(-10000, -10000);
this->update();
}
void SplitContainer::appendNewSplit(bool openChannelNameDialog)
{
util::assertInGuiThread();
@ -468,6 +474,10 @@ void SplitContainer::dragEnterEvent(QDragEnterEvent *event)
void SplitContainer::mouseMoveEvent(QMouseEvent *event)
{
if (Split::modifierStatus == showSplitOverlayModifiers) {
this->setCursor(Qt::PointingHandCursor);
}
this->mouseOverPoint = event->pos();
this->update();
}

View file

@ -188,6 +188,7 @@ public:
void setTab(NotebookTab *tab);
void hideResizeHandles();
void resetMouseStatus();
static bool isDraggingSplit;
static Split *draggingSplit;