mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 06:07:06 +02:00
Use global Fn+F shortcut for toggle fullscreen on macOS.
This commit is contained in:
parent
eae2788f73
commit
152661dcea
11 changed files with 60 additions and 6 deletions
|
@ -734,6 +734,17 @@ bool Instance::minimizeCurrentActiveCall() {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Instance::toggleFullScreenCurrentActiveCall() {
|
||||
if (inCall() && _currentCallPanel->isActive()) {
|
||||
_currentCallPanel->toggleFullScreen();
|
||||
return true;
|
||||
} else if (inGroupCall() && _currentGroupCallPanel->isActive()) {
|
||||
_currentGroupCallPanel->toggleFullScreen();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Instance::closeCurrentActiveCall() {
|
||||
if (inGroupCall() && _currentGroupCallPanel->isActive()) {
|
||||
_currentGroupCallPanel->close();
|
||||
|
|
|
@ -93,6 +93,7 @@ public:
|
|||
not_null<Main::Session*> session) const;
|
||||
bool activateCurrentCall(const QString &joinHash = QString());
|
||||
bool minimizeCurrentActiveCall();
|
||||
bool toggleFullScreenCurrentActiveCall();
|
||||
bool closeCurrentActiveCall();
|
||||
[[nodiscard]] auto getVideoCapture(
|
||||
std::optional<QString> deviceId = std::nullopt,
|
||||
|
|
|
@ -128,6 +128,10 @@ void Panel::minimize() {
|
|||
window()->setWindowState(window()->windowState() | Qt::WindowMinimized);
|
||||
}
|
||||
|
||||
void Panel::toggleFullScreen() {
|
||||
toggleFullScreen(!window()->isFullScreen());
|
||||
}
|
||||
|
||||
void Panel::replaceCall(not_null<Call*> call) {
|
||||
reinitWithCall(call);
|
||||
updateControlsGeometry();
|
||||
|
|
|
@ -64,6 +64,7 @@ public:
|
|||
[[nodiscard]] bool isActive() const;
|
||||
void showAndActivate();
|
||||
void minimize();
|
||||
void toggleFullScreen();
|
||||
void replaceCall(not_null<Call*> call);
|
||||
void closeBeforeDestroy();
|
||||
|
||||
|
|
|
@ -487,7 +487,7 @@ void Panel::initControls() {
|
|||
}
|
||||
|
||||
void Panel::toggleFullScreen() {
|
||||
if (_fullScreenOrMaximized.current()) {
|
||||
if (_fullScreenOrMaximized.current() || window()->isFullScreen()) {
|
||||
window()->showNormal();
|
||||
} else {
|
||||
window()->showFullScreen();
|
||||
|
|
|
@ -94,6 +94,7 @@ public:
|
|||
void hideLayer(anim::type animated = anim::type::normal);
|
||||
|
||||
void minimize();
|
||||
void toggleFullScreen();
|
||||
void close();
|
||||
void showAndActivate();
|
||||
void closeBeforeDestroy();
|
||||
|
@ -133,7 +134,6 @@ private:
|
|||
|
||||
bool handleClose();
|
||||
void startScheduledNow();
|
||||
void toggleFullScreen();
|
||||
void trackControls(bool track, bool force = false);
|
||||
void raiseControls();
|
||||
void enlargeVideo();
|
||||
|
|
|
@ -30,6 +30,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "chat_helpers/emoji_keywords.h"
|
||||
#include "chat_helpers/stickers_emoji_image_loader.h"
|
||||
#include "base/qt/qt_common_adapters.h"
|
||||
#include "base/platform/base_platform_global_shortcuts.h"
|
||||
#include "base/platform/base_platform_url_scheme.h"
|
||||
#include "base/platform/base_platform_last_input.h"
|
||||
#include "base/platform/base_platform_info.h"
|
||||
|
@ -618,7 +619,14 @@ bool Application::hideMediaView() {
|
|||
|
||||
bool Application::eventFilter(QObject *object, QEvent *e) {
|
||||
switch (e->type()) {
|
||||
case QEvent::KeyPress:
|
||||
case QEvent::KeyPress: {
|
||||
updateNonIdle();
|
||||
const auto event = static_cast<QKeyEvent*>(e);
|
||||
if (base::Platform::GlobalShortcuts::IsToggleFullScreenKey(event)
|
||||
&& toggleActiveWindowFullScreen()) {
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
case QEvent::MouseButtonPress:
|
||||
case QEvent::TouchBegin:
|
||||
case QEvent::Wheel: {
|
||||
|
@ -1513,7 +1521,9 @@ bool Application::minimizeActiveWindow() {
|
|||
if (_mediaView && _mediaView->isActive()) {
|
||||
_mediaView->minimize();
|
||||
return true;
|
||||
} else if (!calls().minimizeCurrentActiveCall()) {
|
||||
} else if (calls().minimizeCurrentActiveCall()) {
|
||||
return true;
|
||||
} else {
|
||||
if (const auto window = activeWindow()) {
|
||||
window->minimize();
|
||||
return true;
|
||||
|
@ -1522,6 +1532,25 @@ bool Application::minimizeActiveWindow() {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Application::toggleActiveWindowFullScreen() {
|
||||
if (_mediaView && _mediaView->isActive()) {
|
||||
_mediaView->toggleFullScreen();
|
||||
return true;
|
||||
} else if (calls().toggleFullScreenCurrentActiveCall()) {
|
||||
return true;
|
||||
} else if (const auto window = activeWindow()) {
|
||||
if constexpr (Platform::IsMac()) {
|
||||
if (window->widget()->isFullScreen()) {
|
||||
window->widget()->showNormal();
|
||||
} else {
|
||||
window->widget()->showFullScreen();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QWidget *Application::getFileDialogParent() {
|
||||
if (const auto view = _mediaView.get(); view && !view->isHidden()) {
|
||||
return view->widget();
|
||||
|
|
|
@ -182,6 +182,7 @@ public:
|
|||
void windowActivated(not_null<Window::Controller*> window);
|
||||
bool closeActiveWindow();
|
||||
bool minimizeActiveWindow();
|
||||
bool toggleActiveWindowFullScreen();
|
||||
[[nodiscard]] QWidget *getFileDialogParent();
|
||||
void notifyFileDialogShown(bool shown);
|
||||
void checkSystemDarkMode();
|
||||
|
|
|
@ -1826,6 +1826,10 @@ void OverlayWidget::minimize() {
|
|||
_helper->minimize(_window);
|
||||
}
|
||||
|
||||
void OverlayWidget::toggleFullScreen() {
|
||||
toggleFullScreen(!_fullscreen);
|
||||
}
|
||||
|
||||
void OverlayWidget::toggleFullScreen(bool fullscreen) {
|
||||
_helper->clearState();
|
||||
_fullscreen = fullscreen;
|
||||
|
@ -5170,10 +5174,12 @@ bool OverlayWidget::filterApplicationEvent(
|
|||
const auto ctrl = event->modifiers().testFlag(Qt::ControlModifier);
|
||||
if (key == Qt::Key_F && ctrl && _streamed) {
|
||||
playbackToggleFullScreen();
|
||||
return true;
|
||||
} else if (key == Qt::Key_0 && ctrl) {
|
||||
zoomReset();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
} else if (type == QEvent::MouseMove
|
||||
|| type == QEvent::MouseButtonPress
|
||||
|| type == QEvent::MouseButtonRelease) {
|
||||
|
|
|
@ -105,6 +105,7 @@ public:
|
|||
void activateControls();
|
||||
void close();
|
||||
void minimize();
|
||||
void toggleFullScreen();
|
||||
void toggleFullScreen(bool fullscreen);
|
||||
|
||||
void notifyFileDialogShown(bool shown);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 7f129171548a3828693d7f79fbdb783464f31b97
|
||||
Subproject commit 285527e3df689d291cae8a1923479da1b4d361d5
|
Loading…
Add table
Reference in a new issue