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-12 21:31:28 +00:00
|
|
|
#include "mainwindow.h"
|
2016-03-24 12:57:10 +00:00
|
|
|
|
2017-09-26 11:49:16 +00:00
|
|
|
#include "data/data_document.h"
|
2016-09-30 12:52:03 +00:00
|
|
|
#include "dialogs/dialogs_layout.h"
|
2016-06-07 19:59:39 +00:00
|
|
|
#include "styles/style_dialogs.h"
|
2016-11-04 08:23:50 +00:00
|
|
|
#include "styles/style_window.h"
|
2016-11-15 11:56:49 +00:00
|
|
|
#include "styles/style_boxes.h"
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history.h"
|
2016-10-26 16:43:13 +00:00
|
|
|
#include "ui/widgets/popup_menu.h"
|
2016-11-11 13:46:04 +00:00
|
|
|
#include "ui/widgets/buttons.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "ui/widgets/shadow.h"
|
2017-05-30 13:54:05 +00:00
|
|
|
#include "lang/lang_cloud_manager.h"
|
|
|
|
#include "lang/lang_instance.h"
|
2017-04-13 08:27:10 +00:00
|
|
|
#include "lang/lang_keys.h"
|
2016-02-27 19:39:51 +00:00
|
|
|
#include "shortcuts.h"
|
2017-02-23 10:59:19 +00:00
|
|
|
#include "messenger.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "application.h"
|
2015-03-02 12:34:16 +00:00
|
|
|
#include "passcodewidget.h"
|
2016-03-14 16:59:18 +00:00
|
|
|
#include "intro/introwidget.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "mainwidget.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/confirm_box.h"
|
|
|
|
#include "boxes/add_contact_box.h"
|
2017-06-27 19:24:59 +00:00
|
|
|
#include "boxes/connection_box.h"
|
2016-06-02 13:02:55 +00:00
|
|
|
#include "observer_peer.h"
|
2014-08-06 14:40:21 +00:00
|
|
|
#include "mediaview.h"
|
2017-03-04 10:23:56 +00:00
|
|
|
#include "storage/localstorage.h"
|
2016-06-01 13:07:03 +00:00
|
|
|
#include "apiwrap.h"
|
2016-08-17 15:14:08 +00:00
|
|
|
#include "settings/settings_widget.h"
|
2016-10-17 10:55:17 +00:00
|
|
|
#include "platform/platform_notifications_manager.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "window/layer_widget.h"
|
2016-11-02 14:44:33 +00:00
|
|
|
#include "window/notifications_manager.h"
|
2017-02-03 20:07:26 +00:00
|
|
|
#include "window/themes/window_theme.h"
|
|
|
|
#include "window/themes/window_theme_warning.h"
|
2016-11-11 19:51:59 +00:00
|
|
|
#include "window/window_main_menu.h"
|
2017-02-23 09:32:28 +00:00
|
|
|
#include "auth_session.h"
|
2017-03-27 12:24:38 +00:00
|
|
|
#include "window/window_controller.h"
|
2014-08-06 14:40:21 +00:00
|
|
|
|
2017-05-30 13:54:05 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Code for testing languages is F7-F6-F7-F8
|
|
|
|
void FeedLangTestingKey(int key) {
|
|
|
|
static auto codeState = 0;
|
|
|
|
if ((codeState == 0 && key == Qt::Key_F7)
|
|
|
|
|| (codeState == 1 && key == Qt::Key_F6)
|
|
|
|
|| (codeState == 2 && key == Qt::Key_F7)
|
|
|
|
|| (codeState == 3 && key == Qt::Key_F8)) {
|
|
|
|
++codeState;
|
|
|
|
} else {
|
|
|
|
codeState = 0;
|
|
|
|
}
|
|
|
|
if (codeState == 4) {
|
|
|
|
codeState = 0;
|
2017-05-30 17:58:25 +00:00
|
|
|
Lang::CurrentCloudManager().switchToTestLanguage();
|
2017-05-30 13:54:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2016-11-04 08:23:50 +00:00
|
|
|
ConnectingWidget::ConnectingWidget(QWidget *parent, const QString &text, const QString &reconnect) : TWidget(parent)
|
2016-10-01 12:34:23 +00:00
|
|
|
, _reconnect(this, QString()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
set(text, reconnect);
|
2016-11-11 13:46:04 +00:00
|
|
|
connect(_reconnect, SIGNAL(clicked()), this, SLOT(onReconnect()));
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectingWidget::set(const QString &text, const QString &reconnect) {
|
|
|
|
_text = text;
|
2015-10-03 10:09:09 +00:00
|
|
|
_textWidth = st::linkFont->width(_text) + st::linkFont->spacew;
|
2014-05-30 08:53:19 +00:00
|
|
|
int32 _reconnectWidth = 0;
|
|
|
|
if (reconnect.isEmpty()) {
|
2016-11-11 13:46:04 +00:00
|
|
|
_reconnect->hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2016-11-11 13:46:04 +00:00
|
|
|
_reconnect->setText(reconnect);
|
|
|
|
_reconnect->show();
|
2016-12-13 17:07:56 +00:00
|
|
|
_reconnect->move(st::connectingPadding.left() + _textWidth, st::boxRoundShadow.extend.top() + st::connectingPadding.top());
|
2016-11-11 13:46:04 +00:00
|
|
|
_reconnectWidth = _reconnect->width();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-12-13 17:07:56 +00:00
|
|
|
resize(st::connectingPadding.left() + _textWidth + _reconnectWidth + st::connectingPadding.right() + st::boxRoundShadow.extend.right(), st::boxRoundShadow.extend.top() + st::connectingPadding.top() + st::normalFont->height + st::connectingPadding.bottom());
|
2014-05-30 08:53:19 +00:00
|
|
|
update();
|
|
|
|
}
|
2016-01-31 18:01:43 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void ConnectingWidget::paintEvent(QPaintEvent *e) {
|
2016-10-01 12:34:23 +00:00
|
|
|
Painter p(this);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-05-24 12:20:50 +00:00
|
|
|
auto sides = RectPart::Top | RectPart::Right;
|
2016-12-13 17:07:56 +00:00
|
|
|
Ui::Shadow::paint(p, QRect(0, st::boxRoundShadow.extend.top(), width() - st::boxRoundShadow.extend.right(), height() - st::boxRoundShadow.extend.top()), width(), st::boxRoundShadow, sides);
|
2017-05-24 12:20:50 +00:00
|
|
|
auto parts = RectPart::Top | RectPart::TopRight | RectPart::Center | RectPart::Right;
|
2016-12-13 17:07:56 +00:00
|
|
|
App::roundRect(p, QRect(-st::boxRadius, st::boxRoundShadow.extend.top(), width() - st::boxRoundShadow.extend.right() + st::boxRadius, height() - st::boxRoundShadow.extend.top() + st::boxRadius), st::boxBg, BoxCorners, nullptr, parts);
|
|
|
|
|
|
|
|
p.setFont(st::normalFont);
|
|
|
|
p.setPen(st::windowSubTextFg);
|
|
|
|
p.drawText(st::connectingPadding.left(), st::boxRoundShadow.extend.top() + st::connectingPadding.top() + st::normalFont->ascent, _text);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConnectingWidget::onReconnect() {
|
2017-06-27 19:24:59 +00:00
|
|
|
auto throughProxy = (Global::ConnectionType() != dbictAuto);
|
|
|
|
if (throughProxy) {
|
|
|
|
Ui::show(Box<ConnectionBox>());
|
|
|
|
} else {
|
|
|
|
MTP::restart();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-11-04 11:14:47 +00:00
|
|
|
MainWindow::MainWindow() {
|
2017-05-12 15:27:19 +00:00
|
|
|
auto logo = Messenger::Instance().logo();
|
|
|
|
icon16 = logo.scaledToWidth(16, Qt::SmoothTransformation);
|
|
|
|
icon32 = logo.scaledToWidth(32, Qt::SmoothTransformation);
|
|
|
|
icon64 = logo.scaledToWidth(64, Qt::SmoothTransformation);
|
|
|
|
|
|
|
|
auto logoNoMargin = Messenger::Instance().logoNoMargin();
|
|
|
|
iconbig16 = logoNoMargin.scaledToWidth(16, Qt::SmoothTransformation);
|
|
|
|
iconbig32 = logoNoMargin.scaledToWidth(32, Qt::SmoothTransformation);
|
|
|
|
iconbig64 = logoNoMargin.scaledToWidth(64, Qt::SmoothTransformation);
|
2014-09-20 21:31:03 +00:00
|
|
|
|
2016-11-04 11:14:47 +00:00
|
|
|
resize(st::windowDefaultWidth, st::windowDefaultHeight);
|
2015-09-29 13:24:39 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
setLocale(QLocale(QLocale::English, QLocale::UnitedStates));
|
|
|
|
|
2017-04-09 18:06:06 +00:00
|
|
|
subscribe(Global::RefSelfChanged(), [this] { updateGlobalMenu(); });
|
2016-11-02 14:44:33 +00:00
|
|
|
subscribe(Window::Theme::Background(), [this](const Window::Theme::BackgroundUpdate &data) {
|
|
|
|
themeUpdated(data);
|
|
|
|
});
|
2017-04-15 18:48:54 +00:00
|
|
|
subscribe(Messenger::Instance().passcodedChanged(), [this] { updateGlobalMenu(); });
|
2016-08-27 04:49:18 +00:00
|
|
|
|
2015-09-29 13:24:39 +00:00
|
|
|
setAttribute(Qt::WA_NoSystemBackground);
|
|
|
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-11-07 15:24:28 +00:00
|
|
|
void MainWindow::initHook() {
|
|
|
|
Platform::MainWindow::initHook();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-02-23 10:59:19 +00:00
|
|
|
QCoreApplication::instance()->installEventFilter(this);
|
2017-05-19 14:02:55 +00:00
|
|
|
connect(windowHandle(), &QWindow::activeChanged, this, [this] { checkHistoryActivation(); }, Qt::QueuedConnection);
|
2016-10-19 12:24:39 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::firstShow() {
|
2014-09-29 02:47:30 +00:00
|
|
|
#ifdef Q_OS_WIN
|
2017-01-11 05:30:51 +00:00
|
|
|
trayIconMenu = new Ui::PopupMenu(nullptr);
|
2015-11-01 18:14:30 +00:00
|
|
|
trayIconMenu->deleteOnHide(false);
|
2016-10-19 12:24:39 +00:00
|
|
|
#else // Q_OS_WIN
|
2015-07-21 15:35:08 +00:00
|
|
|
trayIconMenu = new QMenu(this);
|
2016-10-19 12:24:39 +00:00
|
|
|
#endif // else for Q_OS_WIN
|
2016-01-01 07:42:06 +00:00
|
|
|
|
2016-10-19 12:24:39 +00:00
|
|
|
auto isLinux = (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64);
|
|
|
|
auto notificationActionText = lang(Global::DesktopNotify()
|
|
|
|
? lng_disable_notifications_from_tray
|
|
|
|
: lng_enable_notifications_from_tray);
|
|
|
|
|
|
|
|
if (isLinux) {
|
2018-01-25 10:10:52 +00:00
|
|
|
trayIconMenu->addAction(lang(lng_open_from_tray), this, SLOT(showFromTray()));
|
|
|
|
trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()));
|
|
|
|
trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray()));
|
|
|
|
trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()));
|
2015-07-21 15:35:08 +00:00
|
|
|
} else {
|
2018-01-25 10:10:52 +00:00
|
|
|
trayIconMenu->addAction(lang(lng_minimize_to_tray), this, SLOT(minimizeToTray()));
|
|
|
|
trayIconMenu->addAction(notificationActionText, this, SLOT(toggleDisplayNotifyFromTray()));
|
|
|
|
trayIconMenu->addAction(lang(lng_quit_from_tray), this, SLOT(quitFromTray()));
|
2015-07-21 15:35:08 +00:00
|
|
|
}
|
2017-03-08 07:31:05 +00:00
|
|
|
Global::RefWorkMode().setForced(Global::WorkMode().value(), true);
|
2016-11-07 15:24:28 +00:00
|
|
|
|
2015-07-21 13:29:38 +00:00
|
|
|
psFirstShow();
|
2014-09-29 02:47:30 +00:00
|
|
|
updateTrayMenu();
|
2014-08-11 09:03:45 +00:00
|
|
|
}
|
|
|
|
|
2017-01-01 16:45:20 +00:00
|
|
|
void MainWindow::clearWidgetsHook() {
|
2016-12-31 13:34:41 +00:00
|
|
|
auto wasMain = (_main != nullptr);
|
2016-11-04 08:23:50 +00:00
|
|
|
_passcode.destroyDelayed();
|
|
|
|
_main.destroy();
|
2016-11-24 19:28:23 +00:00
|
|
|
_intro.destroy();
|
2016-12-31 13:34:41 +00:00
|
|
|
if (wasMain) {
|
|
|
|
App::clearHistories();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
QPixmap MainWindow::grabInner() {
|
2015-10-17 14:52:26 +00:00
|
|
|
QPixmap result;
|
2016-11-04 11:14:47 +00:00
|
|
|
if (_intro) {
|
2017-12-26 12:41:48 +00:00
|
|
|
result = Ui::GrabWidget(_intro);
|
2015-10-17 14:52:26 +00:00
|
|
|
} else if (_passcode) {
|
2017-12-26 12:41:48 +00:00
|
|
|
result = Ui::GrabWidget(_passcode);
|
2016-11-24 19:28:23 +00:00
|
|
|
} else if (_main) {
|
2017-12-26 12:41:48 +00:00
|
|
|
result = Ui::GrabWidget(_main);
|
2015-10-17 14:52:26 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::clearPasscode() {
|
2015-03-02 12:34:16 +00:00
|
|
|
if (!_passcode) return;
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
auto bg = grabInner();
|
2015-03-02 12:34:16 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
_passcode.destroy();
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_intro) {
|
2016-12-05 11:01:08 +00:00
|
|
|
_intro->showAnimated(bg, true);
|
2015-03-02 12:34:16 +00:00
|
|
|
} else {
|
2017-08-17 09:06:26 +00:00
|
|
|
Assert(_main != nullptr);
|
2016-12-05 11:01:08 +00:00
|
|
|
_main->showAnimated(bg, true);
|
2017-06-27 20:11:38 +00:00
|
|
|
Messenger::Instance().checkStartUrl();
|
2016-10-03 08:20:02 +00:00
|
|
|
}
|
2015-03-02 12:34:16 +00:00
|
|
|
}
|
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
void MainWindow::setupPasscode() {
|
|
|
|
auto animated = (_main || _intro);
|
|
|
|
auto bg = animated ? grabInner() : QPixmap();
|
2016-11-04 11:14:47 +00:00
|
|
|
_passcode.create(bodyWidget());
|
2016-11-04 08:23:50 +00:00
|
|
|
updateControlsGeometry();
|
|
|
|
|
|
|
|
if (_main) _main->hide();
|
2017-08-08 09:31:48 +00:00
|
|
|
Messenger::Instance().hideMediaView();
|
2017-09-20 10:23:57 +00:00
|
|
|
Ui::hideSettingsAndLayer(anim::type::instant);
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_intro) _intro->hide();
|
2016-11-04 19:50:35 +00:00
|
|
|
if (animated) {
|
2016-12-05 11:01:08 +00:00
|
|
|
_passcode->showAnimated(bg);
|
2015-03-02 12:34:16 +00:00
|
|
|
} else {
|
2015-09-16 13:04:08 +00:00
|
|
|
setInnerFocus();
|
2015-03-02 12:34:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
void MainWindow::setupIntro() {
|
2018-01-04 19:54:35 +00:00
|
|
|
if (_intro && !_intro->isHidden() && !_main) {
|
|
|
|
return;
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-09-20 10:23:57 +00:00
|
|
|
Ui::hideSettingsAndLayer(anim::type::instant);
|
2016-06-26 15:37:47 +00:00
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
auto animated = (_main || _passcode);
|
|
|
|
auto bg = animated ? grabInner() : QPixmap();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
clearWidgets();
|
2016-11-04 11:14:47 +00:00
|
|
|
_intro.create(bodyWidget());
|
2016-11-04 08:23:50 +00:00
|
|
|
updateControlsGeometry();
|
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
if (animated) {
|
2016-12-05 11:01:08 +00:00
|
|
|
_intro->showAnimated(bg);
|
2016-11-04 19:50:35 +00:00
|
|
|
} else {
|
|
|
|
setInnerFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fixOrder();
|
|
|
|
|
2016-09-21 11:44:20 +00:00
|
|
|
updateConnectingStatus();
|
2014-12-12 16:27:03 +00:00
|
|
|
|
|
|
|
_delayedServiceMsgs.clear();
|
|
|
|
if (_serviceHistoryRequest) {
|
|
|
|
MTP::cancel(_serviceHistoryRequest);
|
|
|
|
_serviceHistoryRequest = 0;
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-12-13 07:59:57 +00:00
|
|
|
void MainWindow::serviceNotification(const TextWithEntities &message, const MTPMessageMedia &media, int32 date, bool force) {
|
|
|
|
if (date <= 0) date = unixtime();
|
2017-08-31 17:53:03 +00:00
|
|
|
auto h = (_main && App::userLoaded(ServiceUserId)) ? App::history(ServiceUserId).get() : nullptr;
|
2014-12-12 16:27:03 +00:00
|
|
|
if (!h || (!force && h->isEmpty())) {
|
2016-12-13 07:59:57 +00:00
|
|
|
_delayedServiceMsgs.push_back(DelayedServiceMsg(message, media, date));
|
2014-12-12 16:27:03 +00:00
|
|
|
return sendServiceHistoryRequest();
|
|
|
|
}
|
|
|
|
|
2017-06-30 11:30:11 +00:00
|
|
|
_main->insertCheckedServiceNotification(message, media, date);
|
2016-12-13 07:59:57 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::showDelayedServiceMsgs() {
|
2016-12-13 07:59:57 +00:00
|
|
|
for (auto &delayed : base::take(_delayedServiceMsgs)) {
|
|
|
|
serviceNotification(delayed.message, delayed.media, delayed.date, true);
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::sendServiceHistoryRequest() {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (!_main || !_main->started() || _delayedServiceMsgs.isEmpty() || _serviceHistoryRequest) return;
|
2014-12-12 16:27:03 +00:00
|
|
|
|
2017-11-20 19:54:05 +00:00
|
|
|
auto user = App::userLoaded(ServiceUserId);
|
2014-12-12 16:27:03 +00:00
|
|
|
if (!user) {
|
2017-03-25 15:42:01 +00:00
|
|
|
auto userFlags = MTPDuser::Flag::f_first_name | MTPDuser::Flag::f_phone | MTPDuser::Flag::f_status | MTPDuser::Flag::f_verified;
|
2017-11-20 19:54:05 +00:00
|
|
|
user = App::feedUsers(MTP_vector<MTPUser>(1, MTP_user(
|
|
|
|
MTP_flags(userFlags),
|
|
|
|
MTP_int(ServiceUserId),
|
|
|
|
MTPlong(),
|
|
|
|
MTP_string("Telegram"),
|
|
|
|
MTPstring(),
|
|
|
|
MTPstring(),
|
|
|
|
MTP_string("42777"),
|
|
|
|
MTP_userProfilePhotoEmpty(),
|
|
|
|
MTP_userStatusRecently(),
|
|
|
|
MTPint(),
|
|
|
|
MTPstring(),
|
|
|
|
MTPstring(),
|
|
|
|
MTPstring())));
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
2017-11-20 19:54:05 +00:00
|
|
|
auto offsetId = 0;
|
|
|
|
auto offsetDate = 0;
|
|
|
|
auto addOffset = 0;
|
|
|
|
auto limit = 1;
|
|
|
|
auto maxId = 0;
|
|
|
|
auto minId = 0;
|
|
|
|
auto historyHash = 0;
|
|
|
|
_serviceHistoryRequest = MTP::send(
|
|
|
|
MTPmessages_GetHistory(
|
|
|
|
user->input,
|
|
|
|
MTP_int(offsetId),
|
|
|
|
MTP_int(offsetDate),
|
|
|
|
MTP_int(addOffset),
|
|
|
|
MTP_int(limit),
|
|
|
|
MTP_int(maxId),
|
|
|
|
MTP_int(minId),
|
|
|
|
MTP_int(historyHash)),
|
|
|
|
_main->rpcDone(&MainWidget::serviceHistoryDone),
|
|
|
|
_main->rpcFail(&MainWidget::serviceHistoryFail));
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
void MainWindow::setupMain(const MTPUser *self) {
|
|
|
|
auto animated = (_intro || _passcode);
|
|
|
|
auto bg = animated ? grabInner() : QPixmap();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
clearWidgets();
|
2017-03-04 19:36:59 +00:00
|
|
|
|
2017-08-17 09:06:26 +00:00
|
|
|
Assert(AuthSession::Exists());
|
2017-03-04 19:36:59 +00:00
|
|
|
|
2017-04-07 18:10:49 +00:00
|
|
|
_main.create(bodyWidget(), controller());
|
2017-01-14 18:50:16 +00:00
|
|
|
_main->show();
|
2016-11-04 08:23:50 +00:00
|
|
|
updateControlsGeometry();
|
|
|
|
|
2016-11-04 19:50:35 +00:00
|
|
|
if (animated) {
|
2016-12-05 11:01:08 +00:00
|
|
|
_main->showAnimated(bg);
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2016-11-04 08:23:50 +00:00
|
|
|
_main->activate();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2017-03-04 19:36:59 +00:00
|
|
|
_main->start(self);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
fixOrder();
|
|
|
|
|
2016-09-21 11:44:20 +00:00
|
|
|
updateConnectingStatus();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::showSettings() {
|
2014-11-18 12:40:43 +00:00
|
|
|
if (isHidden()) showFromTray();
|
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
controller()->showSpecialLayer(Box<Settings::Widget>());
|
2017-02-03 20:07:26 +00:00
|
|
|
}
|
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
void MainWindow::showSpecialLayer(
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Window::LayerWidget> layer,
|
2017-09-20 10:23:57 +00:00
|
|
|
anim::type animated) {
|
2017-02-03 20:07:26 +00:00
|
|
|
if (_passcode) return;
|
|
|
|
|
2017-09-20 10:23:57 +00:00
|
|
|
if (layer) {
|
|
|
|
ensureLayerCreated();
|
|
|
|
_layerBg->showSpecialLayer(std::move(layer), animated);
|
|
|
|
} else if (_layerBg) {
|
|
|
|
_layerBg->hideSpecialLayer(animated);
|
2017-09-15 17:34:41 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2017-10-03 13:05:58 +00:00
|
|
|
bool MainWindow::showSectionInExistingLayer(
|
|
|
|
not_null<Window::SectionMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms) {
|
|
|
|
if (_layerBg) {
|
|
|
|
return _layerBg->showSectionInternal(memento, params);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-11-11 19:51:59 +00:00
|
|
|
void MainWindow::showMainMenu() {
|
|
|
|
if (_passcode) return;
|
|
|
|
|
|
|
|
if (isHidden()) showFromTray();
|
|
|
|
|
2017-04-06 19:14:12 +00:00
|
|
|
ensureLayerCreated();
|
2017-09-20 10:23:57 +00:00
|
|
|
_layerBg->showMainMenu(anim::type::normal);
|
2017-04-06 19:14:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::ensureLayerCreated() {
|
2016-11-11 19:51:59 +00:00
|
|
|
if (!_layerBg) {
|
2017-06-21 21:38:31 +00:00
|
|
|
_layerBg.create(bodyWidget(), controller());
|
|
|
|
if (controller()) {
|
|
|
|
controller()->enableGifPauseReason(Window::GifPauseReason::Layer);
|
2017-04-07 18:10:49 +00:00
|
|
|
}
|
2017-04-06 19:14:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::destroyLayerDelayed() {
|
|
|
|
if (_layerBg) {
|
|
|
|
_layerBg.destroyDelayed();
|
2017-06-21 21:38:31 +00:00
|
|
|
if (controller()) {
|
|
|
|
controller()->disableGifPauseReason(Window::GifPauseReason::Layer);
|
2017-04-07 18:10:49 +00:00
|
|
|
}
|
2016-11-11 19:51:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-20 10:23:57 +00:00
|
|
|
void MainWindow::ui_hideSettingsAndLayer(anim::type animated) {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_layerBg) {
|
2017-09-20 10:23:57 +00:00
|
|
|
_layerBg->hideAll(animated);
|
|
|
|
if (animated == anim::type::instant) {
|
2017-04-06 19:14:12 +00:00
|
|
|
destroyLayerDelayed();
|
2016-11-28 15:45:07 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::mtpStateChanged(int32 dc, int32 state) {
|
2014-05-30 08:53:19 +00:00
|
|
|
if (dc == MTP::maindc()) {
|
2016-09-21 11:44:20 +00:00
|
|
|
updateConnectingStatus();
|
2016-08-27 04:49:18 +00:00
|
|
|
Global::RefConnectionTypeChanged().notify();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-21 11:44:20 +00:00
|
|
|
void MainWindow::updateConnectingStatus() {
|
2017-06-27 19:24:59 +00:00
|
|
|
auto state = MTP::dcstate();
|
|
|
|
auto throughProxy = (Global::ConnectionType() != dbictAuto);
|
2016-03-24 08:57:11 +00:00
|
|
|
if (state == MTP::ConnectingState || state == MTP::DisconnectedState || (state < 0 && state > -600)) {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_main || getms() > 5000 || _connecting) {
|
2017-06-27 19:24:59 +00:00
|
|
|
showConnecting(lang(throughProxy ? lng_connecting_to_proxy : lng_connecting), throughProxy ? lang(lng_connecting_settings) : QString());
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
} else if (state < 0) {
|
2017-06-27 19:24:59 +00:00
|
|
|
showConnecting(lng_reconnecting(lt_count, ((-state) / 1000) + 1), lang(throughProxy ? lng_connecting_settings : lng_reconnecting_try_now));
|
2016-09-21 11:44:20 +00:00
|
|
|
QTimer::singleShot((-state) % 1000, this, SLOT(updateConnectingStatus()));
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
|
|
|
hideConnecting();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
MainWidget *MainWindow::mainWidget() {
|
2016-11-04 08:23:50 +00:00
|
|
|
return _main;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
PasscodeWidget *MainWindow::passcodeWidget() {
|
2015-03-02 12:34:16 +00:00
|
|
|
return _passcode;
|
|
|
|
}
|
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
void MainWindow::ui_showBox(
|
|
|
|
object_ptr<BoxContent> box,
|
2017-09-20 10:23:57 +00:00
|
|
|
LayerOptions options,
|
|
|
|
anim::type animated) {
|
2015-12-07 18:09:05 +00:00
|
|
|
if (box) {
|
2017-04-06 19:14:12 +00:00
|
|
|
ensureLayerCreated();
|
2017-09-15 17:34:41 +00:00
|
|
|
if (options & LayerOption::KeepOther) {
|
|
|
|
if (options & LayerOption::ShowAfterOther) {
|
2017-09-20 10:23:57 +00:00
|
|
|
_layerBg->prependBox(std::move(box), animated);
|
2015-12-07 18:09:05 +00:00
|
|
|
} else {
|
2017-09-20 10:23:57 +00:00
|
|
|
_layerBg->appendBox(std::move(box), animated);
|
2015-12-07 18:09:05 +00:00
|
|
|
}
|
2016-08-16 16:53:10 +00:00
|
|
|
} else {
|
2017-09-20 10:23:57 +00:00
|
|
|
_layerBg->showBox(std::move(box), animated);
|
2015-12-07 18:09:05 +00:00
|
|
|
}
|
2015-09-16 13:04:08 +00:00
|
|
|
} else {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_layerBg) {
|
2017-09-20 10:23:57 +00:00
|
|
|
_layerBg->hideTopLayer(animated);
|
|
|
|
if ((animated == anim::type::instant)
|
2017-12-08 11:53:28 +00:00
|
|
|
&& _layerBg
|
2017-09-20 10:23:57 +00:00
|
|
|
&& !_layerBg->layerShown()) {
|
2017-04-06 19:14:12 +00:00
|
|
|
destroyLayerDelayed();
|
2015-12-07 18:09:05 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
Messenger::Instance().hideMediaView();
|
2015-09-16 13:04:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
bool MainWindow::ui_isLayerShown() {
|
2016-11-04 08:23:50 +00:00
|
|
|
return _layerBg != nullptr;
|
2015-10-27 02:39:02 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::ui_showMediaPreview(DocumentData *document) {
|
2017-04-02 10:25:54 +00:00
|
|
|
if (!document || ((!document->isAnimation() || !document->loaded()) && !document->sticker())) {
|
|
|
|
return;
|
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
if (!_mediaPreview) {
|
2017-04-07 18:10:49 +00:00
|
|
|
_mediaPreview.create(bodyWidget(), controller());
|
2016-10-24 15:36:17 +00:00
|
|
|
updateControlsGeometry();
|
2016-04-10 18:18:26 +00:00
|
|
|
}
|
|
|
|
if (_mediaPreview->isHidden()) {
|
|
|
|
fixOrder();
|
|
|
|
}
|
|
|
|
_mediaPreview->showPreview(document);
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::ui_showMediaPreview(PhotoData *photo) {
|
2016-04-10 18:18:26 +00:00
|
|
|
if (!photo) return;
|
|
|
|
if (!_mediaPreview) {
|
2017-04-07 18:10:49 +00:00
|
|
|
_mediaPreview.create(bodyWidget(), controller());
|
2016-10-24 15:36:17 +00:00
|
|
|
updateControlsGeometry();
|
2016-02-17 16:37:21 +00:00
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
if (_mediaPreview->isHidden()) {
|
2016-02-17 16:37:21 +00:00
|
|
|
fixOrder();
|
|
|
|
}
|
2016-04-10 18:18:26 +00:00
|
|
|
_mediaPreview->showPreview(photo);
|
2016-02-17 16:37:21 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::ui_hideMediaPreview() {
|
2016-04-10 18:18:26 +00:00
|
|
|
if (!_mediaPreview) return;
|
|
|
|
_mediaPreview->hidePreview();
|
2016-02-17 16:37:21 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::showConnecting(const QString &text, const QString &reconnect) {
|
2014-05-30 08:53:19 +00:00
|
|
|
if (_connecting) {
|
|
|
|
_connecting->set(text, reconnect);
|
2017-09-07 13:39:12 +00:00
|
|
|
_connecting->show();
|
2014-05-30 08:53:19 +00:00
|
|
|
} else {
|
2016-11-04 11:14:47 +00:00
|
|
|
_connecting.create(bodyWidget(), text, reconnect);
|
2016-11-08 14:43:10 +00:00
|
|
|
_connecting->show();
|
2016-10-24 15:36:17 +00:00
|
|
|
updateControlsGeometry();
|
2014-08-01 18:49:43 +00:00
|
|
|
fixOrder();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::hideConnecting() {
|
2014-05-30 08:53:19 +00:00
|
|
|
if (_connecting) {
|
2017-09-07 13:39:12 +00:00
|
|
|
_connecting->hide();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-02 14:44:33 +00:00
|
|
|
void MainWindow::themeUpdated(const Window::Theme::BackgroundUpdate &data) {
|
|
|
|
using Type = Window::Theme::BackgroundUpdate::Type;
|
2017-02-03 20:07:26 +00:00
|
|
|
|
|
|
|
// We delay animating theme warning because we want all other
|
|
|
|
// subscribers to receive paltte changed notification before any
|
|
|
|
// animations (that include pixmap caches with old palette values).
|
2016-11-02 14:44:33 +00:00
|
|
|
if (data.type == Type::TestingTheme) {
|
|
|
|
if (!_testingThemeWarning) {
|
2016-11-04 11:14:47 +00:00
|
|
|
_testingThemeWarning.create(bodyWidget());
|
2017-02-03 20:07:26 +00:00
|
|
|
_testingThemeWarning->hide();
|
2016-11-02 14:44:33 +00:00
|
|
|
_testingThemeWarning->setGeometry(rect());
|
|
|
|
_testingThemeWarning->setHiddenCallback([this] { _testingThemeWarning.destroyDelayed(); });
|
|
|
|
}
|
2017-12-30 21:28:38 +00:00
|
|
|
crl::on_main(this, [=] {
|
2017-02-03 20:07:26 +00:00
|
|
|
if (_testingThemeWarning) {
|
|
|
|
_testingThemeWarning->showAnimated();
|
|
|
|
}
|
2017-12-30 21:28:38 +00:00
|
|
|
});
|
2016-11-02 14:44:33 +00:00
|
|
|
} else if (data.type == Type::RevertingTheme || data.type == Type::ApplyingTheme) {
|
2017-02-03 20:07:26 +00:00
|
|
|
if (_testingThemeWarning) {
|
|
|
|
if (_testingThemeWarning->isHidden()) {
|
|
|
|
_testingThemeWarning.destroy();
|
|
|
|
} else {
|
2017-12-30 21:28:38 +00:00
|
|
|
crl::on_main(this, [=] {
|
2017-02-03 20:07:26 +00:00
|
|
|
if (_testingThemeWarning) {
|
|
|
|
_testingThemeWarning->hideAnimated();
|
|
|
|
_testingThemeWarning = nullptr;
|
|
|
|
}
|
|
|
|
setInnerFocus();
|
2017-12-30 21:28:38 +00:00
|
|
|
});
|
2017-02-03 20:07:26 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-02 14:44:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-01 16:45:20 +00:00
|
|
|
bool MainWindow::doWeReadServerHistory() {
|
|
|
|
updateIsActive(0);
|
|
|
|
return isActive() && _main && !Ui::isLayerShown() && _main->doWeReadServerHistory();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2017-08-11 07:16:07 +00:00
|
|
|
bool MainWindow::doWeReadMentions() {
|
|
|
|
updateIsActive(0);
|
|
|
|
return isActive() && _main && !Ui::isLayerShown() && _main->doWeReadMentions();
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::checkHistoryActivation() {
|
2017-03-04 19:36:59 +00:00
|
|
|
if (_main && doWeReadServerHistory()) {
|
2016-11-04 08:23:50 +00:00
|
|
|
_main->markActiveHistoryAsRead();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
bool MainWindow::contentOverlapped(const QRect &globalRect) {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_main && _main->contentOverlapped(globalRect)) return true;
|
|
|
|
if (_layerBg && _layerBg->contentOverlapped(globalRect)) return true;
|
2015-10-01 14:05:05 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::setInnerFocus() {
|
2016-11-02 14:44:33 +00:00
|
|
|
if (_testingThemeWarning) {
|
|
|
|
_testingThemeWarning->setFocus();
|
2016-11-04 08:23:50 +00:00
|
|
|
} else if (_layerBg && _layerBg->canSetFocus()) {
|
|
|
|
_layerBg->setInnerFocus();
|
2015-09-16 13:04:08 +00:00
|
|
|
} else if (_passcode) {
|
2015-03-02 12:34:16 +00:00
|
|
|
_passcode->setInnerFocus();
|
2016-11-04 08:23:50 +00:00
|
|
|
} else if (_main) {
|
|
|
|
_main->setInnerFocus();
|
2016-11-24 19:28:23 +00:00
|
|
|
} else if (_intro) {
|
|
|
|
_intro->setInnerFocus();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-19 14:02:55 +00:00
|
|
|
bool MainWindow::eventFilter(QObject *object, QEvent *e) {
|
2016-02-28 09:48:09 +00:00
|
|
|
switch (e->type()) {
|
2017-08-08 09:31:48 +00:00
|
|
|
case QEvent::KeyPress: {
|
2017-05-30 13:54:05 +00:00
|
|
|
if (cDebug() && e->type() == QEvent::KeyPress && object == windowHandle()) {
|
|
|
|
auto key = static_cast<QKeyEvent*>(e)->key();
|
|
|
|
FeedLangTestingKey(key);
|
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case QEvent::MouseMove: {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_main && _main->isIdle()) {
|
2015-01-26 13:04:41 +00:00
|
|
|
psUserActionDone();
|
2016-11-04 08:23:50 +00:00
|
|
|
_main->checkIdleFinish();
|
2015-01-26 13:04:41 +00:00
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
} break;
|
2016-02-28 09:48:09 +00:00
|
|
|
|
2017-08-08 09:31:48 +00:00
|
|
|
case QEvent::MouseButtonRelease: {
|
2016-04-10 18:18:26 +00:00
|
|
|
Ui::hideMediaPreview();
|
2017-08-08 09:31:48 +00:00
|
|
|
} break;
|
2016-02-28 09:48:09 +00:00
|
|
|
|
2017-08-08 09:31:48 +00:00
|
|
|
case QEvent::ApplicationActivate: {
|
2017-05-19 14:02:55 +00:00
|
|
|
if (object == QCoreApplication::instance()) {
|
2017-08-08 09:31:48 +00:00
|
|
|
InvokeQueued(this, [this] {
|
2017-05-19 14:02:55 +00:00
|
|
|
handleActiveChanged();
|
|
|
|
});
|
2016-02-28 09:48:09 +00:00
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
} break;
|
2016-02-28 09:48:09 +00:00
|
|
|
|
2017-08-08 09:31:48 +00:00
|
|
|
case QEvent::WindowStateChange: {
|
2017-05-19 14:02:55 +00:00
|
|
|
if (object == this) {
|
|
|
|
auto state = (windowState() & Qt::WindowMinimized) ? Qt::WindowMinimized :
|
|
|
|
((windowState() & Qt::WindowMaximized) ? Qt::WindowMaximized :
|
|
|
|
((windowState() & Qt::WindowFullScreen) ? Qt::WindowFullScreen : Qt::WindowNoState));
|
|
|
|
handleStateChanged(state);
|
2016-02-28 09:48:09 +00:00
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
} break;
|
2016-02-28 09:48:09 +00:00
|
|
|
|
|
|
|
case QEvent::Move:
|
2017-08-08 09:31:48 +00:00
|
|
|
case QEvent::Resize: {
|
2017-05-19 14:02:55 +00:00
|
|
|
if (object == this) {
|
2016-11-04 11:14:47 +00:00
|
|
|
positionUpdated();
|
2014-06-20 07:06:21 +00:00
|
|
|
}
|
2017-08-08 09:31:48 +00:00
|
|
|
} break;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
2016-02-28 09:48:09 +00:00
|
|
|
|
2017-05-19 14:02:55 +00:00
|
|
|
return Platform::MainWindow::eventFilter(object, e);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::updateTrayMenu(bool force) {
|
2015-01-15 14:22:15 +00:00
|
|
|
if (!trayIconMenu || (cPlatform() == dbipWindows && !force)) return;
|
|
|
|
|
2016-10-19 12:24:39 +00:00
|
|
|
auto iconMenu = trayIconMenu;
|
|
|
|
auto actions = iconMenu->actions();
|
|
|
|
auto isLinux = (cPlatform() == dbipLinux32 || cPlatform() == dbipLinux64);
|
|
|
|
if (isLinux) {
|
|
|
|
auto minimizeAction = actions.at(1);
|
|
|
|
minimizeAction->setDisabled(!isVisible());
|
2015-10-23 16:45:23 +00:00
|
|
|
} else {
|
2017-01-01 16:45:20 +00:00
|
|
|
updateIsActive(0);
|
|
|
|
auto active = isActive();
|
2016-10-19 12:24:39 +00:00
|
|
|
auto toggleAction = actions.at(0);
|
|
|
|
disconnect(toggleAction, SIGNAL(triggered(bool)), this, SLOT(minimizeToTray()));
|
|
|
|
disconnect(toggleAction, SIGNAL(triggered(bool)), this, SLOT(showFromTray()));
|
|
|
|
connect(toggleAction, SIGNAL(triggered(bool)), this, active ? SLOT(minimizeToTray()) : SLOT(showFromTray()));
|
|
|
|
toggleAction->setText(lang(active ? lng_minimize_to_tray : lng_open_from_tray));
|
|
|
|
|
|
|
|
// On macOS just remove trayIcon menu if the window is not active.
|
|
|
|
// So we will activate the window on click instead of showing the menu.
|
|
|
|
if (!active && (cPlatform() == dbipMac || cPlatform() == dbipMacOld)) {
|
|
|
|
iconMenu = nullptr;
|
|
|
|
}
|
2015-10-23 16:45:23 +00:00
|
|
|
}
|
2016-10-19 12:24:39 +00:00
|
|
|
auto notificationAction = actions.at(isLinux ? 2 : 1);
|
|
|
|
auto notificationActionText = lang(Global::DesktopNotify()
|
|
|
|
? lng_disable_notifications_from_tray
|
|
|
|
: lng_enable_notifications_from_tray);
|
|
|
|
notificationAction->setText(notificationActionText);
|
|
|
|
|
2015-02-16 14:51:50 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2016-10-19 12:24:39 +00:00
|
|
|
if (trayIcon && trayIcon->contextMenu() != iconMenu) {
|
|
|
|
trayIcon->setContextMenu(iconMenu);
|
2015-02-16 14:51:50 +00:00
|
|
|
}
|
2016-10-19 12:24:39 +00:00
|
|
|
#endif // !Q_OS_WIN
|
2015-01-15 14:22:15 +00:00
|
|
|
|
|
|
|
psTrayMenuUpdated();
|
2014-09-26 23:48:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::onShowAddContact() {
|
2014-11-25 12:15:29 +00:00
|
|
|
if (isHidden()) showFromTray();
|
|
|
|
|
2016-11-04 11:14:47 +00:00
|
|
|
if (App::self()) {
|
2017-09-15 17:34:41 +00:00
|
|
|
Ui::show(Box<AddContactBox>(), LayerOption::KeepOther);
|
2016-11-04 11:14:47 +00:00
|
|
|
}
|
2014-11-25 12:15:29 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::onShowNewGroup() {
|
2014-11-18 12:40:43 +00:00
|
|
|
if (isHidden()) showFromTray();
|
|
|
|
|
2016-11-04 11:14:47 +00:00
|
|
|
if (App::self()) {
|
2017-09-15 17:34:41 +00:00
|
|
|
Ui::show(
|
|
|
|
Box<GroupInfoBox>(CreatingGroupGroup, false),
|
|
|
|
LayerOption::KeepOther);
|
2016-11-04 11:14:47 +00:00
|
|
|
}
|
2015-09-21 20:57:42 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::onShowNewChannel() {
|
2015-09-21 20:57:42 +00:00
|
|
|
if (isHidden()) showFromTray();
|
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
if (_main) {
|
|
|
|
Ui::show(
|
|
|
|
Box<GroupInfoBox>(CreatingGroupChannel, false),
|
|
|
|
LayerOption::KeepOther);
|
|
|
|
}
|
2014-11-18 12:40:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::onLogout() {
|
2014-11-18 12:40:43 +00:00
|
|
|
if (isHidden()) showFromTray();
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
Ui::show(Box<ConfirmBox>(lang(lng_sure_logout), lang(lng_settings_logout), st::attentionBoxButton, [] {
|
|
|
|
App::logOut();
|
|
|
|
}));
|
2014-11-18 12:40:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::quitFromTray() {
|
2014-05-30 08:53:19 +00:00
|
|
|
App::quit();
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::activate() {
|
2014-05-30 08:53:19 +00:00
|
|
|
bool wasHidden = !isVisible();
|
|
|
|
setWindowState(windowState() & ~Qt::WindowMinimized);
|
|
|
|
setVisible(true);
|
2014-09-26 23:48:19 +00:00
|
|
|
psActivateProcess();
|
2014-05-30 08:53:19 +00:00
|
|
|
activateWindow();
|
2016-02-18 16:36:33 +00:00
|
|
|
updateIsActive(Global::OnlineFocusTimeout());
|
2014-05-30 08:53:19 +00:00
|
|
|
if (wasHidden) {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_main) {
|
|
|
|
_main->windowShown();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
void MainWindow::noIntro(Intro::Widget *was) {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (was == _intro) {
|
|
|
|
_intro = nullptr;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
void MainWindow::noLayerStack(Window::LayerStackWidget *was) {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (was == _layerBg) {
|
|
|
|
_layerBg = nullptr;
|
2017-06-21 21:38:31 +00:00
|
|
|
if (controller()) {
|
2017-09-30 18:26:45 +00:00
|
|
|
controller()->disableGifPauseReason(
|
|
|
|
Window::GifPauseReason::Layer);
|
2017-04-07 18:10:49 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
void MainWindow::layerFinishedHide(Window::LayerStackWidget *was) {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (was == _layerBg) {
|
2017-09-19 19:15:13 +00:00
|
|
|
auto resetFocus = Ui::InFocusChain(was);
|
|
|
|
if (resetFocus) setFocus();
|
2017-07-13 16:13:10 +00:00
|
|
|
destroyLayerDelayed();
|
2017-09-19 19:15:13 +00:00
|
|
|
if (resetFocus) setInnerFocus();
|
|
|
|
InvokeQueued(this, [this] {
|
2017-07-13 16:13:10 +00:00
|
|
|
checkHistoryActivation();
|
|
|
|
});
|
2014-12-12 16:27:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-19 10:32:34 +00:00
|
|
|
bool MainWindow::takeThirdSectionFromLayer() {
|
|
|
|
return _layerBg ? _layerBg->takeToThirdSection() : false;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::fixOrder() {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_layerBg) _layerBg->raise();
|
2016-04-10 18:18:26 +00:00
|
|
|
if (_mediaPreview) _mediaPreview->raise();
|
2014-05-30 08:53:19 +00:00
|
|
|
if (_connecting) _connecting->raise();
|
2016-11-02 14:44:33 +00:00
|
|
|
if (_testingThemeWarning) _testingThemeWarning->raise();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::showFromTray(QSystemTrayIcon::ActivationReason reason) {
|
2014-05-30 08:53:19 +00:00
|
|
|
if (reason != QSystemTrayIcon::Context) {
|
2017-05-19 14:02:55 +00:00
|
|
|
App::CallDelayed(1, this, [this] {
|
2017-01-01 16:45:20 +00:00
|
|
|
updateTrayMenu();
|
|
|
|
updateGlobalMenu();
|
2017-05-19 14:02:55 +00:00
|
|
|
});
|
2014-06-14 19:32:11 +00:00
|
|
|
activate();
|
2016-04-14 19:24:42 +00:00
|
|
|
Notify::unreadCounterUpdated();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::toggleTray(QSystemTrayIcon::ActivationReason reason) {
|
2017-01-01 16:45:20 +00:00
|
|
|
updateIsActive(0);
|
|
|
|
if ((cPlatform() == dbipMac || cPlatform() == dbipMacOld) && isActive()) return;
|
2014-09-29 02:47:30 +00:00
|
|
|
if (reason == QSystemTrayIcon::Context) {
|
|
|
|
updateTrayMenu(true);
|
|
|
|
QTimer::singleShot(1, this, SLOT(psShowTrayMenu()));
|
|
|
|
} else {
|
2017-01-01 16:45:20 +00:00
|
|
|
if (isActive()) {
|
2014-05-30 08:53:19 +00:00
|
|
|
minimizeToTray();
|
|
|
|
} else {
|
|
|
|
showFromTray(reason);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::toggleDisplayNotifyFromTray() {
|
2015-10-17 18:30:55 +00:00
|
|
|
if (App::passcoded()) {
|
|
|
|
if (!isActive()) showFromTray();
|
2016-12-13 17:07:56 +00:00
|
|
|
Ui::show(Box<InformBox>(lang(lng_passcode_need_unblock)));
|
2015-10-17 18:30:55 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-03-23 12:30:16 +00:00
|
|
|
if (!AuthSession::Exists()) {
|
|
|
|
return;
|
|
|
|
}
|
2016-08-27 04:49:18 +00:00
|
|
|
|
|
|
|
bool soundNotifyChanged = false;
|
|
|
|
Global::SetDesktopNotify(!Global::DesktopNotify());
|
|
|
|
if (Global::DesktopNotify()) {
|
|
|
|
if (Global::RestoreSoundNotifyFromTray() && !Global::SoundNotify()) {
|
|
|
|
Global::SetSoundNotify(true);
|
|
|
|
Global::SetRestoreSoundNotifyFromTray(false);
|
|
|
|
soundNotifyChanged = true;
|
|
|
|
}
|
2015-10-12 21:48:14 +00:00
|
|
|
} else {
|
2016-08-27 04:49:18 +00:00
|
|
|
if (Global::SoundNotify()) {
|
|
|
|
Global::SetSoundNotify(false);
|
|
|
|
Global::SetRestoreSoundNotifyFromTray(true);
|
|
|
|
soundNotifyChanged = true;
|
|
|
|
} else {
|
|
|
|
Global::SetRestoreSoundNotifyFromTray(false);
|
2015-10-12 21:48:14 +00:00
|
|
|
}
|
2016-08-27 04:49:18 +00:00
|
|
|
}
|
|
|
|
Local::writeUserSettings();
|
2017-08-04 14:54:32 +00:00
|
|
|
Auth().notifications().settingsChanged().notify(Window::Notifications::ChangeType::DesktopEnabled);
|
2016-08-27 04:49:18 +00:00
|
|
|
if (soundNotifyChanged) {
|
2017-08-04 14:54:32 +00:00
|
|
|
Auth().notifications().settingsChanged().notify(Window::Notifications::ChangeType::SoundEnabled);
|
2015-02-04 06:14:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::closeEvent(QCloseEvent *e) {
|
2016-06-21 15:58:07 +00:00
|
|
|
if (Sandbox::isSavingSession()) {
|
|
|
|
e->accept();
|
2014-05-30 08:53:19 +00:00
|
|
|
App::quit();
|
2016-06-21 15:58:07 +00:00
|
|
|
} else {
|
|
|
|
e->ignore();
|
2017-08-08 09:56:10 +00:00
|
|
|
if (!AuthSession::Exists() || !hideNoQuit()) {
|
2016-06-21 15:58:07 +00:00
|
|
|
App::quit();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-24 15:36:17 +00:00
|
|
|
void MainWindow::updateControlsGeometry() {
|
2017-02-03 20:07:26 +00:00
|
|
|
Platform::MainWindow::updateControlsGeometry();
|
|
|
|
|
2016-11-04 11:14:47 +00:00
|
|
|
auto body = bodyWidget()->rect();
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_passcode) _passcode->setGeometry(body);
|
|
|
|
if (_main) _main->setGeometry(body);
|
|
|
|
if (_intro) _intro->setGeometry(body);
|
|
|
|
if (_layerBg) _layerBg->setGeometry(body);
|
|
|
|
if (_mediaPreview) _mediaPreview->setGeometry(body);
|
|
|
|
if (_connecting) _connecting->moveToLeft(0, body.height() - _connecting->height());
|
|
|
|
if (_testingThemeWarning) _testingThemeWarning->setGeometry(body);
|
2017-09-15 17:34:41 +00:00
|
|
|
|
2017-09-16 16:53:41 +00:00
|
|
|
if (_main) _main->checkMainSectionToLayer();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
MainWindow::TempDirState MainWindow::tempDirState() {
|
2014-11-22 09:45:04 +00:00
|
|
|
if (_clearManager && _clearManager->hasTask(Local::ClearManagerDownloads)) {
|
2014-05-30 08:53:19 +00:00
|
|
|
return TempDirRemoving;
|
|
|
|
}
|
|
|
|
return QDir(cTempDir()).exists() ? TempDirExists : TempDirEmpty;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
MainWindow::TempDirState MainWindow::localStorageState() {
|
2015-01-02 14:55:24 +00:00
|
|
|
if (_clearManager && _clearManager->hasTask(Local::ClearManagerStorage)) {
|
2014-11-22 09:45:04 +00:00
|
|
|
return TempDirRemoving;
|
|
|
|
}
|
2016-01-01 07:42:06 +00:00
|
|
|
return (Local::hasImages() || Local::hasStickers() || Local::hasWebFiles() || Local::hasAudios()) ? TempDirExists : TempDirEmpty;
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::tempDirDelete(int task) {
|
2014-11-22 09:45:04 +00:00
|
|
|
if (_clearManager) {
|
|
|
|
if (_clearManager->addTask(task)) {
|
|
|
|
return;
|
|
|
|
} else {
|
2016-08-28 19:16:23 +00:00
|
|
|
_clearManager->stop();
|
|
|
|
_clearManager = nullptr;
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_clearManager = new Local::ClearManager();
|
|
|
|
_clearManager->addTask(task);
|
|
|
|
connect(_clearManager, SIGNAL(succeed(int,void*)), this, SLOT(onClearFinished(int,void*)));
|
|
|
|
connect(_clearManager, SIGNAL(failed(int,void*)), this, SLOT(onClearFailed(int,void*)));
|
|
|
|
_clearManager->start();
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::onClearFinished(int task, void *manager) {
|
2014-11-22 09:45:04 +00:00
|
|
|
if (manager && manager == _clearManager) {
|
2016-08-28 19:16:23 +00:00
|
|
|
_clearManager->stop();
|
|
|
|
_clearManager = nullptr;
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
|
|
|
emit tempDirCleared(task);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::onClearFailed(int task, void *manager) {
|
2014-11-22 09:45:04 +00:00
|
|
|
if (manager && manager == _clearManager) {
|
2016-08-28 19:16:23 +00:00
|
|
|
_clearManager->stop();
|
|
|
|
_clearManager = nullptr;
|
2014-11-22 09:45:04 +00:00
|
|
|
}
|
|
|
|
emit tempDirClearFailed(task);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2016-12-23 13:21:01 +00:00
|
|
|
void MainWindow::placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) {
|
2014-09-26 23:48:19 +00:00
|
|
|
QPainter p(&img);
|
|
|
|
|
|
|
|
QString cnt = (count < 100) ? QString("%1").arg(count) : QString("..%1").arg(count % 10, 1, 10, QChar('0'));
|
|
|
|
int32 cntSize = cnt.size();
|
|
|
|
|
|
|
|
p.setBrush(bg->b);
|
|
|
|
p.setPen(Qt::NoPen);
|
|
|
|
p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
int32 fontSize;
|
|
|
|
if (size == 16) {
|
|
|
|
fontSize = 8;
|
|
|
|
} else if (size == 32) {
|
|
|
|
fontSize = (cntSize < 2) ? 12 : 12;
|
|
|
|
} else {
|
|
|
|
fontSize = (cntSize < 2) ? 22 : 22;
|
|
|
|
}
|
2016-04-21 17:57:29 +00:00
|
|
|
style::font f = { fontSize, 0, 0 };
|
2015-10-03 10:09:09 +00:00
|
|
|
int32 w = f->width(cnt), d, r;
|
2014-09-26 23:48:19 +00:00
|
|
|
if (size == 16) {
|
|
|
|
d = (cntSize < 2) ? 2 : 1;
|
|
|
|
r = (cntSize < 2) ? 4 : 3;
|
|
|
|
} else if (size == 32) {
|
|
|
|
d = (cntSize < 2) ? 5 : 2;
|
|
|
|
r = (cntSize < 2) ? 8 : 7;
|
|
|
|
} else {
|
|
|
|
d = (cntSize < 2) ? 9 : 4;
|
|
|
|
r = (cntSize < 2) ? 16 : 14;
|
|
|
|
}
|
|
|
|
p.drawRoundedRect(QRect(shift.x() + size - w - d * 2, shift.y() + size - f->height, w + d * 2, f->height), r, r);
|
|
|
|
p.setFont(f->f);
|
|
|
|
|
|
|
|
p.setPen(color->p);
|
|
|
|
|
|
|
|
p.drawText(shift.x() + size - w - d, shift.y() + size - f->height + f->ascent, cnt);
|
|
|
|
|
|
|
|
}
|
2014-09-20 21:31:03 +00:00
|
|
|
|
2016-12-23 13:21:01 +00:00
|
|
|
QImage MainWindow::iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) {
|
2014-09-20 21:31:03 +00:00
|
|
|
bool layer = false;
|
|
|
|
if (size < 0) {
|
|
|
|
size = -size;
|
|
|
|
layer = true;
|
|
|
|
}
|
|
|
|
if (layer) {
|
2014-12-15 15:55:45 +00:00
|
|
|
if (size != 16 && size != 20 && size != 24) size = 32;
|
2014-09-20 21:31:03 +00:00
|
|
|
|
|
|
|
QString cnt = (count < 1000) ? QString("%1").arg(count) : QString("..%1").arg(count % 100, 2, 10, QChar('0'));
|
|
|
|
QImage result(size, size, QImage::Format_ARGB32);
|
|
|
|
int32 cntSize = cnt.size();
|
2016-10-31 12:29:26 +00:00
|
|
|
result.fill(Qt::transparent);
|
2014-09-20 21:31:03 +00:00
|
|
|
{
|
|
|
|
QPainter p(&result);
|
2016-10-28 12:44:28 +00:00
|
|
|
p.setBrush(bg);
|
2014-09-20 21:31:03 +00:00
|
|
|
p.setPen(Qt::NoPen);
|
|
|
|
p.setRenderHint(QPainter::Antialiasing);
|
|
|
|
int32 fontSize;
|
2014-12-15 15:55:45 +00:00
|
|
|
if (size == 16) {
|
2014-09-20 21:31:03 +00:00
|
|
|
fontSize = (cntSize < 2) ? 11 : ((cntSize < 3) ? 11 : 8);
|
2014-12-15 15:55:45 +00:00
|
|
|
} else if (size == 20) {
|
|
|
|
fontSize = (cntSize < 2) ? 14 : ((cntSize < 3) ? 13 : 10);
|
|
|
|
} else if (size == 24) {
|
|
|
|
fontSize = (cntSize < 2) ? 17 : ((cntSize < 3) ? 16 : 12);
|
2014-09-20 21:31:03 +00:00
|
|
|
} else {
|
|
|
|
fontSize = (cntSize < 2) ? 22 : ((cntSize < 3) ? 20 : 16);
|
|
|
|
}
|
2016-04-21 17:57:29 +00:00
|
|
|
style::font f = { fontSize, 0, 0 };
|
2015-10-03 10:09:09 +00:00
|
|
|
int32 w = f->width(cnt), d, r;
|
2014-12-15 15:55:45 +00:00
|
|
|
if (size == 16) {
|
2014-09-20 21:31:03 +00:00
|
|
|
d = (cntSize < 2) ? 5 : ((cntSize < 3) ? 2 : 1);
|
|
|
|
r = (cntSize < 2) ? 8 : ((cntSize < 3) ? 7 : 3);
|
2014-12-15 15:55:45 +00:00
|
|
|
} else if (size == 20) {
|
|
|
|
d = (cntSize < 2) ? 6 : ((cntSize < 3) ? 2 : 1);
|
|
|
|
r = (cntSize < 2) ? 10 : ((cntSize < 3) ? 9 : 5);
|
|
|
|
} else if (size == 24) {
|
|
|
|
d = (cntSize < 2) ? 7 : ((cntSize < 3) ? 3 : 1);
|
|
|
|
r = (cntSize < 2) ? 12 : ((cntSize < 3) ? 11 : 6);
|
2014-09-20 21:31:03 +00:00
|
|
|
} else {
|
|
|
|
d = (cntSize < 2) ? 9 : ((cntSize < 3) ? 4 : 2);
|
|
|
|
r = (cntSize < 2) ? 16 : ((cntSize < 3) ? 14 : 8);
|
|
|
|
}
|
|
|
|
p.drawRoundedRect(QRect(size - w - d * 2, size - f->height, w + d * 2, f->height), r, r);
|
2016-10-28 12:44:28 +00:00
|
|
|
p.setFont(f);
|
2014-09-20 21:31:03 +00:00
|
|
|
|
2016-10-31 12:29:26 +00:00
|
|
|
p.setPen(fg);
|
2014-09-20 21:31:03 +00:00
|
|
|
|
|
|
|
p.drawText(size - w - d, size - f->height + f->ascent, cnt);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
} else {
|
|
|
|
if (size != 16 && size != 32) size = 64;
|
|
|
|
}
|
|
|
|
|
2014-11-25 20:33:11 +00:00
|
|
|
QImage img(smallIcon ? ((size == 16) ? iconbig16 : (size == 32 ? iconbig32 : iconbig64)) : ((size == 16) ? icon16 : (size == 32 ? icon32 : icon64)));
|
2014-09-20 21:31:03 +00:00
|
|
|
if (!count) return img;
|
|
|
|
|
|
|
|
if (smallIcon) {
|
2016-10-31 12:29:26 +00:00
|
|
|
placeSmallCounter(img, size, count, bg, QPoint(), fg);
|
2014-09-20 21:31:03 +00:00
|
|
|
} else {
|
|
|
|
QPainter p(&img);
|
2016-10-31 12:29:26 +00:00
|
|
|
p.drawPixmap(size / 2, size / 2, App::pixmapFromImageInPlace(iconWithCounter(-size / 2, count, bg, fg, false)));
|
2014-09-20 21:31:03 +00:00
|
|
|
}
|
|
|
|
return img;
|
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
void MainWindow::sendPaths() {
|
2015-03-02 12:34:16 +00:00
|
|
|
if (App::passcoded()) return;
|
2017-08-08 09:31:48 +00:00
|
|
|
Messenger::Instance().hideMediaView();
|
2017-09-20 10:23:57 +00:00
|
|
|
Ui::hideSettingsAndLayer(anim::type::instant);
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_main) {
|
|
|
|
_main->activate();
|
2014-07-18 10:37:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-01 16:45:20 +00:00
|
|
|
void MainWindow::updateIsActiveHook() {
|
2016-11-04 08:23:50 +00:00
|
|
|
if (_main) _main->updateOnline();
|
2015-01-26 13:04:41 +00:00
|
|
|
}
|
|
|
|
|
2016-04-12 21:31:28 +00:00
|
|
|
MainWindow::~MainWindow() {
|
2016-08-28 19:16:23 +00:00
|
|
|
if (_clearManager) {
|
|
|
|
_clearManager->stop();
|
|
|
|
_clearManager = nullptr;
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
delete trayIcon;
|
|
|
|
delete trayIconMenu;
|
|
|
|
}
|