2014-11-05 17:43:32 +00:00
|
|
|
/*
|
2014-05-30 08:53:19 +00:00
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
2016-04-10 18:18:26 +00:00
|
|
|
#include "mainwidget.h"
|
|
|
|
|
2020-06-11 09:41:03 +00:00
|
|
|
#include "api/api_updates.h"
|
2021-09-28 21:23:58 +00:00
|
|
|
#include "api/api_views.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_photo.h"
|
|
|
|
#include "data/data_document.h"
|
2020-04-10 13:18:51 +00:00
|
|
|
#include "data/data_document_media.h"
|
2021-06-14 04:35:51 +00:00
|
|
|
#include "data/data_document_resolver.h"
|
2023-01-21 05:42:57 +00:00
|
|
|
#include "data/data_forum_topic.h"
|
2021-08-13 15:39:50 +00:00
|
|
|
#include "data/data_wall_paper.h"
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_web_page.h"
|
|
|
|
#include "data/data_game.h"
|
2017-09-26 13:53:51 +00:00
|
|
|
#include "data/data_peer_values.h"
|
2018-01-04 17:15:04 +00:00
|
|
|
#include "data/data_drafts.h"
|
|
|
|
#include "data/data_session.h"
|
2020-06-12 14:09:04 +00:00
|
|
|
#include "data/data_changes.h"
|
2018-01-14 16:02:25 +00:00
|
|
|
#include "data/data_media_types.h"
|
2019-04-15 11:54:03 +00:00
|
|
|
#include "data/data_folder.h"
|
2023-01-10 18:56:20 +00:00
|
|
|
#include "data/data_forum_topic.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_channel.h"
|
|
|
|
#include "data/data_chat.h"
|
|
|
|
#include "data/data_user.h"
|
2020-02-07 16:07:21 +00:00
|
|
|
#include "data/data_chat_filters.h"
|
2019-08-08 17:07:55 +00:00
|
|
|
#include "data/data_scheduled_messages.h"
|
2019-12-05 08:32:33 +00:00
|
|
|
#include "data/data_file_origin.h"
|
2020-02-21 07:58:50 +00:00
|
|
|
#include "data/data_histories.h"
|
2020-06-08 17:24:36 +00:00
|
|
|
#include "data/stickers/data_stickers.h"
|
2021-08-27 11:32:18 +00:00
|
|
|
#include "ui/chat/chat_theme.h"
|
2016-11-11 13:46:04 +00:00
|
|
|
#include "ui/widgets/buttons.h"
|
2016-10-12 19:34:25 +00:00
|
|
|
#include "ui/widgets/shadow.h"
|
2016-10-26 16:43:13 +00:00
|
|
|
#include "ui/widgets/dropdown_menu.h"
|
2018-10-23 09:44:42 +00:00
|
|
|
#include "ui/image/image.h"
|
2017-09-25 16:06:53 +00:00
|
|
|
#include "ui/focus_persister.h"
|
2017-11-12 15:41:00 +00:00
|
|
|
#include "ui/resize_area.h"
|
2020-10-10 09:15:37 +00:00
|
|
|
#include "ui/text/text_options.h"
|
2018-10-13 17:35:30 +00:00
|
|
|
#include "ui/emoji_config.h"
|
2021-05-07 14:33:53 +00:00
|
|
|
#include "ui/ui_utility.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "window/section_memento.h"
|
|
|
|
#include "window/section_widget.h"
|
|
|
|
#include "window/window_connecting_widget.h"
|
2020-06-24 07:56:16 +00:00
|
|
|
#include "window/window_top_bar_wrap.h"
|
|
|
|
#include "window/notifications_manager.h"
|
|
|
|
#include "window/window_slide_animation.h"
|
|
|
|
#include "window/window_session_controller.h"
|
|
|
|
#include "window/window_history_hider.h"
|
|
|
|
#include "window/window_controller.h"
|
2022-11-01 04:46:31 +00:00
|
|
|
#include "window/window_peer_menu.h"
|
2020-06-24 07:56:16 +00:00
|
|
|
#include "window/themes/window_theme.h"
|
2019-08-16 12:44:20 +00:00
|
|
|
#include "chat_helpers/tabbed_selector.h" // TabbedSelector::refreshStickers
|
2017-04-08 13:27:53 +00:00
|
|
|
#include "chat_helpers/message_field.h"
|
2017-11-28 20:01:00 +00:00
|
|
|
#include "info/info_memento.h"
|
2017-12-05 14:07:01 +00:00
|
|
|
#include "info/info_controller.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "apiwrap.h"
|
2017-08-01 12:01:42 +00:00
|
|
|
#include "dialogs/dialogs_widget.h"
|
2018-01-04 19:54:35 +00:00
|
|
|
#include "dialogs/dialogs_key.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history.h"
|
2017-06-29 10:27:09 +00:00
|
|
|
#include "history/history_widget.h"
|
2022-12-14 12:15:46 +00:00
|
|
|
#include "history/history_item.h"
|
|
|
|
#include "history/history_item_helpers.h" // GetErrorTextForSending.
|
2019-08-02 13:21:09 +00:00
|
|
|
#include "history/view/media/history_view_media.h"
|
2018-01-09 17:08:31 +00:00
|
|
|
#include "history/view/history_view_service_message.h"
|
2018-01-11 19:33:26 +00:00
|
|
|
#include "history/view/history_view_element.h"
|
2017-04-13 08:27:10 +00:00
|
|
|
#include "lang/lang_keys.h"
|
2017-04-18 15:21:03 +00:00
|
|
|
#include "lang/lang_cloud_manager.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/add_contact_box.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "mainwindow.h"
|
2016-04-10 18:18:26 +00:00
|
|
|
#include "inline_bots/inline_bot_layout_item.h"
|
2021-10-18 21:36:55 +00:00
|
|
|
#include "ui/boxes/confirm_box.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/sticker_set_box.h"
|
2017-08-15 09:35:19 +00:00
|
|
|
#include "boxes/peer_list_controllers.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/download_path_box.h"
|
2018-05-07 17:44:33 +00:00
|
|
|
#include "boxes/connection_box.h"
|
2020-06-09 16:57:05 +00:00
|
|
|
#include "storage/storage_account.h"
|
2023-02-15 04:44:10 +00:00
|
|
|
#include "main/main_domain.h"
|
2019-02-13 12:36:59 +00:00
|
|
|
#include "media/audio/media_audio.h"
|
2016-10-12 19:34:25 +00:00
|
|
|
#include "media/player/media_player_panel.h"
|
2016-09-17 19:28:33 +00:00
|
|
|
#include "media/player/media_player_widget.h"
|
2021-11-18 17:02:12 +00:00
|
|
|
#include "media/player/media_player_dropdown.h"
|
2016-09-23 16:04:26 +00:00
|
|
|
#include "media/player/media_player_instance.h"
|
2017-05-22 15:25:49 +00:00
|
|
|
#include "media/player/media_player_float.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "base/qthelp_regex.h"
|
|
|
|
#include "base/qthelp_url.h"
|
2017-08-11 07:16:07 +00:00
|
|
|
#include "base/flat_set.h"
|
2020-06-17 09:36:25 +00:00
|
|
|
#include "mtproto/mtproto_dc_options.h"
|
2017-02-28 15:43:03 +00:00
|
|
|
#include "core/file_utilities.h"
|
2018-04-26 16:14:21 +00:00
|
|
|
#include "core/update_checker.h"
|
2018-11-16 12:15:14 +00:00
|
|
|
#include "core/shortcuts.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/application.h"
|
2020-06-18 11:17:58 +00:00
|
|
|
#include "core/changelogs.h"
|
2022-11-01 07:18:56 +00:00
|
|
|
#include "core/mime_type.h"
|
2019-07-10 17:28:33 +00:00
|
|
|
#include "base/unixtime.h"
|
2021-04-22 16:05:17 +00:00
|
|
|
#include "calls/calls_call.h"
|
2017-04-19 09:44:07 +00:00
|
|
|
#include "calls/calls_instance.h"
|
2017-04-25 20:36:04 +00:00
|
|
|
#include "calls/calls_top_bar.h"
|
2021-04-22 16:05:17 +00:00
|
|
|
#include "calls/group/calls_group_call.h"
|
2018-06-22 23:18:43 +00:00
|
|
|
#include "export/export_settings.h"
|
2020-06-25 07:14:05 +00:00
|
|
|
#include "export/export_manager.h"
|
2018-06-20 00:02:36 +00:00
|
|
|
#include "export/view/export_view_top_bar.h"
|
|
|
|
#include "export/view/export_view_panel_controller.h"
|
2019-07-24 11:45:24 +00:00
|
|
|
#include "main/main_session.h"
|
2020-06-18 12:47:09 +00:00
|
|
|
#include "main/main_session_settings.h"
|
2019-11-22 09:40:52 +00:00
|
|
|
#include "main/main_account.h"
|
2018-12-03 11:20:31 +00:00
|
|
|
#include "support/support_helper.h"
|
2017-09-04 11:40:02 +00:00
|
|
|
#include "storage/storage_facade.h"
|
|
|
|
#include "storage/storage_shared_media.h"
|
2017-08-29 19:52:52 +00:00
|
|
|
#include "storage/storage_user_photos.h"
|
2018-01-04 17:15:04 +00:00
|
|
|
#include "styles/style_dialogs.h"
|
2020-10-10 09:15:37 +00:00
|
|
|
#include "styles/style_chat.h"
|
2018-01-04 17:15:04 +00:00
|
|
|
#include "styles/style_boxes.h"
|
2022-12-19 11:48:24 +00:00
|
|
|
#include "styles/style_window.h"
|
2016-04-05 07:45:53 +00:00
|
|
|
|
2019-09-04 07:19:15 +00:00
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
#include <QtCore/QMimeData>
|
|
|
|
|
2017-10-03 18:13:36 +00:00
|
|
|
enum StackItemType {
|
|
|
|
HistoryStackItem,
|
|
|
|
SectionStackItem,
|
|
|
|
};
|
|
|
|
|
|
|
|
class StackItem {
|
|
|
|
public:
|
2022-10-12 12:57:17 +00:00
|
|
|
explicit StackItem(PeerData *peer) : _peer(peer) {
|
2017-10-03 18:13:36 +00:00
|
|
|
}
|
|
|
|
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] PeerData *peer() const {
|
2017-10-03 18:13:36 +00:00
|
|
|
return _peer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setThirdSectionMemento(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> memento);
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] auto takeThirdSectionMemento()
|
|
|
|
-> std::shared_ptr<Window::SectionMemento> {
|
2017-11-28 20:01:00 +00:00
|
|
|
return std::move(_thirdSectionMemento);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setThirdSectionWeak(QPointer<Window::SectionWidget> section) {
|
|
|
|
_thirdSectionWeak = section;
|
|
|
|
}
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] QPointer<Window::SectionWidget> thirdSectionWeak() const {
|
2017-11-28 20:01:00 +00:00
|
|
|
return _thirdSectionWeak;
|
2017-10-03 18:13:36 +00:00
|
|
|
}
|
|
|
|
|
2022-10-12 12:57:17 +00:00
|
|
|
[[nodiscard]] rpl::lifetime &lifetime() {
|
|
|
|
return _lifetime;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] virtual StackItemType type() const = 0;
|
2023-01-21 05:42:57 +00:00
|
|
|
[[nodiscard]] rpl::producer<> removeRequests() const {
|
|
|
|
return rpl::merge(
|
|
|
|
_thirdSectionRemoveRequests.events(),
|
|
|
|
sectionRemoveRequests());
|
|
|
|
}
|
2017-10-03 18:13:36 +00:00
|
|
|
virtual ~StackItem() = default;
|
|
|
|
|
|
|
|
private:
|
2023-01-21 05:42:57 +00:00
|
|
|
[[nodiscard]] virtual rpl::producer<> sectionRemoveRequests() const = 0;
|
|
|
|
|
2017-10-03 18:13:36 +00:00
|
|
|
PeerData *_peer = nullptr;
|
2017-11-28 20:01:00 +00:00
|
|
|
QPointer<Window::SectionWidget> _thirdSectionWeak;
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> _thirdSectionMemento;
|
2023-01-21 05:42:57 +00:00
|
|
|
rpl::event_stream<> _thirdSectionRemoveRequests;
|
2017-10-03 18:13:36 +00:00
|
|
|
|
2022-10-12 12:57:17 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
2017-10-03 18:13:36 +00:00
|
|
|
};
|
|
|
|
|
2022-10-12 12:57:17 +00:00
|
|
|
class StackItemHistory final : public StackItem {
|
2017-10-03 18:13:36 +00:00
|
|
|
public:
|
|
|
|
StackItemHistory(
|
2018-01-04 17:15:04 +00:00
|
|
|
not_null<History*> history,
|
2017-10-03 18:13:36 +00:00
|
|
|
MsgId msgId,
|
2022-10-08 11:14:38 +00:00
|
|
|
QVector<FullMsgId> replyReturns)
|
2018-01-04 17:15:04 +00:00
|
|
|
: StackItem(history->peer)
|
|
|
|
, history(history)
|
2017-10-03 18:13:36 +00:00
|
|
|
, msgId(msgId)
|
|
|
|
, replyReturns(replyReturns) {
|
|
|
|
}
|
|
|
|
|
|
|
|
StackItemType type() const override {
|
|
|
|
return HistoryStackItem;
|
|
|
|
}
|
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
not_null<History*> history;
|
2017-10-03 18:13:36 +00:00
|
|
|
MsgId msgId;
|
2022-10-08 11:14:38 +00:00
|
|
|
QVector<FullMsgId> replyReturns;
|
2017-10-03 18:13:36 +00:00
|
|
|
|
2023-01-21 05:42:57 +00:00
|
|
|
private:
|
|
|
|
rpl::producer<> sectionRemoveRequests() const override {
|
|
|
|
return rpl::never<>();
|
|
|
|
}
|
|
|
|
|
2017-10-03 18:13:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class StackItemSection : public StackItem {
|
|
|
|
public:
|
|
|
|
StackItemSection(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> memento);
|
2017-10-03 18:13:36 +00:00
|
|
|
|
|
|
|
StackItemType type() const override {
|
|
|
|
return SectionStackItem;
|
|
|
|
}
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> takeMemento() {
|
2020-11-21 22:37:05 +00:00
|
|
|
return std::move(_memento);
|
2017-10-03 18:13:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2023-01-21 05:42:57 +00:00
|
|
|
rpl::producer<> sectionRemoveRequests() const override;
|
|
|
|
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> _memento;
|
2017-10-03 18:13:36 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
void StackItem::setThirdSectionMemento(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> memento) {
|
2017-10-03 18:13:36 +00:00
|
|
|
_thirdSectionMemento = std::move(memento);
|
2023-01-21 05:42:57 +00:00
|
|
|
if (const auto memento = _thirdSectionMemento.get()) {
|
|
|
|
memento->removeRequests(
|
|
|
|
) | rpl::start_to_stream(_thirdSectionRemoveRequests, _lifetime);
|
|
|
|
}
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 18:13:36 +00:00
|
|
|
StackItemSection::StackItemSection(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> memento)
|
2017-10-03 18:13:36 +00:00
|
|
|
: StackItem(nullptr)
|
|
|
|
, _memento(std::move(memento)) {
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
|
|
|
|
2023-01-21 05:42:57 +00:00
|
|
|
rpl::producer<> StackItemSection::sectionRemoveRequests() const {
|
|
|
|
if (const auto topic = _memento->topicForRemoveRequests()) {
|
|
|
|
return rpl::merge(_memento->removeRequests(), topic->destroyed());
|
|
|
|
}
|
|
|
|
return _memento->removeRequests();
|
|
|
|
}
|
|
|
|
|
2019-01-16 12:39:35 +00:00
|
|
|
struct MainWidget::SettingBackground {
|
2019-01-28 13:59:49 +00:00
|
|
|
explicit SettingBackground(const Data::WallPaper &data);
|
|
|
|
|
2019-01-16 12:39:35 +00:00
|
|
|
Data::WallPaper data;
|
2020-04-10 13:18:51 +00:00
|
|
|
std::shared_ptr<Data::DocumentMedia> dataMedia;
|
2019-01-16 12:39:35 +00:00
|
|
|
base::binary_guard generating;
|
|
|
|
};
|
|
|
|
|
2019-01-28 13:59:49 +00:00
|
|
|
MainWidget::SettingBackground::SettingBackground(
|
|
|
|
const Data::WallPaper &data)
|
|
|
|
: data(data) {
|
|
|
|
}
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
MainWidget::MainWidget(
|
|
|
|
QWidget *parent,
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionController*> controller)
|
2017-09-13 16:57:44 +00:00
|
|
|
: RpWidget(parent)
|
2017-04-07 18:10:49 +00:00
|
|
|
, _controller(controller)
|
2017-11-12 16:50:58 +00:00
|
|
|
, _dialogsWidth(st::columnMinimalWidthLeft)
|
|
|
|
, _thirdColumnWidth(st::columnMinimalWidthThird)
|
2022-01-04 13:13:00 +00:00
|
|
|
, _sideShadow(isPrimary()
|
|
|
|
? base::make_unique_q<Ui::PlainShadow>(this)
|
|
|
|
: nullptr)
|
|
|
|
, _dialogs(isPrimary()
|
2022-11-30 06:31:33 +00:00
|
|
|
? base::make_unique_q<Dialogs::Widget>(
|
|
|
|
this,
|
|
|
|
_controller,
|
|
|
|
Dialogs::Widget::Layout::Main)
|
2022-01-04 13:13:00 +00:00
|
|
|
: nullptr)
|
|
|
|
, _history(std::in_place, this, _controller)
|
2019-02-28 21:03:25 +00:00
|
|
|
, _playerPlaylist(this, _controller)
|
2020-06-18 11:17:58 +00:00
|
|
|
, _changelogs(Core::Changelogs::Create(&controller->session())) {
|
2022-06-16 08:25:37 +00:00
|
|
|
if (isPrimary()) {
|
|
|
|
setupConnectingWidget();
|
|
|
|
}
|
2015-02-03 15:02:46 +00:00
|
|
|
|
2020-11-12 16:19:04 +00:00
|
|
|
_history->cancelRequests(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
handleHistoryBack();
|
|
|
|
}, lifetime());
|
2019-05-11 10:46:04 +00:00
|
|
|
|
2020-06-25 17:57:36 +00:00
|
|
|
Core::App().calls().currentCallValue(
|
|
|
|
) | rpl::start_with_next([=](Calls::Call *call) {
|
2020-06-25 07:14:05 +00:00
|
|
|
setCurrentCall(call);
|
2020-06-25 17:57:36 +00:00
|
|
|
}, lifetime());
|
2020-11-24 14:40:10 +00:00
|
|
|
Core::App().calls().currentGroupCallValue(
|
|
|
|
) | rpl::start_with_next([=](Calls::GroupCall *call) {
|
|
|
|
setCurrentGroupCall(call);
|
|
|
|
}, lifetime());
|
2020-06-25 17:57:36 +00:00
|
|
|
if (_callTopBar) {
|
|
|
|
_callTopBar->finishAnimating();
|
|
|
|
}
|
2018-06-20 00:02:36 +00:00
|
|
|
|
2023-01-19 07:40:39 +00:00
|
|
|
controller->window().setDefaultFloatPlayerDelegate(
|
|
|
|
floatPlayerDelegate());
|
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
Core::App().floatPlayerClosed(
|
|
|
|
) | rpl::start_with_next([=](FullMsgId itemId) {
|
|
|
|
floatPlayerClosed(itemId);
|
2020-06-25 15:01:10 +00:00
|
|
|
}, lifetime());
|
2020-06-25 14:17:37 +00:00
|
|
|
|
2020-06-25 07:14:05 +00:00
|
|
|
Core::App().exportManager().currentView(
|
2018-06-20 00:02:36 +00:00
|
|
|
) | rpl::start_with_next([=](Export::View::PanelController *view) {
|
|
|
|
setCurrentExportView(view);
|
|
|
|
}, lifetime());
|
2020-06-25 07:14:05 +00:00
|
|
|
if (_exportTopBar) {
|
|
|
|
_exportTopBar->finishAnimating();
|
|
|
|
}
|
2018-06-20 00:02:36 +00:00
|
|
|
|
2023-01-19 05:38:52 +00:00
|
|
|
Media::Player::instance()->closePlayerRequests(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
closeBothPlayers();
|
|
|
|
}, lifetime());
|
|
|
|
|
2020-06-25 11:12:50 +00:00
|
|
|
Media::Player::instance()->updatedNotifier(
|
|
|
|
) | rpl::start_with_next([=](const Media::Player::TrackState &state) {
|
|
|
|
handleAudioUpdate(state);
|
|
|
|
}, lifetime());
|
|
|
|
handleAudioUpdate(Media::Player::instance()->getState(AudioMsgId::Type::Song));
|
|
|
|
handleAudioUpdate(Media::Player::instance()->getState(AudioMsgId::Type::Voice));
|
|
|
|
if (_player) {
|
|
|
|
_player->finishAnimating();
|
|
|
|
}
|
|
|
|
|
2022-11-11 07:21:40 +00:00
|
|
|
rpl::merge(
|
|
|
|
_controller->dialogsListFocusedChanges(),
|
|
|
|
_controller->dialogsListDisplayForcedChanges()
|
|
|
|
) | rpl::start_with_next([=] {
|
2017-01-14 18:50:16 +00:00
|
|
|
updateDialogsWidthAnimated();
|
2022-11-11 07:21:40 +00:00
|
|
|
}, lifetime());
|
|
|
|
|
2017-11-12 16:50:58 +00:00
|
|
|
rpl::merge(
|
2020-06-25 12:16:09 +00:00
|
|
|
Core::App().settings().dialogsWidthRatioChanges() | rpl::to_empty,
|
|
|
|
Core::App().settings().thirdColumnWidthChanges() | rpl::to_empty
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
updateControlsGeometry();
|
|
|
|
}, lifetime());
|
2017-09-26 13:53:51 +00:00
|
|
|
|
2020-06-12 14:09:04 +00:00
|
|
|
session().changes().historyUpdates(
|
|
|
|
Data::HistoryUpdate::Flag::MessageSent
|
|
|
|
) | rpl::start_with_next([=](const Data::HistoryUpdate &update) {
|
|
|
|
const auto history = update.history;
|
2022-11-01 04:46:31 +00:00
|
|
|
history->forgetScrollState();
|
|
|
|
if (const auto from = history->peer->migrateFrom()) {
|
|
|
|
auto &owner = history->owner();
|
|
|
|
if (const auto migrated = owner.historyLoaded(from)) {
|
|
|
|
migrated->forgetScrollState();
|
2021-01-15 16:55:22 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-12 12:12:34 +00:00
|
|
|
}, lifetime());
|
|
|
|
|
2022-11-01 04:46:31 +00:00
|
|
|
session().changes().entryUpdates(
|
|
|
|
Data::EntryUpdate::Flag::LocalDraftSet
|
|
|
|
) | rpl::start_with_next([=](const Data::EntryUpdate &update) {
|
2023-03-08 12:48:23 +00:00
|
|
|
auto params = Window::SectionShow();
|
|
|
|
params.reapplyLocalDraft = true;
|
|
|
|
controller->showThread(
|
|
|
|
update.entry->asThread(),
|
|
|
|
ShowAtUnreadMsgId,
|
|
|
|
params);
|
2022-11-01 04:46:31 +00:00
|
|
|
controller->hideLayer();
|
|
|
|
}, lifetime());
|
|
|
|
|
2018-08-14 19:12:41 +00:00
|
|
|
// MSVC BUG + REGRESSION rpl::mappers::tuple :(
|
2017-09-26 13:53:51 +00:00
|
|
|
using namespace rpl::mappers;
|
2018-01-22 16:42:25 +00:00
|
|
|
_controller->activeChatValue(
|
|
|
|
) | rpl::map([](Dialogs::Key key) {
|
|
|
|
const auto peer = key.peer();
|
2022-10-25 07:20:22 +00:00
|
|
|
const auto topic = key.topic();
|
|
|
|
auto canWrite = topic
|
2023-01-10 18:56:20 +00:00
|
|
|
? Data::CanSendAnyOfValue(
|
|
|
|
topic,
|
|
|
|
Data::TabbedPanelSendRestrictions())
|
2022-10-25 07:20:22 +00:00
|
|
|
: peer
|
2023-01-10 18:56:20 +00:00
|
|
|
? Data::CanSendAnyOfValue(
|
|
|
|
|
|
|
|
peer, Data::TabbedPanelSendRestrictions())
|
2017-12-22 07:05:20 +00:00
|
|
|
: rpl::single(false);
|
2018-08-14 19:12:41 +00:00
|
|
|
return std::move(
|
|
|
|
canWrite
|
|
|
|
) | rpl::map([=](bool can) {
|
|
|
|
return std::make_tuple(key, can);
|
|
|
|
});
|
2017-12-22 07:05:20 +00:00
|
|
|
}) | rpl::flatten_latest(
|
2018-01-22 16:42:25 +00:00
|
|
|
) | rpl::start_with_next([this](Dialogs::Key key, bool canWrite) {
|
|
|
|
updateThirdColumnToCurrentChat(key, canWrite);
|
2017-12-22 07:05:20 +00:00
|
|
|
}, lifetime());
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2017-02-23 10:59:19 +00:00
|
|
|
QCoreApplication::instance()->installEventFilter(this);
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2021-11-19 11:55:09 +00:00
|
|
|
Media::Player::instance()->tracksFinished(
|
|
|
|
) | rpl::start_with_next([=](AudioMsgId::Type type) {
|
2017-05-21 13:16:39 +00:00
|
|
|
if (type == AudioMsgId::Type::Voice) {
|
2023-01-19 05:38:52 +00:00
|
|
|
const auto songState = Media::Player::instance()->getState(
|
|
|
|
AudioMsgId::Type::Song);
|
2017-05-21 13:16:39 +00:00
|
|
|
if (!songState.id || IsStoppedOrStopping(songState.state)) {
|
2023-01-19 05:38:52 +00:00
|
|
|
Media::Player::instance()->stopAndClose();
|
2017-05-21 13:16:39 +00:00
|
|
|
}
|
2020-10-23 12:22:38 +00:00
|
|
|
} else if (type == AudioMsgId::Type::Song) {
|
2023-01-19 05:38:52 +00:00
|
|
|
const auto songState = Media::Player::instance()->getState(
|
|
|
|
AudioMsgId::Type::Song);
|
2020-10-23 12:22:38 +00:00
|
|
|
if (!songState.id) {
|
2023-01-19 05:38:52 +00:00
|
|
|
Media::Player::instance()->stopAndClose();
|
2020-10-23 12:22:38 +00:00
|
|
|
}
|
2017-05-21 13:16:39 +00:00
|
|
|
}
|
2021-11-19 11:55:09 +00:00
|
|
|
}, lifetime());
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2021-06-24 05:33:52 +00:00
|
|
|
_controller->adaptive().changes(
|
2021-05-26 23:20:27 +00:00
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
handleAdaptiveLayoutUpdate();
|
|
|
|
}, lifetime());
|
2016-08-27 04:49:18 +00:00
|
|
|
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
_dialogs->show();
|
|
|
|
}
|
|
|
|
if (_dialogs && isOneColumn()) {
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->hide();
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->show();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
orderWidgets();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-07-11 22:14:44 +00:00
|
|
|
if (!Core::UpdaterDisabled()) {
|
|
|
|
Core::UpdateChecker checker;
|
|
|
|
checker.start();
|
|
|
|
}
|
2020-06-16 14:19:23 +00:00
|
|
|
|
|
|
|
cSetOtherOnline(0);
|
2020-06-24 12:52:06 +00:00
|
|
|
|
2020-06-16 14:19:23 +00:00
|
|
|
_history->start();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2020-06-11 09:41:03 +00:00
|
|
|
MainWidget::~MainWidget() = default;
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
Main::Session &MainWidget::session() const {
|
2019-01-18 12:27:37 +00:00
|
|
|
return _controller->session();
|
|
|
|
}
|
|
|
|
|
2020-06-10 18:08:17 +00:00
|
|
|
not_null<Window::SessionController*> MainWidget::controller() const {
|
|
|
|
return _controller;
|
|
|
|
}
|
|
|
|
|
2018-05-07 17:44:33 +00:00
|
|
|
void MainWidget::setupConnectingWidget() {
|
|
|
|
using namespace rpl::mappers;
|
2019-02-10 16:29:55 +00:00
|
|
|
_connecting = std::make_unique<Window::ConnectionState>(
|
2018-05-07 17:44:33 +00:00
|
|
|
this,
|
2020-06-10 14:52:44 +00:00
|
|
|
&session().account(),
|
2021-05-26 23:20:27 +00:00
|
|
|
_controller->adaptive().oneColumnValue() | rpl::map(!_1));
|
2022-03-01 15:38:45 +00:00
|
|
|
_controller->connectingBottomSkipValue(
|
|
|
|
) | rpl::start_with_next([=](int skip) {
|
|
|
|
_connecting->setBottomSkip(skip);
|
|
|
|
}, lifetime());
|
2018-05-07 17:44:33 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 11:16:09 +00:00
|
|
|
not_null<Media::Player::FloatDelegate*> MainWidget::floatPlayerDelegate() {
|
|
|
|
return static_cast<Media::Player::FloatDelegate*>(this);
|
2017-05-23 14:04:59 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 11:16:09 +00:00
|
|
|
not_null<Ui::RpWidget*> MainWidget::floatPlayerWidget() {
|
|
|
|
return this;
|
2017-05-24 12:07:58 +00:00
|
|
|
}
|
|
|
|
|
2023-01-19 07:40:39 +00:00
|
|
|
void MainWidget::floatPlayerToggleGifsPaused(bool paused) {
|
|
|
|
constexpr auto kReason = Window::GifPauseReason::RoundPlaying;
|
|
|
|
if (paused) {
|
|
|
|
_controller->enableGifPauseReason(kReason);
|
|
|
|
} else {
|
|
|
|
_controller->disableGifPauseReason(kReason);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
auto MainWidget::floatPlayerGetSection(Window::Column column)
|
|
|
|
-> not_null<Media::Player::FloatSectionDelegate*> {
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isThreeColumn()) {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs && column == Window::Column::First) {
|
2017-05-22 15:25:49 +00:00
|
|
|
return _dialogs;
|
2017-09-16 16:53:41 +00:00
|
|
|
} else if (column == Window::Column::Second
|
2022-01-04 13:13:00 +00:00
|
|
|
|| !_dialogs
|
2017-09-16 16:53:41 +00:00
|
|
|
|| !_thirdSection) {
|
|
|
|
if (_mainSection) {
|
|
|
|
return _mainSection;
|
|
|
|
}
|
2017-05-22 15:25:49 +00:00
|
|
|
return _history;
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
return _thirdSection;
|
2021-05-26 23:20:27 +00:00
|
|
|
} else if (isNormalColumn()) {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs && column == Window::Column::First) {
|
2017-09-16 16:53:41 +00:00
|
|
|
return _dialogs;
|
|
|
|
} else if (_mainSection) {
|
|
|
|
return _mainSection;
|
|
|
|
}
|
|
|
|
return _history;
|
|
|
|
} else if (_mainSection) {
|
|
|
|
return _mainSection;
|
2021-05-26 23:20:27 +00:00
|
|
|
} else if (!isOneColumn() || _history->peer()) {
|
2017-09-16 16:53:41 +00:00
|
|
|
return _history;
|
2017-05-22 15:25:49 +00:00
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
Assert(_dialogs != nullptr);
|
2017-09-16 16:53:41 +00:00
|
|
|
return _dialogs;
|
2017-05-22 15:25:49 +00:00
|
|
|
}
|
|
|
|
|
2018-11-05 11:16:09 +00:00
|
|
|
void MainWidget::floatPlayerEnumerateSections(Fn<void(
|
2020-06-25 14:17:37 +00:00
|
|
|
not_null<Media::Player::FloatSectionDelegate*> widget,
|
2018-11-05 11:16:09 +00:00
|
|
|
Window::Column widgetColumn)> callback) {
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isThreeColumn()) {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
callback(_dialogs, Window::Column::First);
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_mainSection) {
|
2018-11-05 11:16:09 +00:00
|
|
|
callback(_mainSection, Window::Column::Second);
|
2017-05-23 18:00:57 +00:00
|
|
|
} else {
|
2018-11-05 11:16:09 +00:00
|
|
|
callback(_history, Window::Column::Second);
|
2017-05-23 18:00:57 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_thirdSection) {
|
2018-11-05 11:16:09 +00:00
|
|
|
callback(_thirdSection, Window::Column::Third);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
2021-05-26 23:20:27 +00:00
|
|
|
} else if (isNormalColumn()) {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
callback(_dialogs, Window::Column::First);
|
|
|
|
}
|
2017-11-13 08:05:56 +00:00
|
|
|
if (_mainSection) {
|
2018-11-05 11:16:09 +00:00
|
|
|
callback(_mainSection, Window::Column::Second);
|
2017-05-23 18:00:57 +00:00
|
|
|
} else {
|
2018-11-05 11:16:09 +00:00
|
|
|
callback(_history, Window::Column::Second);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-11-30 12:02:40 +00:00
|
|
|
if (_mainSection) {
|
2018-11-05 11:16:09 +00:00
|
|
|
callback(_mainSection, Window::Column::Second);
|
2021-05-26 23:20:27 +00:00
|
|
|
} else if (!isOneColumn() || _history->peer()) {
|
2018-11-05 11:16:09 +00:00
|
|
|
callback(_history, Window::Column::Second);
|
2017-09-16 16:53:41 +00:00
|
|
|
} else {
|
2022-01-04 13:13:00 +00:00
|
|
|
Assert(_dialogs != nullptr);
|
2018-11-05 11:16:09 +00:00
|
|
|
callback(_dialogs, Window::Column::First);
|
2017-05-23 18:00:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-11-05 13:18:54 +00:00
|
|
|
bool MainWidget::floatPlayerIsVisible(not_null<HistoryItem*> item) {
|
2022-03-09 10:52:44 +00:00
|
|
|
return session().data().queryItemVisibility(item);
|
2018-11-05 13:18:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::floatPlayerClosed(FullMsgId itemId) {
|
2018-11-05 11:16:09 +00:00
|
|
|
if (_player) {
|
|
|
|
const auto voiceData = Media::Player::instance()->current(
|
|
|
|
AudioMsgId::Type::Voice);
|
|
|
|
if (voiceData.contextId() == itemId) {
|
2020-11-10 13:52:17 +00:00
|
|
|
stopAndClosePlayer();
|
2017-05-23 18:00:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-15 23:06:22 +00:00
|
|
|
void MainWidget::floatPlayerDoubleClickEvent(
|
|
|
|
not_null<const HistoryItem*> item) {
|
2022-10-28 12:30:59 +00:00
|
|
|
_controller->showMessage(item);
|
2021-06-15 23:06:22 +00:00
|
|
|
}
|
|
|
|
|
2022-11-01 04:46:31 +00:00
|
|
|
bool MainWidget::setForwardDraft(
|
|
|
|
not_null<Data::Thread*> thread,
|
|
|
|
Data::ForwardDraft &&draft) {
|
|
|
|
const auto history = thread->owningHistory();
|
2022-10-25 07:20:22 +00:00
|
|
|
const auto items = session().data().idsToItems(draft.ids);
|
2022-11-01 04:46:31 +00:00
|
|
|
const auto topicRootId = thread->topicRootId();
|
2019-08-30 13:17:46 +00:00
|
|
|
const auto error = GetErrorTextForSending(
|
2022-11-01 04:46:31 +00:00
|
|
|
history->peer,
|
|
|
|
{
|
|
|
|
.topicRootId = topicRootId,
|
|
|
|
.forward = &items,
|
|
|
|
.ignoreSlowmodeCountdown = true,
|
|
|
|
});
|
2017-07-11 17:11:06 +00:00
|
|
|
if (!error.isEmpty()) {
|
2023-01-10 18:56:20 +00:00
|
|
|
_controller->show(Ui::MakeInformBox(error));
|
2017-07-11 10:23:15 +00:00
|
|
|
return false;
|
2017-06-11 18:33:20 +00:00
|
|
|
}
|
|
|
|
|
2022-11-01 04:46:31 +00:00
|
|
|
history->setForwardDraft(topicRootId, std::move(draft));
|
|
|
|
_controller->showThread(
|
|
|
|
thread,
|
|
|
|
ShowAtUnreadMsgId,
|
|
|
|
SectionShow::Way::Forward);
|
2015-09-07 07:52:37 +00:00
|
|
|
return true;
|
2015-03-24 10:00:27 +00:00
|
|
|
}
|
|
|
|
|
2017-11-30 17:45:36 +00:00
|
|
|
bool MainWidget::shareUrl(
|
2022-11-01 04:46:31 +00:00
|
|
|
not_null<Data::Thread*> thread,
|
2017-11-30 17:45:36 +00:00
|
|
|
const QString &url,
|
2022-06-09 04:05:46 +00:00
|
|
|
const QString &text) const {
|
2023-01-10 18:56:20 +00:00
|
|
|
if (!Data::CanSendTexts(thread)) {
|
2022-06-09 04:05:46 +00:00
|
|
|
_controller->show(Ui::MakeInformBox(tr::lng_share_cant()));
|
2015-10-18 12:49:34 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-06-09 04:05:46 +00:00
|
|
|
const auto textWithTags = TextWithTags{
|
2017-11-30 17:45:36 +00:00
|
|
|
url + '\n' + text,
|
|
|
|
TextWithTags::Tags()
|
|
|
|
};
|
2022-06-09 04:05:46 +00:00
|
|
|
const auto cursor = MessageCursor{
|
2021-10-19 13:00:21 +00:00
|
|
|
int(url.size()) + 1,
|
|
|
|
int(url.size()) + 1 + int(text.size()),
|
2017-11-30 17:45:36 +00:00
|
|
|
QFIXED_MAX
|
|
|
|
};
|
2022-11-01 04:46:31 +00:00
|
|
|
const auto history = thread->owningHistory();
|
|
|
|
const auto topicRootId = thread->topicRootId();
|
2021-01-29 11:27:17 +00:00
|
|
|
history->setLocalDraft(std::make_unique<Data::Draft>(
|
|
|
|
textWithTags,
|
2022-10-17 16:29:48 +00:00
|
|
|
0, // replyTo
|
|
|
|
topicRootId,
|
2021-01-29 11:27:17 +00:00
|
|
|
cursor,
|
|
|
|
Data::PreviewState::Allowed));
|
2022-10-17 16:29:48 +00:00
|
|
|
history->clearLocalEditDraft(topicRootId);
|
2022-11-01 04:46:31 +00:00
|
|
|
history->session().changes().entryUpdated(
|
|
|
|
thread,
|
|
|
|
Data::EntryUpdate::Flag::LocalDraftSet);
|
2015-10-18 12:49:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-11-30 12:02:40 +00:00
|
|
|
bool MainWidget::sendPaths(
|
|
|
|
not_null<Data::Thread*> thread,
|
|
|
|
const QStringList &paths) {
|
2023-01-10 18:56:20 +00:00
|
|
|
if (!Data::CanSendAnyOf(thread, Data::FilesSendRestrictions())) {
|
|
|
|
_controller->show(Ui::MakeInformBox(
|
|
|
|
tr::lng_forward_send_files_cant()));
|
2017-06-11 18:33:20 +00:00
|
|
|
return false;
|
2023-01-10 18:56:20 +00:00
|
|
|
} else if (const auto error = Data::AnyFileRestrictionError(
|
|
|
|
thread->peer())) {
|
|
|
|
_controller->show(Ui::MakeInformBox(*error));
|
2019-01-05 10:50:04 +00:00
|
|
|
return false;
|
2022-11-01 04:46:31 +00:00
|
|
|
} else {
|
2022-11-30 06:31:33 +00:00
|
|
|
_controller->showThread(
|
2022-11-01 04:46:31 +00:00
|
|
|
thread,
|
|
|
|
ShowAtTheEndMsgId,
|
|
|
|
Window::SectionShow::Way::ClearStack);
|
|
|
|
}
|
2022-11-30 06:31:33 +00:00
|
|
|
return (_controller->activeChatCurrent().thread() == thread)
|
2022-11-01 07:18:56 +00:00
|
|
|
&& (_mainSection
|
2022-11-30 12:02:40 +00:00
|
|
|
? _mainSection->confirmSendingFiles(paths)
|
|
|
|
: _history->confirmSendingFiles(paths));
|
2014-07-18 10:37:34 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 12:02:40 +00:00
|
|
|
bool MainWidget::filesOrForwardDrop(
|
2022-11-01 04:46:31 +00:00
|
|
|
not_null<Data::Thread*> thread,
|
2022-11-01 07:18:56 +00:00
|
|
|
not_null<const QMimeData*> data) {
|
2022-11-01 09:00:17 +00:00
|
|
|
if (const auto forum = thread->asForum()) {
|
2022-11-01 07:18:56 +00:00
|
|
|
Window::ShowDropMediaBox(
|
|
|
|
_controller,
|
|
|
|
Core::ShareMimeMediaData(data),
|
|
|
|
forum);
|
|
|
|
if (_hider) {
|
|
|
|
_hider->startHide();
|
|
|
|
clearHider(_hider);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2022-11-29 21:46:36 +00:00
|
|
|
if (data->hasFormat(u"application/x-td-forward"_q)) {
|
2021-08-31 16:47:38 +00:00
|
|
|
auto draft = Data::ForwardDraft{
|
|
|
|
.ids = session().data().takeMimeForwardIds(),
|
|
|
|
};
|
2022-11-01 07:18:56 +00:00
|
|
|
if (setForwardDraft(thread, std::move(draft))) {
|
|
|
|
return true;
|
2022-11-01 04:46:31 +00:00
|
|
|
}
|
|
|
|
// We've already released the mouse button,
|
|
|
|
// so the forwarding is cancelled.
|
|
|
|
if (_hider) {
|
|
|
|
_hider->startHide();
|
|
|
|
clearHider(_hider);
|
2018-01-11 15:51:59 +00:00
|
|
|
}
|
2022-11-01 07:18:56 +00:00
|
|
|
return false;
|
2023-01-10 18:56:20 +00:00
|
|
|
} else if (!Data::CanSendAnyOf(thread, Data::FilesSendRestrictions())) {
|
|
|
|
_controller->show(Ui::MakeInformBox(
|
|
|
|
tr::lng_forward_send_files_cant()));
|
|
|
|
return false;
|
|
|
|
} else if (const auto error = Data::AnyFileRestrictionError(
|
|
|
|
thread->peer())) {
|
|
|
|
_controller->show(Ui::MakeInformBox(*error));
|
2022-11-01 07:18:56 +00:00
|
|
|
return false;
|
2015-06-27 13:02:00 +00:00
|
|
|
} else {
|
2022-11-30 06:31:33 +00:00
|
|
|
_controller->showThread(
|
2022-11-01 04:46:31 +00:00
|
|
|
thread,
|
|
|
|
ShowAtTheEndMsgId,
|
|
|
|
Window::SectionShow::Way::ClearStack);
|
2022-11-30 06:31:33 +00:00
|
|
|
if (_controller->activeChatCurrent().thread() != thread) {
|
2022-11-01 07:18:56 +00:00
|
|
|
return false;
|
2017-06-11 18:33:20 +00:00
|
|
|
}
|
2022-11-01 07:18:56 +00:00
|
|
|
(_mainSection
|
|
|
|
? _mainSection->confirmSendingFiles(data)
|
|
|
|
: _history->confirmSendingFiles(data));
|
|
|
|
return true;
|
2015-06-27 13:02:00 +00:00
|
|
|
}
|
2015-06-26 09:07:59 +00:00
|
|
|
}
|
|
|
|
|
2016-08-12 16:28:10 +00:00
|
|
|
bool MainWidget::notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) {
|
|
|
|
return _history->notify_switchInlineBotButtonReceived(query, samePeerBot, samePeerReplyTo);
|
2016-04-08 14:16:52 +00:00
|
|
|
}
|
|
|
|
|
2018-11-26 14:01:29 +00:00
|
|
|
void MainWidget::clearHider(not_null<Window::HistoryHider*> instance) {
|
|
|
|
if (_hider != instance) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_hider.release();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2018-11-26 14:01:29 +00:00
|
|
|
void MainWidget::hiderLayer(base::unique_qptr<Window::HistoryHider> hider) {
|
2022-11-30 06:31:33 +00:00
|
|
|
if (!_dialogs || _controller->window().locked()) {
|
2015-04-04 20:01:34 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2018-11-26 14:01:29 +00:00
|
|
|
_hider = std::move(hider);
|
|
|
|
_hider->setParent(this);
|
|
|
|
|
|
|
|
_hider->hidden(
|
|
|
|
) | rpl::start_with_next([=, instance = _hider.get()] {
|
|
|
|
clearHider(instance);
|
2019-10-07 14:28:36 +00:00
|
|
|
instance->hide();
|
2018-11-26 14:01:29 +00:00
|
|
|
instance->deleteLater();
|
|
|
|
}, _hider->lifetime());
|
|
|
|
|
2022-11-30 12:02:40 +00:00
|
|
|
_hider->show();
|
|
|
|
updateControlsGeometry();
|
|
|
|
_dialogs->setInnerFocus();
|
2014-12-12 16:27:03 +00:00
|
|
|
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerCheckVisibility();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 12:02:40 +00:00
|
|
|
void MainWidget::showDragForwardInfo() {
|
2018-11-26 14:01:29 +00:00
|
|
|
hiderLayer(base::make_unique_q<Window::HistoryHider>(
|
|
|
|
this,
|
2022-11-30 12:02:40 +00:00
|
|
|
tr::lng_forward_choose(tr::now)));
|
2015-10-18 12:49:34 +00:00
|
|
|
}
|
|
|
|
|
2022-11-30 12:02:40 +00:00
|
|
|
void MainWidget::hideDragForwardInfo() {
|
2022-11-01 04:46:31 +00:00
|
|
|
if (_hider) {
|
|
|
|
_hider->startHide();
|
|
|
|
_hider.release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-26 20:06:14 +00:00
|
|
|
void MainWidget::sendBotCommand(Bot::SendCommandRequest request) {
|
2021-07-26 23:18:11 +00:00
|
|
|
const auto type = _mainSection
|
|
|
|
? _mainSection->sendBotCommand(request)
|
|
|
|
: Window::SectionActionResult::Fallback;
|
|
|
|
if (type == Window::SectionActionResult::Fallback) {
|
2022-11-30 06:31:33 +00:00
|
|
|
_controller->showPeerHistory(
|
|
|
|
request.peer,
|
2022-07-05 05:11:22 +00:00
|
|
|
SectionShow::Way::Forward,
|
2021-07-26 23:18:11 +00:00
|
|
|
ShowAtTheEndMsgId);
|
|
|
|
_history->sendBotCommand(request);
|
|
|
|
}
|
2016-03-29 17:17:00 +00:00
|
|
|
}
|
|
|
|
|
2016-11-20 12:54:07 +00:00
|
|
|
void MainWidget::hideSingleUseKeyboard(PeerData *peer, MsgId replyTo) {
|
|
|
|
_history->hideSingleUseKeyboard(peer, replyTo);
|
|
|
|
}
|
|
|
|
|
2018-02-14 19:38:01 +00:00
|
|
|
void MainWidget::searchMessages(const QString &query, Dialogs::Key inChat) {
|
2023-01-18 09:35:52 +00:00
|
|
|
if (controller()->isPrimary()) {
|
|
|
|
_dialogs->searchMessages(query, inChat);
|
|
|
|
if (isOneColumn()) {
|
|
|
|
_controller->clearSectionStack();
|
|
|
|
} else {
|
|
|
|
_dialogs->setInnerFocus();
|
|
|
|
}
|
2015-09-21 20:57:42 +00:00
|
|
|
} else {
|
2023-01-18 09:35:52 +00:00
|
|
|
const auto searchIn = [&](not_null<Window::Controller*> window) {
|
|
|
|
if (const auto controller = window->sessionController()) {
|
|
|
|
controller->content()->searchMessages(query, inChat);
|
|
|
|
controller->widget()->activate();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const auto account = &session().account();
|
|
|
|
if (const auto peer = inChat.peer()) {
|
|
|
|
if (peer == controller()->singlePeer()) {
|
|
|
|
if (_history->peer() != peer) {
|
|
|
|
controller()->showPeerHistory(peer);
|
|
|
|
}
|
|
|
|
_history->searchInChatEmbedded(query);
|
|
|
|
} else if (const auto window = Core::App().windowFor(peer)) {
|
|
|
|
searchIn(window);
|
|
|
|
}
|
|
|
|
} else if (const auto window = Core::App().windowFor(account)) {
|
|
|
|
searchIn(window);
|
|
|
|
}
|
2015-09-21 20:57:42 +00:00
|
|
|
}
|
2014-07-16 06:58:36 +00:00
|
|
|
}
|
|
|
|
|
2019-03-04 11:28:52 +00:00
|
|
|
void MainWidget::handleAudioUpdate(const Media::Player::TrackState &state) {
|
2017-01-24 21:24:39 +00:00
|
|
|
using State = Media::Player::State;
|
2019-03-04 11:28:52 +00:00
|
|
|
const auto document = state.id.audio();
|
|
|
|
if (!Media::Player::IsStoppedOrStopping(state.state)) {
|
|
|
|
createPlayer();
|
|
|
|
} else if (state.state == State::StoppedAtStart) {
|
2023-01-19 05:38:52 +00:00
|
|
|
Media::Player::instance()->stopAndClose();
|
2015-07-03 08:47:16 +00:00
|
|
|
}
|
|
|
|
|
2019-04-25 12:45:15 +00:00
|
|
|
if (const auto item = session().data().message(state.id.contextId())) {
|
2019-01-18 12:27:37 +00:00
|
|
|
session().data().requestItemRepaint(item);
|
2016-09-21 11:44:20 +00:00
|
|
|
}
|
2021-06-11 15:11:58 +00:00
|
|
|
if (document) {
|
|
|
|
if (const auto items = InlineBots::Layout::documentItems()) {
|
|
|
|
if (const auto i = items->find(document); i != items->end()) {
|
2021-09-08 10:53:54 +00:00
|
|
|
for (const auto &item : i->second) {
|
2021-06-11 15:11:58 +00:00
|
|
|
item->update();
|
|
|
|
}
|
2018-01-17 16:21:01 +00:00
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-04 07:33:44 +00:00
|
|
|
}
|
|
|
|
|
2016-10-18 15:19:13 +00:00
|
|
|
void MainWidget::closeBothPlayers() {
|
2019-02-28 21:03:25 +00:00
|
|
|
if (_player) {
|
2017-10-01 08:15:40 +00:00
|
|
|
_player->hide(anim::type::normal);
|
2016-11-04 08:23:50 +00:00
|
|
|
}
|
2016-10-18 15:19:13 +00:00
|
|
|
_playerPlaylist->hideIgnoringEnterEvents();
|
|
|
|
}
|
|
|
|
|
2020-11-10 13:52:17 +00:00
|
|
|
void MainWidget::stopAndClosePlayer() {
|
|
|
|
if (_player) {
|
|
|
|
_player->entity()->stopAndClose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-12 19:34:25 +00:00
|
|
|
void MainWidget::createPlayer() {
|
2017-05-21 13:16:39 +00:00
|
|
|
if (!_player) {
|
2020-06-09 16:57:05 +00:00
|
|
|
_player.create(
|
|
|
|
this,
|
2021-11-24 14:26:39 +00:00
|
|
|
object_ptr<Media::Player::Widget>(this, this, _controller),
|
2021-05-26 21:29:12 +00:00
|
|
|
_controller->adaptive().oneColumnValue());
|
2017-12-21 06:50:35 +00:00
|
|
|
rpl::merge(
|
2020-06-21 16:25:29 +00:00
|
|
|
_player->heightValue() | rpl::map_to(true),
|
2017-12-22 07:05:20 +00:00
|
|
|
_player->shownValue()
|
|
|
|
) | rpl::start_with_next(
|
|
|
|
[this] { playerHeightUpdated(); },
|
2017-12-27 07:18:09 +00:00
|
|
|
_player->lifetime());
|
2023-01-19 05:38:52 +00:00
|
|
|
_player->entity()->setCloseCallback([=] {
|
|
|
|
Media::Player::instance()->stopAndClose();
|
|
|
|
});
|
2021-06-15 23:06:22 +00:00
|
|
|
_player->entity()->setShowItemCallback([=](
|
|
|
|
not_null<const HistoryItem*> item) {
|
2022-10-28 12:30:59 +00:00
|
|
|
_controller->showMessage(item);
|
2021-06-15 23:06:22 +00:00
|
|
|
});
|
2021-11-19 11:55:09 +00:00
|
|
|
|
|
|
|
_player->entity()->togglePlaylistRequests(
|
|
|
|
) | rpl::start_with_next([=](bool shown) {
|
|
|
|
if (!shown) {
|
|
|
|
_playerPlaylist->hideFromOther();
|
|
|
|
return;
|
|
|
|
} else if (_playerPlaylist->isHidden()) {
|
|
|
|
auto position = mapFromGlobal(QCursor::pos()).x();
|
|
|
|
auto bestPosition = _playerPlaylist->bestPositionFor(position);
|
|
|
|
if (rtl()) bestPosition = position + 2 * (position - bestPosition) - _playerPlaylist->width();
|
|
|
|
updateMediaPlaylistPosition(bestPosition);
|
|
|
|
}
|
|
|
|
_playerPlaylist->showFromOther();
|
|
|
|
}, _player->lifetime());
|
|
|
|
|
2017-05-21 13:16:39 +00:00
|
|
|
orderWidgets();
|
2022-12-01 10:14:35 +00:00
|
|
|
if (_showAnimation) {
|
2017-10-01 08:15:40 +00:00
|
|
|
_player->show(anim::type::instant);
|
|
|
|
_player->setVisible(false);
|
2018-12-13 08:48:31 +00:00
|
|
|
Shortcuts::ToggleMediaShortcuts(true);
|
2017-05-21 13:16:39 +00:00
|
|
|
} else {
|
2017-10-01 08:15:40 +00:00
|
|
|
_player->hide(anim::type::instant);
|
2017-05-21 13:16:39 +00:00
|
|
|
}
|
|
|
|
}
|
2017-10-01 08:15:40 +00:00
|
|
|
if (_player && !_player->toggled()) {
|
2022-12-01 10:14:35 +00:00
|
|
|
if (!_showAnimation) {
|
2017-10-01 08:15:40 +00:00
|
|
|
_player->show(anim::type::normal);
|
2016-11-04 08:23:50 +00:00
|
|
|
_playerHeight = _contentScrollAddToY = _player->contentHeight();
|
|
|
|
updateControlsGeometry();
|
2018-12-13 08:48:31 +00:00
|
|
|
Shortcuts::ToggleMediaShortcuts(true);
|
2016-11-04 08:23:50 +00:00
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::playerHeightUpdated() {
|
2017-12-27 07:18:09 +00:00
|
|
|
if (!_player) {
|
|
|
|
// Player could be already "destroyDelayed", but still handle events.
|
|
|
|
return;
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
auto playerHeight = _player->contentHeight();
|
|
|
|
if (playerHeight != _playerHeight) {
|
|
|
|
_contentScrollAddToY += playerHeight - _playerHeight;
|
|
|
|
_playerHeight = playerHeight;
|
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
2016-11-04 08:23:50 +00:00
|
|
|
if (!_playerHeight && _player->isHidden()) {
|
2019-02-28 21:03:25 +00:00
|
|
|
const auto state = Media::Player::instance()->getState(Media::Player::instance()->getActiveType());
|
2017-05-21 13:16:39 +00:00
|
|
|
if (!state.id || Media::Player::IsStoppedOrStopping(state.state)) {
|
2016-11-04 08:23:50 +00:00
|
|
|
_player.destroyDelayed();
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-25 20:36:04 +00:00
|
|
|
void MainWidget::setCurrentCall(Calls::Call *call) {
|
2020-11-24 14:40:10 +00:00
|
|
|
if (!call && _currentGroupCall) {
|
|
|
|
return;
|
|
|
|
}
|
2020-06-25 17:57:36 +00:00
|
|
|
_currentCallLifetime.destroy();
|
2017-04-25 20:36:04 +00:00
|
|
|
_currentCall = call;
|
|
|
|
if (_currentCall) {
|
2020-11-28 16:18:51 +00:00
|
|
|
_callTopBar.destroy();
|
2020-06-25 17:57:36 +00:00
|
|
|
_currentCall->stateValue(
|
|
|
|
) | rpl::start_with_next([=](Calls::Call::State state) {
|
2017-04-25 20:36:04 +00:00
|
|
|
using State = Calls::Call::State;
|
2020-11-28 16:18:51 +00:00
|
|
|
if (state != State::Established) {
|
2017-04-25 20:36:04 +00:00
|
|
|
destroyCallTopBar();
|
2020-11-28 16:18:51 +00:00
|
|
|
} else if (!_callTopBar) {
|
|
|
|
createCallTopBar();
|
2017-04-25 20:36:04 +00:00
|
|
|
}
|
2020-06-25 17:57:36 +00:00
|
|
|
}, _currentCallLifetime);
|
2017-04-25 20:36:04 +00:00
|
|
|
} else {
|
|
|
|
destroyCallTopBar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-24 14:40:10 +00:00
|
|
|
void MainWidget::setCurrentGroupCall(Calls::GroupCall *call) {
|
|
|
|
if (!call && _currentCall) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
_currentCallLifetime.destroy();
|
|
|
|
_currentGroupCall = call;
|
|
|
|
if (_currentGroupCall) {
|
2020-11-28 16:18:51 +00:00
|
|
|
_callTopBar.destroy();
|
2020-11-24 14:40:10 +00:00
|
|
|
_currentGroupCall->stateValue(
|
|
|
|
) | rpl::start_with_next([=](Calls::GroupCall::State state) {
|
|
|
|
using State = Calls::GroupCall::State;
|
2020-11-29 12:29:25 +00:00
|
|
|
if (state != State::Creating
|
2021-04-05 10:29:03 +00:00
|
|
|
&& state != State::Waiting
|
2020-11-29 12:29:25 +00:00
|
|
|
&& state != State::Joining
|
|
|
|
&& state != State::Joined
|
|
|
|
&& state != State::Connecting) {
|
2020-11-24 14:40:10 +00:00
|
|
|
destroyCallTopBar();
|
2020-11-28 16:18:51 +00:00
|
|
|
} else if (!_callTopBar) {
|
|
|
|
createCallTopBar();
|
2020-11-24 14:40:10 +00:00
|
|
|
}
|
|
|
|
}, _currentCallLifetime);
|
|
|
|
} else {
|
|
|
|
destroyCallTopBar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-25 20:36:04 +00:00
|
|
|
void MainWidget::createCallTopBar() {
|
2020-11-24 14:40:10 +00:00
|
|
|
Expects(_currentCall != nullptr || _currentGroupCall != nullptr);
|
2018-06-20 00:02:36 +00:00
|
|
|
|
2023-05-02 09:33:19 +00:00
|
|
|
const auto show = controller()->uiShow();
|
2020-11-24 14:40:10 +00:00
|
|
|
_callTopBar.create(
|
|
|
|
this,
|
|
|
|
(_currentCall
|
2022-06-14 11:20:38 +00:00
|
|
|
? object_ptr<Calls::TopBar>(this, _currentCall, show)
|
|
|
|
: object_ptr<Calls::TopBar>(this, _currentGroupCall, show)));
|
2020-12-09 11:43:54 +00:00
|
|
|
_callTopBar->entity()->initBlobsUnder(this, _callTopBar->geometryValue());
|
2017-12-22 07:05:20 +00:00
|
|
|
_callTopBar->heightValue(
|
|
|
|
) | rpl::start_with_next([this](int value) {
|
|
|
|
callTopBarHeightUpdated(value);
|
|
|
|
}, lifetime());
|
2017-04-25 20:36:04 +00:00
|
|
|
orderWidgets();
|
2022-12-01 10:14:35 +00:00
|
|
|
if (_showAnimation) {
|
2017-10-01 08:15:40 +00:00
|
|
|
_callTopBar->show(anim::type::instant);
|
|
|
|
_callTopBar->setVisible(false);
|
2017-04-25 20:36:04 +00:00
|
|
|
} else {
|
2017-10-01 08:15:40 +00:00
|
|
|
_callTopBar->hide(anim::type::instant);
|
|
|
|
_callTopBar->show(anim::type::normal);
|
2017-04-25 20:36:04 +00:00
|
|
|
_callTopBarHeight = _contentScrollAddToY = _callTopBar->height();
|
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::destroyCallTopBar() {
|
|
|
|
if (_callTopBar) {
|
2017-10-01 08:15:40 +00:00
|
|
|
_callTopBar->hide(anim::type::normal);
|
2017-04-25 20:36:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-13 16:57:44 +00:00
|
|
|
void MainWidget::callTopBarHeightUpdated(int callTopBarHeight) {
|
2020-11-24 14:40:10 +00:00
|
|
|
if (!callTopBarHeight && !_currentCall && !_currentGroupCall) {
|
2017-04-25 20:36:04 +00:00
|
|
|
_callTopBar.destroyDelayed();
|
|
|
|
}
|
|
|
|
if (callTopBarHeight != _callTopBarHeight) {
|
|
|
|
_contentScrollAddToY += callTopBarHeight - _callTopBarHeight;
|
|
|
|
_callTopBarHeight = callTopBarHeight;
|
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-20 00:02:36 +00:00
|
|
|
void MainWidget::setCurrentExportView(Export::View::PanelController *view) {
|
|
|
|
_currentExportView = view;
|
|
|
|
if (_currentExportView) {
|
|
|
|
_currentExportView->progressState(
|
|
|
|
) | rpl::start_with_next([=](Export::View::Content &&data) {
|
2018-06-20 15:54:13 +00:00
|
|
|
if (!data.rows.empty()
|
|
|
|
&& data.rows[0].id == Export::View::Content::kDoneId) {
|
2018-06-24 02:15:12 +00:00
|
|
|
LOG(("Export Info: Destroy top bar by Done."));
|
2018-06-20 00:02:36 +00:00
|
|
|
destroyExportTopBar();
|
|
|
|
} else if (!_exportTopBar) {
|
2018-06-24 02:15:12 +00:00
|
|
|
LOG(("Export Info: Create top bar by State."));
|
2018-06-20 00:02:36 +00:00
|
|
|
createExportTopBar(std::move(data));
|
|
|
|
} else {
|
|
|
|
_exportTopBar->entity()->updateData(std::move(data));
|
|
|
|
}
|
2020-06-25 07:14:05 +00:00
|
|
|
}, _exportViewLifetime);
|
2018-06-20 00:02:36 +00:00
|
|
|
} else {
|
2020-06-25 07:14:05 +00:00
|
|
|
_exportViewLifetime.destroy();
|
|
|
|
|
2018-06-24 02:15:12 +00:00
|
|
|
LOG(("Export Info: Destroy top bar by controller removal."));
|
2018-06-20 00:02:36 +00:00
|
|
|
destroyExportTopBar();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::createExportTopBar(Export::View::Content &&data) {
|
|
|
|
_exportTopBar.create(
|
|
|
|
this,
|
2021-05-26 21:29:12 +00:00
|
|
|
object_ptr<Export::View::TopBar>(this, std::move(data)),
|
|
|
|
_controller->adaptive().oneColumnValue());
|
2018-06-20 00:02:36 +00:00
|
|
|
_exportTopBar->entity()->clicks(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
if (_currentExportView) {
|
|
|
|
_currentExportView->activatePanel();
|
|
|
|
}
|
|
|
|
}, _exportTopBar->lifetime());
|
|
|
|
orderWidgets();
|
2022-12-01 10:14:35 +00:00
|
|
|
if (_showAnimation) {
|
2018-06-20 00:02:36 +00:00
|
|
|
_exportTopBar->show(anim::type::instant);
|
|
|
|
_exportTopBar->setVisible(false);
|
|
|
|
} else {
|
|
|
|
_exportTopBar->hide(anim::type::instant);
|
|
|
|
_exportTopBar->show(anim::type::normal);
|
|
|
|
_exportTopBarHeight = _contentScrollAddToY = _exportTopBar->contentHeight();
|
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
2018-07-20 12:28:06 +00:00
|
|
|
rpl::merge(
|
2020-06-21 16:25:29 +00:00
|
|
|
_exportTopBar->heightValue() | rpl::map_to(true),
|
2018-07-20 12:28:06 +00:00
|
|
|
_exportTopBar->shownValue()
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
exportTopBarHeightUpdated();
|
|
|
|
}, _exportTopBar->lifetime());
|
2018-06-20 00:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::destroyExportTopBar() {
|
|
|
|
if (_exportTopBar) {
|
|
|
|
_exportTopBar->hide(anim::type::normal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::exportTopBarHeightUpdated() {
|
|
|
|
if (!_exportTopBar) {
|
|
|
|
// Player could be already "destroyDelayed", but still handle events.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const auto exportTopBarHeight = _exportTopBar->contentHeight();
|
|
|
|
if (exportTopBarHeight != _exportTopBarHeight) {
|
|
|
|
_contentScrollAddToY += exportTopBarHeight - _exportTopBarHeight;
|
|
|
|
_exportTopBarHeight = exportTopBarHeight;
|
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
|
|
|
if (!_exportTopBarHeight && _exportTopBar->isHidden()) {
|
|
|
|
_exportTopBar.destroyDelayed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-02 16:11:20 +00:00
|
|
|
SendMenu::Type MainWidget::sendMenuType() const {
|
|
|
|
return _history->sendMenuType();
|
|
|
|
}
|
|
|
|
|
2020-06-11 16:33:15 +00:00
|
|
|
bool MainWidget::sendExistingDocument(not_null<DocumentData*> document) {
|
2021-11-09 15:24:13 +00:00
|
|
|
return sendExistingDocument(document, {});
|
2021-11-02 16:11:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWidget::sendExistingDocument(
|
|
|
|
not_null<DocumentData*> document,
|
|
|
|
Api::SendOptions options) {
|
|
|
|
return _history->sendExistingDocument(document, options);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::dialogsCancelled() {
|
2015-07-17 19:17:37 +00:00
|
|
|
if (_hider) {
|
|
|
|
_hider->startHide();
|
2018-11-26 14:01:29 +00:00
|
|
|
clearHider(_hider);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->activate();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2019-01-17 08:18:23 +00:00
|
|
|
void MainWidget::setChatBackground(
|
|
|
|
const Data::WallPaper &background,
|
|
|
|
QImage &&image) {
|
|
|
|
using namespace Window::Theme;
|
|
|
|
|
|
|
|
if (isReadyChatBackground(background, image)) {
|
|
|
|
setReadyChatBackground(background, std::move(image));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-28 13:59:49 +00:00
|
|
|
_background = std::make_unique<SettingBackground>(background);
|
2020-04-10 13:18:51 +00:00
|
|
|
if (const auto document = _background->data.document()) {
|
|
|
|
_background->dataMedia = document->createMediaView();
|
2020-04-15 14:06:34 +00:00
|
|
|
_background->dataMedia->thumbnailWanted(
|
|
|
|
_background->data.fileOrigin());
|
2020-04-10 13:18:51 +00:00
|
|
|
}
|
2019-01-28 13:59:49 +00:00
|
|
|
_background->data.loadDocument();
|
2015-02-03 15:02:46 +00:00
|
|
|
checkChatBackground();
|
2019-01-16 12:25:29 +00:00
|
|
|
|
2019-01-28 13:59:49 +00:00
|
|
|
const auto tile = Data::IsLegacy1DefaultWallPaper(background);
|
2021-07-15 11:12:38 +00:00
|
|
|
Window::Theme::Background()->downloadingStarted(tile);
|
2015-02-03 15:02:46 +00:00
|
|
|
}
|
|
|
|
|
2019-01-17 08:18:23 +00:00
|
|
|
bool MainWidget::isReadyChatBackground(
|
|
|
|
const Data::WallPaper &background,
|
|
|
|
const QImage &image) const {
|
2019-01-28 13:59:49 +00:00
|
|
|
return !image.isNull() || !background.document();
|
2019-01-17 08:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::setReadyChatBackground(
|
|
|
|
const Data::WallPaper &background,
|
|
|
|
QImage &&image) {
|
|
|
|
using namespace Window::Theme;
|
|
|
|
|
|
|
|
if (image.isNull()
|
2019-01-28 13:59:49 +00:00
|
|
|
&& !background.document()
|
2020-05-29 15:10:25 +00:00
|
|
|
&& background.localThumbnail()) {
|
2020-04-15 14:06:34 +00:00
|
|
|
image = background.localThumbnail()->original();
|
2019-01-17 08:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const auto resetToDefault = image.isNull()
|
2019-01-28 13:59:49 +00:00
|
|
|
&& !background.document()
|
2021-08-12 09:32:30 +00:00
|
|
|
&& background.backgroundColors().empty()
|
2019-01-28 13:59:49 +00:00
|
|
|
&& !Data::IsLegacy1DefaultWallPaper(background);
|
2019-01-17 08:18:23 +00:00
|
|
|
const auto ready = resetToDefault
|
2019-01-28 13:59:49 +00:00
|
|
|
? Data::DefaultWallPaper()
|
2019-01-17 08:18:23 +00:00
|
|
|
: background;
|
|
|
|
|
2019-01-29 10:57:29 +00:00
|
|
|
Background()->set(ready, std::move(image));
|
2019-01-28 13:59:49 +00:00
|
|
|
const auto tile = Data::IsLegacy1DefaultWallPaper(ready);
|
2019-01-17 08:18:23 +00:00
|
|
|
Background()->setTile(tile);
|
|
|
|
Ui::ForceFullRepaint(this);
|
|
|
|
}
|
|
|
|
|
2015-02-03 15:02:46 +00:00
|
|
|
bool MainWidget::chatBackgroundLoading() {
|
2016-06-22 13:39:54 +00:00
|
|
|
return (_background != nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
float64 MainWidget::chatBackgroundProgress() const {
|
|
|
|
if (_background) {
|
2019-01-17 08:18:23 +00:00
|
|
|
if (_background->generating) {
|
2019-01-16 12:39:35 +00:00
|
|
|
return 1.;
|
2019-01-28 13:59:49 +00:00
|
|
|
} else if (const auto document = _background->data.document()) {
|
2020-04-10 13:18:51 +00:00
|
|
|
return _background->dataMedia->progress();
|
2019-01-16 12:25:29 +00:00
|
|
|
}
|
2016-06-22 13:39:54 +00:00
|
|
|
}
|
|
|
|
return 1.;
|
2015-02-03 15:02:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::checkChatBackground() {
|
2019-01-17 08:18:23 +00:00
|
|
|
if (!_background || _background->generating) {
|
2019-01-16 12:25:29 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-04-10 13:18:51 +00:00
|
|
|
const auto &media = _background->dataMedia;
|
|
|
|
Assert(media != nullptr);
|
|
|
|
if (!media->loaded()) {
|
2019-01-16 12:25:29 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-10 13:18:51 +00:00
|
|
|
const auto document = _background->data.document();
|
|
|
|
Assert(document != nullptr);
|
|
|
|
|
2019-02-04 15:53:00 +00:00
|
|
|
const auto generateCallback = [=](QImage &&image) {
|
2019-01-17 08:18:23 +00:00
|
|
|
const auto background = base::take(_background);
|
|
|
|
const auto ready = image.isNull()
|
2019-01-28 13:59:49 +00:00
|
|
|
? Data::DefaultWallPaper()
|
2019-01-17 08:18:23 +00:00
|
|
|
: background->data;
|
2019-01-28 13:59:49 +00:00
|
|
|
setReadyChatBackground(ready, std::move(image));
|
2019-02-04 15:53:00 +00:00
|
|
|
};
|
2021-08-27 11:32:18 +00:00
|
|
|
_background->generating = Data::ReadBackgroundImageAsync(
|
2020-04-10 13:18:51 +00:00
|
|
|
media.get(),
|
2021-08-27 11:32:18 +00:00
|
|
|
Ui::PreprocessBackgroundImage,
|
2019-02-04 15:53:00 +00:00
|
|
|
generateCallback);
|
2019-01-16 12:39:35 +00:00
|
|
|
}
|
|
|
|
|
2019-01-25 14:37:28 +00:00
|
|
|
Image *MainWidget::newBackgroundThumb() {
|
2020-04-15 14:06:34 +00:00
|
|
|
return !_background
|
|
|
|
? nullptr
|
|
|
|
: _background->data.localThumbnail()
|
|
|
|
? _background->data.localThumbnail()
|
|
|
|
: _background->dataMedia
|
|
|
|
? _background->dataMedia->thumbnail()
|
|
|
|
: nullptr;
|
2019-01-16 12:39:35 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void MainWidget::setInnerFocus() {
|
2016-04-12 21:31:28 +00:00
|
|
|
if (_hider || !_history->peer()) {
|
2018-11-26 14:01:29 +00:00
|
|
|
if (!_hider && _mainSection) {
|
2017-09-16 16:53:41 +00:00
|
|
|
_mainSection->setInnerFocus();
|
2017-04-07 18:10:49 +00:00
|
|
|
} else if (!_hider && _thirdSection) {
|
|
|
|
_thirdSection->setInnerFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2022-02-25 13:11:49 +00:00
|
|
|
Assert(_dialogs != nullptr);
|
2019-04-24 14:12:35 +00:00
|
|
|
_dialogs->setInnerFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
} else if (_mainSection) {
|
|
|
|
_mainSection->setInnerFocus();
|
|
|
|
} else if (_history->peer() || !_thirdSection) {
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->setInnerFocus();
|
2017-09-16 16:53:41 +00:00
|
|
|
} else {
|
|
|
|
_thirdSection->setInnerFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-17 19:17:37 +00:00
|
|
|
void MainWidget::clearBotStartToken(PeerData *peer) {
|
2019-03-12 10:36:33 +00:00
|
|
|
if (peer && peer->isUser() && peer->asUser()->isBot()) {
|
2015-07-17 19:17:37 +00:00
|
|
|
peer->asUser()->botInfo->startToken = QString();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
}
|
|
|
|
|
2015-09-16 13:04:08 +00:00
|
|
|
void MainWidget::ctrlEnterSubmitUpdated() {
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->updateFieldSubmitSettings();
|
2015-09-16 13:04:08 +00:00
|
|
|
}
|
|
|
|
|
2021-02-15 17:37:22 +00:00
|
|
|
void MainWidget::showChooseReportMessages(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
Ui::ReportReason reason,
|
|
|
|
Fn<void(MessageIdsList)> done) {
|
|
|
|
_history->setChooseReportMessagesDetails(reason, std::move(done));
|
2022-11-30 06:31:33 +00:00
|
|
|
_controller->showPeerHistory(
|
|
|
|
peer,
|
2021-02-16 13:50:41 +00:00
|
|
|
SectionShow::Way::Forward,
|
|
|
|
ShowForChooseMessagesMsgId);
|
2023-05-02 09:33:19 +00:00
|
|
|
controller()->showToast(tr::lng_report_please_select_messages(tr::now));
|
2021-02-15 17:37:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::clearChooseReportMessages() {
|
|
|
|
_history->setChooseReportMessagesDetails({}, nullptr);
|
|
|
|
}
|
|
|
|
|
2023-04-18 12:47:31 +00:00
|
|
|
void MainWidget::toggleChooseChatTheme(
|
|
|
|
not_null<PeerData*> peer,
|
|
|
|
std::optional<bool> show) {
|
|
|
|
_history->toggleChooseChatTheme(peer, show);
|
2021-09-24 15:10:25 +00:00
|
|
|
}
|
|
|
|
|
2022-01-04 16:36:33 +00:00
|
|
|
bool MainWidget::showHistoryInDifferentWindow(
|
|
|
|
PeerId peerId,
|
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId showAtMsgId) {
|
|
|
|
const auto peer = session().data().peer(peerId);
|
2023-02-15 04:44:10 +00:00
|
|
|
const auto account = &session().account();
|
|
|
|
auto primary = Core::App().separateWindowForAccount(account);
|
2022-01-04 16:36:33 +00:00
|
|
|
if (const auto separate = Core::App().separateWindowForPeer(peer)) {
|
2022-11-30 06:31:33 +00:00
|
|
|
if (separate == &_controller->window()) {
|
2022-01-04 16:36:33 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
separate->sessionController()->showPeerHistory(
|
|
|
|
peerId,
|
|
|
|
params,
|
|
|
|
showAtMsgId);
|
|
|
|
separate->activate();
|
|
|
|
return true;
|
2023-01-17 15:47:58 +00:00
|
|
|
} else if (isPrimary()) {
|
2023-01-30 14:01:10 +00:00
|
|
|
if (primary && primary != &_controller->window()) {
|
2023-01-17 15:47:58 +00:00
|
|
|
primary->sessionController()->showPeerHistory(
|
|
|
|
peerId,
|
|
|
|
params,
|
|
|
|
showAtMsgId);
|
|
|
|
primary->activate();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2023-02-03 16:48:12 +00:00
|
|
|
} else if (!peerId) {
|
|
|
|
return true;
|
2023-01-17 15:47:58 +00:00
|
|
|
} else if (singlePeer()->id == peerId) {
|
2022-01-04 16:36:33 +00:00
|
|
|
return false;
|
2023-02-15 04:44:10 +00:00
|
|
|
} else if (!primary) {
|
|
|
|
Core::App().domain().activate(account);
|
|
|
|
primary = Core::App().separateWindowForAccount(account);
|
2022-01-04 16:36:33 +00:00
|
|
|
}
|
2023-02-15 04:44:10 +00:00
|
|
|
if (primary && &primary->account() == account) {
|
2022-01-04 16:36:33 +00:00
|
|
|
primary->sessionController()->showPeerHistory(
|
|
|
|
peerId,
|
|
|
|
params,
|
|
|
|
showAtMsgId);
|
2023-02-15 04:44:10 +00:00
|
|
|
primary->activate();
|
2022-01-04 16:36:33 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-01-27 15:56:43 +00:00
|
|
|
void MainWidget::showHistory(
|
2017-09-20 10:23:57 +00:00
|
|
|
PeerId peerId,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms,
|
|
|
|
MsgId showAtMsgId) {
|
2022-01-04 16:36:33 +00:00
|
|
|
if (peerId && _controller->window().locked()) {
|
2021-12-06 08:31:08 +00:00
|
|
|
return;
|
|
|
|
} else if (auto peer = session().data().peerLoaded(peerId)) {
|
2015-11-13 15:14:33 +00:00
|
|
|
if (peer->migrateTo()) {
|
2016-03-23 13:21:26 +00:00
|
|
|
peer = peer->migrateTo();
|
|
|
|
peerId = peer->id;
|
2015-11-13 15:14:33 +00:00
|
|
|
if (showAtMsgId > 0) showAtMsgId = -showAtMsgId;
|
|
|
|
}
|
2019-12-09 13:57:33 +00:00
|
|
|
const auto unavailable = peer->computeUnavailableReason();
|
2019-01-04 07:57:07 +00:00
|
|
|
if (!unavailable.isEmpty()) {
|
2022-06-22 11:30:56 +00:00
|
|
|
Assert(isPrimary());
|
2017-10-03 13:05:58 +00:00
|
|
|
if (params.activation != anim::activation::background) {
|
2022-11-30 06:31:33 +00:00
|
|
|
_controller->show(Ui::MakeInformBox(unavailable));
|
2023-01-27 15:56:43 +00:00
|
|
|
_controller->window().activate();
|
2017-09-20 10:23:57 +00:00
|
|
|
}
|
2016-03-23 13:21:26 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-11-13 15:14:33 +00:00
|
|
|
}
|
2022-05-13 14:54:35 +00:00
|
|
|
if ((IsServerMsgId(showAtMsgId) || Data::IsScheduledMsgId(showAtMsgId))
|
2020-08-31 11:17:02 +00:00
|
|
|
&& _mainSection
|
|
|
|
&& _mainSection->showMessage(peerId, params, showAtMsgId)) {
|
2021-12-29 15:26:25 +00:00
|
|
|
session().data().hideShownSpoilers();
|
2020-08-31 11:17:02 +00:00
|
|
|
return;
|
2022-01-04 16:36:33 +00:00
|
|
|
} else if (showHistoryInDifferentWindow(peerId, params, showAtMsgId)) {
|
|
|
|
return;
|
2020-08-31 11:17:02 +00:00
|
|
|
}
|
|
|
|
|
2023-01-27 15:56:43 +00:00
|
|
|
if (peerId && params.activation != anim::activation::background) {
|
|
|
|
_controller->window().activate();
|
|
|
|
}
|
|
|
|
|
2023-03-01 13:27:13 +00:00
|
|
|
const auto alreadyThatPeer = _history->peer()
|
|
|
|
&& (_history->peer()->id == peerId);
|
|
|
|
if (!alreadyThatPeer
|
2020-11-21 23:18:58 +00:00
|
|
|
&& preventsCloseSection(
|
2023-01-27 15:56:43 +00:00
|
|
|
[=] { showHistory(peerId, params, showAtMsgId); },
|
2020-11-21 23:18:58 +00:00
|
|
|
params)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-08-31 11:17:02 +00:00
|
|
|
using OriginMessage = SectionShow::OriginMessage;
|
|
|
|
if (const auto origin = std::get_if<OriginMessage>(¶ms.origin)) {
|
|
|
|
if (const auto returnTo = session().data().message(origin->id)) {
|
|
|
|
if (returnTo->history()->peer->id == peerId) {
|
|
|
|
_history->pushReplyReturn(returnTo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-07-05 14:48:36 +00:00
|
|
|
|
2022-11-11 07:21:40 +00:00
|
|
|
_controller->setDialogsListFocused(false);
|
2019-04-02 09:13:30 +00:00
|
|
|
_a_dialogsWidth.stop();
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
using Way = SectionShow::Way;
|
|
|
|
auto way = params.way;
|
|
|
|
bool back = (way == Way::Backward || !peerId);
|
2016-07-05 14:48:36 +00:00
|
|
|
bool foundInStack = !peerId;
|
2017-10-03 13:05:58 +00:00
|
|
|
if (foundInStack || (way == Way::ClearStack)) {
|
2019-04-24 14:12:35 +00:00
|
|
|
for (const auto &item : _stack) {
|
2017-10-03 18:13:36 +00:00
|
|
|
clearBotStartToken(item->peer());
|
2016-07-05 14:48:36 +00:00
|
|
|
}
|
|
|
|
_stack.clear();
|
|
|
|
} else {
|
2017-02-21 14:37:53 +00:00
|
|
|
for (auto i = 0, s = int(_stack.size()); i < s; ++i) {
|
2017-10-03 18:13:36 +00:00
|
|
|
if (_stack.at(i)->type() == HistoryStackItem && _stack.at(i)->peer()->id == peerId) {
|
2016-07-05 14:48:36 +00:00
|
|
|
foundInStack = true;
|
2017-02-21 14:37:53 +00:00
|
|
|
while (int(_stack.size()) > i + 1) {
|
2017-10-03 18:13:36 +00:00
|
|
|
clearBotStartToken(_stack.back()->peer());
|
2016-07-05 14:48:36 +00:00
|
|
|
_stack.pop_back();
|
|
|
|
}
|
2016-10-20 09:46:16 +00:00
|
|
|
_stack.pop_back();
|
2016-07-05 14:48:36 +00:00
|
|
|
if (!back) {
|
|
|
|
back = true;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-02-14 19:38:01 +00:00
|
|
|
if (const auto activeChat = _controller->activeChatCurrent()) {
|
|
|
|
if (const auto peer = activeChat.peer()) {
|
|
|
|
if (way == Way::Forward && peer->id == peerId) {
|
2020-10-30 13:27:53 +00:00
|
|
|
way = _mainSection ? Way::Backward : Way::ClearStack;
|
2018-02-14 19:38:01 +00:00
|
|
|
}
|
2016-09-03 16:35:12 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-05 14:48:36 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
const auto wasActivePeer = _controller->activeChatCurrent().peer();
|
2017-10-03 13:05:58 +00:00
|
|
|
if (params.activation != anim::activation::background) {
|
2022-11-30 06:31:33 +00:00
|
|
|
_controller->window().hideSettingsAndLayer();
|
2017-09-20 10:23:57 +00:00
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
auto animatedShow = [&] {
|
2022-12-01 10:14:35 +00:00
|
|
|
if (_showAnimation
|
2020-06-24 07:56:16 +00:00
|
|
|
|| Core::App().passcodeLocked()
|
2017-10-03 13:05:58 +00:00
|
|
|
|| (params.animated == anim::type::instant)) {
|
2017-01-14 18:50:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!peerId) {
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isOneColumn()) {
|
2022-01-04 13:13:00 +00:00
|
|
|
return _dialogs && _dialogs->isHidden();
|
2017-01-14 18:50:16 +00:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2017-09-15 17:34:41 +00:00
|
|
|
if (_history->isHidden()) {
|
2021-05-26 23:20:27 +00:00
|
|
|
if (!isOneColumn() && way == Way::ClearStack) {
|
2018-01-19 17:10:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
return (_mainSection != nullptr)
|
2022-01-04 13:13:00 +00:00
|
|
|
|| (isOneColumn() && _dialogs && !_dialogs->isHidden());
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
2017-10-03 13:05:58 +00:00
|
|
|
if (back || way == Way::Forward) {
|
2017-01-14 18:50:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2017-04-21 13:17:54 +00:00
|
|
|
|
2023-03-01 13:27:13 +00:00
|
|
|
auto animationParams = animatedShow()
|
|
|
|
? prepareHistoryAnimation(peerId)
|
|
|
|
: Window::SectionSlideParams();
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
if (!back && (way != Way::ClearStack)) {
|
2017-06-24 17:05:32 +00:00
|
|
|
// This may modify the current section, for example remove its contents.
|
|
|
|
saveSectionInStack();
|
|
|
|
}
|
|
|
|
|
2023-03-01 13:27:13 +00:00
|
|
|
if (_history->peer()
|
|
|
|
&& _history->peer()->id != peerId
|
|
|
|
&& way != Way::Forward) {
|
2016-07-05 14:48:36 +00:00
|
|
|
clearBotStartToken(_history->peer());
|
|
|
|
}
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->showHistory(peerId, showAtMsgId);
|
2023-03-01 13:27:13 +00:00
|
|
|
if (alreadyThatPeer && params.reapplyLocalDraft) {
|
|
|
|
_history->applyDraft(HistoryWidget::FieldHistoryAction::NewEntry);
|
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
auto noPeer = !_history->peer();
|
2021-05-26 23:20:27 +00:00
|
|
|
auto onlyDialogs = noPeer && isOneColumn();
|
2019-08-16 12:44:20 +00:00
|
|
|
_mainSection.destroy();
|
2017-05-22 15:25:49 +00:00
|
|
|
|
|
|
|
updateControlsGeometry();
|
2018-01-30 14:31:25 +00:00
|
|
|
|
|
|
|
if (noPeer) {
|
|
|
|
_controller->setActiveChatEntry(Dialogs::Key());
|
2022-11-30 06:31:33 +00:00
|
|
|
_controller->setChatStyleTheme(_controller->defaultChatTheme());
|
2018-01-30 14:31:25 +00:00
|
|
|
}
|
|
|
|
|
2015-07-17 19:17:37 +00:00
|
|
|
if (onlyDialogs) {
|
2022-01-04 13:13:00 +00:00
|
|
|
Assert(_dialogs != nullptr);
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->hide();
|
2022-12-01 10:14:35 +00:00
|
|
|
if (!_showAnimation) {
|
2017-01-14 18:50:16 +00:00
|
|
|
if (animationParams) {
|
|
|
|
auto direction = back ? Window::SlideDirection::FromLeft : Window::SlideDirection::FromRight;
|
|
|
|
_dialogs->showAnimated(direction, animationParams);
|
2016-05-19 12:03:51 +00:00
|
|
|
} else {
|
2016-11-06 17:23:13 +00:00
|
|
|
_dialogs->showFast();
|
2014-08-15 11:19:32 +00:00
|
|
|
}
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
} else {
|
2018-01-22 16:42:25 +00:00
|
|
|
const auto nowActivePeer = _controller->activeChatCurrent().peer();
|
|
|
|
if (nowActivePeer && nowActivePeer != wasActivePeer) {
|
2021-09-28 21:23:58 +00:00
|
|
|
session().api().views().removeIncremented(nowActivePeer);
|
2018-01-22 16:42:25 +00:00
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
if (isOneColumn() && _dialogs && !_dialogs->isHidden()) {
|
2018-01-22 16:42:25 +00:00
|
|
|
_dialogs->hide();
|
2015-07-17 19:17:37 +00:00
|
|
|
}
|
2022-12-01 10:14:35 +00:00
|
|
|
if (!_showAnimation) {
|
2016-05-19 12:03:51 +00:00
|
|
|
if (!animationParams.oldContentCache.isNull()) {
|
2017-09-16 16:53:41 +00:00
|
|
|
_history->showAnimated(
|
|
|
|
back
|
|
|
|
? Window::SlideDirection::FromLeft
|
|
|
|
: Window::SlideDirection::FromRight,
|
|
|
|
animationParams);
|
2016-05-19 12:03:51 +00:00
|
|
|
} else {
|
|
|
|
_history->show();
|
2021-02-25 15:12:51 +00:00
|
|
|
crl::on_main(this, [=] {
|
|
|
|
_controller->widget()->setInnerFocus();
|
2019-01-03 12:36:01 +00:00
|
|
|
});
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs && !_dialogs->isHidden()) {
|
2015-12-07 10:06:59 +00:00
|
|
|
if (!back) {
|
2018-01-04 17:15:04 +00:00
|
|
|
if (const auto history = _history->history()) {
|
2018-11-16 13:36:42 +00:00
|
|
|
_dialogs->scrollToEntry(Dialogs::RowDescriptor(
|
|
|
|
history,
|
2021-12-09 07:32:54 +00:00
|
|
|
FullMsgId(history->peer->id, showAtMsgId)));
|
2018-01-04 17:15:04 +00:00
|
|
|
}
|
2015-12-07 10:06:59 +00:00
|
|
|
}
|
2016-04-12 21:31:28 +00:00
|
|
|
_dialogs->update();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2017-05-23 14:04:59 +00:00
|
|
|
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerCheckVisibility();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2022-11-01 07:18:56 +00:00
|
|
|
void MainWidget::showMessage(
|
|
|
|
not_null<const HistoryItem*> item,
|
|
|
|
const SectionShow ¶ms) {
|
|
|
|
const auto peerId = item->history()->peer->id;
|
|
|
|
const auto itemId = item->id;
|
|
|
|
if (!v::is_null(params.origin)) {
|
|
|
|
if (_mainSection) {
|
|
|
|
if (_mainSection->showMessage(peerId, params, itemId)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (_history->peer() == item->history()->peer) {
|
2023-01-27 15:56:43 +00:00
|
|
|
showHistory(peerId, params, itemId);
|
2022-11-01 07:18:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (const auto topic = item->topic()) {
|
|
|
|
_controller->showTopic(topic, item->id, params);
|
|
|
|
} else {
|
|
|
|
_controller->showPeerHistory(
|
|
|
|
item->history(),
|
|
|
|
params,
|
|
|
|
item->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-30 06:31:33 +00:00
|
|
|
void MainWidget::showForum(
|
|
|
|
not_null<Data::Forum*> forum,
|
|
|
|
const SectionShow ¶ms) {
|
|
|
|
Expects(isPrimary() || (singlePeer() && singlePeer()->forum() == forum));
|
|
|
|
|
|
|
|
_dialogs->showForum(forum, params);
|
|
|
|
|
|
|
|
if (params.activation != anim::activation::background) {
|
|
|
|
_controller->hideLayer();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-18 10:18:17 +00:00
|
|
|
PeerData *MainWidget::peer() const {
|
2017-11-13 08:05:56 +00:00
|
|
|
return _history->peer();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2022-05-18 10:18:17 +00:00
|
|
|
Ui::ChatTheme *MainWidget::customChatTheme() const {
|
|
|
|
return _history->customChatTheme();
|
|
|
|
}
|
|
|
|
|
2016-07-05 14:48:36 +00:00
|
|
|
void MainWidget::saveSectionInStack() {
|
2017-11-13 08:05:56 +00:00
|
|
|
if (_mainSection) {
|
2017-09-16 16:53:41 +00:00
|
|
|
if (auto memento = _mainSection->createMemento()) {
|
|
|
|
_stack.push_back(std::make_unique<StackItemSection>(
|
|
|
|
std::move(memento)));
|
2022-10-12 12:57:17 +00:00
|
|
|
} else {
|
|
|
|
return;
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
2018-01-04 17:15:04 +00:00
|
|
|
} else if (const auto history = _history->history()) {
|
2017-09-16 16:53:41 +00:00
|
|
|
_stack.push_back(std::make_unique<StackItemHistory>(
|
2018-01-22 16:42:25 +00:00
|
|
|
history,
|
|
|
|
_history->msgId(),
|
2017-09-16 16:53:41 +00:00
|
|
|
_history->replyReturns()));
|
2022-10-12 12:57:17 +00:00
|
|
|
} else {
|
|
|
|
return;
|
2016-07-05 14:48:36 +00:00
|
|
|
}
|
2022-10-12 12:57:17 +00:00
|
|
|
const auto raw = _stack.back().get();
|
|
|
|
raw->setThirdSectionWeak(_thirdSection.data());
|
|
|
|
raw->removeRequests(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
for (auto i = begin(_stack); i != end(_stack); ++i) {
|
|
|
|
if (i->get() == raw) {
|
|
|
|
_stack.erase(i);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, raw->lifetime());
|
2016-07-05 14:48:36 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
void MainWidget::showSection(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> memento,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms) {
|
|
|
|
if (_mainSection && _mainSection->showInternal(
|
2020-11-21 22:37:05 +00:00
|
|
|
memento.get(),
|
2017-10-03 13:05:58 +00:00
|
|
|
params)) {
|
2023-02-21 06:23:57 +00:00
|
|
|
if (params.activation != anim::activation::background) {
|
|
|
|
_controller->window().hideSettingsAndLayer();
|
|
|
|
}
|
2018-02-16 15:46:24 +00:00
|
|
|
if (const auto entry = _mainSection->activeChat(); entry.key) {
|
|
|
|
_controller->setActiveChatEntry(entry);
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
return;
|
2017-12-04 07:33:33 +00:00
|
|
|
//
|
|
|
|
// Now third section handles only its own showSection() requests.
|
|
|
|
// General showSection() should show layer or main_section instead.
|
|
|
|
//
|
|
|
|
//} else if (_thirdSection && _thirdSection->showInternal(
|
|
|
|
// &memento,
|
|
|
|
// params)) {
|
|
|
|
// return;
|
2015-11-13 15:14:33 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
|
2020-11-21 23:18:58 +00:00
|
|
|
if (preventsCloseSection(
|
2020-12-14 14:48:10 +00:00
|
|
|
[=] { showSection(memento, params); },
|
2020-11-21 23:18:58 +00:00
|
|
|
params)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
// If the window was not resized, but we've enabled
|
|
|
|
// tabbedSelectorSectionEnabled or thirdSectionInfoEnabled
|
|
|
|
// we need to update adaptive layout to Adaptive::ThirdColumn().
|
|
|
|
updateColumnLayout();
|
|
|
|
|
2020-12-14 14:48:10 +00:00
|
|
|
showNewSection(std::move(memento), params);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::updateColumnLayout() {
|
|
|
|
updateWindowAdaptiveLayout();
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
2014-08-11 09:03:45 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
Window::SectionSlideParams MainWidget::prepareThirdSectionAnimation(Window::SectionWidget *section) {
|
|
|
|
Expects(_thirdSection != nullptr);
|
|
|
|
|
|
|
|
Window::SectionSlideParams result;
|
|
|
|
result.withTopBarShadow = section->hasTopBarShadow();
|
|
|
|
if (!_thirdSection->hasTopBarShadow()) {
|
|
|
|
result.withTopBarShadow = false;
|
|
|
|
}
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerHideAll();
|
2017-09-16 16:53:41 +00:00
|
|
|
result.oldContentCache = _thirdSection->grabForShowAnimation(result);
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerShowVisible();
|
2017-09-16 16:53:41 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window::SectionSlideParams MainWidget::prepareShowAnimation(
|
|
|
|
bool willHaveTopBarShadow) {
|
2016-05-19 12:03:51 +00:00
|
|
|
Window::SectionSlideParams result;
|
|
|
|
result.withTopBarShadow = willHaveTopBarShadow;
|
2022-11-30 12:02:40 +00:00
|
|
|
if (_mainSection) {
|
2017-09-16 16:53:41 +00:00
|
|
|
if (!_mainSection->hasTopBarShadow()) {
|
2016-05-19 12:03:51 +00:00
|
|
|
result.withTopBarShadow = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2017-11-13 08:05:56 +00:00
|
|
|
} else if (!_history->peer()) {
|
2016-05-19 12:03:51 +00:00
|
|
|
result.withTopBarShadow = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerHideAll();
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
2021-11-24 14:26:39 +00:00
|
|
|
_player->entity()->hideShadowAndDropdowns();
|
2021-11-18 17:02:39 +00:00
|
|
|
}
|
2022-11-30 12:02:40 +00:00
|
|
|
const auto playerPlaylistVisible = !_playerPlaylist->isHidden();
|
2016-10-14 17:10:15 +00:00
|
|
|
if (playerPlaylistVisible) {
|
|
|
|
_playerPlaylist->hide();
|
|
|
|
}
|
2022-11-30 12:02:40 +00:00
|
|
|
const auto hiderVisible = (_hider && !_hider->isHidden());
|
|
|
|
if (hiderVisible) {
|
|
|
|
_hider->hide();
|
|
|
|
}
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
auto sectionTop = getMainSectionTop();
|
2022-11-30 12:02:40 +00:00
|
|
|
if (_mainSection) {
|
2017-09-16 16:53:41 +00:00
|
|
|
result.oldContentCache = _mainSection->grabForShowAnimation(result);
|
2021-05-26 23:20:27 +00:00
|
|
|
} else if (!isOneColumn() || !_history->isHidden()) {
|
2018-04-06 16:23:09 +00:00
|
|
|
result.oldContentCache = _history->grabForShowAnimation(result);
|
2018-07-24 18:37:22 +00:00
|
|
|
} else {
|
|
|
|
result.oldContentCache = Ui::GrabWidget(this, QRect(
|
|
|
|
0,
|
|
|
|
sectionTop,
|
|
|
|
_dialogsWidth,
|
|
|
|
height() - sectionTop));
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2022-11-30 12:02:40 +00:00
|
|
|
if (_hider && hiderVisible) {
|
|
|
|
_hider->show();
|
|
|
|
}
|
2016-10-14 17:10:15 +00:00
|
|
|
if (playerPlaylistVisible) {
|
|
|
|
_playerPlaylist->show();
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
2021-11-24 14:26:39 +00:00
|
|
|
_player->entity()->showShadowAndDropdowns();
|
2016-10-12 19:34:25 +00:00
|
|
|
}
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerShowVisible();
|
2016-05-19 12:03:51 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
Window::SectionSlideParams MainWidget::prepareMainSectionAnimation(Window::SectionWidget *section) {
|
|
|
|
return prepareShowAnimation(section->hasTopBarShadow());
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Window::SectionSlideParams MainWidget::prepareHistoryAnimation(PeerId historyPeerId) {
|
2017-09-16 16:53:41 +00:00
|
|
|
return prepareShowAnimation(historyPeerId != 0);
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Window::SectionSlideParams MainWidget::prepareDialogsAnimation() {
|
2017-09-16 16:53:41 +00:00
|
|
|
return prepareShowAnimation(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::showNewSection(
|
2020-12-14 14:48:10 +00:00
|
|
|
std::shared_ptr<Window::SectionMemento> memento,
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms) {
|
2017-09-16 16:53:41 +00:00
|
|
|
using Column = Window::Column;
|
|
|
|
|
2021-12-06 08:31:08 +00:00
|
|
|
if (_controller->window().locked()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-10-03 13:05:58 +00:00
|
|
|
auto saveInStack = (params.way == SectionShow::Way::Forward);
|
2020-03-24 12:44:15 +00:00
|
|
|
const auto thirdSectionTop = getThirdSectionTop();
|
|
|
|
const auto newThirdGeometry = QRect(
|
2017-09-16 16:53:41 +00:00
|
|
|
width() - st::columnMinimalWidthThird,
|
|
|
|
thirdSectionTop,
|
|
|
|
st::columnMinimalWidthThird,
|
|
|
|
height() - thirdSectionTop);
|
2021-05-26 23:20:27 +00:00
|
|
|
auto newThirdSection = (isThreeColumn() && params.thirdColumn)
|
2020-11-21 22:37:05 +00:00
|
|
|
? memento->createWidget(
|
2017-09-16 16:53:41 +00:00
|
|
|
this,
|
|
|
|
_controller,
|
|
|
|
Column::Third,
|
|
|
|
newThirdGeometry)
|
|
|
|
: nullptr;
|
2020-03-24 12:44:15 +00:00
|
|
|
const auto layerRect = parentWidget()->rect();
|
2017-09-16 16:53:41 +00:00
|
|
|
if (newThirdSection) {
|
|
|
|
saveInStack = false;
|
2020-11-21 22:37:05 +00:00
|
|
|
} else if (auto layer = memento->createLayer(_controller, layerRect)) {
|
2017-12-26 13:55:15 +00:00
|
|
|
if (params.activation != anim::activation::background) {
|
2022-06-09 03:37:46 +00:00
|
|
|
_controller->hideLayer(anim::type::instant);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
2017-12-26 13:55:15 +00:00
|
|
|
_controller->showSpecialLayer(std::move(layer));
|
|
|
|
return;
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
if (params.activation != anim::activation::background) {
|
2022-11-30 06:31:33 +00:00
|
|
|
_controller->window().hideSettingsAndLayer();
|
2017-09-20 10:23:57 +00:00
|
|
|
}
|
|
|
|
|
2022-11-11 07:21:40 +00:00
|
|
|
_controller->setDialogsListFocused(false);
|
2019-04-02 09:13:30 +00:00
|
|
|
_a_dialogsWidth.stop();
|
2017-01-14 18:50:16 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
auto mainSectionTop = getMainSectionTop();
|
|
|
|
auto newMainGeometry = QRect(
|
|
|
|
_history->x(),
|
|
|
|
mainSectionTop,
|
|
|
|
_history->width(),
|
|
|
|
height() - mainSectionTop);
|
|
|
|
auto newMainSection = newThirdSection
|
|
|
|
? nullptr
|
2020-11-21 22:37:05 +00:00
|
|
|
: memento->createWidget(
|
2017-09-16 16:53:41 +00:00
|
|
|
this,
|
|
|
|
_controller,
|
2021-05-26 23:20:27 +00:00
|
|
|
isOneColumn() ? Column::First : Column::Second,
|
2017-09-16 16:53:41 +00:00
|
|
|
newMainGeometry);
|
|
|
|
Assert(newMainSection || newThirdSection);
|
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
auto animatedShow = [&] {
|
2022-12-01 10:14:35 +00:00
|
|
|
if (_showAnimation
|
2020-06-24 07:56:16 +00:00
|
|
|
|| Core::App().passcodeLocked()
|
2017-10-03 13:05:58 +00:00
|
|
|
|| (params.animated == anim::type::instant)
|
2020-11-21 22:37:05 +00:00
|
|
|
|| memento->instant()) {
|
2017-01-14 18:50:16 +00:00
|
|
|
return false;
|
|
|
|
}
|
2021-05-26 23:20:27 +00:00
|
|
|
if (!isOneColumn() && params.way == SectionShow::Way::ClearStack) {
|
2018-01-19 17:10:58 +00:00
|
|
|
return false;
|
2021-05-26 23:20:27 +00:00
|
|
|
} else if (isOneColumn()
|
2017-09-16 16:53:41 +00:00
|
|
|
|| (newThirdSection && _thirdSection)
|
|
|
|
|| (newMainSection && isMainSectionShown())) {
|
2017-01-14 18:50:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
2017-09-15 17:34:41 +00:00
|
|
|
}();
|
2017-09-16 16:53:41 +00:00
|
|
|
auto animationParams = animatedShow
|
|
|
|
? (newThirdSection
|
|
|
|
? prepareThirdSectionAnimation(newThirdSection)
|
|
|
|
: prepareMainSectionAnimation(newMainSection))
|
|
|
|
: Window::SectionSlideParams();
|
2016-05-19 12:03:51 +00:00
|
|
|
|
2017-06-24 17:05:32 +00:00
|
|
|
setFocus(); // otherwise dialogs widget could be focused.
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
if (saveInStack) {
|
2017-06-24 17:05:32 +00:00
|
|
|
// This may modify the current section, for example remove its contents.
|
2016-12-13 17:07:56 +00:00
|
|
|
saveSectionInStack();
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
auto &settingSection = newThirdSection
|
|
|
|
? _thirdSection
|
|
|
|
: _mainSection;
|
|
|
|
if (newThirdSection) {
|
|
|
|
_thirdSection = std::move(newThirdSection);
|
2022-10-12 12:57:17 +00:00
|
|
|
_thirdSection->removeRequests(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
_thirdSection.destroy();
|
|
|
|
_thirdShadow.destroy();
|
|
|
|
updateControlsGeometry();
|
|
|
|
}, _thirdSection->lifetime());
|
2017-09-16 16:53:41 +00:00
|
|
|
if (!_thirdShadow) {
|
2017-09-30 18:26:45 +00:00
|
|
|
_thirdShadow.create(this);
|
2017-09-16 16:53:41 +00:00
|
|
|
_thirdShadow->show();
|
|
|
|
orderWidgets();
|
|
|
|
}
|
|
|
|
updateControlsGeometry();
|
|
|
|
} else {
|
|
|
|
_mainSection = std::move(newMainSection);
|
2017-09-30 19:20:40 +00:00
|
|
|
_history->finishAnimating();
|
2017-09-16 16:53:41 +00:00
|
|
|
_history->showHistory(0, 0);
|
2022-11-09 06:59:27 +00:00
|
|
|
|
|
|
|
if (const auto entry = _mainSection->activeChat(); entry.key) {
|
|
|
|
_controller->setActiveChatEntry(entry);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Depends on SessionController::activeChatEntry
|
|
|
|
// for tabbed selector showing in the third column.
|
|
|
|
updateControlsGeometry();
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
_history->hide();
|
2022-01-04 13:13:00 +00:00
|
|
|
if (isOneColumn() && _dialogs) {
|
|
|
|
_dialogs->hide();
|
|
|
|
}
|
2014-08-01 11:09:46 +00:00
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
if (animationParams) {
|
2017-10-03 13:05:58 +00:00
|
|
|
auto back = (params.way == SectionShow::Way::Backward);
|
2017-09-16 16:53:41 +00:00
|
|
|
auto direction = (back || settingSection->forceAnimateBack())
|
|
|
|
? Window::SlideDirection::FromLeft
|
|
|
|
: Window::SlideDirection::FromRight;
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isOneColumn()) {
|
2018-09-06 14:58:43 +00:00
|
|
|
_controller->removeLayerBlackout();
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
settingSection->showAnimated(direction, animationParams);
|
2017-01-14 18:50:16 +00:00
|
|
|
} else {
|
2017-09-16 16:53:41 +00:00
|
|
|
settingSection->showFast();
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
2017-01-07 11:55:05 +00:00
|
|
|
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerCheckVisibility();
|
2015-07-17 19:17:37 +00:00
|
|
|
orderWidgets();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
void MainWidget::checkMainSectionToLayer() {
|
|
|
|
if (!_mainSection) {
|
2017-09-15 17:34:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-09-25 16:06:53 +00:00
|
|
|
Ui::FocusPersister persister(this);
|
2017-09-30 18:26:45 +00:00
|
|
|
if (auto layer = _mainSection->moveContentToLayer(rect())) {
|
2017-09-16 16:53:41 +00:00
|
|
|
dropMainSection(_mainSection);
|
2017-09-15 17:34:41 +00:00
|
|
|
_controller->showSpecialLayer(
|
|
|
|
std::move(layer),
|
2017-09-20 10:23:57 +00:00
|
|
|
anim::type::instant);
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
void MainWidget::dropMainSection(Window::SectionWidget *widget) {
|
|
|
|
if (_mainSection != widget) {
|
2017-09-15 17:34:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
_mainSection.destroy();
|
2017-09-20 10:23:57 +00:00
|
|
|
_controller->showBackFromStack(
|
2017-10-03 13:05:58 +00:00
|
|
|
SectionShow(
|
|
|
|
anim::type::instant,
|
|
|
|
anim::activation::background));
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
|
|
|
|
2022-01-04 13:13:00 +00:00
|
|
|
PeerData *MainWidget::singlePeer() const {
|
|
|
|
return _controller->singlePeer();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWidget::isPrimary() const {
|
|
|
|
return _controller->isPrimary();
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
bool MainWidget::isMainSectionShown() const {
|
2017-11-13 08:05:56 +00:00
|
|
|
return _mainSection || _history->peer();
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWidget::isThirdSectionShown() const {
|
|
|
|
return _thirdSection != nullptr;
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
|
|
|
|
2022-02-05 15:15:24 +00:00
|
|
|
Dialogs::RowDescriptor MainWidget::resolveChatNext(
|
|
|
|
Dialogs::RowDescriptor from) const {
|
|
|
|
return _dialogs ? _dialogs->resolveChatNext(from) : Dialogs::RowDescriptor();
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialogs::RowDescriptor MainWidget::resolveChatPrevious(
|
|
|
|
Dialogs::RowDescriptor from) const {
|
|
|
|
return _dialogs ? _dialogs->resolveChatPrevious(from) : Dialogs::RowDescriptor();
|
|
|
|
}
|
|
|
|
|
2016-07-05 14:48:36 +00:00
|
|
|
bool MainWidget::stackIsEmpty() const {
|
2017-02-21 13:45:56 +00:00
|
|
|
return _stack.empty();
|
2016-07-05 14:48:36 +00:00
|
|
|
}
|
|
|
|
|
2020-12-13 13:08:16 +00:00
|
|
|
bool MainWidget::preventsCloseSection(Fn<void()> callback) const {
|
|
|
|
if (Core::App().passcodeLocked()) {
|
2020-11-21 23:18:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
auto copy = callback;
|
|
|
|
return (_mainSection && _mainSection->preventsClose(std::move(copy)))
|
|
|
|
|| (_history && _history->preventsClose(std::move(callback)));
|
|
|
|
}
|
|
|
|
|
2020-12-13 13:08:16 +00:00
|
|
|
bool MainWidget::preventsCloseSection(
|
|
|
|
Fn<void()> callback,
|
|
|
|
const SectionShow ¶ms) const {
|
2022-10-12 12:57:17 +00:00
|
|
|
return !params.thirdColumn
|
|
|
|
&& (params.activation != anim::activation::background)
|
|
|
|
&& preventsCloseSection(std::move(callback));
|
2020-12-13 13:08:16 +00:00
|
|
|
}
|
|
|
|
|
2017-09-20 10:23:57 +00:00
|
|
|
void MainWidget::showBackFromStack(
|
2017-10-03 13:05:58 +00:00
|
|
|
const SectionShow ¶ms) {
|
2020-11-21 23:18:58 +00:00
|
|
|
if (preventsCloseSection([=] { showBackFromStack(params); }, params)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-11-30 12:02:40 +00:00
|
|
|
if (_stack.empty()) {
|
2023-01-18 11:36:32 +00:00
|
|
|
if (isPrimary()) {
|
|
|
|
_controller->clearSectionStack(params);
|
|
|
|
}
|
2021-02-25 15:12:51 +00:00
|
|
|
crl::on_main(this, [=] {
|
|
|
|
_controller->widget()->setInnerFocus();
|
2019-01-03 12:36:01 +00:00
|
|
|
});
|
2015-07-03 08:47:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-02-21 13:45:56 +00:00
|
|
|
auto item = std::move(_stack.back());
|
2014-08-15 11:19:32 +00:00
|
|
|
_stack.pop_back();
|
2016-05-19 12:03:51 +00:00
|
|
|
if (auto currentHistoryPeer = _history->peer()) {
|
|
|
|
clearBotStartToken(currentHistoryPeer);
|
|
|
|
}
|
2017-11-28 20:01:00 +00:00
|
|
|
_thirdSectionFromStack = item->takeThirdSectionMemento();
|
2014-08-15 11:19:32 +00:00
|
|
|
if (item->type() == HistoryStackItem) {
|
2017-01-14 18:50:16 +00:00
|
|
|
auto historyItem = static_cast<StackItemHistory*>(item.get());
|
2017-09-20 10:23:57 +00:00
|
|
|
_controller->showPeerHistory(
|
2017-10-03 18:13:36 +00:00
|
|
|
historyItem->peer()->id,
|
2017-10-03 13:05:58 +00:00
|
|
|
params.withWay(SectionShow::Way::Backward),
|
|
|
|
ShowAtUnreadMsgId);
|
2022-10-08 11:14:38 +00:00
|
|
|
_history->setReplyReturns(
|
|
|
|
historyItem->peer()->id,
|
|
|
|
std::move(historyItem->replyReturns));
|
2016-05-19 12:03:51 +00:00
|
|
|
} else if (item->type() == SectionStackItem) {
|
2017-01-14 18:50:16 +00:00
|
|
|
auto sectionItem = static_cast<StackItemSection*>(item.get());
|
2017-09-16 16:53:41 +00:00
|
|
|
showNewSection(
|
2020-11-21 22:37:05 +00:00
|
|
|
sectionItem->takeMemento(),
|
2017-10-03 13:05:58 +00:00
|
|
|
params.withWay(SectionShow::Way::Backward));
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2017-11-28 20:01:00 +00:00
|
|
|
if (_thirdSectionFromStack && _thirdSection) {
|
|
|
|
_controller->showSection(
|
2020-11-21 22:37:05 +00:00
|
|
|
base::take(_thirdSectionFromStack),
|
2017-11-28 20:01:00 +00:00
|
|
|
SectionShow(
|
|
|
|
SectionShow::Way::ClearStack,
|
|
|
|
anim::type::instant,
|
|
|
|
anim::activation::background));
|
|
|
|
|
2017-10-03 18:13:36 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-07-17 19:17:37 +00:00
|
|
|
void MainWidget::orderWidgets() {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
2023-07-28 08:10:01 +00:00
|
|
|
_dialogs->raiseWithTooltip();
|
2022-01-04 13:13:00 +00:00
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
|
|
|
_player->raise();
|
|
|
|
}
|
2018-06-20 00:02:36 +00:00
|
|
|
if (_exportTopBar) {
|
|
|
|
_exportTopBar->raise();
|
|
|
|
}
|
|
|
|
if (_callTopBar) {
|
|
|
|
_callTopBar->raise();
|
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_sideShadow) {
|
|
|
|
_sideShadow->raise();
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_thirdShadow) {
|
|
|
|
_thirdShadow->raise();
|
|
|
|
}
|
2017-11-12 15:41:00 +00:00
|
|
|
if (_firstColumnResizeArea) {
|
|
|
|
_firstColumnResizeArea->raise();
|
|
|
|
}
|
|
|
|
if (_thirdColumnResizeArea) {
|
|
|
|
_thirdColumnResizeArea->raise();
|
|
|
|
}
|
2022-06-16 08:25:37 +00:00
|
|
|
if (_connecting) {
|
|
|
|
_connecting->raise();
|
|
|
|
}
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerRaiseAll();
|
2021-11-19 12:42:14 +00:00
|
|
|
_playerPlaylist->raise();
|
2021-11-24 14:26:39 +00:00
|
|
|
if (_player) {
|
|
|
|
_player->entity()->raiseDropdowns();
|
2021-11-19 12:42:14 +00:00
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
if (_hider) _hider->raise();
|
|
|
|
}
|
|
|
|
|
2016-05-19 12:03:51 +00:00
|
|
|
QPixmap MainWidget::grabForShowAnimation(const Window::SectionSlideParams ¶ms) {
|
|
|
|
QPixmap result;
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerHideAll();
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
2021-11-24 14:26:39 +00:00
|
|
|
_player->entity()->hideShadowAndDropdowns();
|
2021-11-18 17:02:39 +00:00
|
|
|
}
|
2022-11-30 12:02:40 +00:00
|
|
|
const auto playerPlaylistVisible = !_playerPlaylist->isHidden();
|
2016-10-14 17:10:15 +00:00
|
|
|
if (playerPlaylistVisible) {
|
|
|
|
_playerPlaylist->hide();
|
|
|
|
}
|
2022-11-30 12:02:40 +00:00
|
|
|
const auto hiderVisible = (_hider && !_hider->isHidden());
|
|
|
|
if (hiderVisible) {
|
|
|
|
_hider->hide();
|
|
|
|
}
|
2016-10-14 17:10:15 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
auto sectionTop = getMainSectionTop();
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isOneColumn()) {
|
2017-12-26 12:41:48 +00:00
|
|
|
result = Ui::GrabWidget(this, QRect(
|
2017-11-12 16:50:58 +00:00
|
|
|
0,
|
|
|
|
sectionTop,
|
2022-06-07 18:05:37 +00:00
|
|
|
width(),
|
2017-11-12 16:50:58 +00:00
|
|
|
height() - sectionTop));
|
2016-05-19 12:03:51 +00:00
|
|
|
} else {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_sideShadow) {
|
|
|
|
_sideShadow->hide();
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_thirdShadow) {
|
|
|
|
_thirdShadow->hide();
|
|
|
|
}
|
2017-12-26 12:41:48 +00:00
|
|
|
result = Ui::GrabWidget(this, QRect(
|
2017-11-12 16:50:58 +00:00
|
|
|
_dialogsWidth,
|
|
|
|
sectionTop,
|
|
|
|
width() - _dialogsWidth,
|
|
|
|
height() - sectionTop));
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_sideShadow) {
|
|
|
|
_sideShadow->show();
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_thirdShadow) {
|
|
|
|
_thirdShadow->show();
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
}
|
2022-11-30 12:02:40 +00:00
|
|
|
if (_hider && hiderVisible) {
|
|
|
|
_hider->show();
|
|
|
|
}
|
2016-10-14 17:10:15 +00:00
|
|
|
if (playerPlaylistVisible) {
|
|
|
|
_playerPlaylist->show();
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
2021-11-24 14:26:39 +00:00
|
|
|
_player->entity()->showShadowAndDropdowns();
|
2016-05-19 12:03:51 +00:00
|
|
|
}
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerShowVisible();
|
2016-05-19 12:03:51 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void MainWidget::windowShown() {
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->windowShown();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::dialogsToUp() {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
2022-10-06 16:06:24 +00:00
|
|
|
_dialogs->jumpToTop();
|
2022-01-04 13:13:00 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 16:03:42 +00:00
|
|
|
void MainWidget::checkActivation() {
|
|
|
|
_history->checkActivation();
|
|
|
|
if (_mainSection) {
|
|
|
|
_mainSection->checkActivation();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 10:14:35 +00:00
|
|
|
void MainWidget::showAnimated(QPixmap oldContentCache, bool back) {
|
|
|
|
_showAnimation = nullptr;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
showAll();
|
2020-06-25 14:17:37 +00:00
|
|
|
floatPlayerHideAll();
|
2022-12-01 10:14:35 +00:00
|
|
|
auto newContentCache = Ui::GrabWidget(this);
|
2015-10-17 14:52:26 +00:00
|
|
|
hideAll();
|
2020-06-25 14:17:37 +00:00
|
|
|
floatPlayerShowVisible();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2022-12-01 10:14:35 +00:00
|
|
|
_showAnimation = std::make_unique<Window::SlideAnimation>();
|
|
|
|
_showAnimation->setDirection(back
|
|
|
|
? Window::SlideDirection::FromLeft
|
|
|
|
: Window::SlideDirection::FromRight);
|
|
|
|
_showAnimation->setRepaintCallback([=] { update(); });
|
|
|
|
_showAnimation->setFinishedCallback([=] { showFinished(); });
|
|
|
|
_showAnimation->setPixmaps(oldContentCache, newContentCache);
|
|
|
|
_showAnimation->start();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
2022-12-01 10:14:35 +00:00
|
|
|
void MainWidget::showFinished() {
|
|
|
|
_showAnimation = nullptr;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2022-12-01 10:14:35 +00:00
|
|
|
showAll();
|
|
|
|
activate();
|
2015-10-17 14:52:26 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void MainWidget::paintEvent(QPaintEvent *e) {
|
2019-01-16 12:25:29 +00:00
|
|
|
if (_background) {
|
|
|
|
checkChatBackground();
|
|
|
|
}
|
2022-12-01 10:14:35 +00:00
|
|
|
if (_showAnimation) {
|
|
|
|
auto p = QPainter(this);
|
|
|
|
_showAnimation->paintContents(p);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
int MainWidget::getMainSectionTop() const {
|
2018-06-20 00:02:36 +00:00
|
|
|
return _callTopBarHeight + _exportTopBarHeight + _playerHeight;
|
2017-04-25 20:36:04 +00:00
|
|
|
}
|
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
int MainWidget::getThirdSectionTop() const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void MainWidget::hideAll() {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
_dialogs->hide();
|
|
|
|
}
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->hide();
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_mainSection) {
|
|
|
|
_mainSection->hide();
|
|
|
|
}
|
|
|
|
if (_thirdSection) {
|
|
|
|
_thirdSection->hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_sideShadow) {
|
|
|
|
_sideShadow->hide();
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_thirdShadow) {
|
|
|
|
_thirdShadow->hide();
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
2017-10-01 08:15:40 +00:00
|
|
|
_player->setVisible(false);
|
2016-04-14 16:08:36 +00:00
|
|
|
_playerHeight = 0;
|
|
|
|
}
|
2020-06-25 17:57:36 +00:00
|
|
|
if (_callTopBar) {
|
|
|
|
_callTopBar->setVisible(false);
|
|
|
|
_callTopBarHeight = 0;
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::showAll() {
|
2015-04-02 10:33:19 +00:00
|
|
|
if (cPasswordRecovered()) {
|
|
|
|
cSetPasswordRecovered(false);
|
2023-01-10 18:56:20 +00:00
|
|
|
_controller->show(Ui::MakeInformBox(
|
|
|
|
tr::lng_cloud_password_updated()));
|
2015-04-02 10:33:19 +00:00
|
|
|
}
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isOneColumn()) {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_sideShadow) {
|
|
|
|
_sideShadow->hide();
|
|
|
|
}
|
2015-07-17 19:17:37 +00:00
|
|
|
if (_hider) {
|
|
|
|
_hider->hide();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2022-11-30 12:02:40 +00:00
|
|
|
if (_mainSection) {
|
2017-09-16 16:53:41 +00:00
|
|
|
_mainSection->show();
|
2016-04-12 21:31:28 +00:00
|
|
|
} else if (_history->peer()) {
|
|
|
|
_history->show();
|
2016-10-18 10:32:33 +00:00
|
|
|
_history->updateControlsGeometry();
|
2014-12-12 16:27:03 +00:00
|
|
|
} else {
|
2022-01-04 13:13:00 +00:00
|
|
|
Assert(_dialogs != nullptr);
|
2016-11-06 17:23:13 +00:00
|
|
|
_dialogs->showFast();
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->hide();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2022-11-30 12:02:40 +00:00
|
|
|
if (_dialogs && isMainSectionShown()) {
|
2022-01-04 13:13:00 +00:00
|
|
|
_dialogs->hide();
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_sideShadow) {
|
|
|
|
_sideShadow->show();
|
|
|
|
}
|
2016-02-08 14:54:55 +00:00
|
|
|
if (_hider) {
|
|
|
|
_hider->show();
|
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
_dialogs->showFast();
|
|
|
|
}
|
2017-11-13 08:05:56 +00:00
|
|
|
if (_mainSection) {
|
2017-09-16 16:53:41 +00:00
|
|
|
_mainSection->show();
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
2016-04-12 21:31:28 +00:00
|
|
|
_history->show();
|
2016-10-18 10:32:33 +00:00
|
|
|
_history->updateControlsGeometry();
|
2016-02-08 14:54:55 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_thirdSection) {
|
|
|
|
_thirdSection->show();
|
|
|
|
}
|
|
|
|
if (_thirdShadow) {
|
|
|
|
_thirdShadow->show();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
2017-10-01 08:15:40 +00:00
|
|
|
_player->setVisible(true);
|
2016-10-12 19:34:25 +00:00
|
|
|
_playerHeight = _player->contentHeight();
|
2015-10-17 08:31:48 +00:00
|
|
|
}
|
2020-06-25 17:57:36 +00:00
|
|
|
if (_callTopBar) {
|
|
|
|
_callTopBar->setVisible(true);
|
2020-07-17 04:32:51 +00:00
|
|
|
|
|
|
|
// show() could've send pending resize event that would update
|
|
|
|
// the height value and destroy the top bar if it was hiding.
|
|
|
|
if (_callTopBar) {
|
|
|
|
_callTopBarHeight = _callTopBar->height();
|
|
|
|
}
|
2020-06-25 17:57:36 +00:00
|
|
|
}
|
2017-01-30 15:27:13 +00:00
|
|
|
updateControlsGeometry();
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerCheckVisibility();
|
2015-10-17 08:31:48 +00:00
|
|
|
|
2022-11-02 16:03:42 +00:00
|
|
|
_controller->widget()->checkActivation();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::resizeEvent(QResizeEvent *e) {
|
2016-10-12 19:34:25 +00:00
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::updateControlsGeometry() {
|
2023-01-18 06:25:56 +00:00
|
|
|
if (!width()) {
|
|
|
|
return;
|
|
|
|
}
|
2017-01-14 18:50:16 +00:00
|
|
|
updateWindowAdaptiveLayout();
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
|
|
|
_a_dialogsWidth.stop();
|
|
|
|
}
|
|
|
|
if (!_a_dialogsWidth.animating()) {
|
|
|
|
_dialogs->stopWidthAnimation();
|
|
|
|
}
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isThreeColumn()) {
|
2017-09-19 10:32:34 +00:00
|
|
|
if (!_thirdSection
|
|
|
|
&& !_controller->takeThirdSectionFromLayer()) {
|
2017-11-12 09:54:18 +00:00
|
|
|
auto params = Window::SectionShow(
|
|
|
|
Window::SectionShow::Way::ClearStack,
|
|
|
|
anim::type::instant,
|
|
|
|
anim::activation::background);
|
2020-05-05 12:55:05 +00:00
|
|
|
const auto active = _controller->activeChatCurrent();
|
2022-10-25 08:07:47 +00:00
|
|
|
if (const auto thread = active.thread()) {
|
2020-06-25 12:16:09 +00:00
|
|
|
if (Core::App().settings().tabbedSelectorSectionEnabled()) {
|
2020-10-01 14:20:08 +00:00
|
|
|
if (_mainSection) {
|
2022-10-25 08:07:47 +00:00
|
|
|
_mainSection->pushTabbedSelectorToThirdSection(
|
|
|
|
thread,
|
|
|
|
params);
|
2020-10-01 14:20:08 +00:00
|
|
|
} else {
|
2022-10-25 08:07:47 +00:00
|
|
|
_history->pushTabbedSelectorToThirdSection(
|
|
|
|
thread,
|
|
|
|
params);
|
2020-10-01 14:20:08 +00:00
|
|
|
}
|
2020-06-25 12:16:09 +00:00
|
|
|
} else if (Core::App().settings().thirdSectionInfoEnabled()) {
|
2018-01-22 19:51:38 +00:00
|
|
|
_controller->showSection(
|
2022-10-25 08:07:47 +00:00
|
|
|
(thread->asTopic()
|
|
|
|
? std::make_shared<Info::Memento>(
|
|
|
|
thread->asTopic())
|
|
|
|
: Info::Memento::Default(
|
|
|
|
thread->asHistory()->peer)),
|
2018-01-22 19:51:38 +00:00
|
|
|
params.withThirdColumn());
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_thirdSection.destroy();
|
|
|
|
_thirdShadow.destroy();
|
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
const auto mainSectionTop = getMainSectionTop();
|
|
|
|
auto dialogsWidth = _dialogs
|
|
|
|
? qRound(_a_dialogsWidth.value(_dialogsWidth))
|
|
|
|
: isOneColumn()
|
2022-06-07 18:05:37 +00:00
|
|
|
? width()
|
2022-01-04 13:13:00 +00:00
|
|
|
: 0;
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isOneColumn()) {
|
2017-04-25 20:36:04 +00:00
|
|
|
if (_callTopBar) {
|
|
|
|
_callTopBar->resizeToWidth(dialogsWidth);
|
|
|
|
_callTopBar->moveToLeft(0, 0);
|
|
|
|
}
|
2018-06-20 00:02:36 +00:00
|
|
|
if (_exportTopBar) {
|
|
|
|
_exportTopBar->resizeToWidth(dialogsWidth);
|
|
|
|
_exportTopBar->moveToLeft(0, _callTopBarHeight);
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
2017-01-14 18:50:16 +00:00
|
|
|
_player->resizeToWidth(dialogsWidth);
|
2018-06-20 00:02:36 +00:00
|
|
|
_player->moveToLeft(0, _callTopBarHeight + _exportTopBarHeight);
|
2016-10-12 19:34:25 +00:00
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
const auto mainSectionGeometry = QRect(
|
2017-09-16 16:53:41 +00:00
|
|
|
0,
|
|
|
|
mainSectionTop,
|
|
|
|
dialogsWidth,
|
|
|
|
height() - mainSectionTop);
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
_dialogs->setGeometryWithTopMoved(
|
|
|
|
mainSectionGeometry,
|
|
|
|
_contentScrollAddToY);
|
|
|
|
}
|
|
|
|
_history->setGeometryWithTopMoved(
|
|
|
|
mainSectionGeometry,
|
|
|
|
_contentScrollAddToY);
|
2017-01-14 18:50:16 +00:00
|
|
|
if (_hider) _hider->setGeometry(0, 0, dialogsWidth, height());
|
2016-02-08 14:54:55 +00:00
|
|
|
} else {
|
2017-11-12 16:50:58 +00:00
|
|
|
auto thirdSectionWidth = _thirdSection ? _thirdColumnWidth : 0;
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_thirdSection) {
|
|
|
|
auto thirdSectionTop = getThirdSectionTop();
|
|
|
|
_thirdSection->setGeometry(
|
|
|
|
width() - thirdSectionWidth,
|
|
|
|
thirdSectionTop,
|
|
|
|
thirdSectionWidth,
|
|
|
|
height() - thirdSectionTop);
|
|
|
|
}
|
2020-07-07 13:54:39 +00:00
|
|
|
const auto shadowTop = _controller->window().verticalShadowTop();
|
|
|
|
const auto shadowHeight = height() - shadowTop;
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
accumulate_min(
|
|
|
|
dialogsWidth,
|
|
|
|
width() - st::columnMinimalWidthMain);
|
|
|
|
_dialogs->setGeometryToLeft(0, 0, dialogsWidth, height());
|
|
|
|
}
|
|
|
|
if (_sideShadow) {
|
|
|
|
_sideShadow->setGeometryToLeft(
|
|
|
|
dialogsWidth,
|
|
|
|
shadowTop,
|
|
|
|
st::lineWidth,
|
|
|
|
shadowHeight);
|
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_thirdShadow) {
|
|
|
|
_thirdShadow->setGeometryToLeft(
|
|
|
|
width() - thirdSectionWidth - st::lineWidth,
|
2020-07-07 13:54:39 +00:00
|
|
|
shadowTop,
|
2017-09-16 16:53:41 +00:00
|
|
|
st::lineWidth,
|
2020-07-07 13:54:39 +00:00
|
|
|
shadowHeight);
|
2017-09-16 16:53:41 +00:00
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
const auto mainSectionWidth = width()
|
|
|
|
- dialogsWidth
|
|
|
|
- thirdSectionWidth;
|
2017-04-25 20:36:04 +00:00
|
|
|
if (_callTopBar) {
|
2017-09-16 16:53:41 +00:00
|
|
|
_callTopBar->resizeToWidth(mainSectionWidth);
|
2017-04-25 20:36:04 +00:00
|
|
|
_callTopBar->moveToLeft(dialogsWidth, 0);
|
|
|
|
}
|
2018-06-20 00:02:36 +00:00
|
|
|
if (_exportTopBar) {
|
|
|
|
_exportTopBar->resizeToWidth(mainSectionWidth);
|
|
|
|
_exportTopBar->moveToLeft(dialogsWidth, _callTopBarHeight);
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
2017-09-16 16:53:41 +00:00
|
|
|
_player->resizeToWidth(mainSectionWidth);
|
2018-06-20 00:02:36 +00:00
|
|
|
_player->moveToLeft(
|
|
|
|
dialogsWidth,
|
|
|
|
_callTopBarHeight + _exportTopBarHeight);
|
2016-10-12 19:34:25 +00:00
|
|
|
}
|
2022-01-04 13:13:00 +00:00
|
|
|
_history->setGeometryWithTopMoved(QRect(
|
|
|
|
dialogsWidth,
|
|
|
|
mainSectionTop,
|
|
|
|
mainSectionWidth,
|
|
|
|
height() - mainSectionTop
|
|
|
|
), _contentScrollAddToY);
|
2015-10-17 08:31:48 +00:00
|
|
|
if (_hider) {
|
2022-01-04 13:13:00 +00:00
|
|
|
_hider->setGeometryToLeft(
|
|
|
|
dialogsWidth,
|
|
|
|
0,
|
|
|
|
mainSectionWidth,
|
|
|
|
height());
|
2015-10-17 08:31:48 +00:00
|
|
|
}
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_mainSection) {
|
2022-01-04 13:13:00 +00:00
|
|
|
const auto mainSectionGeometry = QRect(
|
|
|
|
_history->x(),
|
|
|
|
mainSectionTop,
|
|
|
|
_history->width(),
|
|
|
|
height() - mainSectionTop);
|
|
|
|
_mainSection->setGeometryWithTopMoved(
|
|
|
|
mainSectionGeometry,
|
|
|
|
_contentScrollAddToY);
|
2016-05-12 16:05:20 +00:00
|
|
|
}
|
2017-11-12 15:41:00 +00:00
|
|
|
refreshResizeAreas();
|
2021-11-24 14:26:39 +00:00
|
|
|
if (_player) {
|
|
|
|
_player->entity()->updateDropdownsGeometry();
|
|
|
|
}
|
2016-10-14 17:10:15 +00:00
|
|
|
updateMediaPlaylistPosition(_playerPlaylist->x());
|
2015-07-03 08:47:16 +00:00
|
|
|
_contentScrollAddToY = 0;
|
2018-11-05 11:16:09 +00:00
|
|
|
|
2018-11-05 13:18:54 +00:00
|
|
|
floatPlayerUpdatePositions();
|
2015-07-03 08:47:16 +00:00
|
|
|
}
|
|
|
|
|
2017-11-12 15:41:00 +00:00
|
|
|
void MainWidget::refreshResizeAreas() {
|
2022-06-07 18:05:37 +00:00
|
|
|
if (!isOneColumn() && _dialogs) {
|
2017-11-12 15:41:00 +00:00
|
|
|
ensureFirstColumnResizeAreaCreated();
|
|
|
|
_firstColumnResizeArea->setGeometryToLeft(
|
|
|
|
_history->x(),
|
|
|
|
0,
|
|
|
|
st::historyResizeWidth,
|
|
|
|
height());
|
|
|
|
} else if (_firstColumnResizeArea) {
|
|
|
|
_firstColumnResizeArea.destroy();
|
|
|
|
}
|
|
|
|
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isThreeColumn() && _thirdSection) {
|
2017-11-12 15:41:00 +00:00
|
|
|
ensureThirdColumnResizeAreaCreated();
|
|
|
|
_thirdColumnResizeArea->setGeometryToLeft(
|
|
|
|
_thirdSection->x(),
|
|
|
|
0,
|
|
|
|
st::historyResizeWidth,
|
|
|
|
height());
|
|
|
|
} else if (_thirdColumnResizeArea) {
|
|
|
|
_thirdColumnResizeArea.destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename MoveCallback, typename FinishCallback>
|
|
|
|
void MainWidget::createResizeArea(
|
|
|
|
object_ptr<Ui::ResizeArea> &area,
|
|
|
|
MoveCallback &&moveCallback,
|
|
|
|
FinishCallback &&finishCallback) {
|
|
|
|
area.create(this);
|
|
|
|
area->show();
|
|
|
|
area->addMoveLeftCallback(
|
|
|
|
std::forward<MoveCallback>(moveCallback));
|
|
|
|
area->addMoveFinishedCallback(
|
|
|
|
std::forward<FinishCallback>(finishCallback));
|
|
|
|
orderWidgets();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::ensureFirstColumnResizeAreaCreated() {
|
2022-06-07 18:05:37 +00:00
|
|
|
Expects(_dialogs != nullptr);
|
|
|
|
|
2017-11-12 15:41:00 +00:00
|
|
|
if (_firstColumnResizeArea) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto moveLeftCallback = [=](int globalLeft) {
|
|
|
|
auto newWidth = globalLeft - mapToGlobal(QPoint(0, 0)).x();
|
2017-11-12 16:50:58 +00:00
|
|
|
auto newRatio = (newWidth < st::columnMinimalWidthLeft / 2)
|
2017-11-12 15:41:00 +00:00
|
|
|
? 0.
|
|
|
|
: float64(newWidth) / width();
|
2020-06-25 12:16:09 +00:00
|
|
|
Core::App().settings().setDialogsWidthRatio(newRatio);
|
2017-11-12 15:41:00 +00:00
|
|
|
};
|
|
|
|
auto moveFinishedCallback = [=] {
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isOneColumn()) {
|
2017-11-12 16:50:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-06-25 12:16:09 +00:00
|
|
|
if (Core::App().settings().dialogsWidthRatio() > 0) {
|
|
|
|
Core::App().settings().setDialogsWidthRatio(
|
2017-11-12 15:41:00 +00:00
|
|
|
float64(_dialogsWidth) / width());
|
|
|
|
}
|
2020-06-25 12:16:09 +00:00
|
|
|
Core::App().saveSettingsDelayed();
|
2017-11-12 15:41:00 +00:00
|
|
|
};
|
|
|
|
createResizeArea(
|
|
|
|
_firstColumnResizeArea,
|
|
|
|
std::move(moveLeftCallback),
|
|
|
|
std::move(moveFinishedCallback));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::ensureThirdColumnResizeAreaCreated() {
|
|
|
|
if (_thirdColumnResizeArea) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto moveLeftCallback = [=](int globalLeft) {
|
2017-11-12 16:50:58 +00:00
|
|
|
auto newWidth = mapToGlobal(QPoint(width(), 0)).x() - globalLeft;
|
2020-06-25 12:16:09 +00:00
|
|
|
Core::App().settings().setThirdColumnWidth(newWidth);
|
2017-11-12 15:41:00 +00:00
|
|
|
};
|
|
|
|
auto moveFinishedCallback = [=] {
|
2021-05-26 23:20:27 +00:00
|
|
|
if (!isThreeColumn() || !_thirdSection) {
|
2017-11-12 16:50:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-01-23 03:29:50 +00:00
|
|
|
Core::App().settings().setThirdColumnWidth(std::clamp(
|
2020-06-25 12:16:09 +00:00
|
|
|
Core::App().settings().thirdColumnWidth(),
|
2017-11-12 16:50:58 +00:00
|
|
|
st::columnMinimalWidthThird,
|
|
|
|
st::columnMaximalWidthThird));
|
2020-06-25 12:16:09 +00:00
|
|
|
Core::App().saveSettingsDelayed();
|
2017-11-12 15:41:00 +00:00
|
|
|
};
|
|
|
|
createResizeArea(
|
|
|
|
_thirdColumnResizeArea,
|
|
|
|
std::move(moveLeftCallback),
|
|
|
|
std::move(moveFinishedCallback));
|
|
|
|
}
|
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
void MainWidget::updateDialogsWidthAnimated() {
|
2022-01-04 13:13:00 +00:00
|
|
|
if (!_dialogs || Core::App().settings().dialogsWidthRatio() > 0) {
|
2017-01-14 18:50:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto dialogsWidth = _dialogsWidth;
|
|
|
|
updateWindowAdaptiveLayout();
|
2020-06-25 12:16:09 +00:00
|
|
|
if (!Core::App().settings().dialogsWidthRatio()
|
2017-09-19 18:59:10 +00:00
|
|
|
&& (_dialogsWidth != dialogsWidth
|
|
|
|
|| _a_dialogsWidth.animating())) {
|
2017-01-14 18:50:16 +00:00
|
|
|
_dialogs->startWidthAnimation();
|
2017-09-19 18:59:10 +00:00
|
|
|
_a_dialogsWidth.start(
|
|
|
|
[this] { updateControlsGeometry(); },
|
|
|
|
dialogsWidth,
|
|
|
|
_dialogsWidth,
|
|
|
|
st::dialogsWidthDuration,
|
|
|
|
anim::easeOutCirc);
|
2017-01-14 18:50:16 +00:00
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-28 20:01:00 +00:00
|
|
|
bool MainWidget::saveThirdSectionToStackBack() const {
|
|
|
|
return !_stack.empty()
|
|
|
|
&& _thirdSection != nullptr
|
|
|
|
&& _stack.back()->thirdSectionWeak() == _thirdSection.data();
|
|
|
|
}
|
|
|
|
|
|
|
|
auto MainWidget::thirdSectionForCurrentMainSection(
|
2018-01-22 16:42:25 +00:00
|
|
|
Dialogs::Key key)
|
2020-12-14 14:48:10 +00:00
|
|
|
-> std::shared_ptr<Window::SectionMemento> {
|
2017-11-28 20:01:00 +00:00
|
|
|
if (_thirdSectionFromStack) {
|
|
|
|
return std::move(_thirdSectionFromStack);
|
2022-09-27 12:05:47 +00:00
|
|
|
} else if (const auto topic = key.topic()) {
|
|
|
|
return std::make_shared<Info::Memento>(topic);
|
2018-01-22 16:42:25 +00:00
|
|
|
} else if (const auto peer = key.peer()) {
|
2020-12-14 14:48:10 +00:00
|
|
|
return std::make_shared<Info::Memento>(
|
2020-06-08 09:06:50 +00:00
|
|
|
peer,
|
2019-04-15 11:54:03 +00:00
|
|
|
Info::Memento::DefaultSection(peer));
|
2017-11-28 20:01:00 +00:00
|
|
|
}
|
2018-01-22 19:51:38 +00:00
|
|
|
Unexpected("Key in MainWidget::thirdSectionForCurrentMainSection().");
|
2017-11-28 20:01:00 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 16:42:25 +00:00
|
|
|
void MainWidget::updateThirdColumnToCurrentChat(
|
|
|
|
Dialogs::Key key,
|
2017-09-20 18:40:23 +00:00
|
|
|
bool canWrite) {
|
2017-10-03 18:13:36 +00:00
|
|
|
auto saveOldThirdSection = [&] {
|
2017-11-28 20:01:00 +00:00
|
|
|
if (saveThirdSectionToStackBack()) {
|
2017-10-03 18:13:36 +00:00
|
|
|
_stack.back()->setThirdSectionMemento(
|
|
|
|
_thirdSection->createMemento());
|
2017-11-13 06:00:38 +00:00
|
|
|
_thirdSection.destroy();
|
2017-10-03 18:13:36 +00:00
|
|
|
}
|
|
|
|
};
|
2020-06-25 12:16:09 +00:00
|
|
|
auto &settings = Core::App().settings();
|
2017-11-12 09:54:18 +00:00
|
|
|
auto params = Window::SectionShow(
|
|
|
|
Window::SectionShow::Way::ClearStack,
|
|
|
|
anim::type::instant,
|
|
|
|
anim::activation::background);
|
2017-10-03 18:13:36 +00:00
|
|
|
auto switchInfoFast = [&] {
|
|
|
|
saveOldThirdSection();
|
2017-11-28 20:01:00 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Like in _controller->showPeerInfo()
|
|
|
|
//
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isThreeColumn()
|
2020-06-25 12:16:09 +00:00
|
|
|
&& !settings.thirdSectionInfoEnabled()) {
|
|
|
|
settings.setThirdSectionInfoEnabled(true);
|
|
|
|
Core::App().saveSettingsDelayed();
|
2017-11-28 20:01:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_controller->showSection(
|
2020-11-21 22:37:05 +00:00
|
|
|
thirdSectionForCurrentMainSection(key),
|
2017-12-04 07:33:33 +00:00
|
|
|
params.withThirdColumn());
|
2017-10-03 18:13:36 +00:00
|
|
|
};
|
2022-10-25 08:07:47 +00:00
|
|
|
auto switchTabbedFast = [&](not_null<Data::Thread*> thread) {
|
2017-10-03 18:13:36 +00:00
|
|
|
saveOldThirdSection();
|
2020-10-01 14:20:08 +00:00
|
|
|
return _mainSection
|
2022-10-25 08:07:47 +00:00
|
|
|
? _mainSection->pushTabbedSelectorToThirdSection(thread, params)
|
|
|
|
: _history->pushTabbedSelectorToThirdSection(thread, params);
|
2017-10-03 18:13:36 +00:00
|
|
|
};
|
2021-05-26 23:20:27 +00:00
|
|
|
if (isThreeColumn()
|
2020-06-25 12:16:09 +00:00
|
|
|
&& settings.tabbedSelectorSectionEnabled()
|
2018-01-22 16:42:25 +00:00
|
|
|
&& key) {
|
2017-09-20 18:40:23 +00:00
|
|
|
if (!canWrite) {
|
2017-10-03 18:13:36 +00:00
|
|
|
switchInfoFast();
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.setTabbedSelectorSectionEnabled(true);
|
|
|
|
settings.setTabbedReplacedWithInfo(true);
|
|
|
|
} else if (settings.tabbedReplacedWithInfo()
|
2022-10-25 08:07:47 +00:00
|
|
|
&& key.thread()
|
|
|
|
&& switchTabbedFast(key.thread())) {
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.setTabbedReplacedWithInfo(false);
|
2017-09-19 19:44:34 +00:00
|
|
|
}
|
|
|
|
} else {
|
2020-06-25 12:16:09 +00:00
|
|
|
settings.setTabbedReplacedWithInfo(false);
|
2018-01-22 16:42:25 +00:00
|
|
|
if (!key) {
|
2017-11-08 16:45:30 +00:00
|
|
|
if (_thirdSection) {
|
|
|
|
_thirdSection.destroy();
|
|
|
|
_thirdShadow.destroy();
|
|
|
|
updateControlsGeometry();
|
|
|
|
}
|
2021-05-26 23:20:27 +00:00
|
|
|
} else if (isThreeColumn()
|
2020-06-25 12:16:09 +00:00
|
|
|
&& settings.thirdSectionInfoEnabled()) {
|
2017-10-03 18:13:36 +00:00
|
|
|
switchInfoFast();
|
2017-09-19 19:44:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-14 17:10:15 +00:00
|
|
|
void MainWidget::updateMediaPlaylistPosition(int x) {
|
|
|
|
if (_player) {
|
|
|
|
auto playlistLeft = x;
|
|
|
|
auto playlistWidth = _playerPlaylist->width();
|
|
|
|
auto playlistTop = _player->y() + _player->height();
|
|
|
|
auto rightEdge = width();
|
|
|
|
if (playlistLeft + playlistWidth > rightEdge) {
|
|
|
|
playlistLeft = rightEdge - playlistWidth;
|
|
|
|
} else if (playlistLeft < 0) {
|
|
|
|
playlistLeft = 0;
|
|
|
|
}
|
|
|
|
_playerPlaylist->move(playlistLeft, playlistTop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-16 12:44:20 +00:00
|
|
|
void MainWidget::returnTabbedSelector() {
|
|
|
|
if (!_mainSection || !_mainSection->returnTabbedSelector()) {
|
|
|
|
_history->returnTabbedSelector();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
bool MainWidget::eventFilter(QObject *o, QEvent *e) {
|
2023-01-18 11:36:32 +00:00
|
|
|
const auto widget = o->isWidgetType()
|
|
|
|
? static_cast<QWidget*>(o)
|
|
|
|
: nullptr;
|
2017-11-12 15:41:00 +00:00
|
|
|
if (e->type() == QEvent::FocusIn) {
|
2023-01-18 11:36:32 +00:00
|
|
|
if (widget && (widget->window() == window())) {
|
2017-01-14 18:50:16 +00:00
|
|
|
if (_history == widget || _history->isAncestorOf(widget)
|
2023-01-18 11:36:32 +00:00
|
|
|
|| (_mainSection
|
|
|
|
&& (_mainSection == widget
|
|
|
|
|| _mainSection->isAncestorOf(widget)))
|
|
|
|
|| (_thirdSection
|
|
|
|
&& (_thirdSection == widget
|
|
|
|
|| _thirdSection->isAncestorOf(widget)))) {
|
2022-11-11 07:21:40 +00:00
|
|
|
_controller->setDialogsListFocused(false);
|
2022-01-04 13:13:00 +00:00
|
|
|
} else if (_dialogs
|
2023-01-18 11:36:32 +00:00
|
|
|
&& (_dialogs == widget
|
|
|
|
|| _dialogs->isAncestorOf(widget))) {
|
2022-11-11 07:21:40 +00:00
|
|
|
_controller->setDialogsListFocused(true);
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
|
|
|
}
|
2017-02-09 13:49:43 +00:00
|
|
|
} else if (e->type() == QEvent::MouseButtonPress) {
|
2023-01-18 11:36:32 +00:00
|
|
|
if (widget && (widget->window() == window())) {
|
|
|
|
const auto event = static_cast<QMouseEvent*>(e);
|
|
|
|
if (event->button() == Qt::BackButton) {
|
|
|
|
if (!Core::App().hideMediaView()) {
|
|
|
|
handleHistoryBack();
|
|
|
|
}
|
|
|
|
return true;
|
2019-06-30 13:21:53 +00:00
|
|
|
}
|
2017-02-09 13:49:43 +00:00
|
|
|
}
|
2018-11-05 11:16:09 +00:00
|
|
|
} else if (e->type() == QEvent::Wheel) {
|
2023-01-18 11:36:32 +00:00
|
|
|
if (widget && (widget->window() == window())) {
|
|
|
|
if (const auto result = floatPlayerFilterWheelEvent(o, e)) {
|
|
|
|
return *result;
|
|
|
|
}
|
2017-05-22 15:25:49 +00:00
|
|
|
}
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
2018-11-05 11:16:09 +00:00
|
|
|
return RpWidget::eventFilter(o, e);
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWidget::handleAdaptiveLayoutUpdate() {
|
2014-12-12 16:27:03 +00:00
|
|
|
showAll();
|
2022-01-04 13:13:00 +00:00
|
|
|
if (_sideShadow) {
|
|
|
|
_sideShadow->setVisible(!isOneColumn());
|
|
|
|
}
|
2016-10-12 19:34:25 +00:00
|
|
|
if (_player) {
|
|
|
|
_player->updateAdaptiveLayout();
|
|
|
|
}
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
|
2019-05-12 12:59:01 +00:00
|
|
|
void MainWidget::handleHistoryBack() {
|
|
|
|
const auto openedFolder = _controller->openedFolder().current();
|
2022-11-30 06:31:33 +00:00
|
|
|
const auto openedForum = _controller->shownForum().current();
|
2022-11-10 18:42:15 +00:00
|
|
|
const auto rootPeer = !_stack.empty()
|
|
|
|
? _stack.front()->peer()
|
|
|
|
: _history->peer()
|
2022-11-08 17:20:25 +00:00
|
|
|
? _history->peer()
|
2022-11-10 18:42:15 +00:00
|
|
|
: _mainSection
|
|
|
|
? _mainSection->activeChat().key.peer()
|
|
|
|
: nullptr;
|
2022-11-08 17:20:25 +00:00
|
|
|
const auto rootHistory = rootPeer
|
|
|
|
? rootPeer->owner().historyLoaded(rootPeer)
|
|
|
|
: nullptr;
|
|
|
|
const auto rootFolder = rootHistory ? rootHistory->folder() : nullptr;
|
2022-12-02 09:48:30 +00:00
|
|
|
if (openedForum && (!rootPeer || rootPeer->forum() != openedForum)) {
|
2022-11-10 18:42:15 +00:00
|
|
|
_controller->closeForum();
|
|
|
|
} else if (!openedFolder
|
2023-01-18 11:36:32 +00:00
|
|
|
|| (rootFolder == openedFolder)
|
|
|
|
|| (!_dialogs || _dialogs->isHidden())) {
|
2019-05-12 12:59:01 +00:00
|
|
|
_controller->showBackFromStack();
|
2023-01-18 11:36:32 +00:00
|
|
|
if (_dialogs) {
|
|
|
|
_dialogs->setInnerFocus();
|
|
|
|
}
|
2019-05-12 12:59:01 +00:00
|
|
|
} else {
|
|
|
|
_controller->closeFolder();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-14 18:50:16 +00:00
|
|
|
void MainWidget::updateWindowAdaptiveLayout() {
|
2017-04-09 18:06:06 +00:00
|
|
|
auto layout = _controller->computeColumnLayout();
|
2020-06-25 12:16:09 +00:00
|
|
|
auto dialogsWidthRatio = Core::App().settings().dialogsWidthRatio();
|
2017-05-17 11:50:00 +00:00
|
|
|
|
|
|
|
// Check if we are in a single-column layout in a wide enough window
|
|
|
|
// for the normal layout. If so, switch to the normal layout.
|
2021-05-27 13:54:24 +00:00
|
|
|
if (layout.windowLayout == Window::Adaptive::WindowLayout::OneColumn) {
|
2017-05-17 12:38:42 +00:00
|
|
|
auto chatWidth = layout.chatWidth;
|
2019-01-18 12:27:37 +00:00
|
|
|
//if (session().settings().tabbedSelectorSectionEnabled()
|
2017-09-16 16:53:41 +00:00
|
|
|
// && chatWidth >= _history->minimalWidthForTabbedSelectorSection()) {
|
|
|
|
// chatWidth -= _history->tabbedSelectorSectionWidth();
|
|
|
|
//}
|
|
|
|
auto minimalNormalWidth = st::columnMinimalWidthLeft
|
|
|
|
+ st::columnMinimalWidthMain;
|
|
|
|
if (chatWidth >= minimalNormalWidth) {
|
2017-05-13 12:02:07 +00:00
|
|
|
// Switch layout back to normal in a wide enough window.
|
2021-05-27 13:54:24 +00:00
|
|
|
layout.windowLayout = Window::Adaptive::WindowLayout::Normal;
|
2017-09-16 16:53:41 +00:00
|
|
|
layout.dialogsWidth = st::columnMinimalWidthLeft;
|
2017-05-17 12:38:42 +00:00
|
|
|
layout.chatWidth = layout.bodyWidth - layout.dialogsWidth;
|
|
|
|
dialogsWidthRatio = float64(layout.dialogsWidth) / layout.bodyWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if we are going to create the third column and shrink the
|
|
|
|
// dialogs widget to provide a wide enough chat history column.
|
|
|
|
// Don't shrink the column on the first call, when window is inited.
|
2021-05-27 13:54:24 +00:00
|
|
|
if (layout.windowLayout == Window::Adaptive::WindowLayout::ThreeColumn
|
2020-06-16 14:19:23 +00:00
|
|
|
&& _controller->widget()->positionInited()) {
|
2017-09-16 16:53:41 +00:00
|
|
|
//auto chatWidth = layout.chatWidth;
|
|
|
|
//if (_history->willSwitchToTabbedSelectorWithWidth(chatWidth)) {
|
|
|
|
// auto thirdColumnWidth = _history->tabbedSelectorSectionWidth();
|
|
|
|
// auto twoColumnsWidth = (layout.bodyWidth - thirdColumnWidth);
|
|
|
|
// auto sameRatioChatWidth = twoColumnsWidth - qRound(dialogsWidthRatio * twoColumnsWidth);
|
2018-01-09 17:08:31 +00:00
|
|
|
// auto desiredChatWidth = qMax(sameRatioChatWidth, HistoryView::WideChatWidth());
|
2017-09-16 16:53:41 +00:00
|
|
|
// chatWidth -= thirdColumnWidth;
|
|
|
|
// auto extendChatBy = desiredChatWidth - chatWidth;
|
|
|
|
// accumulate_min(extendChatBy, layout.dialogsWidth - st::columnMinimalWidthLeft);
|
|
|
|
// if (extendChatBy > 0) {
|
|
|
|
// layout.dialogsWidth -= extendChatBy;
|
|
|
|
// layout.chatWidth += extendChatBy;
|
|
|
|
// dialogsWidthRatio = float64(layout.dialogsWidth) / layout.bodyWidth;
|
|
|
|
// }
|
|
|
|
//}
|
2017-05-13 12:02:07 +00:00
|
|
|
}
|
2017-05-17 11:50:00 +00:00
|
|
|
|
2020-06-25 12:16:09 +00:00
|
|
|
Core::App().settings().setDialogsWidthRatio(dialogsWidthRatio);
|
2017-05-17 12:38:42 +00:00
|
|
|
|
2021-05-26 23:20:27 +00:00
|
|
|
auto useSmallColumnWidth = !isOneColumn()
|
2017-09-19 18:59:10 +00:00
|
|
|
&& !dialogsWidthRatio
|
|
|
|
&& !_controller->forceWideDialogs();
|
2022-02-20 08:38:07 +00:00
|
|
|
_dialogsWidth = !_dialogs
|
|
|
|
? 0
|
|
|
|
: useSmallColumnWidth
|
2017-09-19 18:59:10 +00:00
|
|
|
? _controller->dialogsSmallColumnWidth()
|
|
|
|
: layout.dialogsWidth;
|
2017-11-12 16:50:58 +00:00
|
|
|
_thirdColumnWidth = layout.thirdWidth;
|
2021-05-26 23:20:27 +00:00
|
|
|
_controller->adaptive().setWindowLayout(layout.windowLayout);
|
2017-01-14 18:50:16 +00:00
|
|
|
}
|
|
|
|
|
2016-10-12 19:34:25 +00:00
|
|
|
int MainWidget::backgroundFromY() const {
|
2017-09-16 16:53:41 +00:00
|
|
|
return -getMainSectionTop();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 17:39:20 +00:00
|
|
|
void MainWidget::searchInChat(Dialogs::Key chat) {
|
2023-01-18 11:17:32 +00:00
|
|
|
searchMessages(QString(), chat);
|
2015-08-04 15:01:47 +00:00
|
|
|
}
|
|
|
|
|
2020-09-17 17:57:06 +00:00
|
|
|
bool MainWidget::contentOverlapped(const QRect &globalRect) {
|
2021-11-24 14:26:39 +00:00
|
|
|
return _history->contentOverlapped(globalRect)
|
|
|
|
|| _playerPlaylist->overlaps(globalRect);
|
2020-09-17 17:57:06 +00:00
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void MainWidget::activate() {
|
2022-12-01 10:14:35 +00:00
|
|
|
if (_showAnimation) {
|
2020-06-08 17:24:36 +00:00
|
|
|
return;
|
2022-11-30 12:02:40 +00:00
|
|
|
} else if (const auto paths = cSendPaths(); !paths.isEmpty()) {
|
2022-11-26 21:20:17 +00:00
|
|
|
const auto interpret = u"interpret://"_q;
|
2022-11-30 12:02:40 +00:00
|
|
|
cSetSendPaths(QStringList());
|
|
|
|
if (paths[0].startsWith(interpret)) {
|
2022-11-01 07:18:56 +00:00
|
|
|
const auto error = Support::InterpretSendPath(
|
|
|
|
_controller,
|
2022-11-30 12:02:40 +00:00
|
|
|
paths[0].mid(interpret.size()));
|
2022-11-01 07:18:56 +00:00
|
|
|
if (!error.isEmpty()) {
|
2023-01-10 18:56:20 +00:00
|
|
|
_controller->show(Ui::MakeInformBox(error));
|
2022-11-01 07:18:56 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-11-30 12:02:40 +00:00
|
|
|
const auto chosen = [=](not_null<Data::Thread*> thread) {
|
|
|
|
return sendPaths(thread, paths);
|
|
|
|
};
|
|
|
|
Window::ShowChooseRecipientBox(_controller, chosen);
|
2022-11-01 07:18:56 +00:00
|
|
|
}
|
|
|
|
} else if (_mainSection) {
|
|
|
|
_mainSection->setInnerFocus();
|
|
|
|
} else if (_hider) {
|
|
|
|
Assert(_dialogs != nullptr);
|
|
|
|
_dialogs->setInnerFocus();
|
2022-11-30 13:28:09 +00:00
|
|
|
} else if (!_controller->isLayerShown()) {
|
2022-11-01 07:18:56 +00:00
|
|
|
if (_history->peer()) {
|
|
|
|
_history->activate();
|
|
|
|
} else {
|
2022-01-04 13:13:00 +00:00
|
|
|
Assert(_dialogs != nullptr);
|
2019-04-24 14:12:35 +00:00
|
|
|
_dialogs->setInnerFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-25 15:12:51 +00:00
|
|
|
_controller->widget()->fixOrder();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2022-11-02 16:03:42 +00:00
|
|
|
bool MainWidget::animatingShow() const {
|
2022-12-01 10:14:35 +00:00
|
|
|
return _showAnimation != nullptr;
|
2017-08-11 07:16:07 +00:00
|
|
|
}
|
|
|
|
|
2021-05-26 23:20:27 +00:00
|
|
|
bool MainWidget::isOneColumn() const {
|
|
|
|
return _controller->adaptive().isOneColumn();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWidget::isNormalColumn() const {
|
|
|
|
return _controller->adaptive().isNormal();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWidget::isThreeColumn() const {
|
|
|
|
return _controller->adaptive().isThreeColumn();
|
|
|
|
}
|