mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Improve Ctrl+W / Ctrl+M handling by media viewer.
This commit is contained in:
parent
24a1208b9a
commit
27d446bdda
8 changed files with 46 additions and 15 deletions
|
@ -1499,13 +1499,12 @@ void Application::windowActivated(not_null<Window::Controller*> window) {
|
|||
}
|
||||
|
||||
bool Application::closeActiveWindow() {
|
||||
if (hideMediaView()) {
|
||||
if (_mediaView && _mediaView->isActive()) {
|
||||
_mediaView->close();
|
||||
return true;
|
||||
}
|
||||
if (!calls().closeCurrentActiveCall()) {
|
||||
} else if (!calls().closeCurrentActiveCall()) {
|
||||
if (const auto window = activeWindow()) {
|
||||
if (window->widget()->isVisible()
|
||||
&& window->widget()->isActive()) {
|
||||
if (window->widget()->isActive()) {
|
||||
window->close();
|
||||
return true;
|
||||
}
|
||||
|
@ -1515,8 +1514,10 @@ bool Application::closeActiveWindow() {
|
|||
}
|
||||
|
||||
bool Application::minimizeActiveWindow() {
|
||||
hideMediaView();
|
||||
if (!calls().minimizeCurrentActiveCall()) {
|
||||
if (_mediaView && _mediaView->isActive()) {
|
||||
_mediaView->minimize();
|
||||
return true;
|
||||
} else if (!calls().minimizeCurrentActiveCall()) {
|
||||
if (const auto window = activeWindow()) {
|
||||
window->minimize();
|
||||
return true;
|
||||
|
|
|
@ -1533,6 +1533,9 @@ void OverlayWidget::clearSession() {
|
|||
|
||||
OverlayWidget::~OverlayWidget() {
|
||||
clearSession();
|
||||
|
||||
// Otherwise dropdownHidden() may be called from the destructor.
|
||||
_dropdown.destroy();
|
||||
}
|
||||
|
||||
void OverlayWidget::assignMediaPointer(DocumentData *document) {
|
||||
|
@ -1592,6 +1595,13 @@ void OverlayWidget::close() {
|
|||
}
|
||||
}
|
||||
|
||||
void OverlayWidget::minimize() {
|
||||
if (isHidden()) {
|
||||
return;
|
||||
}
|
||||
_helper->minimize(_window);
|
||||
}
|
||||
|
||||
void OverlayWidget::toggleFullScreen(bool fullscreen) {
|
||||
if constexpr (Platform::IsMac()) {
|
||||
_fullscreen = fullscreen;
|
||||
|
@ -2548,6 +2558,10 @@ void OverlayWidget::update(const QRegion ®ion) {
|
|||
_widget->update(region);
|
||||
}
|
||||
|
||||
bool OverlayWidget::isActive() const {
|
||||
return !isHidden() && !isMinimized() && Ui::InFocusChain(_window);
|
||||
}
|
||||
|
||||
bool OverlayWidget::isHidden() const {
|
||||
return _window->isHidden();
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ public:
|
|||
None,
|
||||
};
|
||||
|
||||
[[nodiscard]] bool isActive() const;
|
||||
[[nodiscard]] bool isHidden() const;
|
||||
[[nodiscard]] bool isMinimized() const;
|
||||
[[nodiscard]] bool isFullScreen() const;
|
||||
|
@ -102,6 +103,7 @@ public:
|
|||
|
||||
void activateControls();
|
||||
void close();
|
||||
void minimize();
|
||||
void toggleFullScreen(bool fullscreen);
|
||||
|
||||
void notifyFileDialogShown(bool shown);
|
||||
|
|
|
@ -17,10 +17,11 @@ public:
|
|||
not_null<Ui::RpWindow*> window,
|
||||
Fn<void(bool)> maximize);
|
||||
~MacOverlayWidgetHelper();
|
||||
|
||||
|
||||
void beforeShow(bool fullscreen) override;
|
||||
void afterShow(bool fullscreen) override;
|
||||
void notifyFileDialogShown(bool shown) override;
|
||||
void minimize(not_null<Ui::RpWindow*> window) override;
|
||||
|
||||
private:
|
||||
struct Data;
|
||||
|
@ -29,9 +30,9 @@ private:
|
|||
void resolveNative();
|
||||
void updateStyles(bool fullscreen);
|
||||
void refreshButtons(bool fullscreen);
|
||||
|
||||
|
||||
std::unique_ptr<Data> _data;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace {
|
|||
const auto full = [window frame];
|
||||
const auto inner = [window contentRectForFrameRect:full].size.height;
|
||||
const auto height = std::max(full.size.height - inner, 0.);
|
||||
|
||||
|
||||
result[int(NSWindowToolbarButton)] = { CGPoint(), CGSize{ full.size.width, height }};
|
||||
return result;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ void MacOverlayWidgetHelper::updateStyles(bool fullscreen) {
|
|||
|
||||
void MacOverlayWidgetHelper::refreshButtons(bool fullscreen) {
|
||||
Expects(_data->native != nullptr);
|
||||
|
||||
|
||||
const auto window = _data->native;
|
||||
auto next = CGPoint();
|
||||
const auto added = [&](NSRect frame) {
|
||||
|
@ -250,6 +250,13 @@ void MacOverlayWidgetHelper::notifyFileDialogShown(bool shown) {
|
|||
}
|
||||
}
|
||||
|
||||
void MacOverlayWidgetHelper::minimize(not_null<Ui::RpWindow*> window) {
|
||||
resolveNative();
|
||||
if (_data->native) {
|
||||
[_data->native miniaturize:_data->handler];
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<OverlayWidgetHelper> CreateOverlayWidgetHelper(
|
||||
not_null<Ui::RpWindow*> window,
|
||||
Fn<void(bool)> maximize) {
|
||||
|
|
|
@ -8,10 +8,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "platform/platform_overlay_widget.h"
|
||||
|
||||
#include "ui/platform/ui_platform_window_title.h"
|
||||
#include "ui/widgets/rp_window.h"
|
||||
#include "styles/style_calls.h"
|
||||
|
||||
namespace Platform {
|
||||
|
||||
void OverlayWidgetHelper::minimize(not_null<Ui::RpWindow*> window) {
|
||||
window->setWindowState(window->windowState() | Qt::WindowMinimized);
|
||||
}
|
||||
|
||||
DefaultOverlayWidgetHelper::DefaultOverlayWidgetHelper(
|
||||
not_null<Ui::RpWindow*> window,
|
||||
Fn<void(bool)> maximize)
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
}
|
||||
virtual void notifyFileDialogShown(bool shown) {
|
||||
}
|
||||
virtual void minimize(not_null<Ui::RpWindow*> window);
|
||||
};
|
||||
|
||||
[[nodiscard]] std::unique_ptr<OverlayWidgetHelper> CreateOverlayWidgetHelper(
|
||||
|
@ -44,10 +45,10 @@ public:
|
|||
not_null<Ui::RpWindow*> window,
|
||||
Fn<void(bool)> maximize);
|
||||
~DefaultOverlayWidgetHelper();
|
||||
|
||||
|
||||
void orderWidgets() override;
|
||||
bool skipTitleHitTest(QPoint position) override;
|
||||
|
||||
|
||||
private:
|
||||
const std::unique_ptr<Ui::Platform::SeparateTitleControls> _controls;
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
void updateIsActive();
|
||||
|
||||
[[nodiscard]] bool isActive() const {
|
||||
return _isActive;
|
||||
return !isHidden() && _isActive;
|
||||
}
|
||||
[[nodiscard]] virtual bool isActiveForTrayMenu() {
|
||||
updateIsActive();
|
||||
|
|
Loading…
Add table
Reference in a new issue