2014-05-30 08:53: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.
|
2014-05-30 08:53: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
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
2016-04-09 20:41:20 +00:00
|
|
|
#include "app.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2021-07-15 11:12:38 +00:00
|
|
|
#include "history/view/history_view_element.h"
|
2018-12-18 10:45:06 +00:00
|
|
|
#include "core/update_checker.h"
|
2019-01-21 13:42:21 +00:00
|
|
|
#include "core/sandbox.h"
|
|
|
|
#include "core/application.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "mainwindow.h"
|
2015-07-21 14:55:23 +00:00
|
|
|
|
2019-09-04 07:19:15 +00:00
|
|
|
#include <QtCore/QBuffer>
|
|
|
|
#include <QtGui/QFontDatabase>
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
namespace {
|
|
|
|
|
2020-04-13 11:12:43 +00:00
|
|
|
constexpr auto kImageAreaLimit = 12'032 * 9'024;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2020-03-23 11:27:07 +00:00
|
|
|
App::LaunchState _launchState = App::Launched;
|
2015-05-20 19:28:24 +00:00
|
|
|
|
2020-03-23 11:27:07 +00:00
|
|
|
HistoryView::Element *hoveredItem = nullptr,
|
|
|
|
*pressedItem = nullptr,
|
|
|
|
*hoveredLinkItem = nullptr,
|
|
|
|
*pressedLinkItem = nullptr,
|
|
|
|
*mousedItem = nullptr;
|
|
|
|
|
2017-12-17 08:13:26 +00:00
|
|
|
} // namespace
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
namespace App {
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void hoveredItem(HistoryView::Element *item) {
|
2014-05-30 08:53:19 +00:00
|
|
|
::hoveredItem = item;
|
|
|
|
}
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *hoveredItem() {
|
2014-05-30 08:53:19 +00:00
|
|
|
return ::hoveredItem;
|
|
|
|
}
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void pressedItem(HistoryView::Element *item) {
|
2014-05-30 08:53:19 +00:00
|
|
|
::pressedItem = item;
|
|
|
|
}
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *pressedItem() {
|
2014-05-30 08:53:19 +00:00
|
|
|
return ::pressedItem;
|
|
|
|
}
|
2016-01-03 01:43:42 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void hoveredLinkItem(HistoryView::Element *item) {
|
2014-05-30 08:53:19 +00:00
|
|
|
::hoveredLinkItem = item;
|
|
|
|
}
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *hoveredLinkItem() {
|
2014-05-30 08:53:19 +00:00
|
|
|
return ::hoveredLinkItem;
|
|
|
|
}
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void pressedLinkItem(HistoryView::Element *item) {
|
2014-05-30 08:53:19 +00:00
|
|
|
::pressedLinkItem = item;
|
|
|
|
}
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *pressedLinkItem() {
|
2014-05-30 08:53:19 +00:00
|
|
|
return ::pressedLinkItem;
|
|
|
|
}
|
2016-01-03 01:43:42 +00:00
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
void mousedItem(HistoryView::Element *item) {
|
2014-05-30 08:53:19 +00:00
|
|
|
::mousedItem = item;
|
|
|
|
}
|
|
|
|
|
2018-01-11 19:33:26 +00:00
|
|
|
HistoryView::Element *mousedItem() {
|
2014-05-30 08:53:19 +00:00
|
|
|
return ::mousedItem;
|
|
|
|
}
|
|
|
|
|
2016-06-14 16:26:41 +00:00
|
|
|
void clearMousedItems() {
|
|
|
|
hoveredItem(nullptr);
|
|
|
|
pressedItem(nullptr);
|
|
|
|
hoveredLinkItem(nullptr);
|
|
|
|
pressedLinkItem(nullptr);
|
|
|
|
mousedItem(nullptr);
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void quit() {
|
2018-06-20 17:30:57 +00:00
|
|
|
if (quitting()) {
|
|
|
|
return;
|
2019-07-24 14:00:30 +00:00
|
|
|
} else if (Core::IsAppLaunched()
|
|
|
|
&& Core::App().exportPreventsQuit()) {
|
2018-06-20 17:30:57 +00:00
|
|
|
return;
|
|
|
|
}
|
2016-03-02 18:34:42 +00:00
|
|
|
setLaunchState(QuitRequested);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-12-04 12:10:00 +00:00
|
|
|
if (auto window = App::wnd()) {
|
2019-01-21 13:42:21 +00:00
|
|
|
if (!Core::Sandbox::Instance().isSavingSession()) {
|
2016-06-21 15:58:07 +00:00
|
|
|
window->hide();
|
|
|
|
}
|
2016-06-07 19:59:39 +00:00
|
|
|
}
|
2019-01-21 13:42:21 +00:00
|
|
|
Core::Application::QuitAttempt();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-02 18:34:42 +00:00
|
|
|
bool quitting() {
|
|
|
|
return _launchState != Launched;
|
|
|
|
}
|
|
|
|
|
|
|
|
LaunchState launchState() {
|
|
|
|
return _launchState;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-02 18:34:42 +00:00
|
|
|
void setLaunchState(LaunchState state) {
|
|
|
|
_launchState = state;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-10-28 12:44:28 +00:00
|
|
|
void restart() {
|
2018-07-11 22:14:44 +00:00
|
|
|
using namespace Core;
|
|
|
|
const auto updateReady = !UpdaterDisabled()
|
|
|
|
&& (UpdateChecker().state() == UpdateChecker::State::Ready);
|
2016-10-28 12:44:28 +00:00
|
|
|
if (updateReady) {
|
|
|
|
cSetRestartingUpdate(true);
|
|
|
|
} else {
|
|
|
|
cSetRestarting(true);
|
|
|
|
cSetRestartingToSettings(true);
|
|
|
|
}
|
|
|
|
App::quit();
|
|
|
|
}
|
|
|
|
|
2015-11-20 13:34:37 +00:00
|
|
|
}
|