Fixes #309 alt tabbing doesn't hide resize handles

This commit is contained in:
fourtf 2018-05-25 16:11:03 +02:00
parent f654528e28
commit afb5a1e5bf
9 changed files with 39 additions and 9 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

After

Width:  |  Height:  |  Size: 361 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 812 B

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 811 B

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 793 B

After

Width:  |  Height:  |  Size: 361 B

View file

@ -65,14 +65,14 @@ SplitOverlay::SplitOverlay(Split *parent)
up->setFocusPolicy(Qt::NoFocus); up->setFocusPolicy(Qt::NoFocus);
down->setFocusPolicy(Qt::NoFocus); down->setFocusPolicy(Qt::NoFocus);
move->setCursor(Qt::PointingHandCursor); move->setCursor(Qt::SizeAllCursor);
left->setCursor(Qt::PointingHandCursor); left->setCursor(Qt::PointingHandCursor);
right->setCursor(Qt::PointingHandCursor); right->setCursor(Qt::PointingHandCursor);
up->setCursor(Qt::PointingHandCursor); up->setCursor(Qt::PointingHandCursor);
down->setCursor(Qt::PointingHandCursor); down->setCursor(Qt::PointingHandCursor);
this->managedConnect(this->scaleChanged, [=](float _scale) { this->managedConnect(this->scaleChanged, [=](float _scale) {
int a = _scale * 40; int a = int(_scale * 30);
QSize size(a, a); QSize size(a, a);
move->setIconSize(size); move->setIconSize(size);
@ -83,9 +83,11 @@ SplitOverlay::SplitOverlay(Split *parent)
}); });
this->setMouseTracking(true); this->setMouseTracking(true);
this->setCursor(Qt::ArrowCursor);
} }
void SplitOverlay::paintEvent(QPaintEvent *event) void SplitOverlay::paintEvent(QPaintEvent *)
{ {
QPainter painter(this); QPainter painter(this);
painter.fillRect(this->rect(), QColor(0, 0, 0, 150)); painter.fillRect(this->rect(), QColor(0, 0, 0, 150));
@ -95,16 +97,22 @@ void SplitOverlay::paintEvent(QPaintEvent *event)
case SplitLeft: { case SplitLeft: {
rect = QRect(0, 0, this->width() / 2, this->height()); rect = QRect(0, 0, this->width() / 2, this->height());
} break; } break;
case SplitRight: { case SplitRight: {
rect = QRect(this->width() / 2, 0, this->width() / 2, this->height()); rect = QRect(this->width() / 2, 0, this->width() / 2, this->height());
} break; } break;
case SplitUp: { case SplitUp: {
rect = QRect(0, 0, this->width(), this->height() / 2); rect = QRect(0, 0, this->width(), this->height() / 2);
} break; } break;
case SplitDown: { case SplitDown: {
rect = QRect(0, this->height() / 2, this->width(), this->height() / 2); rect = QRect(0, this->height() / 2, this->width(), this->height() / 2);
} break; } break;
default:;
} }
if (!rect.isNull()) { if (!rect.isNull()) {
painter.setPen(getApp()->themes->splits.dropPreviewBorder); painter.setPen(getApp()->themes->splits.dropPreviewBorder);
painter.setBrush(getApp()->themes->splits.dropPreview); painter.setBrush(getApp()->themes->splits.dropPreview);
@ -174,19 +182,22 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched, QEvent *even
this->parent->split->drag(); this->parent->split->drag();
} }
return true; return true;
} else { }
} break;
case QEvent::MouseButtonRelease: {
if (this->hoveredElement != HoveredElement::SplitMove) {
SplitContainer *container = this->parent->split->getContainer(); SplitContainer *container = this->parent->split->getContainer();
if (container != nullptr) { if (container != nullptr) {
auto *_split = new Split(container); auto *_split = new Split(container);
container->insertSplit( auto dir = SplitContainer::Direction(this->hoveredElement +
_split, SplitContainer::Left - SplitLeft);
(SplitContainer::Direction)(this->hoveredElement + SplitContainer::Left - container->insertSplit(_split, dir, this->parent->split);
SplitLeft), this->parent->hide();
this->parent->split);
} }
} }
} break; } break;
default:;
} }
return QObject::eventFilter(watched, event); return QObject::eventFilter(watched, event);
} }

View file

@ -82,6 +82,15 @@ void SplitContainer::setTab(NotebookTab *_tab)
this->refreshTabTitle(); this->refreshTabTitle();
} }
void SplitContainer::hideResizeHandles()
{
this->overlay.hide();
for (std::unique_ptr<ResizeHandle> &handle : this->resizeHandles) {
handle->hide();
}
}
void SplitContainer::appendNewSplit(bool openChannelNameDialog) void SplitContainer::appendNewSplit(bool openChannelNameDialog)
{ {
util::assertInGuiThread(); util::assertInGuiThread();
@ -155,6 +164,7 @@ void SplitContainer::addSplit(Split *split)
this->tab->setHighlightState(state); this->tab->setHighlightState(state);
} }
}); });
split->focused.connect([this, split] { this->setSelected(split); }); split->focused.connect([this, split] { this->setSelected(split); });
this->layout(); this->layout();
@ -197,6 +207,10 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split)
this->refreshTabTitle(); this->refreshTabTitle();
// fourtf: really bad
split->getChannelView().tabHighlightRequested.disconnectAll();
split->focused.disconnectAll();
split->getChannelView().tabHighlightRequested.disconnectAll(); split->getChannelView().tabHighlightRequested.disconnectAll();
return position; return position;

View file

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

View file

@ -164,6 +164,10 @@ bool Window::event(QEvent *event)
split->updateLastReadMessage(); split->updateLastReadMessage();
} }
} }
if (SplitContainer *container = dynamic_cast<SplitContainer *>(page)) {
container->hideResizeHandles();
}
} break; } break;
default:; default:;