2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-04 00:25:17 +00:00

Allow showing boxes in passport panel.

This commit is contained in:
John Preston
2018-04-06 20:23:09 +04:00
parent f1519b76f6
commit d0e854e9d8
32 changed files with 293 additions and 236 deletions

View File

@@ -301,17 +301,17 @@ void MainWindow::showSpecialLayer(
if (layer) {
ensureLayerCreated();
_layerBg->showSpecialLayer(std::move(layer), animated);
} else if (_layerBg) {
_layerBg->hideSpecialLayer(animated);
_layer->showSpecialLayer(std::move(layer), animated);
} else if (_layer) {
_layer->hideSpecialLayer(animated);
}
}
bool MainWindow::showSectionInExistingLayer(
not_null<Window::SectionMemento*> memento,
const Window::SectionShow &params) {
if (_layerBg) {
return _layerBg->showSectionInternal(memento, params);
if (_layer) {
return _layer->showSectionInternal(memento, params);
}
return false;
}
@@ -322,12 +322,16 @@ void MainWindow::showMainMenu() {
if (isHidden()) showFromTray();
ensureLayerCreated();
_layerBg->showMainMenu(anim::type::normal);
_layer->showMainMenu(controller(), anim::type::normal);
}
void MainWindow::ensureLayerCreated() {
if (!_layerBg) {
_layerBg.create(bodyWidget(), controller());
if (!_layer) {
_layer.create(bodyWidget());
_layer->hideFinishEvents(
) | rpl::start_with_next([=, pointer = _layer.data()] {
layerHidden(pointer);
}, _layer->lifetime());
if (controller()) {
controller()->enableGifPauseReason(Window::GifPauseReason::Layer);
}
@@ -335,8 +339,8 @@ void MainWindow::ensureLayerCreated() {
}
void MainWindow::destroyLayerDelayed() {
if (_layerBg) {
_layerBg.destroyDelayed();
if (_layer) {
_layer.destroyDelayed();
if (controller()) {
controller()->disableGifPauseReason(Window::GifPauseReason::Layer);
}
@@ -344,8 +348,8 @@ void MainWindow::destroyLayerDelayed() {
}
void MainWindow::ui_hideSettingsAndLayer(anim::type animated) {
if (_layerBg) {
_layerBg->hideAll(animated);
if (_layer) {
_layer->hideAll(animated);
if (animated == anim::type::instant) {
destroyLayerDelayed();
}
@@ -366,21 +370,13 @@ void MainWindow::ui_showBox(
anim::type animated) {
if (box) {
ensureLayerCreated();
if (options & LayerOption::KeepOther) {
if (options & LayerOption::ShowAfterOther) {
_layerBg->prependBox(std::move(box), animated);
} else {
_layerBg->appendBox(std::move(box), animated);
}
} else {
_layerBg->showBox(std::move(box), animated);
}
_layer->showBox(std::move(box), options, animated);
} else {
if (_layerBg) {
_layerBg->hideTopLayer(animated);
if (_layer) {
_layer->hideTopLayer(animated);
if ((animated == anim::type::instant)
&& _layerBg
&& !_layerBg->layerShown()) {
&& _layer
&& !_layer->layerShown()) {
destroyLayerDelayed();
}
}
@@ -389,7 +385,7 @@ void MainWindow::ui_showBox(
}
bool MainWindow::ui_isLayerShown() {
return _layerBg != nullptr;
return _layer != nullptr;
}
void MainWindow::ui_showMediaPreview(DocumentData *document) {
@@ -476,15 +472,15 @@ void MainWindow::checkHistoryActivation() {
bool MainWindow::contentOverlapped(const QRect &globalRect) {
if (_main && _main->contentOverlapped(globalRect)) return true;
if (_layerBg && _layerBg->contentOverlapped(globalRect)) return true;
if (_layer && _layer->contentOverlapped(globalRect)) return true;
return false;
}
void MainWindow::setInnerFocus() {
if (_testingThemeWarning) {
_testingThemeWarning->setFocus();
} else if (_layerBg && _layerBg->canSetFocus()) {
_layerBg->setInnerFocus();
} else if (_layer && _layer->canSetFocus()) {
_layer->setInnerFocus();
} else if (_passcode) {
_passcode->setInnerFocus();
} else if (_main) {
@@ -641,34 +637,25 @@ void MainWindow::noIntro(Intro::Widget *was) {
}
}
void MainWindow::noLayerStack(Window::LayerStackWidget *was) {
if (was == _layerBg) {
_layerBg = nullptr;
if (controller()) {
controller()->disableGifPauseReason(
Window::GifPauseReason::Layer);
}
}
}
void MainWindow::layerFinishedHide(Window::LayerStackWidget *was) {
if (was == _layerBg) {
auto resetFocus = Ui::InFocusChain(was);
if (resetFocus) setFocus();
destroyLayerDelayed();
if (resetFocus) setInnerFocus();
InvokeQueued(this, [this] {
checkHistoryActivation();
});
void MainWindow::layerHidden(not_null<Window::LayerStackWidget*> layer) {
if (_layer != layer) {
return;
}
auto resetFocus = Ui::InFocusChain(layer);
if (resetFocus) setFocus();
destroyLayerDelayed();
if (resetFocus) setInnerFocus();
InvokeQueued(this, [this] {
checkHistoryActivation();
});
}
bool MainWindow::takeThirdSectionFromLayer() {
return _layerBg ? _layerBg->takeToThirdSection() : false;
return _layer ? _layer->takeToThirdSection() : false;
}
void MainWindow::fixOrder() {
if (_layerBg) _layerBg->raise();
if (_layer) _layer->raise();
if (_mediaPreview) _mediaPreview->raise();
if (_testingThemeWarning) _testingThemeWarning->raise();
}
@@ -759,7 +746,7 @@ void MainWindow::updateControlsGeometry() {
if (_passcode) _passcode->setGeometry(body);
if (_main) _main->setGeometry(body);
if (_intro) _intro->setGeometry(body);
if (_layerBg) _layerBg->setGeometry(body);
if (_layer) _layer->setGeometry(body);
if (_mediaPreview) _mediaPreview->setGeometry(body);
if (_testingThemeWarning) _testingThemeWarning->setGeometry(body);