Improved conflict handle between IV shortcuts and Shortcuts.

This commit is contained in:
23rd 2025-01-30 11:00:50 +03:00
parent d6ba6ac41e
commit cf1fa718a8
4 changed files with 18 additions and 1 deletions

View file

@ -1214,6 +1214,7 @@ void Widget::setupShortcuts() {
});
request->check(Command::ShowChatMenu, 1) && request->handle([=] {
if (_inner) {
Window::ActivateWindow(controller());
_inner->showPeerMenu();
}
return true;

View file

@ -2010,6 +2010,7 @@ void HistoryWidget::setupShortcuts() {
return true;
});
request->check(Command::ShowChatMenu, 1) && request->handle([=] {
Window::ActivateWindow(controller());
_topBar->showPeerMenu();
return true;
});

View file

@ -502,6 +502,7 @@ void WrapWidget::addTopBarMenuButton() {
using Command = Shortcuts::Command;
request->check(Command::ShowChatMenu, 1) && request->handle([=] {
Window::ActivateWindow(_controller->parentController());
showTopBarMenu(false);
return true;
});

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "iv/iv_controller.h"
#include "base/event_filter.h"
#include "base/platform/base_platform_info.h"
#include "base/qt/qt_key_modifiers.h"
#include "base/invoke_queued.h"
@ -679,18 +680,31 @@ void Controller::createWebview(const Webview::StorageId &storageId) {
if (event->key() == Qt::Key_Escape) {
escape();
}
}
}, window->lifetime());
base::install_event_filter(window, qApp, [=](not_null<QEvent*> e) {
if (e->type() == QEvent::ShortcutOverride) {
if (!window->isActiveWindow()) {
return base::EventFilterResult::Continue;
}
const auto event = static_cast<QKeyEvent*>(e.get());
if (event->modifiers() & Qt::ControlModifier) {
if (event->key() == Qt::Key_Plus
|| event->key() == Qt::Key_Equal) {
_delegate->ivSetZoom(_delegate->ivZoom() + kZoomStep);
return base::EventFilterResult::Cancel;
} else if (event->key() == Qt::Key_Minus) {
_delegate->ivSetZoom(_delegate->ivZoom() - kZoomStep);
return base::EventFilterResult::Cancel;
} else if (event->key() == Qt::Key_0) {
_delegate->ivSetZoom(kDefaultZoom);
return base::EventFilterResult::Cancel;
}
}
}
}, window->lifetime());
return base::EventFilterResult::Continue;
});
const auto widget = raw->widget();
if (!widget) {