2016-06-16 12:59:54 +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.
|
2016-06-16 12:59:54 +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
|
2016-06-16 12:59:54 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-02-28 10:51:00 +00:00
|
|
|
#include "platform/platform_main_window.h"
|
2017-03-04 10:23:56 +00:00
|
|
|
#include "platform/mac/specific_mac_p.h"
|
2017-04-12 11:58:37 +00:00
|
|
|
#include "base/timer.h"
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2019-09-08 20:04:21 +00:00
|
|
|
#include <QtWidgets/QMenuBar>
|
2019-09-13 06:06:02 +00:00
|
|
|
#include <QtCore/QTimer>
|
2019-09-08 20:04:21 +00:00
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
namespace Platform {
|
|
|
|
|
|
|
|
class MainWindow : public Window::MainWindow {
|
2019-01-18 11:26:43 +00:00
|
|
|
// The Q_OBJECT meta info is used for qobject_cast!
|
2016-06-16 12:59:54 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-06-06 11:20:21 +00:00
|
|
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
bool psFilterNativeEvent(void *event);
|
|
|
|
|
2016-12-23 13:21:01 +00:00
|
|
|
virtual QImage iconWithCounter(int size, int count, style::color bg, style::color fg, bool smallIcon) = 0;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2016-11-08 14:07:25 +00:00
|
|
|
int getCustomTitleHeight() const {
|
|
|
|
return _customTitleHeight;
|
|
|
|
}
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
~MainWindow();
|
|
|
|
|
2019-06-06 11:20:21 +00:00
|
|
|
void updateWindowIcon() override;
|
2016-11-08 14:07:25 +00:00
|
|
|
|
2020-08-28 16:14:19 +00:00
|
|
|
void psShowTrayMenu();
|
|
|
|
|
2019-06-06 12:01:01 +00:00
|
|
|
class Private;
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
public slots:
|
|
|
|
void psMacUndo();
|
|
|
|
void psMacRedo();
|
|
|
|
void psMacCut();
|
|
|
|
void psMacCopy();
|
|
|
|
void psMacPaste();
|
|
|
|
void psMacDelete();
|
|
|
|
void psMacSelectAll();
|
2019-11-26 21:07:03 +00:00
|
|
|
void psMacEmojiAndSymbols();
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2019-08-20 11:29:21 +00:00
|
|
|
void psMacBold();
|
|
|
|
void psMacItalic();
|
|
|
|
void psMacUnderline();
|
|
|
|
void psMacStrikeOut();
|
|
|
|
void psMacMonospace();
|
|
|
|
void psMacClearFormat();
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
protected:
|
2016-11-09 08:34:38 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *evt) override;
|
|
|
|
|
2017-11-15 12:46:34 +00:00
|
|
|
void handleActiveChangedHook() override;
|
2016-06-16 15:17:39 +00:00
|
|
|
void stateChangedHook(Qt::WindowState state) override;
|
2016-11-08 14:07:25 +00:00
|
|
|
void initHook() override;
|
2016-11-09 08:34:38 +00:00
|
|
|
void titleVisibilityChangedHook() override;
|
|
|
|
void unreadCounterChangedHook() override;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
QImage psTrayIcon(bool selected = false) const;
|
2017-01-01 16:45:20 +00:00
|
|
|
bool hasTrayIcon() const override {
|
2016-06-16 12:59:54 +00:00
|
|
|
return trayIcon;
|
|
|
|
}
|
|
|
|
|
2017-01-01 16:45:20 +00:00
|
|
|
void updateGlobalMenuHook() override;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2017-03-04 19:36:59 +00:00
|
|
|
void workmodeUpdated(DBIWorkMode mode) override;
|
|
|
|
|
2016-06-16 15:17:39 +00:00
|
|
|
QSystemTrayIcon *trayIcon = nullptr;
|
|
|
|
QMenu *trayIconMenu = nullptr;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
QImage trayImg, trayImgSel;
|
|
|
|
|
|
|
|
void psTrayMenuUpdated();
|
|
|
|
void psSetupTrayIcon();
|
2016-12-23 13:21:01 +00:00
|
|
|
virtual void placeSmallCounter(QImage &img, int size, int count, style::color bg, const QPoint &shift, style::color color) = 0;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
QTimer psUpdatedPositionTimer;
|
|
|
|
|
2020-02-12 08:09:17 +00:00
|
|
|
void initShadows() override;
|
2016-12-31 15:19:22 +00:00
|
|
|
void closeWithoutDestroy() override;
|
2020-02-12 08:09:17 +00:00
|
|
|
void createGlobalMenu() override;
|
2016-12-31 15:19:22 +00:00
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
private:
|
2019-06-06 11:20:21 +00:00
|
|
|
friend class Private;
|
|
|
|
|
2017-02-20 10:36:25 +00:00
|
|
|
void hideAndDeactivate();
|
2016-11-09 08:34:38 +00:00
|
|
|
void updateTitleCounter();
|
|
|
|
void updateIconCounters();
|
2016-11-04 11:14:47 +00:00
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<Private> _private;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
mutable bool psIdle;
|
|
|
|
mutable QTimer psIdleTimer;
|
|
|
|
|
2017-04-12 11:58:37 +00:00
|
|
|
base::Timer _hideAfterFullScreenTimer;
|
2016-06-16 15:17:39 +00:00
|
|
|
|
2020-07-09 21:12:06 +00:00
|
|
|
rpl::variable<bool> _canApplyMarkdown;
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
QMenuBar psMainMenu;
|
2016-06-16 15:17:39 +00:00
|
|
|
QAction *psLogout = nullptr;
|
|
|
|
QAction *psUndo = nullptr;
|
|
|
|
QAction *psRedo = nullptr;
|
|
|
|
QAction *psCut = nullptr;
|
|
|
|
QAction *psCopy = nullptr;
|
|
|
|
QAction *psPaste = nullptr;
|
|
|
|
QAction *psDelete = nullptr;
|
|
|
|
QAction *psSelectAll = nullptr;
|
|
|
|
QAction *psContacts = nullptr;
|
|
|
|
QAction *psAddContact = nullptr;
|
|
|
|
QAction *psNewGroup = nullptr;
|
|
|
|
QAction *psNewChannel = nullptr;
|
|
|
|
QAction *psShowTelegram = nullptr;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2019-08-11 16:27:59 +00:00
|
|
|
QAction *psBold = nullptr;
|
|
|
|
QAction *psItalic = nullptr;
|
|
|
|
QAction *psUnderline = nullptr;
|
|
|
|
QAction *psStrikeOut = nullptr;
|
|
|
|
QAction *psMonospace = nullptr;
|
|
|
|
QAction *psClearFormat = nullptr;
|
|
|
|
|
2016-11-08 14:07:25 +00:00
|
|
|
int _customTitleHeight = 0;
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Platform
|