mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to open peer in new window from short info box.
This commit is contained in:
parent
743c3c54a7
commit
10b026dfe0
5 changed files with 92 additions and 24 deletions
|
@ -7,27 +7,36 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/peers/peer_short_info_box.h"
|
#include "boxes/peers/peer_short_info_box.h"
|
||||||
|
|
||||||
#include "ui/effects/radial_animation.h"
|
#include "base/event_filter.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "core/application.h"
|
||||||
#include "ui/widgets/scroll_area.h"
|
|
||||||
#include "ui/wrap/vertical_layout.h"
|
|
||||||
#include "ui/wrap/slide_wrap.h"
|
|
||||||
#include "ui/wrap/wrap.h"
|
|
||||||
#include "ui/image/image_prepare.h"
|
|
||||||
#include "ui/text/text_utilities.h"
|
|
||||||
#include "ui/painter.h"
|
|
||||||
#include "info/profile/info_profile_text.h"
|
#include "info/profile/info_profile_text.h"
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
|
#include "lang/lang_keys.h"
|
||||||
#include "media/streaming/media_streaming_instance.h"
|
#include "media/streaming/media_streaming_instance.h"
|
||||||
#include "media/streaming/media_streaming_player.h"
|
#include "media/streaming/media_streaming_player.h"
|
||||||
#include "base/event_filter.h"
|
#include "ui/effects/radial_animation.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "ui/image/image_prepare.h"
|
||||||
|
#include "ui/painter.h"
|
||||||
|
#include "ui/text/text_utilities.h"
|
||||||
|
#include "ui/widgets/labels.h"
|
||||||
|
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||||
|
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
|
||||||
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
#include "ui/widgets/scroll_area.h"
|
||||||
|
#include "ui/wrap/slide_wrap.h"
|
||||||
|
#include "ui/wrap/vertical_layout.h"
|
||||||
|
#include "ui/wrap/wrap.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_layers.h"
|
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
#include "styles/style_layers.h"
|
||||||
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using MenuCallback = Ui::Menu::MenuCallback;
|
||||||
|
|
||||||
constexpr auto kShadowMaxAlpha = 80;
|
constexpr auto kShadowMaxAlpha = 80;
|
||||||
constexpr auto kInactiveBarOpacity = 0.5;
|
constexpr auto kInactiveBarOpacity = 0.5;
|
||||||
|
|
||||||
|
@ -833,6 +842,24 @@ void PeerShortInfoBox::refreshRoundedTopImage(const QColor &color) {
|
||||||
RectPart::TopLeft | RectPart::TopRight);
|
RectPart::TopLeft | RectPart::TopRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpl::producer<MenuCallback> PeerShortInfoBox::fillMenuRequests() const {
|
||||||
|
return _fillMenuRequests.events();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PeerShortInfoBox::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
|
_menuHolder = nullptr;
|
||||||
|
const auto menu = Ui::CreateChild<Ui::PopupMenu>(
|
||||||
|
this,
|
||||||
|
st::popupMenuWithIcons);
|
||||||
|
_fillMenuRequests.fire(Ui::Menu::CreateAddActionCallback(menu));
|
||||||
|
_menuHolder.reset(menu);
|
||||||
|
if (menu->empty()) {
|
||||||
|
_menuHolder = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
menu->popup(e->globalPos());
|
||||||
|
}
|
||||||
|
|
||||||
rpl::producer<QString> PeerShortInfoBox::nameValue() const {
|
rpl::producer<QString> PeerShortInfoBox::nameValue() const {
|
||||||
return _fields.value(
|
return _fields.value(
|
||||||
) | rpl::map([](const PeerShortInfoFields &fields) {
|
) | rpl::map([](const PeerShortInfoFields &fields) {
|
||||||
|
|
|
@ -15,6 +15,10 @@ struct ShortInfoCover;
|
||||||
struct ShortInfoBox;
|
struct ShortInfoBox;
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
||||||
|
namespace Ui::Menu {
|
||||||
|
struct MenuCallback;
|
||||||
|
} // namespace Ui::Menu
|
||||||
|
|
||||||
namespace Media::Streaming {
|
namespace Media::Streaming {
|
||||||
class Document;
|
class Document;
|
||||||
class Instance;
|
class Instance;
|
||||||
|
@ -160,6 +164,11 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<> openRequests() const;
|
[[nodiscard]] rpl::producer<> openRequests() const;
|
||||||
[[nodiscard]] rpl::producer<int> moveRequests() const;
|
[[nodiscard]] rpl::producer<int> moveRequests() const;
|
||||||
|
[[nodiscard]] auto fillMenuRequests() const
|
||||||
|
-> rpl::producer<Ui::Menu::MenuCallback>;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -192,6 +201,9 @@ private:
|
||||||
not_null<Ui::VerticalLayout*> _rows;
|
not_null<Ui::VerticalLayout*> _rows;
|
||||||
PeerShortInfoCover _cover;
|
PeerShortInfoCover _cover;
|
||||||
|
|
||||||
|
base::unique_qptr<Ui::RpWidget> _menuHolder;
|
||||||
|
rpl::event_stream<Ui::Menu::MenuCallback> _fillMenuRequests;
|
||||||
|
|
||||||
rpl::event_stream<> _openRequests;
|
rpl::event_stream<> _openRequests;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,26 +7,30 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/peers/prepare_short_info_box.h"
|
#include "boxes/peers/prepare_short_info_box.h"
|
||||||
|
|
||||||
|
#include "base/unixtime.h"
|
||||||
#include "boxes/peers/peer_short_info_box.h"
|
#include "boxes/peers/peer_short_info_box.h"
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "data/data_changes.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_chat.h"
|
||||||
|
#include "data/data_file_origin.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
|
#include "data/data_peer_values.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_photo_media.h"
|
#include "data/data_photo_media.h"
|
||||||
#include "data/data_streaming.h"
|
|
||||||
#include "data/data_file_origin.h"
|
|
||||||
#include "data/data_user.h"
|
|
||||||
#include "data/data_chat.h"
|
|
||||||
#include "data/data_channel.h"
|
|
||||||
#include "data/data_peer_values.h"
|
|
||||||
#include "data/data_user_photos.h"
|
|
||||||
#include "data/data_changes.h"
|
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "main/main_session.h"
|
#include "data/data_streaming.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_user_photos.h"
|
||||||
#include "info/profile/info_profile_values.h"
|
#include "info/profile/info_profile_values.h"
|
||||||
#include "ui/text/format_values.h"
|
|
||||||
#include "base/unixtime.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "main/main_session.h"
|
||||||
|
#include "ui/delayed_activation.h" // PreventDelayedActivation
|
||||||
|
#include "ui/text/format_values.h"
|
||||||
|
#include "ui/widgets/menu/menu_add_action_callback.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -446,6 +450,7 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Fn<void()> open,
|
Fn<void()> open,
|
||||||
Fn<bool()> videoPaused,
|
Fn<bool()> videoPaused,
|
||||||
|
Fn<void(Ui::Menu::MenuCallback)> menuFiller,
|
||||||
const style::ShortInfoBox *stOverride) {
|
const style::ShortInfoBox *stOverride) {
|
||||||
const auto type = peer->isSelf()
|
const auto type = peer->isSelf()
|
||||||
? PeerShortInfoType::Self
|
? PeerShortInfoType::Self
|
||||||
|
@ -463,6 +468,13 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
std::move(videoPaused),
|
std::move(videoPaused),
|
||||||
stOverride);
|
stOverride);
|
||||||
|
|
||||||
|
if (menuFiller) {
|
||||||
|
result->fillMenuRequests(
|
||||||
|
) | rpl::start_with_next([=](Ui::Menu::MenuCallback callback) {
|
||||||
|
menuFiller(std::move(callback));
|
||||||
|
}, result->lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
result->openRequests(
|
result->openRequests(
|
||||||
) | rpl::start_with_next(open, result->lifetime());
|
) | rpl::start_with_next(open, result->lifetime());
|
||||||
|
|
||||||
|
@ -481,10 +493,21 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
return navigation->parentController()->isGifPausedAtLeastFor(
|
return navigation->parentController()->isGifPausedAtLeastFor(
|
||||||
Window::GifPauseReason::Layer);
|
Window::GifPauseReason::Layer);
|
||||||
};
|
};
|
||||||
|
auto menuFiller = [=](Ui::Menu::MenuCallback addAction) {
|
||||||
|
const auto controller = navigation->parentController();
|
||||||
|
const auto peerSeparateId = Window::SeparateId(peer);
|
||||||
|
if (controller->windowId() != peerSeparateId) {
|
||||||
|
addAction(tr::lng_context_new_window(tr::now), [=] {
|
||||||
|
Ui::PreventDelayedActivation();
|
||||||
|
controller->showInNewWindow(peer);
|
||||||
|
}, &st::menuIconNewWindow);
|
||||||
|
}
|
||||||
|
};
|
||||||
return PrepareShortInfoBox(
|
return PrepareShortInfoBox(
|
||||||
peer,
|
peer,
|
||||||
open,
|
open,
|
||||||
videoIsPaused,
|
videoIsPaused,
|
||||||
|
std::move(menuFiller),
|
||||||
stOverride);
|
stOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@ struct ShortInfoCover;
|
||||||
struct ShortInfoBox;
|
struct ShortInfoBox;
|
||||||
} // namespace style
|
} // namespace style
|
||||||
|
|
||||||
|
namespace Ui::Menu {
|
||||||
|
struct MenuCallback;
|
||||||
|
} // namespace Ui::Menu
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class BoxContent;
|
class BoxContent;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
@ -35,6 +39,7 @@ struct PreparedShortInfoUserpic {
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Fn<void()> open,
|
Fn<void()> open,
|
||||||
Fn<bool()> videoPaused,
|
Fn<bool()> videoPaused,
|
||||||
|
Fn<void(Ui::Menu::MenuCallback)> menuFiller,
|
||||||
const style::ShortInfoBox *stOverride = nullptr);
|
const style::ShortInfoBox *stOverride = nullptr);
|
||||||
|
|
||||||
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareShortInfoBox(
|
||||||
|
|
|
@ -1921,6 +1921,7 @@ object_ptr<Ui::BoxContent> PrepareShortInfoBox(not_null<PeerData*> peer) {
|
||||||
peer,
|
peer,
|
||||||
open,
|
open,
|
||||||
[] { return false; },
|
[] { return false; },
|
||||||
|
nullptr,
|
||||||
&st::storiesShortInfoBox);
|
&st::storiesShortInfoBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue