2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 23:55:12 +00:00

Add "Open in new window" to context menu.

This commit is contained in:
John Preston
2023-02-03 19:32:25 +04:00
parent 94b489835c
commit bbd937115c
18 changed files with 92 additions and 48 deletions

View File

@@ -1460,7 +1460,7 @@ void SessionController::closeThirdSection() {
bool SessionController::canShowSeparateWindow(
not_null<PeerData*> peer) const {
return peer->computeUnavailableReason().isEmpty();
return !peer->isForum() && peer->computeUnavailableReason().isEmpty();
}
void SessionController::showPeer(not_null<PeerData*> peer, MsgId msgId) {
@@ -1690,6 +1690,33 @@ void SessionController::clearChooseReportMessages() {
content()->clearChooseReportMessages();
}
void SessionController::showInNewWindow(
not_null<PeerData*> peer,
MsgId msgId) {
if (!canShowSeparateWindow(peer)) {
showThread(
peer->owner().history(peer),
msgId,
Window::SectionShow::Way::ClearStack);
return;
}
const auto active = activeChatCurrent();
const auto fromActive = active.history()
? (active.history()->peer == peer)
: false;
const auto toSeparate = [=] {
Core::App().ensureSeparateWindowForPeer(peer, msgId);
};
if (fromActive) {
window().preventOrInvoke([=] {
clearSectionStack();
toSeparate();
});
} else {
toSeparate();
}
}
void SessionController::toggleChooseChatTheme(not_null<PeerData*> peer) {
content()->toggleChooseChatTheme(peer);
}