Add Ui::AppInFocus() method.
This commit is contained in:
parent
f0e95ee933
commit
765e525458
4 changed files with 14 additions and 10 deletions
|
|
@ -462,10 +462,10 @@ void LayerStackWidget::setCacheImages() {
|
|||
|
||||
void LayerStackWidget::closeLayer(not_null<LayerWidget*> layer) {
|
||||
const auto weak = Ui::MakeWeak(layer.get());
|
||||
if (weak->inFocusChain()) {
|
||||
if (Ui::InFocusChain(layer)) {
|
||||
setFocus();
|
||||
}
|
||||
if (!weak || !weak->setClosing()) {
|
||||
if (!layer->setClosing()) {
|
||||
// This layer is already closing.
|
||||
return;
|
||||
} else if (!weak) {
|
||||
|
|
@ -734,9 +734,11 @@ void LayerStackWidget::appendBox(
|
|||
LayerWidget *LayerStackWidget::pushBox(
|
||||
object_ptr<BoxContent> box,
|
||||
anim::type animated) {
|
||||
auto oldLayer = currentLayer();
|
||||
const auto oldLayer = currentLayer();
|
||||
if (oldLayer) {
|
||||
if (oldLayer->inFocusChain()) setFocus();
|
||||
if (Ui::InFocusChain(oldLayer)) {
|
||||
setFocus();
|
||||
}
|
||||
oldLayer->hide();
|
||||
}
|
||||
_layers.push_back(
|
||||
|
|
@ -793,7 +795,7 @@ void LayerStackWidget::clearClosingLayers() {
|
|||
while (!_closingLayers.empty()) {
|
||||
const auto index = _closingLayers.size() - 1;
|
||||
const auto layer = _closingLayers.back().get();
|
||||
if (layer->inFocusChain()) {
|
||||
if (Ui::InFocusChain(layer)) {
|
||||
setFocus();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ public:
|
|||
return QMargins();
|
||||
}
|
||||
|
||||
bool inFocusChain() const {
|
||||
return Ui::InFocusChain(this);
|
||||
}
|
||||
|
||||
void hideChildren() {
|
||||
for (auto child : Base::children()) {
|
||||
if (child->isWidgetType()) {
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include "ui/style/style_core.h"
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtGui/QWindow>
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QtEvents>
|
||||
|
||||
#include <array>
|
||||
|
|
@ -82,6 +82,10 @@ void SendPendingEventsRecursive(QWidget *target, bool parentHiddenFlag) {
|
|||
|
||||
} // namespace
|
||||
|
||||
bool AppInFocus() {
|
||||
return QApplication::focusWidget() != nullptr;
|
||||
}
|
||||
|
||||
void SendPendingMoveResizeEvents(not_null<QWidget*> target) {
|
||||
CreateWidgetStateRecursive(target);
|
||||
SendPendingEventsRecursive(target, !target->isVisible());
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ inline not_null<std::decay_t<Value>*> AttachAsChild(
|
|||
std::forward<Value>(value))->value();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool AppInFocus();
|
||||
|
||||
[[nodiscard]] inline bool InFocusChain(not_null<const QWidget*> widget) {
|
||||
if (const auto top = widget->window()) {
|
||||
if (auto focused = top->focusWidget()) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue