mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Skip refocus InputField::Inner if field unfocused.
I hope this fixes #26223.
This commit is contained in:
parent
f671897a4d
commit
2fb7bdc803
13 changed files with 152 additions and 130 deletions
|
@ -80,11 +80,13 @@ public:
|
||||||
explicit Show(not_null<Panel*> panel);
|
explicit Show(not_null<Panel*> panel);
|
||||||
~Show();
|
~Show();
|
||||||
|
|
||||||
void showBox(
|
void showOrHideBoxOrLayer(
|
||||||
object_ptr<Ui::BoxContent> content,
|
std::variant<
|
||||||
Ui::LayerOptions options
|
v::null_t,
|
||||||
= Ui::LayerOption::KeepOther) const override;
|
object_ptr<Ui::BoxContent>,
|
||||||
void hideLayer() const override;
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated) const override;
|
||||||
[[nodiscard]] not_null<QWidget*> toastParent() const override;
|
[[nodiscard]] not_null<QWidget*> toastParent() const override;
|
||||||
[[nodiscard]] bool valid() const override;
|
[[nodiscard]] bool valid() const override;
|
||||||
operator bool() const override;
|
operator bool() const override;
|
||||||
|
@ -102,19 +104,27 @@ Show::Show(not_null<Panel*> panel)
|
||||||
|
|
||||||
Show::~Show() = default;
|
Show::~Show() = default;
|
||||||
|
|
||||||
void Show::showBox(
|
void Show::showOrHideBoxOrLayer(
|
||||||
object_ptr<Ui::BoxContent> content,
|
std::variant<
|
||||||
Ui::LayerOptions options) const {
|
v::null_t,
|
||||||
if (const auto panel = _panel.get()) {
|
object_ptr<Ui::BoxContent>,
|
||||||
panel->showBox(std::move(content), options);
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated) const {
|
||||||
|
using UniqueLayer = std::unique_ptr<Ui::LayerWidget>;
|
||||||
|
using ObjectBox = object_ptr<Ui::BoxContent>;
|
||||||
|
if (auto layerWidget = std::get_if<UniqueLayer>(&layer)) {
|
||||||
|
if (const auto panel = _panel.get()) {
|
||||||
|
panel->showLayer(std::move(*layerWidget), options, animated);
|
||||||
|
}
|
||||||
|
} else if (auto box = std::get_if<ObjectBox>(&layer)) {
|
||||||
|
if (const auto panel = _panel.get()) {
|
||||||
|
panel->showBox(std::move(*box), options, animated);
|
||||||
|
}
|
||||||
|
} else if (const auto panel = _panel.get()) {
|
||||||
|
panel->hideLayer(animated);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Show::hideLayer() const {
|
|
||||||
if (const auto panel = _panel.get()) {
|
|
||||||
panel->hideLayer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
not_null<QWidget*> Show::toastParent() const {
|
not_null<QWidget*> Show::toastParent() const {
|
||||||
const auto panel = _panel.get();
|
const auto panel = _panel.get();
|
||||||
|
@ -1527,6 +1537,20 @@ void Panel::showBox(
|
||||||
_layerBg->showBox(std::move(box), options, animated);
|
_layerBg->showBox(std::move(box), options, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Panel::showLayer(
|
||||||
|
std::unique_ptr<Ui::LayerWidget> layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated) {
|
||||||
|
hideStickedTooltip(StickedTooltipHide::Unavailable);
|
||||||
|
if (window()->width() < st::groupCallWidth
|
||||||
|
|| window()->height() < st::groupCallWidth) {
|
||||||
|
window()->resize(
|
||||||
|
std::max(window()->width(), st::groupCallWidth),
|
||||||
|
std::max(window()->height(), st::groupCallWidth));
|
||||||
|
}
|
||||||
|
_layerBg->showLayer(std::move(layer), options, animated);
|
||||||
|
}
|
||||||
|
|
||||||
void Panel::hideLayer(anim::type animated) {
|
void Panel::hideLayer(anim::type animated) {
|
||||||
_layerBg->hideAll(animated);
|
_layerBg->hideAll(animated);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ class GroupCall;
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class BoxContent;
|
class BoxContent;
|
||||||
|
class LayerWidget;
|
||||||
enum class LayerOption;
|
enum class LayerOption;
|
||||||
using LayerOptions = base::flags<LayerOption>;
|
using LayerOptions = base::flags<LayerOption>;
|
||||||
class AbstractButton;
|
class AbstractButton;
|
||||||
|
@ -106,6 +107,10 @@ public:
|
||||||
object_ptr<Ui::BoxContent> box,
|
object_ptr<Ui::BoxContent> box,
|
||||||
Ui::LayerOptions options,
|
Ui::LayerOptions options,
|
||||||
anim::type animated = anim::type::normal);
|
anim::type animated = anim::type::normal);
|
||||||
|
void showLayer(
|
||||||
|
std::unique_ptr<Ui::LayerWidget> layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated = anim::type::normal);
|
||||||
void hideLayer(anim::type animated = anim::type::normal);
|
void hideLayer(anim::type animated = anim::type::normal);
|
||||||
[[nodiscard]] bool isLayerShown() const;
|
[[nodiscard]] bool isLayerShown() const;
|
||||||
|
|
||||||
|
|
|
@ -156,7 +156,7 @@ PanelController::~PanelController() {
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
}
|
||||||
if (_panel) {
|
if (_panel) {
|
||||||
_panel->destroyLayer();
|
_panel->hideLayer(anim::type::instant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,13 @@ public:
|
||||||
std::shared_ptr<Ui::Show> show,
|
std::shared_ptr<Ui::Show> show,
|
||||||
not_null<Session*> session);
|
not_null<Session*> session);
|
||||||
|
|
||||||
void showBox(
|
void showOrHideBoxOrLayer(
|
||||||
object_ptr<Ui::BoxContent> content,
|
std::variant<
|
||||||
Ui::LayerOptions options
|
v::null_t,
|
||||||
= Ui::LayerOption::KeepOther) const override;
|
object_ptr<Ui::BoxContent>,
|
||||||
void hideLayer() const override;
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated) const override;
|
||||||
not_null<QWidget*> toastParent() const override;
|
not_null<QWidget*> toastParent() const override;
|
||||||
bool valid() const override;
|
bool valid() const override;
|
||||||
operator bool() const override;
|
operator bool() const override;
|
||||||
|
@ -40,14 +42,14 @@ SimpleSessionShow::SimpleSessionShow(
|
||||||
, _session(session) {
|
, _session(session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleSessionShow::showBox(
|
void SimpleSessionShow::showOrHideBoxOrLayer(
|
||||||
object_ptr<Ui::BoxContent> content,
|
std::variant<
|
||||||
Ui::LayerOptions options) const {
|
v::null_t,
|
||||||
_show->showBox(std::move(content), options);
|
object_ptr<Ui::BoxContent>,
|
||||||
}
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
void SimpleSessionShow::hideLayer() const {
|
anim::type animated) const {
|
||||||
_show->hideLayer();
|
_show->showOrHideBoxOrLayer(std::move(layer), options, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<QWidget*> SimpleSessionShow::toastParent() const {
|
not_null<QWidget*> SimpleSessionShow::toastParent() const {
|
||||||
|
|
|
@ -407,7 +407,7 @@ MainWidget *MainWindow::sessionContent() const {
|
||||||
return _main.data();
|
return _main.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showBoxOrLayer(
|
void MainWindow::showOrHideBoxOrLayer(
|
||||||
std::variant<
|
std::variant<
|
||||||
v::null_t,
|
v::null_t,
|
||||||
object_ptr<Ui::BoxContent>,
|
object_ptr<Ui::BoxContent>,
|
||||||
|
@ -419,7 +419,7 @@ void MainWindow::showBoxOrLayer(
|
||||||
if (auto layerWidget = std::get_if<UniqueLayer>(&layer)) {
|
if (auto layerWidget = std::get_if<UniqueLayer>(&layer)) {
|
||||||
ensureLayerCreated();
|
ensureLayerCreated();
|
||||||
_layer->showLayer(std::move(*layerWidget), options, animated);
|
_layer->showLayer(std::move(*layerWidget), options, animated);
|
||||||
} else if (auto box = std::get_if<ObjectBox>(&layer); *box != nullptr) {
|
} else if (auto box = std::get_if<ObjectBox>(&layer)) {
|
||||||
ensureLayerCreated();
|
ensureLayerCreated();
|
||||||
_layer->showBox(std::move(*box), options, animated);
|
_layer->showBox(std::move(*box), options, animated);
|
||||||
} else {
|
} else {
|
||||||
|
@ -435,20 +435,6 @@ void MainWindow::showBoxOrLayer(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::ui_showBox(
|
|
||||||
object_ptr<Ui::BoxContent> box,
|
|
||||||
Ui::LayerOptions options,
|
|
||||||
anim::type animated) {
|
|
||||||
showBoxOrLayer(std::move(box), options, animated);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::showLayer(
|
|
||||||
std::unique_ptr<Ui::LayerWidget> &&layer,
|
|
||||||
Ui::LayerOptions options,
|
|
||||||
anim::type animated) {
|
|
||||||
showBoxOrLayer(std::move(layer), options, animated);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MainWindow::ui_isLayerShown() const {
|
bool MainWindow::ui_isLayerShown() const {
|
||||||
return _layer != nullptr;
|
return _layer != nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,11 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] QPixmap grabForSlideAnimation();
|
[[nodiscard]] QPixmap grabForSlideAnimation();
|
||||||
|
|
||||||
void showLayer(
|
void showOrHideBoxOrLayer(
|
||||||
std::unique_ptr<Ui::LayerWidget> &&layer,
|
std::variant<
|
||||||
|
v::null_t,
|
||||||
|
object_ptr<Ui::BoxContent>,
|
||||||
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
Ui::LayerOptions options,
|
Ui::LayerOptions options,
|
||||||
anim::type animated);
|
anim::type animated);
|
||||||
void showSpecialLayer(
|
void showSpecialLayer(
|
||||||
|
@ -93,10 +96,6 @@ public:
|
||||||
bool showSectionInExistingLayer(
|
bool showSectionInExistingLayer(
|
||||||
not_null<Window::SectionMemento*> memento,
|
not_null<Window::SectionMemento*> memento,
|
||||||
const Window::SectionShow ¶ms);
|
const Window::SectionShow ¶ms);
|
||||||
void ui_showBox(
|
|
||||||
object_ptr<Ui::BoxContent> box,
|
|
||||||
Ui::LayerOptions options,
|
|
||||||
anim::type animated);
|
|
||||||
void ui_hideSettingsAndLayer(anim::type animated);
|
void ui_hideSettingsAndLayer(anim::type animated);
|
||||||
void ui_removeLayerBlackout();
|
void ui_removeLayerBlackout();
|
||||||
[[nodiscard]] bool ui_isLayerShown() const;
|
[[nodiscard]] bool ui_isLayerShown() const;
|
||||||
|
@ -122,14 +121,6 @@ private:
|
||||||
void ensureLayerCreated();
|
void ensureLayerCreated();
|
||||||
void destroyLayer();
|
void destroyLayer();
|
||||||
|
|
||||||
void showBoxOrLayer(
|
|
||||||
std::variant<
|
|
||||||
v::null_t,
|
|
||||||
object_ptr<Ui::BoxContent>,
|
|
||||||
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
|
||||||
Ui::LayerOptions options,
|
|
||||||
anim::type animated);
|
|
||||||
|
|
||||||
void themeUpdated(const Window::Theme::BackgroundUpdate &data);
|
void themeUpdated(const Window::Theme::BackgroundUpdate &data);
|
||||||
|
|
||||||
QPoint _lastMousePosition;
|
QPoint _lastMousePosition;
|
||||||
|
|
|
@ -487,7 +487,7 @@ bool Panel::showWebview(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
showWebviewProgress();
|
showWebviewProgress();
|
||||||
_widget->destroyLayer();
|
_widget->hideLayer(anim::type::instant);
|
||||||
_webview->window.navigate(url);
|
_webview->window.navigate(url);
|
||||||
_widget->setBackAllowed(allowBack);
|
_widget->setBackAllowed(allowBack);
|
||||||
if (bottomText) {
|
if (bottomText) {
|
||||||
|
|
|
@ -510,7 +510,7 @@ bool Panel::showWebview(
|
||||||
}
|
}
|
||||||
const auto allowBack = false;
|
const auto allowBack = false;
|
||||||
showWebviewProgress();
|
showWebviewProgress();
|
||||||
_widget->destroyLayer();
|
_widget->hideLayer(anim::type::instant);
|
||||||
updateThemeParams(params);
|
updateThemeParams(params);
|
||||||
_webview->window.navigate(url);
|
_webview->window.navigate(url);
|
||||||
_widget->setBackAllowed(allowBack);
|
_widget->setBackAllowed(allowBack);
|
||||||
|
|
|
@ -45,11 +45,13 @@ class Show final : public Ui::Show {
|
||||||
public:
|
public:
|
||||||
explicit Show(not_null<Controller*> window);
|
explicit Show(not_null<Controller*> window);
|
||||||
|
|
||||||
void showBox(
|
void showOrHideBoxOrLayer(
|
||||||
object_ptr<Ui::BoxContent> content,
|
std::variant<
|
||||||
Ui::LayerOptions options
|
v::null_t,
|
||||||
= Ui::LayerOption::KeepOther) const override;
|
object_ptr<Ui::BoxContent>,
|
||||||
void hideLayer() const override;
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated) const override;
|
||||||
[[nodiscard]] not_null<QWidget*> toastParent() const override;
|
[[nodiscard]] not_null<QWidget*> toastParent() const override;
|
||||||
[[nodiscard]] bool valid() const override;
|
[[nodiscard]] bool valid() const override;
|
||||||
operator bool() const override;
|
operator bool() const override;
|
||||||
|
@ -63,19 +65,18 @@ Show::Show(not_null<Controller*> window)
|
||||||
: _window(base::make_weak(window)) {
|
: _window(base::make_weak(window)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Show::showBox(
|
void Show::showOrHideBoxOrLayer(
|
||||||
object_ptr<Ui::BoxContent> content,
|
std::variant<
|
||||||
Ui::LayerOptions options) const {
|
v::null_t,
|
||||||
|
object_ptr<Ui::BoxContent>,
|
||||||
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated) const {
|
||||||
if (const auto window = _window.get()) {
|
if (const auto window = _window.get()) {
|
||||||
window->show(std::move(content), options);
|
window->widget()->showOrHideBoxOrLayer(
|
||||||
}
|
std::move(layer),
|
||||||
}
|
options,
|
||||||
|
animated);
|
||||||
void Show::hideLayer() const {
|
|
||||||
if (const auto window = _window.get()) {
|
|
||||||
window->show(
|
|
||||||
object_ptr<Ui::BoxContent>{ nullptr },
|
|
||||||
Ui::LayerOption::CloseOther);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,14 +409,14 @@ void Controller::showLayer(
|
||||||
std::unique_ptr<Ui::LayerWidget> &&layer,
|
std::unique_ptr<Ui::LayerWidget> &&layer,
|
||||||
Ui::LayerOptions options,
|
Ui::LayerOptions options,
|
||||||
anim::type animated) {
|
anim::type animated) {
|
||||||
_widget.showLayer(std::move(layer), options, animated);
|
_widget.showOrHideBoxOrLayer(std::move(layer), options, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::showBox(
|
void Controller::showBox(
|
||||||
object_ptr<Ui::BoxContent> content,
|
object_ptr<Ui::BoxContent> content,
|
||||||
Ui::LayerOptions options,
|
Ui::LayerOptions options,
|
||||||
anim::type animated) {
|
anim::type animated) {
|
||||||
_widget.ui_showBox(std::move(content), options, animated);
|
_widget.showOrHideBoxOrLayer(std::move(content), options, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::showRightColumn(object_ptr<TWidget> widget) {
|
void Controller::showRightColumn(object_ptr<TWidget> widget) {
|
||||||
|
@ -423,7 +424,7 @@ void Controller::showRightColumn(object_ptr<TWidget> widget) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::hideLayer(anim::type animated) {
|
void Controller::hideLayer(anim::type animated) {
|
||||||
_widget.ui_showBox({ nullptr }, Ui::LayerOption::CloseOther, animated);
|
_widget.showOrHideBoxOrLayer(v::null, Ui::LayerOption::CloseOther, animated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::hideSettingsAndLayer(anim::type animated) {
|
void Controller::hideSettingsAndLayer(anim::type animated) {
|
||||||
|
|
|
@ -86,31 +86,38 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] int verticalShadowTop() const;
|
[[nodiscard]] int verticalShadowTop() const;
|
||||||
|
|
||||||
template <typename BoxType>
|
|
||||||
QPointer<BoxType> show(
|
|
||||||
object_ptr<BoxType> content,
|
|
||||||
Ui::LayerOptions options = Ui::LayerOption::KeepOther,
|
|
||||||
anim::type animated = anim::type::normal) {
|
|
||||||
const auto result = QPointer<BoxType>(content.data());
|
|
||||||
showBox(std::move(content), options, animated);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void showToast(Ui::Toast::Config &&config);
|
void showToast(Ui::Toast::Config &&config);
|
||||||
void showToast(TextWithEntities &&text, crl::time duration = 0);
|
void showToast(TextWithEntities &&text, crl::time duration = 0);
|
||||||
void showToast(const QString &text, crl::time duration = 0);
|
void showToast(const QString &text, crl::time duration = 0);
|
||||||
|
|
||||||
|
void showRightColumn(object_ptr<TWidget> widget);
|
||||||
|
|
||||||
|
void showBox(
|
||||||
|
object_ptr<Ui::BoxContent> content,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated);
|
||||||
void showLayer(
|
void showLayer(
|
||||||
std::unique_ptr<Ui::LayerWidget> &&layer,
|
std::unique_ptr<Ui::LayerWidget> &&layer,
|
||||||
Ui::LayerOptions options,
|
Ui::LayerOptions options,
|
||||||
anim::type animated = anim::type::normal);
|
anim::type animated = anim::type::normal);
|
||||||
|
|
||||||
void showRightColumn(object_ptr<TWidget> widget);
|
|
||||||
|
|
||||||
void hideLayer(anim::type animated = anim::type::normal);
|
void hideLayer(anim::type animated = anim::type::normal);
|
||||||
void hideSettingsAndLayer(anim::type animated = anim::type::normal);
|
void hideSettingsAndLayer(anim::type animated = anim::type::normal);
|
||||||
[[nodiscard]] bool isLayerShown() const;
|
[[nodiscard]] bool isLayerShown() const;
|
||||||
|
|
||||||
|
template <
|
||||||
|
typename BoxType,
|
||||||
|
typename = std::enable_if_t<
|
||||||
|
std::is_base_of_v<Ui::BoxContent, BoxType>>>
|
||||||
|
QPointer<BoxType> show(
|
||||||
|
object_ptr<BoxType> content,
|
||||||
|
Ui::LayerOptions options = Ui::LayerOption::KeepOther,
|
||||||
|
anim::type animated = anim::type()) {
|
||||||
|
auto result = QPointer<BoxType>(content.data());
|
||||||
|
showBox(std::move(content), options, animated);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void activate();
|
void activate();
|
||||||
void reActivate();
|
void reActivate();
|
||||||
void updateIsActiveFocus();
|
void updateIsActiveFocus();
|
||||||
|
@ -162,10 +169,6 @@ private:
|
||||||
void setupSideBar();
|
void setupSideBar();
|
||||||
void sideBarChanged();
|
void sideBarChanged();
|
||||||
|
|
||||||
void showBox(
|
|
||||||
object_ptr<Ui::BoxContent> content,
|
|
||||||
Ui::LayerOptions options,
|
|
||||||
anim::type animated);
|
|
||||||
void checkThemeEditor();
|
void checkThemeEditor();
|
||||||
void checkLockByTerms();
|
void checkLockByTerms();
|
||||||
void showTermsDecline();
|
void showTermsDecline();
|
||||||
|
|
|
@ -111,13 +111,16 @@ constexpr auto kMaxChatEntryHistorySize = 50;
|
||||||
|
|
||||||
class MainWindowShow final : public ChatHelpers::Show {
|
class MainWindowShow final : public ChatHelpers::Show {
|
||||||
public:
|
public:
|
||||||
explicit MainWindowShow(not_null<SessionNavigation*> navigation);
|
explicit MainWindowShow(not_null<SessionController*> controller);
|
||||||
|
|
||||||
|
void showOrHideBoxOrLayer(
|
||||||
|
std::variant<
|
||||||
|
v::null_t,
|
||||||
|
object_ptr<Ui::BoxContent>,
|
||||||
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated) const override;
|
||||||
|
|
||||||
void showBox(
|
|
||||||
object_ptr<Ui::BoxContent> content,
|
|
||||||
Ui::LayerOptions options
|
|
||||||
= Ui::LayerOption::KeepOther) const override;
|
|
||||||
void hideLayer() const override;
|
|
||||||
not_null<QWidget*> toastParent() const override;
|
not_null<QWidget*> toastParent() const override;
|
||||||
bool valid() const override;
|
bool valid() const override;
|
||||||
operator bool() const override;
|
operator bool() const override;
|
||||||
|
@ -144,24 +147,22 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MainWindowShow::MainWindowShow(
|
MainWindowShow::MainWindowShow(not_null<SessionController*> controller)
|
||||||
not_null<SessionNavigation*> navigation)
|
: _window(base::make_weak(controller)) {
|
||||||
: _window(base::make_weak(navigation->parentController())) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindowShow::showBox(
|
void MainWindowShow::showOrHideBoxOrLayer(
|
||||||
object_ptr<Ui::BoxContent> content,
|
std::variant<
|
||||||
Ui::LayerOptions options) const {
|
v::null_t,
|
||||||
|
object_ptr<Ui::BoxContent>,
|
||||||
|
std::unique_ptr<Ui::LayerWidget>> &&layer,
|
||||||
|
Ui::LayerOptions options,
|
||||||
|
anim::type animated) const {
|
||||||
if (const auto window = _window.get()) {
|
if (const auto window = _window.get()) {
|
||||||
window->show(std::move(content), options);
|
window->window().widget()->showOrHideBoxOrLayer(
|
||||||
}
|
std::move(layer),
|
||||||
}
|
options,
|
||||||
|
animated);
|
||||||
void MainWindowShow::hideLayer() const {
|
|
||||||
if (const auto window = _window.get()) {
|
|
||||||
window->show(
|
|
||||||
object_ptr<Ui::BoxContent>{ nullptr },
|
|
||||||
Ui::LayerOption::CloseOther);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,8 +396,7 @@ void SessionNavigation::resolveChannelById(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto fail = crl::guard(this, [=] {
|
const auto fail = crl::guard(this, [=] {
|
||||||
MainWindowShow(this).showToast(
|
uiShow()->showToast(tr::lng_error_post_link_invalid(tr::now));
|
||||||
tr::lng_error_post_link_invalid(tr::now));
|
|
||||||
});
|
});
|
||||||
_api.request(base::take(_resolveRequestId)).cancel();
|
_api.request(base::take(_resolveRequestId)).cancel();
|
||||||
_resolveRequestId = _api.request(MTPchannels_GetChannels(
|
_resolveRequestId = _api.request(MTPchannels_GetChannels(
|
||||||
|
@ -594,8 +594,7 @@ void SessionNavigation::joinVoiceChatFromLink(
|
||||||
Expects(info.voicechatHash.has_value());
|
Expects(info.voicechatHash.has_value());
|
||||||
|
|
||||||
const auto bad = crl::guard(this, [=] {
|
const auto bad = crl::guard(this, [=] {
|
||||||
MainWindowShow(this).showToast(
|
uiShow()->showToast(tr::lng_group_invite_bad_link(tr::now));
|
||||||
tr::lng_group_invite_bad_link(tr::now));
|
|
||||||
});
|
});
|
||||||
const auto hash = *info.voicechatHash;
|
const auto hash = *info.voicechatHash;
|
||||||
_api.request(base::take(_resolveRequestId)).cancel();
|
_api.request(base::take(_resolveRequestId)).cancel();
|
||||||
|
@ -824,23 +823,23 @@ void SessionNavigation::showPollResults(
|
||||||
|
|
||||||
auto SessionNavigation::showToast(Ui::Toast::Config &&config)
|
auto SessionNavigation::showToast(Ui::Toast::Config &&config)
|
||||||
-> base::weak_ptr<Ui::Toast::Instance> {
|
-> base::weak_ptr<Ui::Toast::Instance> {
|
||||||
return MainWindowShow(this).showToast(std::move(config));
|
return uiShow()->showToast(std::move(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SessionNavigation::showToast(const QString &text, crl::time duration)
|
auto SessionNavigation::showToast(const QString &text, crl::time duration)
|
||||||
-> base::weak_ptr<Ui::Toast::Instance> {
|
-> base::weak_ptr<Ui::Toast::Instance> {
|
||||||
return MainWindowShow(this).showToast(text);
|
return uiShow()->showToast(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto SessionNavigation::showToast(
|
auto SessionNavigation::showToast(
|
||||||
TextWithEntities &&text,
|
TextWithEntities &&text,
|
||||||
crl::time duration)
|
crl::time duration)
|
||||||
-> base::weak_ptr<Ui::Toast::Instance> {
|
-> base::weak_ptr<Ui::Toast::Instance> {
|
||||||
return MainWindowShow(this).showToast(std::move(text));
|
return uiShow()->showToast(std::move(text));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ChatHelpers::Show> SessionNavigation::uiShow() {
|
std::shared_ptr<ChatHelpers::Show> SessionNavigation::uiShow() {
|
||||||
return std::make_shared<MainWindowShow>(this);
|
return parentController()->uiShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SessionController::CachedThemeKey {
|
struct SessionController::CachedThemeKey {
|
||||||
|
@ -2485,6 +2484,13 @@ bool SessionController::contentOverlapped(QWidget *w, QPaintEvent *e) {
|
||||||
return widget()->contentOverlapped(w, e);
|
return widget()->contentOverlapped(w, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<ChatHelpers::Show> SessionController::uiShow() {
|
||||||
|
if (!_cachedShow) {
|
||||||
|
_cachedShow = std::make_shared<MainWindowShow>(this);
|
||||||
|
}
|
||||||
|
return _cachedShow;
|
||||||
|
}
|
||||||
|
|
||||||
SessionController::~SessionController() {
|
SessionController::~SessionController() {
|
||||||
resetFakeUnreadWhileOpened();
|
resetFakeUnreadWhileOpened();
|
||||||
}
|
}
|
||||||
|
|
|
@ -278,7 +278,7 @@ public:
|
||||||
const QString &text,
|
const QString &text,
|
||||||
crl::time duration = 0);
|
crl::time duration = 0);
|
||||||
|
|
||||||
[[nodiscard]] std::shared_ptr<ChatHelpers::Show> uiShow();
|
[[nodiscard]] virtual std::shared_ptr<ChatHelpers::Show> uiShow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resolvePhone(
|
void resolvePhone(
|
||||||
|
@ -591,6 +591,8 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] bool contentOverlapped(QWidget *w, QPaintEvent *e);
|
[[nodiscard]] bool contentOverlapped(QWidget *w, QPaintEvent *e);
|
||||||
|
|
||||||
|
[[nodiscard]] std::shared_ptr<ChatHelpers::Show> uiShow() override;
|
||||||
|
|
||||||
[[nodiscard]] rpl::lifetime &lifetime() {
|
[[nodiscard]] rpl::lifetime &lifetime() {
|
||||||
return _lifetime;
|
return _lifetime;
|
||||||
}
|
}
|
||||||
|
@ -641,6 +643,8 @@ private:
|
||||||
const std::unique_ptr<ChatHelpers::EmojiInteractions> _emojiInteractions;
|
const std::unique_ptr<ChatHelpers::EmojiInteractions> _emojiInteractions;
|
||||||
const bool _isPrimary = false;
|
const bool _isPrimary = false;
|
||||||
|
|
||||||
|
mutable std::shared_ptr<ChatHelpers::Show> _cachedShow;
|
||||||
|
|
||||||
QString _authedName;
|
QString _authedName;
|
||||||
|
|
||||||
using SendingAnimation = Ui::MessageSendingAnimationController;
|
using SendingAnimation = Ui::MessageSendingAnimationController;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 303a07f9461524dc6debf86ae04d0ee6d3134eb6
|
Subproject commit a7d503188918904d12a069bca7d3f6c92b9fb553
|
Loading…
Add table
Reference in a new issue