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
+14 -6
View File
@@ -45,12 +45,20 @@ void NotebookButton::paintEvent(QPaintEvent *)
float h = height(), w = width(); float h = height(), w = width();
if (icon == IconPlus) { if (icon == IconPlus) {
painter.fillRect( painter.setPen([&] {
QRectF((h / 12) * 2 + 1, (h / 12) * 5 + 1, w - ((h / 12) * 5), (h / 12) * 1), QColor tmp = foreground;
foreground); if (!this->mouseOver) {
painter.fillRect( tmp.setAlpha(180);
QRectF((h / 12) * 5 + 1, (h / 12) * 2 + 1, (h / 12) * 1, w - ((h / 12) * 5)), }
foreground); 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) { } else if (icon == IconUser) {
painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing);
+9 -9
View File
@@ -90,7 +90,7 @@ void Notebook::removePage(QWidget *page)
} }
} }
this->performLayout(); this->performLayout(true);
} }
void Notebook::removeCurrentPage() void Notebook::removeCurrentPage()
@@ -262,7 +262,7 @@ void Notebook::rearrangePage(QWidget *page, int index)
{ {
this->items.move(this->indexOf(page), index); this->items.move(this->indexOf(page), index);
this->performLayout(); this->performLayout(true);
} }
bool Notebook::getAllowUserTabManagement() const bool Notebook::getAllowUserTabManagement() const
@@ -307,7 +307,7 @@ void Notebook::performLayout(bool animated)
{ {
auto app = getApp(); auto app = getApp();
int xStart = (int)(2 * this->getScale()); int xStart = int(2 * this->getScale());
int x = xStart, y = 0; int x = xStart, y = 0;
float scale = this->getScale(); float scale = this->getScale();
@@ -349,12 +349,12 @@ void Notebook::performLayout(bool animated)
for (auto i = this->items.begin(); i != this->items.end(); i++) { for (auto i = this->items.begin(); i != this->items.end(); i++) {
// int yOffset = i->tab->isSelected() ? 0 : 1; // int yOffset = i->tab->isSelected() ? 0 : 1;
if (!first && bool wrap =
(i == this->items.end() && this->showAddButton ? tabHeight : 0) + x + i->tab->width() > !first && (((i + 1 == this->items.end() && this->showAddButton) ? tabHeight : 0) + x +
width()) // i->tab->width()) > width();
{
if (wrap) {
y += i->tab->height(); y += i->tab->height();
// y += 20;
i->tab->moveAnimated(QPoint(xStart, y), animated); i->tab->moveAnimated(QPoint(xStart, y), animated);
x = i->tab->width() + xStart; x = i->tab->width() + xStart;
} else { } else {
@@ -376,7 +376,7 @@ void Notebook::performLayout(bool animated)
this->update(); this->update();
} }
y += (int)(3 * scale); y += int(3 * scale);
for (auto &i : this->items) { for (auto &i : this->items) {
i.tab->raise(); i.tab->raise();
+1 -1
View File
@@ -45,7 +45,7 @@ public:
bool getShowAddButton() const; bool getShowAddButton() const;
void setShowAddButton(bool value); void setShowAddButton(bool value);
void performLayout(bool animate = true); void performLayout(bool animate = false);
protected: protected:
virtual void scaleChangedEvent(float scale) override; virtual void scaleChangedEvent(float scale) override;
+4
View File
@@ -311,6 +311,10 @@ void Split::enterEvent(QEvent *event)
if (modifierStatus == showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/) { if (modifierStatus == showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/) {
this->overlay->show(); this->overlay->show();
} }
if (this->container != nullptr) {
this->container->resetMouseStatus();
}
} }
void Split::leaveEvent(QEvent *event) void Split::leaveEvent(QEvent *event)
+10
View File
@@ -97,6 +97,12 @@ void SplitContainer::hideResizeHandles()
} }
} }
void SplitContainer::resetMouseStatus()
{
this->mouseOverPoint = QPoint(-10000, -10000);
this->update();
}
void SplitContainer::appendNewSplit(bool openChannelNameDialog) void SplitContainer::appendNewSplit(bool openChannelNameDialog)
{ {
util::assertInGuiThread(); util::assertInGuiThread();
@@ -468,6 +474,10 @@ void SplitContainer::dragEnterEvent(QDragEnterEvent *event)
void SplitContainer::mouseMoveEvent(QMouseEvent *event) void SplitContainer::mouseMoveEvent(QMouseEvent *event)
{ {
if (Split::modifierStatus == showSplitOverlayModifiers) {
this->setCursor(Qt::PointingHandCursor);
}
this->mouseOverPoint = event->pos(); this->mouseOverPoint = event->pos();
this->update(); this->update();
} }
+1
View File
@@ -188,6 +188,7 @@ public:
void setTab(NotebookTab *tab); void setTab(NotebookTab *tab);
void hideResizeHandles(); void hideResizeHandles();
void resetMouseStatus();
static bool isDraggingSplit; static bool isDraggingSplit;
static Split *draggingSplit; static Split *draggingSplit;