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-01-30 16:31:10 +00:00
|
|
|
#pragma once
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-03-04 10:23:56 +00:00
|
|
|
#include "platform/platform_specific.h"
|
2016-06-16 12:59:54 +00:00
|
|
|
#include "platform/platform_main_window.h"
|
2018-11-23 11:05:06 +00:00
|
|
|
#include "base/unique_qptr.h"
|
2019-09-18 11:19:05 +00:00
|
|
|
#include "ui/layers/layer_widget.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
#include "ui/effects/animation_value.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
class MainWidget;
|
2016-10-02 09:30:28 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
namespace Intro {
|
|
|
|
class Widget;
|
|
|
|
} // namespace Intro
|
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
namespace Local {
|
2016-08-16 16:53:10 +00:00
|
|
|
class ClearManager;
|
|
|
|
} // namespace Local
|
2016-10-02 09:30:28 +00:00
|
|
|
|
2016-11-02 14:44:33 +00:00
|
|
|
namespace Window {
|
2019-09-13 06:06:02 +00:00
|
|
|
class MediaPreviewWidget;
|
2017-10-03 13:05:58 +00:00
|
|
|
class SectionMemento;
|
|
|
|
struct SectionShow;
|
2018-06-03 13:30:40 +00:00
|
|
|
class PasscodeLockWidget;
|
2016-11-02 14:44:33 +00:00
|
|
|
namespace Theme {
|
|
|
|
struct BackgroundUpdate;
|
|
|
|
class WarningWidget;
|
|
|
|
} // namespace Theme
|
|
|
|
} // namespace Window
|
|
|
|
|
2016-11-11 13:46:04 +00:00
|
|
|
namespace Ui {
|
|
|
|
class LinkButton;
|
2019-09-18 11:19:05 +00:00
|
|
|
class BoxContent;
|
|
|
|
class LayerStackWidget;
|
2016-11-11 13:46:04 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
class MediaPreviewWidget;
|
2016-02-17 16:37:21 +00:00
|
|
|
|
2016-11-04 11:14:47 +00:00
|
|
|
class MainWindow : public Platform::MainWindow {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-06-06 11:20:21 +00:00
|
|
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
2016-04-12 21:31:28 +00:00
|
|
|
~MainWindow();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-09-29 02:47:30 +00:00
|
|
|
void firstShow();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-06-03 13:30:40 +00:00
|
|
|
void setupPasscodeLock();
|
|
|
|
void clearPasscodeLock();
|
2016-11-04 19:50:35 +00:00
|
|
|
void setupIntro();
|
2018-09-11 12:50:40 +00:00
|
|
|
void setupMain();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
MainWidget *chatsWidget() {
|
|
|
|
return mainWidget();
|
|
|
|
}
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
MainWidget *mainWidget();
|
|
|
|
|
2017-01-01 16:45:20 +00:00
|
|
|
bool doWeReadServerHistory();
|
2017-08-11 07:16:07 +00:00
|
|
|
bool doWeReadMentions();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void activate();
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
void noIntro(Intro::Widget *was);
|
2017-09-19 10:32:34 +00:00
|
|
|
bool takeThirdSectionFromLayer();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-10-19 12:24:39 +00:00
|
|
|
void checkHistoryActivation();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void fixOrder();
|
|
|
|
|
|
|
|
enum TempDirState {
|
|
|
|
TempDirRemoving,
|
|
|
|
TempDirExists,
|
|
|
|
TempDirEmpty,
|
|
|
|
};
|
|
|
|
TempDirState tempDirState();
|
2015-01-02 14:55:24 +00:00
|
|
|
TempDirState localStorageState();
|
2014-11-22 09:45:04 +00:00
|
|
|
void tempDirDelete(int task);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-07-18 10:37:34 +00:00
|
|
|
void sendPaths();
|
|
|
|
|
2016-12-23 13:21:01 +00:00
|
|
|
QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) override;
|
2016-04-29 13:46:16 +00:00
|
|
|
|
2015-10-01 14:05:05 +00:00
|
|
|
bool contentOverlapped(const QRect &globalRect);
|
|
|
|
bool contentOverlapped(QWidget *w, QPaintEvent *e) {
|
|
|
|
return contentOverlapped(QRect(w->mapToGlobal(e->rect().topLeft()), e->rect().size()));
|
|
|
|
}
|
|
|
|
bool contentOverlapped(QWidget *w, const QRegion &r) {
|
|
|
|
return contentOverlapped(QRect(w->mapToGlobal(r.boundingRect().topLeft()), r.boundingRect().size()));
|
|
|
|
}
|
|
|
|
|
2016-11-11 19:51:59 +00:00
|
|
|
void showMainMenu();
|
2017-01-01 16:45:20 +00:00
|
|
|
void updateTrayMenu(bool force = false) override;
|
2016-11-11 19:51:59 +00:00
|
|
|
|
2017-09-15 17:34:41 +00:00
|
|
|
void showSpecialLayer(
|
2019-09-18 11:19:05 +00:00
|
|
|
object_ptr<Ui::LayerWidget> layer,
|
2017-09-20 10:23:57 +00:00
|
|
|
anim::type animated);
|
2017-10-03 13:05:58 +00:00
|
|
|
bool showSectionInExistingLayer(
|
|
|
|
not_null<Window::SectionMemento*> memento,
|
|
|
|
const Window::SectionShow ¶ms);
|
2017-09-15 17:34:41 +00:00
|
|
|
void ui_showBox(
|
2019-09-18 11:19:05 +00:00
|
|
|
object_ptr<Ui::BoxContent> box,
|
|
|
|
Ui::LayerOptions options,
|
2017-09-20 10:23:57 +00:00
|
|
|
anim::type animated);
|
|
|
|
void ui_hideSettingsAndLayer(anim::type animated);
|
2018-09-06 14:58:43 +00:00
|
|
|
void ui_removeLayerBlackout();
|
2015-12-22 08:01:02 +00:00
|
|
|
bool ui_isLayerShown();
|
2019-06-29 10:29:04 +00:00
|
|
|
void showMediaPreview(
|
2018-07-13 21:25:47 +00:00
|
|
|
Data::FileOrigin origin,
|
|
|
|
not_null<DocumentData*> document);
|
2019-06-29 10:29:04 +00:00
|
|
|
void showMediaPreview(
|
2018-07-13 21:25:47 +00:00
|
|
|
Data::FileOrigin origin,
|
|
|
|
not_null<PhotoData*> photo);
|
2019-06-29 10:29:04 +00:00
|
|
|
void hideMediaPreview();
|
2015-12-22 08:01:02 +00:00
|
|
|
|
2016-11-04 08:23:50 +00:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *o, QEvent *e) override;
|
|
|
|
void closeEvent(QCloseEvent *e) override;
|
|
|
|
|
2016-11-07 15:24:28 +00:00
|
|
|
void initHook() override;
|
2017-01-01 16:45:20 +00:00
|
|
|
void updateIsActiveHook() override;
|
|
|
|
void clearWidgetsHook() override;
|
2016-11-07 15:24:28 +00:00
|
|
|
|
2017-02-03 20:07:26 +00:00
|
|
|
void updateControlsGeometry() override;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
public slots:
|
|
|
|
void showSettings();
|
2015-03-02 12:34:16 +00:00
|
|
|
void setInnerFocus();
|
2014-09-26 23:48:19 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void quitFromTray();
|
|
|
|
void showFromTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown);
|
2015-02-04 06:14:20 +00:00
|
|
|
void toggleDisplayNotifyFromTray();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-11-22 09:45:04 +00:00
|
|
|
void onClearFinished(int task, void *manager);
|
|
|
|
void onClearFailed(int task, void *manager);
|
2014-07-06 03:32:21 +00:00
|
|
|
|
2014-11-25 12:15:29 +00:00
|
|
|
void onShowAddContact();
|
2014-11-18 12:40:43 +00:00
|
|
|
void onShowNewGroup();
|
2015-09-21 20:57:42 +00:00
|
|
|
void onShowNewChannel();
|
2014-11-18 12:40:43 +00:00
|
|
|
void onLogout();
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
signals:
|
2014-11-22 09:45:04 +00:00
|
|
|
void tempDirCleared(int task);
|
|
|
|
void tempDirClearFailed(int task);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
private:
|
2018-03-09 12:53:44 +00:00
|
|
|
[[nodiscard]] bool skipTrayClick() const;
|
|
|
|
|
2019-04-12 13:21:01 +00:00
|
|
|
void handleTrayIconActication(
|
|
|
|
QSystemTrayIcon::ActivationReason reason) override;
|
|
|
|
|
2017-04-06 19:14:12 +00:00
|
|
|
void ensureLayerCreated();
|
2018-11-23 11:05:06 +00:00
|
|
|
void destroyLayer();
|
2017-04-06 19:14:12 +00:00
|
|
|
|
2016-11-02 14:44:33 +00:00
|
|
|
void themeUpdated(const Window::Theme::BackgroundUpdate &data);
|
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
QPixmap grabInner();
|
|
|
|
|
2016-12-23 13:21:01 +00:00
|
|
|
void placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) override;
|
2014-11-25 20:33:11 +00:00
|
|
|
QImage icon16, icon32, icon64, iconbig16, iconbig32, iconbig64;
|
2014-09-20 21:31:03 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time _lastTrayClickTime = 0;
|
2014-12-12 16:27:03 +00:00
|
|
|
|
2018-06-03 13:30:40 +00:00
|
|
|
object_ptr<Window::PasscodeLockWidget> _passcodeLock = { nullptr };
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Intro::Widget> _intro = { nullptr };
|
|
|
|
object_ptr<MainWidget> _main = { nullptr };
|
2019-09-18 11:19:05 +00:00
|
|
|
base::unique_qptr<Ui::LayerStackWidget> _layer;
|
2019-09-13 06:06:02 +00:00
|
|
|
object_ptr<Window::MediaPreviewWidget> _mediaPreview = { nullptr };
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Window::Theme::WarningWidget> _testingThemeWarning = { nullptr };
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-04-10 18:18:26 +00:00
|
|
|
Local::ClearManager *_clearManager = nullptr;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
2019-09-13 06:06:02 +00:00
|
|
|
|
|
|
|
namespace App {
|
|
|
|
MainWindow *wnd();
|
|
|
|
} // namespace App
|