mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Moved process of separated window for shared media to correspond file.
This commit is contained in:
parent
a676138745
commit
ef9f7ab27a
6 changed files with 109 additions and 107 deletions
|
@ -959,6 +959,7 @@ PRIVATE
|
||||||
info/global_media/info_global_media_inner_widget.h
|
info/global_media/info_global_media_inner_widget.h
|
||||||
info/global_media/info_global_media_provider.cpp
|
info/global_media/info_global_media_provider.cpp
|
||||||
info/global_media/info_global_media_provider.h
|
info/global_media/info_global_media_provider.h
|
||||||
|
info/media/info_media_buttons.cpp
|
||||||
info/media/info_media_buttons.h
|
info/media/info_media_buttons.h
|
||||||
info/media/info_media_common.cpp
|
info/media/info_media_common.cpp
|
||||||
info/media/info_media_common.h
|
info/media/info_media_common.h
|
||||||
|
|
87
Telegram/SourceFiles/info/media/info_media_buttons.cpp
Normal file
87
Telegram/SourceFiles/info/media/info_media_buttons.cpp
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "info/media/info_media_buttons.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "base/call_delayed.h"
|
||||||
|
#include "ui/widgets/popup_menu.h"
|
||||||
|
#include "window/window_separate_id.h"
|
||||||
|
#include "styles/style_menu_icons.h"
|
||||||
|
|
||||||
|
namespace Info {
|
||||||
|
namespace Media {
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
Window::SeparateSharedMediaType ToSeparateType(
|
||||||
|
Storage::SharedMediaType type) {
|
||||||
|
using Type = Storage::SharedMediaType;
|
||||||
|
using SeparatedType = Window::SeparateSharedMediaType;
|
||||||
|
return (type == Type::Photo)
|
||||||
|
? SeparatedType::Photos
|
||||||
|
: (type == Type::Video)
|
||||||
|
? SeparatedType::Videos
|
||||||
|
: (type == Type::File)
|
||||||
|
? SeparatedType::Files
|
||||||
|
: (type == Type::MusicFile)
|
||||||
|
? SeparatedType::Audio
|
||||||
|
: (type == Type::Link)
|
||||||
|
? SeparatedType::Links
|
||||||
|
: (type == Type::RoundVoiceFile)
|
||||||
|
? SeparatedType::Voices
|
||||||
|
: (type == Type::GIF)
|
||||||
|
? SeparatedType::GIF
|
||||||
|
: SeparatedType::None;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
Fn<void()> SeparateWindowFactory(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
MsgId topicRootId,
|
||||||
|
Storage::SharedMediaType type) {
|
||||||
|
const auto separateType = ToSeparateType(type);
|
||||||
|
if (separateType == Window::SeparateSharedMediaType::None) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return [=] {
|
||||||
|
controller->showInNewWindow({
|
||||||
|
Window::SeparateSharedMedia(separateType, peer, topicRootId),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddContextMenuToButton(
|
||||||
|
not_null<Ui::AbstractButton*> button,
|
||||||
|
Fn<void()> openInWindow) {
|
||||||
|
if (!openInWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
button->setAcceptBoth();
|
||||||
|
struct State final {
|
||||||
|
base::unique_qptr<Ui::PopupMenu> menu;
|
||||||
|
};
|
||||||
|
const auto state = button->lifetime().make_state<State>();
|
||||||
|
button->addClickHandler([=](Qt::MouseButton mouse) {
|
||||||
|
if (mouse != Qt::RightButton) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
||||||
|
button.get(),
|
||||||
|
st::popupMenuWithIcons);
|
||||||
|
state->menu->addAction(tr::lng_context_new_window(tr::now), [=] {
|
||||||
|
base::call_delayed(
|
||||||
|
st::popupMenuWithIcons.showDuration,
|
||||||
|
crl::guard(button, openInWindow));
|
||||||
|
}, &st::menuIconNewWindow);
|
||||||
|
state->menu->popup(QCursor::pos());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Media
|
||||||
|
} // namespace Info
|
|
@ -84,6 +84,16 @@ inline auto AddCountedButton(
|
||||||
return button;
|
return button;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Fn<void()> SeparateWindowFactory(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
not_null<PeerData*> peer,
|
||||||
|
MsgId topicRootId,
|
||||||
|
Type type);
|
||||||
|
|
||||||
|
void AddContextMenuToButton(
|
||||||
|
not_null<Ui::AbstractButton*> button,
|
||||||
|
Fn<void()> openInWindow);
|
||||||
|
|
||||||
inline auto AddButton(
|
inline auto AddButton(
|
||||||
Ui::VerticalLayout *parent,
|
Ui::VerticalLayout *parent,
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
@ -91,13 +101,18 @@ inline auto AddButton(
|
||||||
MsgId topicRootId,
|
MsgId topicRootId,
|
||||||
PeerData *migrated,
|
PeerData *migrated,
|
||||||
Type type,
|
Type type,
|
||||||
Ui::MultiSlideTracker &tracker,
|
Ui::MultiSlideTracker &tracker) {
|
||||||
Fn<void()> openInWindow) {
|
|
||||||
auto result = AddCountedButton(
|
auto result = AddCountedButton(
|
||||||
parent,
|
parent,
|
||||||
Profile::SharedMediaCountValue(peer, topicRootId, migrated, type),
|
Profile::SharedMediaCountValue(peer, topicRootId, migrated, type),
|
||||||
MediaText(type),
|
MediaText(type),
|
||||||
tracker)->entity();
|
tracker)->entity();
|
||||||
|
const auto openInWindow = SeparateWindowFactory(
|
||||||
|
navigation->parentController(),
|
||||||
|
peer,
|
||||||
|
topicRootId,
|
||||||
|
type);
|
||||||
|
AddContextMenuToButton(result, openInWindow);
|
||||||
result->addClickHandler([=](Qt::MouseButton mouse) {
|
result->addClickHandler([=](Qt::MouseButton mouse) {
|
||||||
if (mouse == Qt::RightButton) {
|
if (mouse == Qt::RightButton) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -92,8 +92,7 @@ void InnerWidget::createTypeButtons() {
|
||||||
topicRootId,
|
topicRootId,
|
||||||
migrated,
|
migrated,
|
||||||
buttonType,
|
buttonType,
|
||||||
tracker,
|
tracker);
|
||||||
nullptr);
|
|
||||||
object_ptr<Profile::FloatingIcon>(
|
object_ptr<Profile::FloatingIcon>(
|
||||||
result,
|
result,
|
||||||
icon,
|
icon,
|
||||||
|
|
|
@ -7,119 +7,29 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/profile/info_profile_inner_widget.h"
|
#include "info/profile/info_profile_inner_widget.h"
|
||||||
|
|
||||||
#include "base/call_delayed.h"
|
|
||||||
#include "info/info_memento.h"
|
|
||||||
#include "info/info_controller.h"
|
|
||||||
#include "info/profile/info_profile_widget.h"
|
#include "info/profile/info_profile_widget.h"
|
||||||
#include "info/profile/info_profile_text.h"
|
|
||||||
#include "info/profile/info_profile_values.h"
|
|
||||||
#include "info/profile/info_profile_cover.h"
|
#include "info/profile/info_profile_cover.h"
|
||||||
#include "info/profile/info_profile_icon.h"
|
#include "info/profile/info_profile_icon.h"
|
||||||
#include "info/profile/info_profile_members.h"
|
#include "info/profile/info_profile_members.h"
|
||||||
#include "info/profile/info_profile_actions.h"
|
#include "info/profile/info_profile_actions.h"
|
||||||
#include "info/media/info_media_buttons.h"
|
#include "info/media/info_media_buttons.h"
|
||||||
#include "boxes/abstract_box.h"
|
|
||||||
#include "boxes/add_contact_box.h"
|
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_forum_topic.h"
|
#include "data/data_forum_topic.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_file_origin.h"
|
#include "data/data_file_origin.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
|
||||||
#include "mainwidget.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "api/api_peer_photo.h"
|
#include "api/api_peer_photo.h"
|
||||||
#include "window/main_window.h"
|
|
||||||
#include "window/window_separate_id.h"
|
|
||||||
#include "window/window_session_controller.h"
|
|
||||||
#include "storage/storage_shared_media.h"
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
|
||||||
#include "ui/widgets/scroll_area.h"
|
#include "ui/widgets/scroll_area.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
#include "ui/widgets/box_content_divider.h"
|
|
||||||
#include "ui/wrap/slide_wrap.h"
|
|
||||||
#include "ui/wrap/vertical_layout.h"
|
|
||||||
#include "ui/ui_utility.h"
|
#include "ui/ui_utility.h"
|
||||||
#include "data/data_channel.h"
|
|
||||||
#include "data/data_shared_media.h"
|
|
||||||
#include "styles/style_info.h"
|
|
||||||
#include "styles/style_boxes.h"
|
|
||||||
#include "styles/style_menu_icons.h"
|
|
||||||
|
|
||||||
namespace Info {
|
namespace Info {
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
Window::SeparateSharedMediaType ToSeparateType(
|
|
||||||
Storage::SharedMediaType type) {
|
|
||||||
using Type = Storage::SharedMediaType;
|
|
||||||
using SeparatedType = Window::SeparateSharedMediaType;
|
|
||||||
return (type == Type::Photo)
|
|
||||||
? SeparatedType::Photos
|
|
||||||
: (type == Type::Video)
|
|
||||||
? SeparatedType::Videos
|
|
||||||
: (type == Type::File)
|
|
||||||
? SeparatedType::Files
|
|
||||||
: (type == Type::MusicFile)
|
|
||||||
? SeparatedType::Audio
|
|
||||||
: (type == Type::Link)
|
|
||||||
? SeparatedType::Links
|
|
||||||
: (type == Type::RoundVoiceFile)
|
|
||||||
? SeparatedType::Voices
|
|
||||||
: (type == Type::GIF)
|
|
||||||
? SeparatedType::GIF
|
|
||||||
: SeparatedType::None;
|
|
||||||
}
|
|
||||||
|
|
||||||
Fn<void()> SeparateWindowFactory(
|
|
||||||
not_null<Window::SessionController*> controller,
|
|
||||||
not_null<PeerData*> peer,
|
|
||||||
MsgId topicRootId,
|
|
||||||
Storage::SharedMediaType type) {
|
|
||||||
const auto separateType = ToSeparateType(type);
|
|
||||||
if (separateType == Window::SeparateSharedMediaType::None) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return [=] {
|
|
||||||
controller->showInNewWindow({
|
|
||||||
Window::SeparateSharedMedia(separateType, peer, topicRootId),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddContextMenu(
|
|
||||||
not_null<Ui::AbstractButton*> button,
|
|
||||||
Fn<void()> openInWindow) {
|
|
||||||
if (!openInWindow) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
button->setAcceptBoth();
|
|
||||||
struct State final {
|
|
||||||
base::unique_qptr<Ui::PopupMenu> menu;
|
|
||||||
};
|
|
||||||
const auto state = button->lifetime().make_state<State>();
|
|
||||||
button->addClickHandler([=](Qt::MouseButton mouse) {
|
|
||||||
if (mouse != Qt::RightButton) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
state->menu = base::make_unique_q<Ui::PopupMenu>(
|
|
||||||
button.get(),
|
|
||||||
st::popupMenuWithIcons);
|
|
||||||
state->menu->addAction(tr::lng_context_new_window(tr::now), [=] {
|
|
||||||
base::call_delayed(
|
|
||||||
st::popupMenuWithIcons.showDuration,
|
|
||||||
crl::guard(button, openInWindow));
|
|
||||||
}, &st::menuIconNewWindow);
|
|
||||||
state->menu->popup(QCursor::pos());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
InnerWidget::InnerWidget(
|
InnerWidget::InnerWidget(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Controller*> controller,
|
not_null<Controller*> controller,
|
||||||
|
@ -224,23 +134,14 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
||||||
auto addMediaButton = [&](
|
auto addMediaButton = [&](
|
||||||
MediaType type,
|
MediaType type,
|
||||||
const style::icon &icon) {
|
const style::icon &icon) {
|
||||||
const auto topicRootId = _topic ? _topic->rootId() : 0;
|
|
||||||
const auto window = _controller->parentController();
|
|
||||||
const auto openInWindow = SeparateWindowFactory(
|
|
||||||
window,
|
|
||||||
_peer,
|
|
||||||
topicRootId,
|
|
||||||
type);
|
|
||||||
auto result = Media::AddButton(
|
auto result = Media::AddButton(
|
||||||
content,
|
content,
|
||||||
_controller,
|
_controller,
|
||||||
_peer,
|
_peer,
|
||||||
topicRootId,
|
_topic ? _topic->rootId() : 0,
|
||||||
_migrated,
|
_migrated,
|
||||||
type,
|
type,
|
||||||
tracker,
|
tracker);
|
||||||
openInWindow);
|
|
||||||
AddContextMenu(result, openInWindow);
|
|
||||||
object_ptr<Profile::FloatingIcon>(
|
object_ptr<Profile::FloatingIcon>(
|
||||||
result,
|
result,
|
||||||
icon,
|
icon,
|
||||||
|
|
|
@ -109,8 +109,7 @@ void SublistsWidget::setupOtherTypes() {
|
||||||
MsgId(), // topicRootId
|
MsgId(), // topicRootId
|
||||||
nullptr, // migrated
|
nullptr, // migrated
|
||||||
buttonType,
|
buttonType,
|
||||||
tracker,
|
tracker);
|
||||||
nullptr);
|
|
||||||
object_ptr<Profile::FloatingIcon>(
|
object_ptr<Profile::FloatingIcon>(
|
||||||
result,
|
result,
|
||||||
icon,
|
icon,
|
||||||
|
|
Loading…
Add table
Reference in a new issue