mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added shortcut to open chat menu from dialogs, chat info and history.
This commit is contained in:
parent
5f5a2a3ef2
commit
157a928f5a
9 changed files with 54 additions and 4 deletions
|
@ -100,6 +100,8 @@ const auto CommandByName = base::flat_map<QString, Command>{
|
||||||
|
|
||||||
{ u"read_chat"_q , Command::ReadChat },
|
{ u"read_chat"_q , Command::ReadChat },
|
||||||
|
|
||||||
|
{ u"show_chat_menu"_q , Command::ShowChatMenu },
|
||||||
|
|
||||||
// Shortcuts that have no default values.
|
// Shortcuts that have no default values.
|
||||||
{ u"message"_q , Command::JustSendMessage },
|
{ u"message"_q , Command::JustSendMessage },
|
||||||
{ u"message_silently"_q , Command::SendSilentMessage },
|
{ u"message_silently"_q , Command::SendSilentMessage },
|
||||||
|
@ -147,6 +149,8 @@ const auto CommandNames = base::flat_map<Command, QString>{
|
||||||
{ Command::ShowContacts , u"show_contacts"_q },
|
{ Command::ShowContacts , u"show_contacts"_q },
|
||||||
|
|
||||||
{ Command::ReadChat , u"read_chat"_q },
|
{ Command::ReadChat , u"read_chat"_q },
|
||||||
|
|
||||||
|
{ Command::ShowChatMenu , u"show_chat_menu"_q },
|
||||||
};
|
};
|
||||||
|
|
||||||
[[maybe_unused]] constexpr auto kNoValue = {
|
[[maybe_unused]] constexpr auto kNoValue = {
|
||||||
|
@ -435,6 +439,8 @@ void Manager::fillDefaults() {
|
||||||
set(u"ctrl+j"_q, Command::ShowContacts);
|
set(u"ctrl+j"_q, Command::ShowContacts);
|
||||||
|
|
||||||
set(u"ctrl+r"_q, Command::ReadChat);
|
set(u"ctrl+r"_q, Command::ReadChat);
|
||||||
|
|
||||||
|
set(u"ctrl+="_q, Command::ShowChatMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::writeDefaultFile() {
|
void Manager::writeDefaultFile() {
|
||||||
|
|
|
@ -71,6 +71,8 @@ enum class Command {
|
||||||
|
|
||||||
MediaViewerFullscreen,
|
MediaViewerFullscreen,
|
||||||
|
|
||||||
|
ShowChatMenu,
|
||||||
|
|
||||||
SupportReloadTemplates,
|
SupportReloadTemplates,
|
||||||
SupportToggleMuted,
|
SupportToggleMuted,
|
||||||
SupportScrollToCurrent,
|
SupportScrollToCurrent,
|
||||||
|
|
|
@ -1523,6 +1523,21 @@ void InnerWidget::paintSearchTags(
|
||||||
_searchTags->paint(p, position, context.now, context.paused);
|
_searchTags->paint(p, position, context.now, context.paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InnerWidget::showPeerMenu() {
|
||||||
|
if (!_selected) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto &padding = st::defaultDialogRow.padding;
|
||||||
|
const auto pos = QPoint(
|
||||||
|
width() - padding.right(),
|
||||||
|
_selected->top() + _selected->height() + padding.bottom());
|
||||||
|
auto event = QContextMenuEvent(
|
||||||
|
QContextMenuEvent::Keyboard,
|
||||||
|
pos,
|
||||||
|
mapToGlobal(pos));
|
||||||
|
InnerWidget::contextMenuEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
void InnerWidget::mouseMoveEvent(QMouseEvent *e) {
|
void InnerWidget::mouseMoveEvent(QMouseEvent *e) {
|
||||||
if (_chatPreviewTouchGlobal || _touchDragStartGlobal) {
|
if (_chatPreviewTouchGlobal || _touchDragStartGlobal) {
|
||||||
return;
|
return;
|
||||||
|
@ -2835,7 +2850,9 @@ bool InnerWidget::scheduleChatPreview(QPoint positionOverride) {
|
||||||
void InnerWidget::contextMenuEvent(QContextMenuEvent *e) {
|
void InnerWidget::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
_menu = nullptr;
|
_menu = nullptr;
|
||||||
|
|
||||||
if (e->reason() == QContextMenuEvent::Mouse) {
|
const auto fromMouse = e->reason() == QContextMenuEvent::Mouse;
|
||||||
|
|
||||||
|
if (fromMouse) {
|
||||||
selectByMouse(e->globalPos());
|
selectByMouse(e->globalPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2898,6 +2915,9 @@ void InnerWidget::contextMenuEvent(QContextMenuEvent *e) {
|
||||||
if (_menuRow.key) {
|
if (_menuRow.key) {
|
||||||
updateDialogRow(base::take(_menuRow));
|
updateDialogRow(base::take(_menuRow));
|
||||||
}
|
}
|
||||||
|
if (!fromMouse) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto globalPosition = QCursor::pos();
|
const auto globalPosition = QCursor::pos();
|
||||||
if (rect().contains(mapFromGlobal(globalPosition))) {
|
if (rect().contains(mapFromGlobal(globalPosition))) {
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
|
@ -141,6 +141,8 @@ public:
|
||||||
void refreshEmpty();
|
void refreshEmpty();
|
||||||
void resizeEmpty();
|
void resizeEmpty();
|
||||||
|
|
||||||
|
void showPeerMenu();
|
||||||
|
|
||||||
[[nodiscard]] bool isUserpicPress() const;
|
[[nodiscard]] bool isUserpicPress() const;
|
||||||
[[nodiscard]] bool isUserpicPressOnWide() const;
|
[[nodiscard]] bool isUserpicPressOnWide() const;
|
||||||
void cancelChatPreview();
|
void cancelChatPreview();
|
||||||
|
|
|
@ -1212,6 +1212,12 @@ void Widget::setupShortcuts() {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
request->check(Command::ShowChatMenu, 1) && request->handle([=] {
|
||||||
|
if (_inner) {
|
||||||
|
_inner->showPeerMenu();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
|
@ -2006,6 +2006,10 @@ void HistoryWidget::setupShortcuts() {
|
||||||
controller()->searchInChat(_history);
|
controller()->searchInChat(_history);
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
request->check(Command::ShowChatMenu, 1) && request->handle([=] {
|
||||||
|
_topBar->showPeerMenu();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
_canSendMessages
|
_canSendMessages
|
||||||
&& request->check(Command::ShowScheduled, 1)
|
&& request->check(Command::ShowScheduled, 1)
|
||||||
&& request->handle([=] {
|
&& request->handle([=] {
|
||||||
|
|
|
@ -119,6 +119,7 @@ public:
|
||||||
QRect geometry,
|
QRect geometry,
|
||||||
int narrowWidth,
|
int narrowWidth,
|
||||||
float64 narrowRatio);
|
float64 narrowRatio);
|
||||||
|
void showPeerMenu();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
@ -142,7 +143,6 @@ private:
|
||||||
|
|
||||||
void call();
|
void call();
|
||||||
void groupCall();
|
void groupCall();
|
||||||
void showPeerMenu();
|
|
||||||
void showGroupCallMenu(not_null<PeerData*> peer);
|
void showGroupCallMenu(not_null<PeerData*> peer);
|
||||||
void toggleInfoSection();
|
void toggleInfoSection();
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/storage_shared_media.h"
|
#include "storage/storage_shared_media.h"
|
||||||
#include "boxes/delete_messages_box.h"
|
#include "boxes/delete_messages_box.h"
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
#include "mainwidget.h"
|
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
|
@ -24,7 +23,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/wrap/fade_wrap.h"
|
#include "ui/wrap/fade_wrap.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
#include "ui/search_field_controller.h"
|
#include "ui/search_field_controller.h"
|
||||||
#include "window/window_peer_menu.h"
|
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
|
|
@ -492,6 +492,18 @@ void WrapWidget::addTopBarMenuButton() {
|
||||||
_topBarMenuToggle->addClickHandler([this] {
|
_topBarMenuToggle->addClickHandler([this] {
|
||||||
showTopBarMenu(false);
|
showTopBarMenu(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Shortcuts::Requests(
|
||||||
|
) | rpl::filter([=] {
|
||||||
|
return (_controller->section().type() == Section::Type::Profile);
|
||||||
|
}) | rpl::start_with_next([=](not_null<Shortcuts::Request*> request) {
|
||||||
|
using Command = Shortcuts::Command;
|
||||||
|
|
||||||
|
request->check(Command::ShowChatMenu, 1) && request->handle([=] {
|
||||||
|
showTopBarMenu(false);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}, _topBarMenuToggle->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WrapWidget::closeByOutsideClick() const {
|
bool WrapWidget::closeByOutsideClick() const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue