mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Don't lose focus when showing image editor.
This commit is contained in:
parent
77078f704c
commit
17f40d6a1f
1 changed files with 20 additions and 5 deletions
|
@ -107,21 +107,36 @@ void LayerWidget::checkBackgroundStale() {
|
|||
}
|
||||
|
||||
QImage LayerWidget::renderBackground() {
|
||||
const auto target = parentWidget()->parentWidget();
|
||||
const auto parent = parentWidget();
|
||||
const auto target = parent->parentWidget();
|
||||
Ui::SendPendingMoveResizeEvents(target);
|
||||
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
auto image = QImage(size() * ratio, QImage::Format_ARGB32_Premultiplied);
|
||||
image.setDevicePixelRatio(ratio);
|
||||
|
||||
const auto shown = !parentWidget()->isHidden();
|
||||
if (shown) parentWidget()->hide();
|
||||
|
||||
const auto shown = !parent->isHidden();
|
||||
const auto focused = shown && Ui::InFocusChain(parent);
|
||||
if (shown) {
|
||||
if (focused) {
|
||||
target->setFocus();
|
||||
}
|
||||
parent->hide();
|
||||
}
|
||||
auto p = QPainter(&image);
|
||||
Ui::RenderWidget(p, target, QPoint(), geometry());
|
||||
p.end();
|
||||
|
||||
if (shown) parentWidget()->show();
|
||||
if (shown) {
|
||||
parent->show();
|
||||
if (focused) {
|
||||
if (isHidden()) {
|
||||
parent->setFocus();
|
||||
} else {
|
||||
setInnerFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue