| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | /*
 | 
					
						
							|  |  |  | This file is part of Telegram Desktop, | 
					
						
							| 
									
										
										
										
											2018-01-03 13:23:14 +03:00
										 |  |  | the official desktop application for the Telegram messaging service. | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-03 13:23:14 +03:00
										 |  |  | For license and copyright information please follow this link: | 
					
						
							|  |  |  | https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | */ | 
					
						
							| 
									
										
										
										
											2016-01-30 19:31:10 +03:00
										 |  |  | #pragma once
 | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-04 13:23:56 +03:00
										 |  |  | #include "platform/platform_specific.h"
 | 
					
						
							| 
									
										
										
										
											2016-06-16 15:59:54 +03:00
										 |  |  | #include "platform/platform_main_window.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-05 19:56:27 +03:00
										 |  |  | #include "core/single_timer.h"
 | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | class MainWidget; | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | class BoxContent; | 
					
						
							| 
									
										
										
										
											2016-10-02 12:30:28 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-24 22:28:23 +03:00
										 |  |  | namespace Intro { | 
					
						
							|  |  |  | class Widget; | 
					
						
							|  |  |  | } // namespace Intro
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-22 12:45:04 +03:00
										 |  |  | namespace Local { | 
					
						
							| 
									
										
										
										
											2016-08-16 19:53:10 +03:00
										 |  |  | class ClearManager; | 
					
						
							|  |  |  | } // namespace Local
 | 
					
						
							| 
									
										
										
										
											2016-10-02 12:30:28 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-02 17:44:33 +03:00
										 |  |  | namespace Window { | 
					
						
							| 
									
										
										
										
											2017-10-13 20:35:29 +03:00
										 |  |  | class LayerWidget; | 
					
						
							| 
									
										
										
										
											2017-09-30 21:26:45 +03:00
										 |  |  | class LayerStackWidget; | 
					
						
							| 
									
										
										
										
											2017-10-03 14:05:58 +01:00
										 |  |  | class SectionMemento; | 
					
						
							|  |  |  | struct SectionShow; | 
					
						
							| 
									
										
										
										
											2018-06-03 16:30:40 +03:00
										 |  |  | class PasscodeLockWidget; | 
					
						
							| 
									
										
										
										
											2016-11-02 17:44:33 +03:00
										 |  |  | namespace Theme { | 
					
						
							|  |  |  | struct BackgroundUpdate; | 
					
						
							|  |  |  | class WarningWidget; | 
					
						
							|  |  |  | } // namespace Theme
 | 
					
						
							|  |  |  | } // namespace Window
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-11 16:46:04 +03:00
										 |  |  | namespace Ui { | 
					
						
							|  |  |  | class LinkButton; | 
					
						
							|  |  |  | } // namespace Ui
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-10 22:18:26 +04:00
										 |  |  | class MediaPreviewWidget; | 
					
						
							| 
									
										
										
										
											2016-02-17 19:37:21 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-04 14:14:47 +03:00
										 |  |  | class MainWindow : public Platform::MainWindow { | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2016-06-16 15:59:54 +03:00
										 |  |  | 	MainWindow(); | 
					
						
							| 
									
										
										
										
											2016-04-13 00:31:28 +03:00
										 |  |  | 	~MainWindow(); | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-28 19:47:30 -07:00
										 |  |  | 	void firstShow(); | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 16:30:40 +03:00
										 |  |  | 	void setupPasscodeLock(); | 
					
						
							|  |  |  | 	void clearPasscodeLock(); | 
					
						
							| 
									
										
										
										
											2016-11-04 22:50:35 +03:00
										 |  |  | 	void setupIntro(); | 
					
						
							| 
									
										
										
										
											2018-09-11 15:50:40 +03:00
										 |  |  | 	void setupMain(); | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 20:34:41 +03:00
										 |  |  | 	MainWidget *chatsWidget() { | 
					
						
							|  |  |  | 		return mainWidget(); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 	MainWidget *mainWidget(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-01 20:45:20 +04:00
										 |  |  | 	bool doWeReadServerHistory(); | 
					
						
							| 
									
										
										
										
											2017-08-11 09:16:07 +02:00
										 |  |  | 	bool doWeReadMentions(); | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void activate(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-24 22:28:23 +03:00
										 |  |  | 	void noIntro(Intro::Widget *was); | 
					
						
							| 
									
										
										
										
											2018-04-06 20:23:09 +04:00
										 |  |  | 	void layerHidden(not_null<Window::LayerStackWidget*> layer); | 
					
						
							| 
									
										
										
										
											2017-09-19 13:32:34 +03:00
										 |  |  | 	bool takeThirdSectionFromLayer(); | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 15:24:39 +03:00
										 |  |  | 	void checkHistoryActivation(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 	void fixOrder(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum TempDirState { | 
					
						
							|  |  |  | 		TempDirRemoving, | 
					
						
							|  |  |  | 		TempDirExists, | 
					
						
							|  |  |  | 		TempDirEmpty, | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	TempDirState tempDirState(); | 
					
						
							| 
									
										
										
										
											2015-01-02 17:55:24 +03:00
										 |  |  | 	TempDirState localStorageState(); | 
					
						
							| 
									
										
										
										
											2014-11-22 12:45:04 +03:00
										 |  |  | 	void tempDirDelete(int task); | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-18 14:37:34 +04:00
										 |  |  | 	void sendPaths(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-23 16:21:01 +03:00
										 |  |  | 	QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) override; | 
					
						
							| 
									
										
										
										
											2016-04-29 16:46:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-01 17:05:05 +03: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 22:51:59 +03:00
										 |  |  | 	void showMainMenu(); | 
					
						
							| 
									
										
										
										
											2017-01-01 20:45:20 +04:00
										 |  |  | 	void updateTrayMenu(bool force = false) override; | 
					
						
							| 
									
										
										
										
											2016-11-11 22:51:59 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-15 20:34:41 +03:00
										 |  |  | 	void showSpecialLayer( | 
					
						
							| 
									
										
										
										
											2017-09-30 21:26:45 +03:00
										 |  |  | 		object_ptr<Window::LayerWidget> layer, | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | 		anim::type animated); | 
					
						
							| 
									
										
										
										
											2017-10-03 14:05:58 +01:00
										 |  |  | 	bool showSectionInExistingLayer( | 
					
						
							|  |  |  | 		not_null<Window::SectionMemento*> memento, | 
					
						
							|  |  |  | 		const Window::SectionShow ¶ms); | 
					
						
							| 
									
										
										
										
											2017-09-15 20:34:41 +03:00
										 |  |  | 	void ui_showBox( | 
					
						
							|  |  |  | 		object_ptr<BoxContent> box, | 
					
						
							| 
									
										
										
										
											2017-09-20 13:23:57 +03:00
										 |  |  | 		LayerOptions options, | 
					
						
							|  |  |  | 		anim::type animated); | 
					
						
							|  |  |  | 	void ui_hideSettingsAndLayer(anim::type animated); | 
					
						
							| 
									
										
										
										
											2018-09-06 17:58:43 +03:00
										 |  |  | 	void ui_removeLayerBlackout(); | 
					
						
							| 
									
										
										
										
											2015-12-22 11:01:02 +03:00
										 |  |  | 	bool ui_isLayerShown(); | 
					
						
							| 
									
										
										
										
											2018-07-14 00:25:47 +03:00
										 |  |  | 	void ui_showMediaPreview( | 
					
						
							|  |  |  | 		Data::FileOrigin origin, | 
					
						
							|  |  |  | 		not_null<DocumentData*> document); | 
					
						
							|  |  |  | 	void ui_showMediaPreview( | 
					
						
							|  |  |  | 		Data::FileOrigin origin, | 
					
						
							|  |  |  | 		not_null<PhotoData*> photo); | 
					
						
							| 
									
										
										
										
											2016-04-10 22:18:26 +04:00
										 |  |  | 	void ui_hideMediaPreview(); | 
					
						
							| 
									
										
										
										
											2015-12-22 11:01:02 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-04 11:23:50 +03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	bool eventFilter(QObject *o, QEvent *e) override; | 
					
						
							|  |  |  | 	void closeEvent(QCloseEvent *e) override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-07 18:24:28 +03:00
										 |  |  | 	void initHook() override; | 
					
						
							| 
									
										
										
										
											2017-01-01 20:45:20 +04:00
										 |  |  | 	void updateIsActiveHook() override; | 
					
						
							|  |  |  | 	void clearWidgetsHook() override; | 
					
						
							| 
									
										
										
										
											2016-11-07 18:24:28 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-03 23:07:26 +03:00
										 |  |  | 	void updateControlsGeometry() override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | public slots: | 
					
						
							|  |  |  | 	void showSettings(); | 
					
						
							| 
									
										
										
										
											2015-03-02 15:34:16 +03:00
										 |  |  | 	void setInnerFocus(); | 
					
						
							| 
									
										
										
										
											2014-09-26 16:48:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 	void quitFromTray(); | 
					
						
							|  |  |  | 	void showFromTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown); | 
					
						
							|  |  |  | 	void toggleTray(QSystemTrayIcon::ActivationReason reason = QSystemTrayIcon::Unknown); | 
					
						
							| 
									
										
										
										
											2015-02-04 08:14:20 +02:00
										 |  |  | 	void toggleDisplayNotifyFromTray(); | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-22 12:45:04 +03:00
										 |  |  | 	void onClearFinished(int task, void *manager); | 
					
						
							|  |  |  | 	void onClearFailed(int task, void *manager); | 
					
						
							| 
									
										
										
										
											2014-07-06 07:32:21 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-25 15:15:29 +03:00
										 |  |  | 	void onShowAddContact(); | 
					
						
							| 
									
										
										
										
											2014-11-18 15:40:43 +03:00
										 |  |  | 	void onShowNewGroup(); | 
					
						
							| 
									
										
										
										
											2015-09-21 23:57:42 +03:00
										 |  |  | 	void onShowNewChannel(); | 
					
						
							| 
									
										
										
										
											2014-11-18 15:40:43 +03:00
										 |  |  | 	void onLogout(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | signals: | 
					
						
							| 
									
										
										
										
											2014-11-22 12:45:04 +03:00
										 |  |  | 	void tempDirCleared(int task); | 
					
						
							|  |  |  | 	void tempDirClearFailed(int task); | 
					
						
							| 
									
										
										
										
											2016-12-13 10:59:57 +03:00
										 |  |  | 	void checkNewAuthorization(); | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2018-03-09 15:53:44 +03:00
										 |  |  | 	[[nodiscard]] bool skipTrayClick() const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-06 22:14:12 +03:00
										 |  |  | 	void ensureLayerCreated(); | 
					
						
							|  |  |  | 	void destroyLayerDelayed(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-02 17:44:33 +03:00
										 |  |  | 	void themeUpdated(const Window::Theme::BackgroundUpdate &data); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-10-17 16:52:26 +02:00
										 |  |  | 	QPixmap grabInner(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-23 16:21:01 +03:00
										 |  |  | 	void placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) override; | 
					
						
							| 
									
										
										
										
											2014-11-25 23:33:11 +03:00
										 |  |  | 	QImage icon16, icon32, icon64, iconbig16, iconbig32, iconbig64; | 
					
						
							| 
									
										
										
										
											2014-09-20 14:31:03 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-09 15:53:44 +03:00
										 |  |  | 	TimeMs _lastTrayClickTime = 0; | 
					
						
							| 
									
										
										
										
											2014-12-12 19:27:03 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-03 16:30:40 +03:00
										 |  |  | 	object_ptr<Window::PasscodeLockWidget> _passcodeLock = { nullptr }; | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 	object_ptr<Intro::Widget> _intro = { nullptr }; | 
					
						
							|  |  |  | 	object_ptr<MainWidget> _main = { nullptr }; | 
					
						
							| 
									
										
										
										
											2018-04-06 20:23:09 +04:00
										 |  |  | 	object_ptr<Window::LayerStackWidget> _layer = { nullptr }; | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 	object_ptr<MediaPreviewWidget> _mediaPreview = { nullptr }; | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-13 20:07:56 +03:00
										 |  |  | 	object_ptr<Window::Theme::WarningWidget> _testingThemeWarning = { nullptr }; | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-10 22:18:26 +04:00
										 |  |  | 	Local::ClearManager *_clearManager = nullptr; | 
					
						
							| 
									
										
										
										
											2014-05-30 12:53:19 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | }; |