mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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/mappers.h>
|
||||||
#include <rpl/map.h>
|
#include <rpl/map.h>
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "base/qt/qt_key_modifiers.h"
|
||||||
#include "data/data_saved_messages.h"
|
#include "data/data_saved_messages.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_stories_ids.h"
|
#include "data/data_stories_ids.h"
|
||||||
|
@ -90,7 +91,8 @@ inline auto AddButton(
|
||||||
MsgId topicRootId,
|
MsgId topicRootId,
|
||||||
PeerData *migrated,
|
PeerData *migrated,
|
||||||
Type type,
|
Type type,
|
||||||
Ui::MultiSlideTracker &tracker) {
|
Ui::MultiSlideTracker &tracker,
|
||||||
|
Fn<void()> openInWindow) {
|
||||||
auto result = AddCountedButton(
|
auto result = AddCountedButton(
|
||||||
parent,
|
parent,
|
||||||
Profile::SharedMediaCountValue(peer, topicRootId, migrated, type),
|
Profile::SharedMediaCountValue(peer, topicRootId, migrated, type),
|
||||||
|
@ -100,6 +102,10 @@ inline auto AddButton(
|
||||||
if (mouse == Qt::RightButton) {
|
if (mouse == Qt::RightButton) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (openInWindow
|
||||||
|
&& (base::IsCtrlPressed() || mouse == Qt::MiddleButton)) {
|
||||||
|
return openInWindow();
|
||||||
|
}
|
||||||
const auto topic = topicRootId
|
const auto topic = topicRootId
|
||||||
? peer->forumTopicFor(topicRootId)
|
? peer->forumTopicFor(topicRootId)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
|
@ -92,7 +92,8 @@ void InnerWidget::createTypeButtons() {
|
||||||
topicRootId,
|
topicRootId,
|
||||||
migrated,
|
migrated,
|
||||||
buttonType,
|
buttonType,
|
||||||
tracker);
|
tracker,
|
||||||
|
nullptr);
|
||||||
object_ptr<Profile::FloatingIcon>(
|
object_ptr<Profile::FloatingIcon>(
|
||||||
result,
|
result,
|
||||||
icon,
|
icon,
|
||||||
|
|
|
@ -93,12 +93,8 @@ Fn<void()> SeparateWindowFactory(
|
||||||
|
|
||||||
void AddContextMenu(
|
void AddContextMenu(
|
||||||
not_null<Ui::AbstractButton*> button,
|
not_null<Ui::AbstractButton*> button,
|
||||||
not_null<Window::SessionController*> window,
|
Fn<void()> openInWindow) {
|
||||||
not_null<PeerData*> peer,
|
if (!openInWindow) {
|
||||||
MsgId rootId,
|
|
||||||
Storage::SharedMediaType type) {
|
|
||||||
const auto callback = SeparateWindowFactory(window, peer, rootId, type);
|
|
||||||
if (!callback) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
button->setAcceptBoth();
|
button->setAcceptBoth();
|
||||||
|
@ -116,7 +112,7 @@ void AddContextMenu(
|
||||||
state->menu->addAction(tr::lng_context_new_window(tr::now), [=] {
|
state->menu->addAction(tr::lng_context_new_window(tr::now), [=] {
|
||||||
base::call_delayed(
|
base::call_delayed(
|
||||||
st::popupMenuWithIcons.showDuration,
|
st::popupMenuWithIcons.showDuration,
|
||||||
crl::guard(button, callback));
|
crl::guard(button, openInWindow));
|
||||||
}, &st::menuIconNewWindow);
|
}, &st::menuIconNewWindow);
|
||||||
state->menu->popup(QCursor::pos());
|
state->menu->popup(QCursor::pos());
|
||||||
});
|
});
|
||||||
|
@ -229,6 +225,12 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
||||||
MediaType type,
|
MediaType type,
|
||||||
const style::icon &icon) {
|
const style::icon &icon) {
|
||||||
const auto topicRootId = _topic ? _topic->rootId() : 0;
|
const auto topicRootId = _topic ? _topic->rootId() : 0;
|
||||||
|
const auto window = _controller->parentController();
|
||||||
|
const auto openInWindow = SeparateWindowFactory(
|
||||||
|
window,
|
||||||
|
_peer,
|
||||||
|
topicRootId,
|
||||||
|
type);
|
||||||
auto result = Media::AddButton(
|
auto result = Media::AddButton(
|
||||||
content,
|
content,
|
||||||
_controller,
|
_controller,
|
||||||
|
@ -236,10 +238,9 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
|
||||||
topicRootId,
|
topicRootId,
|
||||||
_migrated,
|
_migrated,
|
||||||
type,
|
type,
|
||||||
tracker);
|
tracker,
|
||||||
if (const auto window = _controller->parentController()) {
|
openInWindow);
|
||||||
AddContextMenu(result, window, _peer, topicRootId, type);
|
AddContextMenu(result, openInWindow);
|
||||||
}
|
|
||||||
object_ptr<Profile::FloatingIcon>(
|
object_ptr<Profile::FloatingIcon>(
|
||||||
result,
|
result,
|
||||||
icon,
|
icon,
|
||||||
|
|
|
@ -109,7 +109,8 @@ void SublistsWidget::setupOtherTypes() {
|
||||||
MsgId(), // topicRootId
|
MsgId(), // topicRootId
|
||||||
nullptr, // migrated
|
nullptr, // migrated
|
||||||
buttonType,
|
buttonType,
|
||||||
tracker);
|
tracker,
|
||||||
|
nullptr);
|
||||||
object_ptr<Profile::FloatingIcon>(
|
object_ptr<Profile::FloatingIcon>(
|
||||||
result,
|
result,
|
||||||
icon,
|
icon,
|
||||||
|
|
Loading…
Add table
Reference in a new issue