2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +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

@@ -41,6 +41,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
#include "ui/layers/generic_box.h"
#include "ui/toasts/common_toasts.h"
#include "ui/delayed_activation.h"
#include "main/main_session.h"
#include "main/main_session_settings.h"
#include "menu/menu_mute.h"
@@ -81,6 +82,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "export/export_manager.h"
#include "boxes/peers/edit_peer_info_box.h"
#include "styles/style_chat.h"
#include "styles/style_layers.h"
#include "styles/style_boxes.h"
#include "styles/style_window.h" // st::windowMinWidth
@@ -254,6 +256,7 @@ private:
void addToggleMuteSubmenu(bool addSeparator);
void addSupportInfo();
void addInfo();
void addNewWindow();
void addToggleFolder();
void addToggleUnreadMark();
void addToggleArchive();
@@ -597,6 +600,25 @@ void Filler::addToggleUnreadMark() {
}, (unread ? &st::menuIconMarkRead : &st::menuIconMarkUnread));
}
void Filler::addNewWindow() {
const auto history = _request.key.history();
if (!_peer
|| _topic
|| _peer->isForum()
|| (history
&& history->useTopPromotion()
&& !history->topPromotionType().isEmpty())) {
return;
}
const auto peer = _peer;
const auto controller = _controller;
_addAction(tr::lng_context_new_window(tr::now), [=] {
Ui::PreventDelayedActivation();
controller->showInNewWindow(peer);
}, &st::menuIconNewWindow);
AddSeparatorAndShiftUp(_addAction);
}
void Filler::addToggleArchive() {
if (!_peer || _topic) {
return;
@@ -1162,6 +1184,7 @@ void Filler::addVideoChat() {
}
void Filler::fillContextMenuActions() {
addNewWindow();
addHidePromotion();
addToggleArchive();
addTogglePin();
@@ -2413,4 +2436,17 @@ void MarkAsReadThread(not_null<Data::Thread*> thread) {
}
}
void AddSeparatorAndShiftUp(const PeerMenuCallback &addAction) {
addAction({ .isSeparator = true });
const auto &st = st::popupMenuExpandedSeparator.menu;
const auto shift = st::popupMenuExpandedSeparator.scrollPadding.top()
+ st.itemPadding.top()
+ st.itemStyle.font->height
+ st.itemPadding.bottom()
+ st.separator.padding.top()
+ st.separator.width / 2;
addAction({ .addTopShift = -shift });
}
} // namespace Window