Don't lose focus when showing image editor.
This commit is contained in:
parent
77078f704c
commit
17f40d6a1f
|
@ -107,21 +107,36 @@ void LayerWidget::checkBackgroundStale() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QImage LayerWidget::renderBackground() {
|
QImage LayerWidget::renderBackground() {
|
||||||
const auto target = parentWidget()->parentWidget();
|
const auto parent = parentWidget();
|
||||||
|
const auto target = parent->parentWidget();
|
||||||
Ui::SendPendingMoveResizeEvents(target);
|
Ui::SendPendingMoveResizeEvents(target);
|
||||||
|
|
||||||
const auto ratio = style::DevicePixelRatio();
|
const auto ratio = style::DevicePixelRatio();
|
||||||
auto image = QImage(size() * ratio, QImage::Format_ARGB32_Premultiplied);
|
auto image = QImage(size() * ratio, QImage::Format_ARGB32_Premultiplied);
|
||||||
image.setDevicePixelRatio(ratio);
|
image.setDevicePixelRatio(ratio);
|
||||||
|
|
||||||
const auto shown = !parentWidget()->isHidden();
|
const auto shown = !parent->isHidden();
|
||||||
if (shown) parentWidget()->hide();
|
const auto focused = shown && Ui::InFocusChain(parent);
|
||||||
|
if (shown) {
|
||||||
|
if (focused) {
|
||||||
|
target->setFocus();
|
||||||
|
}
|
||||||
|
parent->hide();
|
||||||
|
}
|
||||||
auto p = QPainter(&image);
|
auto p = QPainter(&image);
|
||||||
Ui::RenderWidget(p, target, QPoint(), geometry());
|
Ui::RenderWidget(p, target, QPoint(), geometry());
|
||||||
p.end();
|
p.end();
|
||||||
|
|
||||||
if (shown) parentWidget()->show();
|
if (shown) {
|
||||||
|
parent->show();
|
||||||
|
if (focused) {
|
||||||
|
if (isHidden()) {
|
||||||
|
parent->setFocus();
|
||||||
|
} else {
|
||||||
|
setInnerFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue