2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-10-23 15:06:09 +00:00

Export panel minimizes to a top bar, like a Call.

This commit is contained in:
John Preston
2018-06-20 01:02:36 +01:00
parent eaf3ea9289
commit 329db0d8e9
22 changed files with 437 additions and 127 deletions

View File

@@ -37,6 +37,8 @@ SeparatePanel::SeparatePanel()
void SeparatePanel::setTitle(rpl::producer<QString> title) {
_title.create(this, std::move(title), st::separatePanelTitle);
_title->setAttribute(Qt::WA_TransparentForMouseEvents);
_title->show();
updateTitleGeometry(width());
}
void SeparatePanel::initControls() {
@@ -45,10 +47,7 @@ void SeparatePanel::initControls() {
_back->moveToLeft(_padding.left(), _padding.top());
_close->moveToRight(_padding.right(), _padding.top());
if (_title) {
_title->resizeToWidth(width
- _padding.left() - _back->width()
- _padding.right() - _close->width());
updateTitlePosition();
updateTitleGeometry(width);
}
}, lifetime());
@@ -64,6 +63,13 @@ void SeparatePanel::initControls() {
_titleLeft.finish();
}
void SeparatePanel::updateTitleGeometry(int newWidth) {
_title->resizeToWidth(newWidth
- _padding.left() - _back->width()
- _padding.right() - _close->width());
updateTitlePosition();
}
void SeparatePanel::updateTitlePosition() {
if (!_title) {
return;
@@ -100,6 +106,15 @@ void SeparatePanel::setBackAllowed(bool allowed) {
}
}
void SeparatePanel::setHideOnDeactivate(bool hideOnDeactivate) {
_hideOnDeactivate = hideOnDeactivate;
if (!_hideOnDeactivate) {
showAndActivate();
} else if (!isActiveWindow()) {
hideGetDuration();
}
}
void SeparatePanel::showAndActivate() {
toggleOpacityAnimation(true);
raise();
@@ -115,6 +130,13 @@ void SeparatePanel::keyPressEvent(QKeyEvent *e) {
return RpWidget::keyPressEvent(e);
}
bool SeparatePanel::eventHook(QEvent *e) {
if (e->type() == QEvent::WindowDeactivate && _hideOnDeactivate) {
hideGetDuration();
}
return RpWidget::eventHook(e);
}
void SeparatePanel::initLayout() {
setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint)
| Qt::WindowStaysOnTopHint
@@ -506,7 +528,8 @@ void SeparatePanel::mousePressEvent(QMouseEvent *e) {
_dragging = true;
_dragStartMousePosition = e->globalPos();
_dragStartMyPosition = QPoint(x(), y());
} else if (!rect().contains(e->pos())) {
} else if (!rect().contains(e->pos()) && _hideOnDeactivate) {
hideGetDuration();
}
}
}