mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-10 13:43:54 +00:00
Ctrl+W close active rich message editor window.
This commit is contained in:
@@ -47,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "iv/iv_instance.h"
|
||||
#include "iv/iv_data.h"
|
||||
#include "iv/editor/iv_editor_session.h"
|
||||
#include "iv/editor/iv_editor_window.h"
|
||||
#include "lang/lang_translator.h"
|
||||
#include "lang/lang_cloud_manager.h"
|
||||
#include "lang/lang_hardcoded.h"
|
||||
@@ -1685,7 +1686,9 @@ bool Application::closeActiveWindow() {
|
||||
if (_mediaView && _mediaView->isActive()) {
|
||||
_mediaView->close();
|
||||
return true;
|
||||
} else if (_iv->closeActive() || calls().closeCurrentActiveCall()) {
|
||||
} else if (_iv->closeActive()
|
||||
|| Iv::Editor::CloseActiveWindow()
|
||||
|| calls().closeCurrentActiveCall()) {
|
||||
return true;
|
||||
} else if (const auto window = activeWindow()) {
|
||||
if (window->widget()->isActive()) {
|
||||
|
||||
@@ -23,14 +23,28 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#endif // Q_OS_WIN || Q_OS_MAC
|
||||
|
||||
namespace Iv::Editor {
|
||||
namespace {
|
||||
|
||||
[[nodiscard]] std::vector<not_null<Window*>> &LiveWindows() {
|
||||
static auto result = std::vector<not_null<Window*>>();
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Window::Window(QWidget *parent)
|
||||
: Ui::RpWindow(parent)
|
||||
, _layers(std::make_unique<Ui::LayerManager>(body())) {
|
||||
_layers->setHideByBackgroundClick(true);
|
||||
LiveWindows().push_back(this);
|
||||
}
|
||||
|
||||
Window::~Window() = default;
|
||||
Window::~Window() {
|
||||
auto &list = LiveWindows();
|
||||
list.erase(
|
||||
ranges::remove(list, not_null<Window*>(this)),
|
||||
end(list));
|
||||
}
|
||||
|
||||
void Window::setCloseRequestHandler(Fn<bool()> handler) {
|
||||
_closeRequestHandler = std::move(handler);
|
||||
@@ -122,4 +136,14 @@ bool Window::nativeEvent(
|
||||
|
||||
#endif // Q_OS_WIN || Q_OS_MAC
|
||||
|
||||
bool CloseActiveWindow() {
|
||||
for (const auto &window : LiveWindows()) {
|
||||
if (window->isActiveWindow()) {
|
||||
window->close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Iv::Editor
|
||||
|
||||
@@ -75,4 +75,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
bool CloseActiveWindow();
|
||||
|
||||
} // namespace Iv::Editor
|
||||
|
||||
Reference in New Issue
Block a user