Use Window::Controller to manage MainWindow.
This commit is contained in:
parent
a547f80ae9
commit
dd68c7e90d
|
@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "window/themes/window_theme.h"
|
#include "window/themes/window_theme.h"
|
||||||
#include "window/notifications_manager.h"
|
#include "window/notifications_manager.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "platform/platform_notifications_manager.h"
|
#include "platform/platform_notifications_manager.h"
|
||||||
#include "storage/file_upload.h"
|
#include "storage/file_upload.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
|
@ -102,8 +103,8 @@ namespace App {
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow *wnd() {
|
MainWindow *wnd() {
|
||||||
return Core::IsAppLaunched()
|
return (Core::IsAppLaunched() && Core::App().activeWindow())
|
||||||
? Core::App().getActiveWindow()
|
? Core::App().activeWindow()->widget().get()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "storage/serialize_common.h"
|
#include "storage/serialize_common.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "base/qthelp_regex.h"
|
#include "base/qthelp_regex.h"
|
||||||
#include "base/qthelp_url.h"
|
#include "base/qthelp_url.h"
|
||||||
#include "boxes/connection_box.h"
|
#include "boxes/connection_box.h"
|
||||||
|
@ -171,12 +172,11 @@ void Application::run() {
|
||||||
// Create mime database, so it won't be slow later.
|
// Create mime database, so it won't be slow later.
|
||||||
QMimeDatabase().mimeTypeForName(qsl("text/plain"));
|
QMimeDatabase().mimeTypeForName(qsl("text/plain"));
|
||||||
|
|
||||||
_window = std::make_unique<MainWindow>();
|
_window = std::make_unique<Window::Controller>(&activeAccount());
|
||||||
_window->init();
|
|
||||||
|
|
||||||
auto currentGeometry = _window->geometry();
|
const auto currentGeometry = _window->widget()->geometry();
|
||||||
_mediaView = std::make_unique<Media::View::OverlayWidget>();
|
_mediaView = std::make_unique<Media::View::OverlayWidget>();
|
||||||
_window->setGeometry(currentGeometry);
|
_window->widget()->setGeometry(currentGeometry);
|
||||||
|
|
||||||
QCoreApplication::instance()->installEventFilter(this);
|
QCoreApplication::instance()->installEventFilter(this);
|
||||||
connect(
|
connect(
|
||||||
|
@ -223,8 +223,8 @@ void Application::run() {
|
||||||
bool Application::hideMediaView() {
|
bool Application::hideMediaView() {
|
||||||
if (_mediaView && !_mediaView->isHidden()) {
|
if (_mediaView && !_mediaView->isHidden()) {
|
||||||
_mediaView->hide();
|
_mediaView->hide();
|
||||||
if (auto activeWindow = getActiveWindow()) {
|
if (const auto window = activeWindow()) {
|
||||||
activeWindow->reActivateWindow();
|
window->reActivate();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -966,7 +966,7 @@ rpl::producer<bool> Application::lockValue() const {
|
||||||
_1 || _2);
|
_1 || _2);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow *Application::getActiveWindow() const {
|
Window::Controller *Application::activeWindow() const {
|
||||||
return _window.get();
|
return _window.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,10 +974,8 @@ bool Application::closeActiveWindow() {
|
||||||
if (hideMediaView()) {
|
if (hideMediaView()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (auto activeWindow = getActiveWindow()) {
|
if (const auto window = activeWindow()) {
|
||||||
if (!activeWindow->hideNoQuit()) {
|
window->close();
|
||||||
activeWindow->close();
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -985,19 +983,19 @@ bool Application::closeActiveWindow() {
|
||||||
|
|
||||||
bool Application::minimizeActiveWindow() {
|
bool Application::minimizeActiveWindow() {
|
||||||
hideMediaView();
|
hideMediaView();
|
||||||
if (auto activeWindow = getActiveWindow()) {
|
if (const auto window = activeWindow()) {
|
||||||
if (Global::WorkMode().value() == dbiwmTrayOnly) {
|
window->minimize();
|
||||||
activeWindow->minimizeToTray();
|
|
||||||
} else {
|
|
||||||
activeWindow->setWindowState(Qt::WindowMinimized);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *Application::getFileDialogParent() {
|
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() {
|
void Application::checkMediaViewActivation() {
|
||||||
|
@ -1032,7 +1030,7 @@ void Application::loggedOut() {
|
||||||
clearPasscodeLock();
|
clearPasscodeLock();
|
||||||
Media::Player::mixer()->stopAndClear();
|
Media::Player::mixer()->stopAndClear();
|
||||||
Global::SetVoiceMsgPlaybackDoubled(false);
|
Global::SetVoiceMsgPlaybackDoubled(false);
|
||||||
if (const auto window = getActiveWindow()) {
|
if (const auto window = activeWindow()) {
|
||||||
window->tempDirDelete(Local::ClearManagerAll);
|
window->tempDirDelete(Local::ClearManagerAll);
|
||||||
window->setupIntro();
|
window->setupIntro();
|
||||||
}
|
}
|
||||||
|
@ -1051,12 +1049,8 @@ void Application::loggedOut() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint Application::getPointForCallPanelCenter() const {
|
QPoint Application::getPointForCallPanelCenter() const {
|
||||||
if (auto activeWindow = getActiveWindow()) {
|
if (const auto window = activeWindow()) {
|
||||||
Assert(activeWindow->windowHandle() != nullptr);
|
return window->getPointForCallPanelCenter();
|
||||||
if (activeWindow->isActive()) {
|
|
||||||
return activeWindow->geometry().center();
|
|
||||||
}
|
|
||||||
return activeWindow->windowHandle()->screen()->geometry().center();
|
|
||||||
}
|
}
|
||||||
return QApplication::desktop()->screenGeometry().center();
|
return QApplication::desktop()->screenGeometry().center();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/timer.h"
|
#include "base/timer.h"
|
||||||
|
|
||||||
class AuthSessionSettings;
|
class AuthSessionSettings;
|
||||||
|
class MainWindow;
|
||||||
class MainWidget;
|
class MainWidget;
|
||||||
class FileUploader;
|
class FileUploader;
|
||||||
class Translator;
|
class Translator;
|
||||||
|
@ -23,6 +24,7 @@ class Databases;
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
struct TermsLock;
|
struct TermsLock;
|
||||||
|
class Controller;
|
||||||
} // namespace Window
|
} // namespace Window
|
||||||
|
|
||||||
namespace ChatHelpers {
|
namespace ChatHelpers {
|
||||||
|
@ -89,7 +91,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Windows interface.
|
// Windows interface.
|
||||||
MainWindow *getActiveWindow() const;
|
Window::Controller *activeWindow() const;
|
||||||
bool closeActiveWindow();
|
bool closeActiveWindow();
|
||||||
bool minimizeActiveWindow();
|
bool minimizeActiveWindow();
|
||||||
QWidget *getFileDialogParent();
|
QWidget *getFileDialogParent();
|
||||||
|
@ -272,7 +274,7 @@ private:
|
||||||
const std::unique_ptr<Storage::Databases> _databases;
|
const std::unique_ptr<Storage::Databases> _databases;
|
||||||
const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
|
const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
|
||||||
const std::unique_ptr<Main::Account> _account;
|
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;
|
std::unique_ptr<Media::View::OverlayWidget> _mediaView;
|
||||||
const std::unique_ptr<Lang::Instance> _langpack;
|
const std::unique_ptr<Lang::Instance> _langpack;
|
||||||
std::unique_ptr<Lang::CloudManager> _langCloudManager;
|
std::unique_ptr<Lang::CloudManager> _langCloudManager;
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "core/application.h"
|
#include "core/application.h"
|
||||||
#include "media/player/media_player_instance.h"
|
#include "media/player/media_player_instance.h"
|
||||||
#include "platform/platform_info.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>(
|
auto shortcut = base::make_unique_q<QShortcut>(
|
||||||
result,
|
result,
|
||||||
Core::App().getActiveWindow(),
|
Core::App().activeWindow()->widget().get(),
|
||||||
nullptr,
|
nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
Qt::ApplicationShortcut);
|
Qt::ApplicationShortcut);
|
||||||
|
|
|
@ -66,7 +66,8 @@ void FeedLangTestingKey(int key) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MainWindow::MainWindow() {
|
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
|
: Platform::MainWindow(controller) {
|
||||||
auto logo = Core::App().logo();
|
auto logo = Core::App().logo();
|
||||||
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
||||||
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
||||||
|
|
|
@ -44,7 +44,7 @@ class MainWindow : public Platform::MainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
void firstShow();
|
void firstShow();
|
||||||
|
|
|
@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "window/themes/window_theme_preview.h"
|
#include "window/themes/window_theme_preview.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "main/main_account.h" // Account::sessionValue.
|
#include "main/main_account.h" // Account::sessionValue.
|
||||||
#include "observer_peer.h"
|
#include "observer_peer.h"
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
|
@ -326,8 +327,10 @@ void OverlayWidget::moveToScreen(bool force) {
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
const auto activeWindow = Core::App().getActiveWindow();
|
const auto window = Core::App().activeWindow()
|
||||||
const auto activeWindowScreen = widgetScreen(activeWindow);
|
? Core::App().activeWindow()->widget().get()
|
||||||
|
: nullptr;
|
||||||
|
const auto activeWindowScreen = widgetScreen(window);
|
||||||
const auto myScreen = widgetScreen(this);
|
const auto myScreen = widgetScreen(this);
|
||||||
if (activeWindowScreen && myScreen && myScreen != activeWindowScreen) {
|
if (activeWindowScreen && myScreen && myScreen != activeWindowScreen) {
|
||||||
windowHandle()->setScreen(activeWindowScreen);
|
windowHandle()->setScreen(activeWindowScreen);
|
||||||
|
|
|
@ -193,7 +193,8 @@ quint32 djbStringHash(QString string) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
MainWindow::MainWindow() {
|
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
|
: Window::MainWindow(controller) {
|
||||||
connect(&_psCheckStatusIconTimer, SIGNAL(timeout()), this, SLOT(psStatusIconCheck()));
|
connect(&_psCheckStatusIconTimer, SIGNAL(timeout()), this, SLOT(psStatusIconCheck()));
|
||||||
_psCheckStatusIconTimer.setSingleShot(false);
|
_psCheckStatusIconTimer.setSingleShot(false);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class MainWindow : public Window::MainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
void psFirstShow();
|
void psFirstShow();
|
||||||
void psInitSysMenu();
|
void psInitSysMenu();
|
||||||
|
|
|
@ -18,7 +18,7 @@ class MainWindow : public Window::MainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
void psFirstShow();
|
void psFirstShow();
|
||||||
void psInitSysMenu();
|
void psInitSysMenu();
|
||||||
|
@ -37,7 +37,7 @@ public:
|
||||||
|
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
class Private;
|
void updateWindowIcon() override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void psShowTrayMenu();
|
void psShowTrayMenu();
|
||||||
|
@ -56,7 +56,6 @@ protected:
|
||||||
void handleActiveChangedHook() override;
|
void handleActiveChangedHook() override;
|
||||||
void stateChangedHook(Qt::WindowState state) override;
|
void stateChangedHook(Qt::WindowState state) override;
|
||||||
void initHook() override;
|
void initHook() override;
|
||||||
void updateWindowIcon() override;
|
|
||||||
void titleVisibilityChangedHook() override;
|
void titleVisibilityChangedHook() override;
|
||||||
void unreadCounterChangedHook() override;
|
void unreadCounterChangedHook() override;
|
||||||
|
|
||||||
|
@ -83,13 +82,15 @@ protected:
|
||||||
void closeWithoutDestroy() override;
|
void closeWithoutDestroy() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
class Private;
|
||||||
|
friend class Private;
|
||||||
|
|
||||||
void initTouchBar();
|
void initTouchBar();
|
||||||
void hideAndDeactivate();
|
void hideAndDeactivate();
|
||||||
void createGlobalMenu();
|
void createGlobalMenu();
|
||||||
void updateTitleCounter();
|
void updateTitleCounter();
|
||||||
void updateIconCounters();
|
void updateIconCounters();
|
||||||
|
|
||||||
friend class Private;
|
|
||||||
std::unique_ptr<Private> _private;
|
std::unique_ptr<Private> _private;
|
||||||
|
|
||||||
mutable bool psIdle;
|
mutable bool psIdle;
|
||||||
|
|
|
@ -381,8 +381,9 @@ MainWindow::Private::~Private() {
|
||||||
[_observer release];
|
[_observer release];
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
: _private(std::make_unique<Private>(this)) {
|
: Window::MainWindow(controller)
|
||||||
|
, _private(std::make_unique<Private>(this)) {
|
||||||
#ifndef OS_MAC_OLD
|
#ifndef OS_MAC_OLD
|
||||||
auto forceOpenGL = std::make_unique<QOpenGLWidget>(this);
|
auto forceOpenGL = std::make_unique<QOpenGLWidget>(this);
|
||||||
#endif // !OS_MAC_OLD
|
#endif // !OS_MAC_OLD
|
||||||
|
|
|
@ -598,8 +598,9 @@ bool handleSessionNotification = false;
|
||||||
|
|
||||||
UINT MainWindow::_taskbarCreatedMsgId = 0;
|
UINT MainWindow::_taskbarCreatedMsgId = 0;
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow(not_null<Window::Controller*> controller)
|
||||||
: ps_tbHider_hWnd(createTaskbarHider()) {
|
: Window::MainWindow(controller)
|
||||||
|
, ps_tbHider_hWnd(createTaskbarHider()) {
|
||||||
if (!_taskbarCreatedMsgId) {
|
if (!_taskbarCreatedMsgId) {
|
||||||
_taskbarCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
|
_taskbarCreatedMsgId = RegisterWindowMessage(L"TaskbarButtonCreated");
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ class MainWindow : public Window::MainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
HWND psHwnd() const;
|
HWND psHwnd() const;
|
||||||
HMENU psMenu() const;
|
HMENU psMenu() const;
|
||||||
|
|
|
@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_lock_widgets.h"
|
#include "window/window_lock_widgets.h"
|
||||||
#include "window/window_outdated_bar.h"
|
#include "window/window_outdated_bar.h"
|
||||||
|
#include "window/window_controller.h"
|
||||||
#include "boxes/confirm_box.h"
|
#include "boxes/confirm_box.h"
|
||||||
#include "main/main_account.h" // Account::authSessionValue.
|
#include "main/main_account.h" // Account::authSessionValue.
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
|
@ -108,8 +109,9 @@ QIcon CreateIcon() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow()
|
MainWindow::MainWindow(not_null<Controller*> controller)
|
||||||
: _positionUpdatedTimer([=] { savePosition(); })
|
: _controller(controller)
|
||||||
|
, _positionUpdatedTimer([=] { savePosition(); })
|
||||||
, _outdated(CreateOutdatedBar(this))
|
, _outdated(CreateOutdatedBar(this))
|
||||||
, _body(this)
|
, _body(this)
|
||||||
, _icon(CreateIcon())
|
, _icon(CreateIcon())
|
||||||
|
@ -127,14 +129,6 @@ MainWindow::MainWindow()
|
||||||
workmodeUpdated(mode);
|
workmodeUpdated(mode);
|
||||||
});
|
});
|
||||||
|
|
||||||
Core::App().activeAccount().sessionValue(
|
|
||||||
) | rpl::start_with_next([=](AuthSession *session) {
|
|
||||||
_controller = session
|
|
||||||
? std::make_unique<Window::SessionController>(session, this)
|
|
||||||
: nullptr;
|
|
||||||
updateWindowIcon();
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
Core::App().termsLockValue(
|
Core::App().termsLockValue(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
checkLockByTerms();
|
checkLockByTerms();
|
||||||
|
@ -156,6 +150,10 @@ MainWindow::MainWindow()
|
||||||
_inactivePressTimer.setCallback([this] { setInactivePress(false); });
|
_inactivePressTimer.setCallback([this] { setInactivePress(false); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window::SessionController *MainWindow::sessionController() const {
|
||||||
|
return _controller->sessionController();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::checkLockByTerms() {
|
void MainWindow::checkLockByTerms() {
|
||||||
const auto data = Core::App().termsLocked();
|
const auto data = Core::App().termsLocked();
|
||||||
if (!data || !AuthSession::Exists()) {
|
if (!data || !AuthSession::Exists()) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ class BoxContent;
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
|
||||||
|
class Controller;
|
||||||
class SessionController;
|
class SessionController;
|
||||||
class TitleWidget;
|
class TitleWidget;
|
||||||
struct TermsLock;
|
struct TermsLock;
|
||||||
|
@ -28,11 +29,12 @@ class MainWindow : public Ui::RpWidget, protected base::Subscriber {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow();
|
explicit MainWindow(not_null<Controller*> controller);
|
||||||
|
|
||||||
Window::SessionController *sessionController() const {
|
not_null<Window::Controller*> controller() const {
|
||||||
return _controller.get();
|
return _controller;
|
||||||
}
|
}
|
||||||
|
Window::SessionController *sessionController() const;
|
||||||
void setInactivePress(bool inactive);
|
void setInactivePress(bool inactive);
|
||||||
bool wasInactivePress() const {
|
bool wasInactivePress() const {
|
||||||
return _wasInactivePress;
|
return _wasInactivePress;
|
||||||
|
@ -83,6 +85,8 @@ public:
|
||||||
|
|
||||||
rpl::producer<> leaveEvents() const;
|
rpl::producer<> leaveEvents() const;
|
||||||
|
|
||||||
|
virtual void updateWindowIcon();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool minimizeToTray();
|
bool minimizeToTray();
|
||||||
void updateGlobalMenu() {
|
void updateGlobalMenu() {
|
||||||
|
@ -110,8 +114,6 @@ protected:
|
||||||
virtual void clearWidgetsHook() {
|
virtual void clearWidgetsHook() {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void updateWindowIcon();
|
|
||||||
|
|
||||||
virtual void stateChangedHook(Qt::WindowState state) {
|
virtual void stateChangedHook(Qt::WindowState state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,10 +161,11 @@ private:
|
||||||
|
|
||||||
int computeMinHeight() const;
|
int computeMinHeight() const;
|
||||||
|
|
||||||
|
not_null<Window::Controller*> _controller;
|
||||||
|
|
||||||
base::Timer _positionUpdatedTimer;
|
base::Timer _positionUpdatedTimer;
|
||||||
bool _positionInited = false;
|
bool _positionInited = false;
|
||||||
|
|
||||||
std::unique_ptr<Window::SessionController> _controller;
|
|
||||||
object_ptr<TitleWidget> _title = { nullptr };
|
object_ptr<TitleWidget> _title = { nullptr };
|
||||||
object_ptr<Ui::RpWidget> _outdated;
|
object_ptr<Ui::RpWidget> _outdated;
|
||||||
object_ptr<TWidget> _body;
|
object_ptr<TWidget> _body;
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#include "window/window_controller.h"
|
||||||
|
|
||||||
|
#include "core/application.h"
|
||||||
|
#include "main/main_account.h"
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
|
||||||
|
Controller::Controller(not_null<Main::Account*> account)
|
||||||
|
: _account(account)
|
||||||
|
, _widget(this) {
|
||||||
|
Core::App().activeAccount().sessionValue(
|
||||||
|
) | rpl::start_with_next([=](AuthSession *session) {
|
||||||
|
_sessionController = session
|
||||||
|
? std::make_unique<SessionController>(session, &_widget)
|
||||||
|
: nullptr;
|
||||||
|
_widget.updateWindowIcon();
|
||||||
|
}, _lifetime);
|
||||||
|
|
||||||
|
_widget.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
Controller::~Controller() = default;
|
||||||
|
|
||||||
|
void Controller::firstShow() {
|
||||||
|
_widget.firstShow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::setupPasscodeLock() {
|
||||||
|
_widget.setupPasscodeLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::clearPasscodeLock() {
|
||||||
|
_widget.clearPasscodeLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::setupIntro() {
|
||||||
|
_widget.setupIntro();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::setupMain() {
|
||||||
|
_widget.setupMain();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::showSettings() {
|
||||||
|
_widget.showSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::activate() {
|
||||||
|
_widget.activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::reActivate() {
|
||||||
|
_widget.reActivateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::updateIsActive(int timeout) {
|
||||||
|
_widget.updateIsActive(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::minimize() {
|
||||||
|
if (Global::WorkMode().value() == dbiwmTrayOnly) {
|
||||||
|
_widget.minimizeToTray();
|
||||||
|
} else {
|
||||||
|
_widget.setWindowState(Qt::WindowMinimized);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::close() {
|
||||||
|
if (!_widget.hideNoQuit()) {
|
||||||
|
_widget.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPoint Controller::getPointForCallPanelCenter() const {
|
||||||
|
Expects(_widget.windowHandle() != nullptr);
|
||||||
|
|
||||||
|
return _widget.isActive()
|
||||||
|
? _widget.geometry().center()
|
||||||
|
: _widget.windowHandle()->screen()->geometry().center();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Controller::tempDirDelete(int task) {
|
||||||
|
_widget.tempDirDelete(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Window
|
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
This file is part of Telegram Desktop,
|
||||||
|
the official desktop application for the Telegram messaging service.
|
||||||
|
|
||||||
|
For license and copyright information please follow this link:
|
||||||
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
namespace Main {
|
||||||
|
class Account;
|
||||||
|
} // namespace Main
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
|
||||||
|
class Controller final {
|
||||||
|
public:
|
||||||
|
explicit Controller(not_null<Main::Account*> account);
|
||||||
|
~Controller();
|
||||||
|
|
||||||
|
Controller(const Controller &other) = delete;
|
||||||
|
Controller &operator=(const Controller &other) = delete;
|
||||||
|
|
||||||
|
not_null<Main::Account*> account() const {
|
||||||
|
return _account;
|
||||||
|
}
|
||||||
|
not_null<::MainWindow*> widget() {
|
||||||
|
return &_widget;
|
||||||
|
}
|
||||||
|
SessionController *sessionController() const {
|
||||||
|
return _sessionController.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void firstShow();
|
||||||
|
|
||||||
|
void setupPasscodeLock();
|
||||||
|
void clearPasscodeLock();
|
||||||
|
void setupIntro();
|
||||||
|
void setupMain();
|
||||||
|
|
||||||
|
void showSettings();
|
||||||
|
|
||||||
|
void activate();
|
||||||
|
void reActivate();
|
||||||
|
void updateIsActive(int timeout);
|
||||||
|
void minimize();
|
||||||
|
void close();
|
||||||
|
|
||||||
|
QPoint getPointForCallPanelCenter() const;
|
||||||
|
|
||||||
|
void tempDirDelete(int task);
|
||||||
|
|
||||||
|
private:
|
||||||
|
not_null<Main::Account*> _account;
|
||||||
|
::MainWindow _widget;
|
||||||
|
std::unique_ptr<SessionController> _sessionController;
|
||||||
|
|
||||||
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Window
|
|
@ -827,6 +827,8 @@
|
||||||
<(src_loc)/window/section_widget.h
|
<(src_loc)/window/section_widget.h
|
||||||
<(src_loc)/window/window_connecting_widget.cpp
|
<(src_loc)/window/window_connecting_widget.cpp
|
||||||
<(src_loc)/window/window_connecting_widget.h
|
<(src_loc)/window/window_connecting_widget.h
|
||||||
|
<(src_loc)/window/window_controller.cpp
|
||||||
|
<(src_loc)/window/window_controller.h
|
||||||
<(src_loc)/window/window_history_hider.cpp
|
<(src_loc)/window/window_history_hider.cpp
|
||||||
<(src_loc)/window/window_history_hider.h
|
<(src_loc)/window/window_history_hider.h
|
||||||
<(src_loc)/window/window_lock_widgets.cpp
|
<(src_loc)/window/window_lock_widgets.cpp
|
||||||
|
|
Loading…
Reference in New Issue