mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-07-28 08:22:59 +02:00
Improve separate window support.
This commit is contained in:
parent
50b761fab2
commit
6068678fa1
7 changed files with 31 additions and 29 deletions
|
@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "core/application.h"
|
||||
|
||||
#include "data/data_abstract_structure.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_forum.h"
|
||||
#include "data/data_message_reactions.h"
|
||||
#include "data/data_session.h"
|
||||
|
@ -1377,8 +1378,9 @@ Window::Controller *Application::windowForShowingHistory(
|
|||
|
||||
Window::Controller *Application::windowForShowingForum(
|
||||
not_null<Data::Forum*> forum) const {
|
||||
const auto tabs = forum->channel()->useSubsectionTabs();
|
||||
const auto id = Window::SeparateId(
|
||||
Window::SeparateType::Forum,
|
||||
tabs ? Window::SeparateType::Chat : Window::SeparateType::Forum,
|
||||
forum->history());
|
||||
if (const auto separate = separateWindowFor(id)) {
|
||||
return separate;
|
||||
|
@ -1386,11 +1388,17 @@ Window::Controller *Application::windowForShowingForum(
|
|||
auto result = (Window::Controller*)nullptr;
|
||||
enumerateWindows([&](not_null<Window::Controller*> window) {
|
||||
if (const auto controller = window->sessionController()) {
|
||||
if (tabs) {
|
||||
if (controller->windowId() == id) {
|
||||
result = window;
|
||||
}
|
||||
} else {
|
||||
const auto current = controller->shownForum().current();
|
||||
if (forum == current) {
|
||||
result = window;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -911,8 +911,10 @@ void Widget::chosenRow(const ChosenRow &row) {
|
|||
if (controller()->shownForum().current() == forum) {
|
||||
controller()->closeForum();
|
||||
} else if (row.newWindow) {
|
||||
controller()->showInNewWindow(
|
||||
Window::SeparateId(Window::SeparateType::Forum, history));
|
||||
const auto type = forum->channel()->useSubsectionTabs()
|
||||
? Window::SeparateType::Chat
|
||||
: Window::SeparateType::Forum;
|
||||
controller()->showInNewWindow(Window::SeparateId(type, history));
|
||||
} else {
|
||||
controller()->showForum(
|
||||
forum,
|
||||
|
|
|
@ -1176,9 +1176,11 @@ Window::SessionController *Manager::openNotificationMessage(
|
|||
}
|
||||
});
|
||||
|
||||
const auto separateId = topic
|
||||
? Window::SeparateId(Window::SeparateType::Forum, history)
|
||||
: Window::SeparateId(history->peer);
|
||||
const auto separateId = !topic
|
||||
? Window::SeparateId(history->peer)
|
||||
: history->peer->asChannel()->useSubsectionTabs()
|
||||
? Window::SeparateId(Window::SeparateType::Chat, topic)
|
||||
: Window::SeparateId(Window::SeparateType::Forum, history);
|
||||
const auto separate = Core::App().separateWindowFor(separateId);
|
||||
const auto itemId = openExactlyMessage ? messageId : ShowAtUnreadMsgId;
|
||||
if (openSeparated && !separate && !topic) {
|
||||
|
|
|
@ -669,7 +669,7 @@ void Filler::addNewWindow() {
|
|||
if (const auto sublist = weak.get()) {
|
||||
controller->showInNewWindow(SeparateId(
|
||||
SeparateType::SavedSublist,
|
||||
sublist->owner().history(sublist->sublistPeer())));
|
||||
sublist));
|
||||
}
|
||||
}, &st::menuIconNewWindow);
|
||||
AddSeparatorAndShiftUp(_addAction);
|
||||
|
@ -690,7 +690,9 @@ void Filler::addNewWindow() {
|
|||
_addAction(tr::lng_context_new_window(tr::now), [=] {
|
||||
Ui::PreventDelayedActivation();
|
||||
if (const auto strong = weak.get()) {
|
||||
const auto forum = !strong->asTopic() && peer->isForum();
|
||||
const auto forum = !strong->asTopic()
|
||||
&& peer->isForum()
|
||||
&& !peer->asChannel()->useSubsectionTabs();
|
||||
controller->showInNewWindow(SeparateId(
|
||||
forum ? SeparateType::Forum : SeparateType::Chat,
|
||||
strong));
|
||||
|
@ -2472,7 +2474,7 @@ QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
|||
return true;
|
||||
}
|
||||
const auto id = SeparateId(
|
||||
(peer->isForum()
|
||||
((peer->isForum() && !peer->asChannel()->useSubsectionTabs())
|
||||
? SeparateType::Forum
|
||||
: SeparateType::Chat),
|
||||
thread);
|
||||
|
|
|
@ -31,14 +31,10 @@ SeparateId::SeparateId(SeparateType type, not_null<Main::Session*> session)
|
|||
, account(&session->account()) {
|
||||
}
|
||||
|
||||
SeparateId::SeparateId(
|
||||
SeparateType type,
|
||||
not_null<Data::Thread*> thread,
|
||||
ChannelData *parentChat)
|
||||
SeparateId::SeparateId(SeparateType type, not_null<Data::Thread*> thread)
|
||||
: type(type)
|
||||
, account(&thread->session().account())
|
||||
, thread(thread)
|
||||
, parentChat((type == SeparateType::SavedSublist) ? parentChat : nullptr) {
|
||||
, thread(thread) {
|
||||
}
|
||||
|
||||
SeparateId::SeparateId(not_null<Data::Thread*> thread)
|
||||
|
@ -77,12 +73,9 @@ Data::Folder *SeparateId::folder() const {
|
|||
}
|
||||
|
||||
Data::SavedSublist *SeparateId::sublist() const {
|
||||
const auto monoforum = parentChat ? parentChat->monoforum() : nullptr;
|
||||
return (type != SeparateType::SavedSublist)
|
||||
? nullptr
|
||||
: monoforum
|
||||
? monoforum->sublist(thread->peer()).get()
|
||||
: thread->owner().savedMessages().sublist(thread->peer()).get();
|
||||
: thread->asSublist();
|
||||
}
|
||||
|
||||
bool SeparateId::hasChatsList() const {
|
||||
|
|
|
@ -46,10 +46,7 @@ struct SeparateId {
|
|||
SeparateId(std::nullptr_t);
|
||||
SeparateId(not_null<Main::Account*> account);
|
||||
SeparateId(SeparateType type, not_null<Main::Session*> session);
|
||||
SeparateId(
|
||||
SeparateType type,
|
||||
not_null<Data::Thread*> thread,
|
||||
ChannelData *parentChat = nullptr);
|
||||
SeparateId(SeparateType type, not_null<Data::Thread*> thread);
|
||||
SeparateId(not_null<Data::Thread*> thread);
|
||||
SeparateId(not_null<PeerData*> peer);
|
||||
SeparateId(
|
||||
|
@ -60,7 +57,6 @@ struct SeparateId {
|
|||
Storage::SharedMediaType sharedMediaType = {};
|
||||
Main::Account *account = nullptr;
|
||||
Data::Thread *thread = nullptr; // For types except Main and Archive.
|
||||
ChannelData *parentChat = nullptr;
|
||||
[[nodiscard]] bool valid() const {
|
||||
return account != nullptr;
|
||||
}
|
||||
|
|
|
@ -1877,8 +1877,7 @@ void SessionController::showForum(
|
|||
const SectionShow ¶ms) {
|
||||
if (showForumInDifferentWindow(forum, params)) {
|
||||
return;
|
||||
} else if (HistoryView::SubsectionTabs::UsedFor(
|
||||
forum->owner().history(forum->channel()))) {
|
||||
} else if (forum->channel()->useSubsectionTabs()) {
|
||||
showPeerHistory(forum->channel(), params);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue