mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Use Window::Controller to manage MainWindow.
This commit is contained in:
@@ -53,6 +53,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/effects/animations.h"
|
||||
#include "storage/serialize_common.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "base/qthelp_regex.h"
|
||||
#include "base/qthelp_url.h"
|
||||
#include "boxes/connection_box.h"
|
||||
@@ -171,12 +172,11 @@ void Application::run() {
|
||||
// Create mime database, so it won't be slow later.
|
||||
QMimeDatabase().mimeTypeForName(qsl("text/plain"));
|
||||
|
||||
_window = std::make_unique<MainWindow>();
|
||||
_window->init();
|
||||
_window = std::make_unique<Window::Controller>(&activeAccount());
|
||||
|
||||
auto currentGeometry = _window->geometry();
|
||||
const auto currentGeometry = _window->widget()->geometry();
|
||||
_mediaView = std::make_unique<Media::View::OverlayWidget>();
|
||||
_window->setGeometry(currentGeometry);
|
||||
_window->widget()->setGeometry(currentGeometry);
|
||||
|
||||
QCoreApplication::instance()->installEventFilter(this);
|
||||
connect(
|
||||
@@ -223,8 +223,8 @@ void Application::run() {
|
||||
bool Application::hideMediaView() {
|
||||
if (_mediaView && !_mediaView->isHidden()) {
|
||||
_mediaView->hide();
|
||||
if (auto activeWindow = getActiveWindow()) {
|
||||
activeWindow->reActivateWindow();
|
||||
if (const auto window = activeWindow()) {
|
||||
window->reActivate();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -966,7 +966,7 @@ rpl::producer<bool> Application::lockValue() const {
|
||||
_1 || _2);
|
||||
}
|
||||
|
||||
MainWindow *Application::getActiveWindow() const {
|
||||
Window::Controller *Application::activeWindow() const {
|
||||
return _window.get();
|
||||
}
|
||||
|
||||
@@ -974,10 +974,8 @@ bool Application::closeActiveWindow() {
|
||||
if (hideMediaView()) {
|
||||
return true;
|
||||
}
|
||||
if (auto activeWindow = getActiveWindow()) {
|
||||
if (!activeWindow->hideNoQuit()) {
|
||||
activeWindow->close();
|
||||
}
|
||||
if (const auto window = activeWindow()) {
|
||||
window->close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -985,19 +983,19 @@ bool Application::closeActiveWindow() {
|
||||
|
||||
bool Application::minimizeActiveWindow() {
|
||||
hideMediaView();
|
||||
if (auto activeWindow = getActiveWindow()) {
|
||||
if (Global::WorkMode().value() == dbiwmTrayOnly) {
|
||||
activeWindow->minimizeToTray();
|
||||
} else {
|
||||
activeWindow->setWindowState(Qt::WindowMinimized);
|
||||
}
|
||||
if (const auto window = activeWindow()) {
|
||||
window->minimize();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QWidget *Application::getFileDialogParent() {
|
||||
return (_mediaView && _mediaView->isVisible()) ? (QWidget*)_mediaView.get() : (QWidget*)getActiveWindow();
|
||||
return (_mediaView && _mediaView->isVisible())
|
||||
? (QWidget*)_mediaView.get()
|
||||
: activeWindow()
|
||||
? (QWidget*)activeWindow()->widget()
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
void Application::checkMediaViewActivation() {
|
||||
@@ -1032,7 +1030,7 @@ void Application::loggedOut() {
|
||||
clearPasscodeLock();
|
||||
Media::Player::mixer()->stopAndClear();
|
||||
Global::SetVoiceMsgPlaybackDoubled(false);
|
||||
if (const auto window = getActiveWindow()) {
|
||||
if (const auto window = activeWindow()) {
|
||||
window->tempDirDelete(Local::ClearManagerAll);
|
||||
window->setupIntro();
|
||||
}
|
||||
@@ -1051,12 +1049,8 @@ void Application::loggedOut() {
|
||||
}
|
||||
|
||||
QPoint Application::getPointForCallPanelCenter() const {
|
||||
if (auto activeWindow = getActiveWindow()) {
|
||||
Assert(activeWindow->windowHandle() != nullptr);
|
||||
if (activeWindow->isActive()) {
|
||||
return activeWindow->geometry().center();
|
||||
}
|
||||
return activeWindow->windowHandle()->screen()->geometry().center();
|
||||
if (const auto window = activeWindow()) {
|
||||
return window->getPointForCallPanelCenter();
|
||||
}
|
||||
return QApplication::desktop()->screenGeometry().center();
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "base/timer.h"
|
||||
|
||||
class AuthSessionSettings;
|
||||
class MainWindow;
|
||||
class MainWidget;
|
||||
class FileUploader;
|
||||
class Translator;
|
||||
@@ -23,6 +24,7 @@ class Databases;
|
||||
|
||||
namespace Window {
|
||||
struct TermsLock;
|
||||
class Controller;
|
||||
} // namespace Window
|
||||
|
||||
namespace ChatHelpers {
|
||||
@@ -89,7 +91,7 @@ public:
|
||||
}
|
||||
|
||||
// Windows interface.
|
||||
MainWindow *getActiveWindow() const;
|
||||
Window::Controller *activeWindow() const;
|
||||
bool closeActiveWindow();
|
||||
bool minimizeActiveWindow();
|
||||
QWidget *getFileDialogParent();
|
||||
@@ -272,7 +274,7 @@ private:
|
||||
const std::unique_ptr<Storage::Databases> _databases;
|
||||
const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
|
||||
const std::unique_ptr<Main::Account> _account;
|
||||
std::unique_ptr<MainWindow> _window;
|
||||
std::unique_ptr<Window::Controller> _window;
|
||||
std::unique_ptr<Media::View::OverlayWidget> _mediaView;
|
||||
const std::unique_ptr<Lang::Instance> _langpack;
|
||||
std::unique_ptr<Lang::CloudManager> _langCloudManager;
|
||||
|
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "mainwidget.h"
|
||||
#include "window/window_controller.h"
|
||||
#include "core/application.h"
|
||||
#include "media/player/media_player_instance.h"
|
||||
#include "platform/platform_info.h"
|
||||
@@ -375,7 +376,7 @@ void Manager::set(const QString &keys, Command command) {
|
||||
}
|
||||
auto shortcut = base::make_unique_q<QShortcut>(
|
||||
result,
|
||||
Core::App().getActiveWindow(),
|
||||
Core::App().activeWindow()->widget().get(),
|
||||
nullptr,
|
||||
nullptr,
|
||||
Qt::ApplicationShortcut);
|
||||
|
Reference in New Issue
Block a user