mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved handle of existing separated windows for shared media.
This commit is contained in:
parent
1d8a7f8fd3
commit
f89bac7781
1 changed files with 20 additions and 27 deletions
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "base/call_delayed.h"
|
#include "base/call_delayed.h"
|
||||||
#include "base/qt/qt_key_modifiers.h"
|
#include "base/qt/qt_key_modifiers.h"
|
||||||
|
#include "core/application.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_saved_messages.h"
|
#include "data/data_saved_messages.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
@ -31,7 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
namespace Info::Media {
|
namespace Info::Media {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
Window::SeparateSharedMediaType ToSeparateType(
|
[[nodiscard]] Window::SeparateSharedMediaType ToSeparateType(
|
||||||
Storage::SharedMediaType type) {
|
Storage::SharedMediaType type) {
|
||||||
using Type = Storage::SharedMediaType;
|
using Type = Storage::SharedMediaType;
|
||||||
using SeparatedType = Window::SeparateSharedMediaType;
|
using SeparatedType = Window::SeparateSharedMediaType;
|
||||||
|
@ -52,20 +53,18 @@ Window::SeparateSharedMediaType ToSeparateType(
|
||||||
: SeparatedType::None;
|
: SeparatedType::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fn<void()> SeparateWindowFactory(
|
[[nodiscard]] Window::SeparateId SeparateId(
|
||||||
not_null<Window::SessionController*> controller,
|
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
MsgId topicRootId,
|
MsgId topicRootId,
|
||||||
Storage::SharedMediaType type) {
|
Storage::SharedMediaType type) {
|
||||||
|
if (peer->isSelf()) {
|
||||||
|
return { nullptr };
|
||||||
|
}
|
||||||
const auto separateType = ToSeparateType(type);
|
const auto separateType = ToSeparateType(type);
|
||||||
if (separateType == Window::SeparateSharedMediaType::None) {
|
if (separateType == Window::SeparateSharedMediaType::None) {
|
||||||
return nullptr;
|
return { nullptr };
|
||||||
}
|
}
|
||||||
return [=] {
|
return { Window::SeparateSharedMedia(separateType, peer, topicRootId) };
|
||||||
controller->showInNewWindow({
|
|
||||||
Window::SeparateSharedMedia(separateType, peer, topicRootId),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddContextMenuToButton(
|
void AddContextMenuToButton(
|
||||||
|
@ -146,16 +145,6 @@ not_null<Ui::SlideWrap<Ui::SettingsButton>*> 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);
|
|
||||||
|
|
||||||
not_null<Ui::SettingsButton*> AddButton(
|
not_null<Ui::SettingsButton*> AddButton(
|
||||||
Ui::VerticalLayout *parent,
|
Ui::VerticalLayout *parent,
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
@ -169,11 +158,10 @@ not_null<Ui::SettingsButton*> AddButton(
|
||||||
Profile::SharedMediaCountValue(peer, topicRootId, migrated, type),
|
Profile::SharedMediaCountValue(peer, topicRootId, migrated, type),
|
||||||
MediaText(type),
|
MediaText(type),
|
||||||
tracker)->entity();
|
tracker)->entity();
|
||||||
const auto openInWindow = SeparateWindowFactory(
|
const auto separateId = SeparateId(peer, topicRootId, type);
|
||||||
navigation->parentController(),
|
const auto openInWindow = separateId
|
||||||
peer,
|
? [=] { navigation->parentController()->showInNewWindow(separateId); }
|
||||||
topicRootId,
|
: Fn<void()>(nullptr);
|
||||||
type);
|
|
||||||
AddContextMenuToButton(result, openInWindow);
|
AddContextMenuToButton(result, openInWindow);
|
||||||
result->addClickHandler([=](Qt::MouseButton mouse) {
|
result->addClickHandler([=](Qt::MouseButton mouse) {
|
||||||
if (mouse == Qt::RightButton) {
|
if (mouse == Qt::RightButton) {
|
||||||
|
@ -189,9 +177,14 @@ not_null<Ui::SettingsButton*> AddButton(
|
||||||
if (topicRootId && !topic) {
|
if (topicRootId && !topic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navigation->showSection(topicRootId
|
const auto separateId = SeparateId(peer, topicRootId, type);
|
||||||
? std::make_shared<Info::Memento>(topic, Section(type))
|
if (Core::App().separateWindowFor(separateId) && openInWindow) {
|
||||||
: std::make_shared<Info::Memento>(peer, Section(type)));
|
openInWindow();
|
||||||
|
} else {
|
||||||
|
navigation->showSection(topicRootId
|
||||||
|
? std::make_shared<Info::Memento>(topic, Section(type))
|
||||||
|
: std::make_shared<Info::Memento>(peer, Section(type)));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue