mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
Added ability to open shared media in window with Ctrl+Click.
This commit is contained in:
parent
7442ea7a16
commit
a676138745
4 changed files with 23 additions and 14 deletions
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include <rpl/mappers.h>
|
||||
#include <rpl/map.h>
|
||||
#include "lang/lang_keys.h"
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
#include "data/data_saved_messages.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_stories_ids.h"
|
||||
|
@ -90,7 +91,8 @@ inline auto AddButton(
|
|||
MsgId topicRootId,
|
||||
PeerData *migrated,
|
||||
Type type,
|
||||
Ui::MultiSlideTracker &tracker) {
|
||||
Ui::MultiSlideTracker &tracker,
|
||||
Fn<void()> openInWindow) {
|
||||
auto result = AddCountedButton(
|
||||
parent,
|
||||
Profile::SharedMediaCountValue(peer, topicRootId, migrated, type),
|
||||
|
@ -100,6 +102,10 @@ inline auto AddButton(
|
|||
if (mouse == Qt::RightButton) {
|
||||
return;
|
||||
}
|
||||
if (openInWindow
|
||||
&& (base::IsCtrlPressed() || mouse == Qt::MiddleButton)) {
|
||||
return openInWindow();
|
||||
}
|
||||
const auto topic = topicRootId
|
||||
? peer->forumTopicFor(topicRootId)
|
||||
: nullptr;
|
||||
|
|
|
@ -92,7 +92,8 @@ void InnerWidget::createTypeButtons() {
|
|||
topicRootId,
|
||||
migrated,
|
||||
buttonType,
|
||||
tracker);
|
||||
tracker,
|
||||
nullptr);
|
||||
object_ptr<Profile::FloatingIcon>(
|
||||
result,
|
||||
icon,
|
||||
|
|
|
@ -93,12 +93,8 @@ Fn<void()> SeparateWindowFactory(
|
|||
|
||||
void AddContextMenu(
|
||||
not_null<Ui::AbstractButton*> button,
|
||||
not_null<Window::SessionController*> window,
|
||||
not_null<PeerData*> peer,
|
||||
MsgId rootId,
|
||||
Storage::SharedMediaType type) {
|
||||
const auto callback = SeparateWindowFactory(window, peer, rootId, type);
|
||||
if (!callback) {
|
||||
Fn<void()> openInWindow) {
|
||||
if (!openInWindow) {
|
||||
return;
|
||||
}
|
||||
button->setAcceptBoth();
|
||||
|
@ -116,7 +112,7 @@ void AddContextMenu(
|
|||
state->menu->addAction(tr::lng_context_new_window(tr::now), [=] {
|
||||
base::call_delayed(
|
||||
st::popupMenuWithIcons.showDuration,
|
||||
crl::guard(button, callback));
|
||||
crl::guard(button, openInWindow));
|
||||
}, &st::menuIconNewWindow);
|
||||
state->menu->popup(QCursor::pos());
|
||||
});
|
||||
|
@ -229,6 +225,12 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
|||
MediaType type,
|
||||
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(
|
||||
content,
|
||||
_controller,
|
||||
|
@ -236,10 +238,9 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
|||
topicRootId,
|
||||
_migrated,
|
||||
type,
|
||||
tracker);
|
||||
if (const auto window = _controller->parentController()) {
|
||||
AddContextMenu(result, window, _peer, topicRootId, type);
|
||||
}
|
||||
tracker,
|
||||
openInWindow);
|
||||
AddContextMenu(result, openInWindow);
|
||||
object_ptr<Profile::FloatingIcon>(
|
||||
result,
|
||||
icon,
|
||||
|
|
|
@ -109,7 +109,8 @@ void SublistsWidget::setupOtherTypes() {
|
|||
MsgId(), // topicRootId
|
||||
nullptr, // migrated
|
||||
buttonType,
|
||||
tracker);
|
||||
tracker,
|
||||
nullptr);
|
||||
object_ptr<Profile::FloatingIcon>(
|
||||
result,
|
||||
icon,
|
||||
|
|
Loading…
Add table
Reference in a new issue