2017-02-23 10:59:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-02-23 10:59:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-18 09:28:14 +00:00
|
|
|
#include "mtproto/mtproto_auth_key.h"
|
2019-11-13 14:12:04 +00:00
|
|
|
#include "mtproto/mtproto_proxy_data.h"
|
2017-08-03 13:06:29 +00:00
|
|
|
#include "base/timer.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2022-06-11 00:07:22 +00:00
|
|
|
class History;
|
2017-12-11 14:45:29 +00:00
|
|
|
|
2023-02-27 14:09:12 +00:00
|
|
|
namespace base {
|
|
|
|
class BatterySaving;
|
|
|
|
} // namespace base
|
|
|
|
|
2022-01-04 12:29:40 +00:00
|
|
|
namespace Platform {
|
|
|
|
class Integration;
|
|
|
|
} // namespace Platform
|
|
|
|
|
2018-08-29 13:23:16 +00:00
|
|
|
namespace Storage {
|
|
|
|
class Databases;
|
|
|
|
} // namespace Storage
|
|
|
|
|
2018-06-03 13:30:40 +00:00
|
|
|
namespace Window {
|
2019-06-06 11:20:21 +00:00
|
|
|
class Controller;
|
2018-06-03 13:30:40 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2020-06-19 12:59:31 +00:00
|
|
|
namespace Window {
|
|
|
|
namespace Notifications {
|
|
|
|
class System;
|
|
|
|
} // namespace Notifications
|
|
|
|
} // namespace Window
|
|
|
|
|
2019-03-28 08:48:32 +00:00
|
|
|
namespace ChatHelpers {
|
|
|
|
class EmojiKeywords;
|
|
|
|
} // namespace ChatHelpers
|
|
|
|
|
2019-04-30 11:12:30 +00:00
|
|
|
namespace Main {
|
2020-06-18 18:04:16 +00:00
|
|
|
class Domain;
|
2019-04-30 11:12:30 +00:00
|
|
|
class Account;
|
2020-06-11 09:41:03 +00:00
|
|
|
class Session;
|
2019-04-30 11:12:30 +00:00
|
|
|
} // namespace Main
|
|
|
|
|
2019-02-04 13:34:50 +00:00
|
|
|
namespace Ui {
|
|
|
|
namespace Animations {
|
|
|
|
class Manager;
|
|
|
|
} // namespace Animations
|
2020-06-22 19:01:19 +00:00
|
|
|
namespace Emoji {
|
|
|
|
class UniversalImages;
|
|
|
|
} // namespace Emoji
|
2019-09-18 11:19:05 +00:00
|
|
|
class BoxContent;
|
2019-02-04 13:34:50 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2017-02-23 10:59:19 +00:00
|
|
|
namespace MTP {
|
2020-06-17 09:36:25 +00:00
|
|
|
class Config;
|
2017-02-24 17:15:41 +00:00
|
|
|
class Instance;
|
2017-06-26 17:38:16 +00:00
|
|
|
class AuthKey;
|
|
|
|
using AuthKeyPtr = std::shared_ptr<AuthKey>;
|
|
|
|
using AuthKeysList = std::vector<AuthKeyPtr>;
|
2017-02-23 10:59:19 +00:00
|
|
|
} // namespace MTP
|
|
|
|
|
2017-05-03 11:36:39 +00:00
|
|
|
namespace Media {
|
|
|
|
namespace Audio {
|
|
|
|
class Instance;
|
|
|
|
} // namespace Audio
|
2019-02-12 11:00:47 +00:00
|
|
|
namespace View {
|
|
|
|
class OverlayWidget;
|
2022-06-08 07:04:35 +00:00
|
|
|
struct OpenRequest;
|
2019-02-12 11:00:47 +00:00
|
|
|
} // namespace View
|
2020-06-25 14:17:37 +00:00
|
|
|
namespace Player {
|
|
|
|
class FloatController;
|
|
|
|
class FloatDelegate;
|
|
|
|
} // namespace Player
|
2023-01-19 05:38:52 +00:00
|
|
|
class SystemMediaControlsManager;
|
2017-05-03 11:36:39 +00:00
|
|
|
} // namespace Media
|
|
|
|
|
2017-04-13 08:45:58 +00:00
|
|
|
namespace Lang {
|
2017-04-13 17:59:05 +00:00
|
|
|
class Instance;
|
2017-04-13 08:45:58 +00:00
|
|
|
class Translator;
|
2017-04-18 15:21:03 +00:00
|
|
|
class CloudManager;
|
2017-04-13 08:45:58 +00:00
|
|
|
} // namespace Lang
|
|
|
|
|
2019-09-06 15:31:01 +00:00
|
|
|
namespace Data {
|
|
|
|
struct CloudTheme;
|
2022-02-21 15:40:20 +00:00
|
|
|
class DownloadManager;
|
2019-09-06 15:31:01 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
2020-06-22 19:01:19 +00:00
|
|
|
namespace Stickers {
|
|
|
|
class EmojiImageLoader;
|
|
|
|
} // namespace Stickers
|
|
|
|
|
2020-06-25 07:14:05 +00:00
|
|
|
namespace Export {
|
|
|
|
class Manager;
|
|
|
|
} // namespace Export
|
|
|
|
|
2020-06-25 17:57:36 +00:00
|
|
|
namespace Calls {
|
|
|
|
class Instance;
|
|
|
|
} // namespace Calls
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
class Launcher;
|
|
|
|
struct LocalUrlHandler;
|
2022-06-11 00:07:22 +00:00
|
|
|
class Settings;
|
2022-03-23 15:59:53 +00:00
|
|
|
class Tray;
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2022-01-27 12:48:51 +00:00
|
|
|
enum class LaunchState {
|
|
|
|
Running,
|
|
|
|
QuitRequested,
|
|
|
|
QuitProcessed,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class QuitReason {
|
|
|
|
Default,
|
|
|
|
QtQuitEvent,
|
|
|
|
};
|
|
|
|
|
2021-05-25 10:19:17 +00:00
|
|
|
class Application final : public QObject {
|
2017-02-23 10:59:19 +00:00
|
|
|
public:
|
2020-06-17 09:36:25 +00:00
|
|
|
struct ProxyChange {
|
|
|
|
MTP::ProxyData was;
|
|
|
|
MTP::ProxyData now;
|
|
|
|
};
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
Application(not_null<Launcher*> launcher);
|
|
|
|
Application(const Application &other) = delete;
|
|
|
|
Application &operator=(const Application &other) = delete;
|
2019-03-28 08:48:32 +00:00
|
|
|
~Application();
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2023-02-27 14:09:12 +00:00
|
|
|
void run();
|
|
|
|
|
2022-01-04 12:29:40 +00:00
|
|
|
[[nodiscard]] Launcher &launcher() const {
|
|
|
|
return *_launcher;
|
|
|
|
}
|
|
|
|
[[nodiscard]] Platform::Integration &platformIntegration() const {
|
|
|
|
return *_platformIntegration;
|
2017-12-11 14:45:29 +00:00
|
|
|
}
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] Ui::Animations::Manager &animationManager() const {
|
2019-02-04 13:34:50 +00:00
|
|
|
return *_animationsManager;
|
|
|
|
}
|
2020-06-19 12:59:31 +00:00
|
|
|
[[nodiscard]] Window::Notifications::System ¬ifications() const {
|
2020-06-19 17:13:43 +00:00
|
|
|
Expects(_notifications != nullptr);
|
|
|
|
|
2020-06-19 12:59:31 +00:00
|
|
|
return *_notifications;
|
|
|
|
}
|
2022-02-21 15:40:20 +00:00
|
|
|
[[nodiscard]] Data::DownloadManager &downloadManager() const {
|
|
|
|
return *_downloadManager;
|
|
|
|
}
|
2022-04-20 22:39:01 +00:00
|
|
|
[[nodiscard]] Tray &tray() const {
|
|
|
|
return *_tray;
|
|
|
|
}
|
2023-02-27 14:09:12 +00:00
|
|
|
[[nodiscard]] base::BatterySaving &batterySaving() const {
|
|
|
|
return *_batterySaving;
|
|
|
|
}
|
2019-02-04 13:34:50 +00:00
|
|
|
|
2017-08-08 09:31:48 +00:00
|
|
|
// Windows interface.
|
2020-06-11 09:41:03 +00:00
|
|
|
bool hasActiveWindow(not_null<Main::Session*> session) const;
|
2023-02-02 16:19:32 +00:00
|
|
|
[[nodiscard]] bool savingPositionFor(
|
|
|
|
not_null<Window::Controller*> window) const;
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] Window::Controller *activeWindow() const;
|
2023-01-17 15:47:58 +00:00
|
|
|
[[nodiscard]] Window::Controller *activePrimaryWindow() const;
|
|
|
|
[[nodiscard]] Window::Controller *separateWindowForAccount(
|
|
|
|
not_null<Main::Account*> account) const;
|
2022-01-04 11:18:13 +00:00
|
|
|
[[nodiscard]] Window::Controller *separateWindowForPeer(
|
|
|
|
not_null<PeerData*> peer) const;
|
|
|
|
Window::Controller *ensureSeparateWindowForPeer(
|
2022-01-04 16:36:33 +00:00
|
|
|
not_null<PeerData*> peer,
|
|
|
|
MsgId showAtMsgId);
|
2023-01-17 15:47:58 +00:00
|
|
|
Window::Controller *ensureSeparateWindowForAccount(
|
|
|
|
not_null<Main::Account*> account);
|
|
|
|
[[nodiscard]] Window::Controller *windowFor( // Doesn't auto-switch.
|
|
|
|
not_null<PeerData*> peer) const;
|
|
|
|
[[nodiscard]] Window::Controller *windowFor( // Doesn't auto-switch.
|
|
|
|
not_null<Main::Account*> account) const;
|
|
|
|
[[nodiscard]] bool closeNonLastAsync(
|
|
|
|
not_null<Window::Controller*> window);
|
2022-06-07 18:05:37 +00:00
|
|
|
void closeWindow(not_null<Window::Controller*> window);
|
|
|
|
void windowActivated(not_null<Window::Controller*> window);
|
2017-08-08 09:56:10 +00:00
|
|
|
bool closeActiveWindow();
|
|
|
|
bool minimizeActiveWindow();
|
2023-03-15 12:33:55 +00:00
|
|
|
bool toggleActiveWindowFullScreen();
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] QWidget *getFileDialogParent();
|
2019-10-07 11:34:40 +00:00
|
|
|
void notifyFileDialogShown(bool shown);
|
2020-07-22 12:10:17 +00:00
|
|
|
void checkSystemDarkMode();
|
2022-03-23 17:22:47 +00:00
|
|
|
[[nodiscard]] bool isActiveForTrayMenu() const;
|
2022-06-09 00:46:54 +00:00
|
|
|
void closeChatFromWindows(not_null<PeerData*> peer);
|
2023-01-30 14:01:10 +00:00
|
|
|
void checkWindowAccount(not_null<Window::Controller*> window);
|
2023-01-19 05:38:52 +00:00
|
|
|
void activate();
|
2017-08-08 09:31:48 +00:00
|
|
|
|
2019-02-12 11:00:47 +00:00
|
|
|
// Media view interface.
|
2017-08-08 09:31:48 +00:00
|
|
|
bool hideMediaView();
|
|
|
|
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] QPoint getPointForCallPanelCenter() const;
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2020-07-22 12:10:17 +00:00
|
|
|
void startSettingsAndBackground();
|
2022-01-04 11:18:13 +00:00
|
|
|
[[nodiscard]] Settings &settings();
|
2023-02-27 14:09:12 +00:00
|
|
|
[[nodiscard]] const Settings &settings() const;
|
2019-08-23 13:52:59 +00:00
|
|
|
void saveSettingsDelayed(crl::time delay = kDefaultSaveDelay);
|
2020-06-18 18:04:16 +00:00
|
|
|
void saveSettings();
|
2022-12-29 08:49:03 +00:00
|
|
|
|
|
|
|
[[nodiscard]] bool canReadDefaultDownloadPath(bool always = false) const;
|
2022-11-08 14:24:08 +00:00
|
|
|
[[nodiscard]] bool canSaveFileWithoutAskingForPath() const;
|
2019-08-23 13:52:59 +00:00
|
|
|
|
2020-06-17 09:36:25 +00:00
|
|
|
// Fallback config and proxy.
|
|
|
|
[[nodiscard]] MTP::Config &fallbackProductionConfig() const;
|
|
|
|
void refreshFallbackProductionConfig(const MTP::Config &config);
|
|
|
|
void constructFallbackProductionConfig(const QByteArray &serialized);
|
2018-11-05 13:58:24 +00:00
|
|
|
void setCurrentProxy(
|
2019-11-13 14:12:04 +00:00
|
|
|
const MTP::ProxyData &proxy,
|
|
|
|
MTP::ProxyData::Settings settings);
|
2019-07-24 08:46:23 +00:00
|
|
|
[[nodiscard]] rpl::producer<ProxyChange> proxyChanges() const;
|
2018-05-24 13:40:19 +00:00
|
|
|
void badMtprotoConfigurationError();
|
2017-02-24 17:15:41 +00:00
|
|
|
|
2019-04-30 11:12:30 +00:00
|
|
|
// Databases.
|
2019-07-24 14:00:30 +00:00
|
|
|
[[nodiscard]] Storage::Databases &databases() {
|
2018-08-29 13:23:16 +00:00
|
|
|
return *_databases;
|
|
|
|
}
|
|
|
|
|
2020-06-18 18:04:16 +00:00
|
|
|
// Domain component.
|
|
|
|
[[nodiscard]] Main::Domain &domain() const {
|
|
|
|
return *_domain;
|
2019-04-30 11:12:30 +00:00
|
|
|
}
|
2020-06-15 16:25:02 +00:00
|
|
|
[[nodiscard]] Main::Account &activeAccount() const;
|
|
|
|
[[nodiscard]] bool someSessionExists() const;
|
2020-06-25 07:14:05 +00:00
|
|
|
[[nodiscard]] Export::Manager &exportManager() const {
|
|
|
|
return *_exportManager;
|
|
|
|
}
|
2019-07-24 14:00:30 +00:00
|
|
|
[[nodiscard]] bool exportPreventsQuit();
|
2019-04-30 11:12:30 +00:00
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
// Main::Session component.
|
2022-06-11 23:24:50 +00:00
|
|
|
Main::Session *maybePrimarySession() const;
|
2019-07-24 14:00:30 +00:00
|
|
|
[[nodiscard]] int unreadBadge() const;
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] bool unreadBadgeMuted() const;
|
2020-06-18 11:17:58 +00:00
|
|
|
[[nodiscard]] rpl::producer<> unreadBadgeChanges() const;
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2017-05-03 11:36:39 +00:00
|
|
|
// Media component.
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] Media::Audio::Instance &audio() {
|
2017-05-03 11:36:39 +00:00
|
|
|
return *_audio;
|
|
|
|
}
|
|
|
|
|
2019-03-28 08:48:32 +00:00
|
|
|
// Langpack and emoji keywords.
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] Lang::Instance &langpack() {
|
2019-03-28 08:48:32 +00:00
|
|
|
return *_langpack;
|
|
|
|
}
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] Lang::CloudManager *langCloudManager() {
|
2019-03-28 08:48:32 +00:00
|
|
|
return _langCloudManager.get();
|
|
|
|
}
|
2020-06-10 14:52:44 +00:00
|
|
|
[[nodiscard]] bool offerLegacyLangPackSwitch() const;
|
2020-06-10 13:24:41 +00:00
|
|
|
[[nodiscard]] bool canApplyLangPackWithoutRestart() const;
|
|
|
|
[[nodiscard]] ChatHelpers::EmojiKeywords &emojiKeywords() {
|
2019-03-28 08:48:32 +00:00
|
|
|
return *_emojiKeywords;
|
|
|
|
}
|
2020-06-22 19:01:19 +00:00
|
|
|
[[nodiscard]] auto emojiImageLoader() const
|
|
|
|
-> const crl::object_on_queue<Stickers::EmojiImageLoader> & {
|
|
|
|
return _emojiImageLoader;
|
|
|
|
}
|
2019-03-28 08:48:32 +00:00
|
|
|
|
2017-06-27 20:11:38 +00:00
|
|
|
// Internal links.
|
|
|
|
void checkStartUrl();
|
2022-11-30 13:28:09 +00:00
|
|
|
void checkSendPaths();
|
2018-07-09 18:13:48 +00:00
|
|
|
bool openLocalUrl(const QString &url, QVariant context);
|
2019-12-25 15:20:02 +00:00
|
|
|
bool openInternalUrl(const QString &url, QVariant context);
|
2021-02-04 16:42:32 +00:00
|
|
|
[[nodiscard]] QString changelogLink() const;
|
2017-03-10 17:25:43 +00:00
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
// Float player.
|
2023-01-19 07:40:39 +00:00
|
|
|
void floatPlayerToggleGifsPaused(bool paused);
|
2020-06-25 14:17:37 +00:00
|
|
|
[[nodiscard]] rpl::producer<FullMsgId> floatPlayerClosed() const;
|
|
|
|
|
2020-06-25 17:57:36 +00:00
|
|
|
// Calls.
|
|
|
|
Calls::Instance &calls() const {
|
|
|
|
return *_calls;
|
|
|
|
}
|
|
|
|
|
2020-06-16 09:40:43 +00:00
|
|
|
void logout(Main::Account *account = nullptr);
|
2022-01-26 09:41:27 +00:00
|
|
|
void logoutWithChecks(Main::Account *account);
|
2020-06-16 09:40:43 +00:00
|
|
|
void forceLogOut(
|
|
|
|
not_null<Main::Account*> account,
|
|
|
|
const TextWithEntities &explanation);
|
2022-01-26 09:41:27 +00:00
|
|
|
[[nodiscard]] bool uploadPreventsQuit();
|
2022-03-09 11:30:22 +00:00
|
|
|
[[nodiscard]] bool downloadPreventsQuit();
|
2017-02-23 10:59:19 +00:00
|
|
|
void checkLocalTime();
|
2018-06-03 13:30:40 +00:00
|
|
|
void lockByPasscode();
|
2022-10-12 12:57:17 +00:00
|
|
|
void maybeLockByPasscode();
|
2018-06-03 13:30:40 +00:00
|
|
|
void unlockPasscode();
|
|
|
|
[[nodiscard]] bool passcodeLocked() const;
|
|
|
|
rpl::producer<bool> passcodeLockChanges() const;
|
|
|
|
rpl::producer<bool> passcodeLockValue() const;
|
|
|
|
|
2021-06-18 15:22:36 +00:00
|
|
|
void checkAutoLock(crl::time lastNonIdleTime = 0);
|
2020-06-08 15:56:52 +00:00
|
|
|
void checkAutoLockIn(crl::time time);
|
|
|
|
void localPasscodeChanged();
|
|
|
|
|
2022-01-27 12:48:51 +00:00
|
|
|
[[nodiscard]] bool preventsQuit(QuitReason reason);
|
2022-01-26 09:41:27 +00:00
|
|
|
|
2019-03-09 17:10:51 +00:00
|
|
|
[[nodiscard]] crl::time lastNonIdleTime() const;
|
|
|
|
void updateNonIdle();
|
|
|
|
|
2019-09-13 16:45:48 +00:00
|
|
|
void registerLeaveSubscription(not_null<QWidget*> widget);
|
|
|
|
void unregisterLeaveSubscription(not_null<QWidget*> widget);
|
2017-11-21 10:27:37 +00:00
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
// Sandbox interface.
|
|
|
|
void postponeCall(FnMut<void()> &&callable);
|
|
|
|
void refreshGlobalProxy();
|
2023-02-28 16:49:45 +00:00
|
|
|
void refreshApplicationIcon();
|
2019-01-21 13:42:21 +00:00
|
|
|
|
2017-04-29 20:06:32 +00:00
|
|
|
void quitPreventFinished();
|
|
|
|
|
2017-02-23 10:59:19 +00:00
|
|
|
void handleAppActivated();
|
|
|
|
void handleAppDeactivated();
|
2020-12-06 15:01:37 +00:00
|
|
|
[[nodiscard]] rpl::producer<bool> appDeactivatedValue() const;
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2019-01-18 11:26:43 +00:00
|
|
|
void switchDebugMode();
|
2019-01-21 13:42:21 +00:00
|
|
|
void writeInstallBetaVersionsSetting();
|
2019-01-18 11:26:43 +00:00
|
|
|
|
2020-12-13 13:08:16 +00:00
|
|
|
void preventOrInvoke(Fn<void()> &&callback);
|
|
|
|
|
2021-05-27 14:47:51 +00:00
|
|
|
// Global runtime variables.
|
|
|
|
void setScreenIsLocked(bool locked);
|
|
|
|
bool screenIsLocked() const;
|
|
|
|
|
2021-07-18 03:25:01 +00:00
|
|
|
static void RegisterUrlScheme();
|
|
|
|
|
2017-08-08 09:31:48 +00:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *object, QEvent *event) override;
|
|
|
|
|
2017-02-23 10:59:19 +00:00
|
|
|
private:
|
2019-08-23 13:52:59 +00:00
|
|
|
static constexpr auto kDefaultSaveDelay = crl::time(1000);
|
|
|
|
|
2019-02-04 13:34:50 +00:00
|
|
|
friend bool IsAppLaunched();
|
|
|
|
friend Application &App();
|
|
|
|
|
2020-06-22 19:01:19 +00:00
|
|
|
void clearEmojiSourceImages();
|
|
|
|
[[nodiscard]] auto prepareEmojiSourceImages()
|
|
|
|
-> std::shared_ptr<Ui::Emoji::UniversalImages>;
|
2017-02-23 10:59:19 +00:00
|
|
|
void startLocalStorage();
|
2018-11-16 12:15:14 +00:00
|
|
|
void startShortcuts();
|
2020-07-22 12:10:17 +00:00
|
|
|
void startDomain();
|
2020-06-22 19:01:19 +00:00
|
|
|
void startEmojiImageLoader();
|
2020-07-22 12:10:17 +00:00
|
|
|
void startSystemDarkModeViewer();
|
2023-02-06 09:16:37 +00:00
|
|
|
void startMediaView();
|
2022-03-23 15:59:53 +00:00
|
|
|
void startTray();
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2023-02-06 09:16:37 +00:00
|
|
|
void createTray();
|
2023-02-03 13:51:26 +00:00
|
|
|
void updateWindowTitles();
|
2023-01-19 07:40:39 +00:00
|
|
|
void setLastActiveWindow(Window::Controller *window);
|
2023-01-17 15:47:58 +00:00
|
|
|
void showAccount(not_null<Main::Account*> account);
|
2022-06-08 06:36:50 +00:00
|
|
|
void enumerateWindows(
|
|
|
|
Fn<void(not_null<Window::Controller*>)> callback) const;
|
2023-01-17 15:47:58 +00:00
|
|
|
void processCreatedWindow(not_null<Window::Controller*> window);
|
2023-02-28 16:49:45 +00:00
|
|
|
void refreshApplicationIcon(Main::Session *session);
|
2022-06-08 06:36:50 +00:00
|
|
|
|
2022-01-27 12:48:51 +00:00
|
|
|
friend void QuitAttempt();
|
2017-04-29 20:06:32 +00:00
|
|
|
void quitDelayed();
|
2020-06-26 07:22:53 +00:00
|
|
|
[[nodiscard]] bool readyToQuit();
|
2017-04-29 20:06:32 +00:00
|
|
|
|
2021-06-11 19:01:07 +00:00
|
|
|
void showOpenGLCrashNotification();
|
2018-06-07 07:44:38 +00:00
|
|
|
void clearPasscodeLock();
|
2017-08-08 09:31:48 +00:00
|
|
|
|
2019-12-25 15:20:02 +00:00
|
|
|
bool openCustomUrl(
|
|
|
|
const QString &protocol,
|
|
|
|
const std::vector<LocalUrlHandler> &handlers,
|
|
|
|
const QString &url,
|
|
|
|
const QVariant &context);
|
|
|
|
|
2019-02-04 13:34:50 +00:00
|
|
|
static Application *Instance;
|
2019-07-24 08:46:23 +00:00
|
|
|
struct InstanceSetter {
|
|
|
|
InstanceSetter(not_null<Application*> instance) {
|
|
|
|
Expects(Instance == nullptr);
|
|
|
|
|
|
|
|
Instance = instance;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
InstanceSetter _setter = { this };
|
2019-02-04 13:34:50 +00:00
|
|
|
|
2022-01-04 12:29:40 +00:00
|
|
|
const not_null<Launcher*> _launcher;
|
2019-07-24 08:46:23 +00:00
|
|
|
rpl::event_stream<ProxyChange> _proxyChanges;
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2017-02-24 17:15:41 +00:00
|
|
|
// Some fields are just moved from the declaration.
|
|
|
|
struct Private;
|
|
|
|
const std::unique_ptr<Private> _private;
|
2022-01-04 12:29:40 +00:00
|
|
|
const std::unique_ptr<Platform::Integration> _platformIntegration;
|
2023-02-27 14:09:12 +00:00
|
|
|
const std::unique_ptr<base::BatterySaving> _batterySaving;
|
2017-08-08 09:31:48 +00:00
|
|
|
|
2019-02-04 13:34:50 +00:00
|
|
|
const std::unique_ptr<Storage::Databases> _databases;
|
|
|
|
const std::unique_ptr<Ui::Animations::Manager> _animationsManager;
|
2020-06-22 19:01:19 +00:00
|
|
|
crl::object_on_queue<Stickers::EmojiImageLoader> _emojiImageLoader;
|
|
|
|
base::Timer _clearEmojiImageLoaderTimer;
|
2020-06-25 17:57:36 +00:00
|
|
|
const std::unique_ptr<Media::Audio::Instance> _audio;
|
2020-06-17 09:36:25 +00:00
|
|
|
mutable std::unique_ptr<MTP::Config> _fallbackProductionConfig;
|
2020-06-30 15:33:22 +00:00
|
|
|
|
|
|
|
// Notifications should be destroyed before _audio, after _domain.
|
|
|
|
// Mutable because is created in run() after OpenSSL is inited.
|
|
|
|
std::unique_ptr<Window::Notifications::System> _notifications;
|
|
|
|
|
2023-01-19 05:38:52 +00:00
|
|
|
using MediaControlsManager = Media::SystemMediaControlsManager;
|
2023-01-19 05:53:59 +00:00
|
|
|
std::unique_ptr<MediaControlsManager> _mediaControlsManager;
|
2022-02-21 15:40:20 +00:00
|
|
|
const std::unique_ptr<Data::DownloadManager> _downloadManager;
|
2020-06-18 18:04:16 +00:00
|
|
|
const std::unique_ptr<Main::Domain> _domain;
|
2020-06-25 07:14:05 +00:00
|
|
|
const std::unique_ptr<Export::Manager> _exportManager;
|
2020-06-25 17:57:36 +00:00
|
|
|
const std::unique_ptr<Calls::Instance> _calls;
|
2023-01-17 15:47:58 +00:00
|
|
|
base::flat_map<
|
|
|
|
Main::Account*,
|
|
|
|
std::unique_ptr<Window::Controller>> _primaryWindows;
|
|
|
|
base::flat_set<not_null<Window::Controller*>> _closingAsyncWindows;
|
2022-01-04 11:18:13 +00:00
|
|
|
base::flat_map<
|
|
|
|
not_null<History*>,
|
2022-01-04 16:36:33 +00:00
|
|
|
std::unique_ptr<Window::Controller>> _secondaryWindows;
|
2023-02-03 16:48:12 +00:00
|
|
|
std::vector<not_null<Window::Controller*>> _windowStack;
|
2022-01-04 11:18:13 +00:00
|
|
|
Window::Controller *_lastActiveWindow = nullptr;
|
2023-01-17 15:47:58 +00:00
|
|
|
Window::Controller *_lastActivePrimaryWindow = nullptr;
|
2023-02-02 16:19:32 +00:00
|
|
|
Window::Controller *_windowInSettings = nullptr;
|
2022-01-04 11:18:13 +00:00
|
|
|
|
2019-02-12 11:00:47 +00:00
|
|
|
std::unique_ptr<Media::View::OverlayWidget> _mediaView;
|
2019-02-04 13:34:50 +00:00
|
|
|
const std::unique_ptr<Lang::Instance> _langpack;
|
2019-11-27 08:02:56 +00:00
|
|
|
const std::unique_ptr<Lang::CloudManager> _langCloudManager;
|
2019-03-28 08:48:32 +00:00
|
|
|
const std::unique_ptr<ChatHelpers::EmojiKeywords> _emojiKeywords;
|
2017-04-13 08:45:58 +00:00
|
|
|
std::unique_ptr<Lang::Translator> _translator;
|
2019-09-18 11:19:05 +00:00
|
|
|
QPointer<Ui::BoxContent> _badProxyDisableBox;
|
2017-02-23 10:59:19 +00:00
|
|
|
|
2022-03-23 15:59:53 +00:00
|
|
|
const std::unique_ptr<Tray> _tray;
|
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
std::unique_ptr<Media::Player::FloatController> _floatPlayers;
|
2023-01-19 07:40:39 +00:00
|
|
|
rpl::lifetime _floatPlayerDelegateLifetime;
|
|
|
|
bool _floatPlayerGifsPaused = false;
|
2020-06-25 14:17:37 +00:00
|
|
|
|
2018-06-03 13:30:40 +00:00
|
|
|
rpl::variable<bool> _passcodeLock;
|
2021-05-27 14:47:51 +00:00
|
|
|
bool _screenIsLocked = false;
|
2018-06-03 13:30:40 +00:00
|
|
|
|
2020-06-08 15:56:52 +00:00
|
|
|
crl::time _shouldLockAt = 0;
|
|
|
|
base::Timer _autoLockTimer;
|
|
|
|
|
2021-02-17 15:19:00 +00:00
|
|
|
std::optional<base::Timer> _saveSettingsTimer;
|
2017-08-03 13:06:29 +00:00
|
|
|
|
2021-05-27 05:34:33 +00:00
|
|
|
struct LeaveFilter {
|
|
|
|
std::vector<QPointer<QWidget>> registered;
|
|
|
|
QPointer<QObject> filter;
|
2017-11-21 10:27:37 +00:00
|
|
|
};
|
2021-05-27 05:34:33 +00:00
|
|
|
base::flat_map<not_null<QWidget*>, LeaveFilter> _leaveFilters;
|
2017-11-21 10:27:37 +00:00
|
|
|
|
2022-06-08 07:04:35 +00:00
|
|
|
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
|
|
|
|
|
2018-11-16 12:15:14 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
2019-03-09 17:10:51 +00:00
|
|
|
crl::time _lastNonIdleTime = 0;
|
|
|
|
|
2017-02-23 10:59:19 +00:00
|
|
|
};
|
2019-01-21 13:42:21 +00:00
|
|
|
|
2019-02-04 13:34:50 +00:00
|
|
|
[[nodiscard]] bool IsAppLaunched();
|
|
|
|
[[nodiscard]] Application &App();
|
2019-01-21 13:42:21 +00:00
|
|
|
|
2022-01-27 12:48:51 +00:00
|
|
|
[[nodiscard]] LaunchState CurrentLaunchState();
|
|
|
|
void SetLaunchState(LaunchState state);
|
|
|
|
|
|
|
|
void Quit(QuitReason reason = QuitReason::Default);
|
|
|
|
[[nodiscard]] bool Quitting();
|
|
|
|
|
|
|
|
void Restart();
|
|
|
|
|
2019-01-21 13:42:21 +00:00
|
|
|
} // namespace Core
|