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-08-31 16:28:58 +00:00
|
|
|
#include "base/flags.h"
|
2016-06-16 12:59:54 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2016-10-26 16:43:13 +00:00
|
|
|
namespace Ui {
|
2016-10-01 13:15:27 +00:00
|
|
|
class PopupMenu;
|
2016-10-26 16:43:13 +00:00
|
|
|
} // namespace Ui
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
namespace Platform {
|
|
|
|
|
|
|
|
class MainWindow : public Window::MainWindow {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
MainWindow();
|
|
|
|
|
|
|
|
HWND psHwnd() const;
|
|
|
|
HMENU psMenu() const;
|
|
|
|
|
|
|
|
void psFirstShow();
|
|
|
|
void psInitSysMenu();
|
2017-05-19 14:02:55 +00:00
|
|
|
void updateSystemMenu(Qt::WindowState state);
|
2016-06-16 12:59:54 +00:00
|
|
|
void psUpdateMargins();
|
|
|
|
|
|
|
|
void psRefreshTaskbarIcon();
|
|
|
|
|
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
|
|
|
|
|
|
|
static UINT TaskbarCreatedMsgId() {
|
|
|
|
return _taskbarCreatedMsgId;
|
|
|
|
}
|
|
|
|
static void TaskbarCreated();
|
|
|
|
|
|
|
|
// Custom shadows.
|
|
|
|
enum class ShadowsChange {
|
2017-09-03 18:36:06 +00:00
|
|
|
Moved = (1 << 0),
|
|
|
|
Resized = (1 << 1),
|
|
|
|
Shown = (1 << 2),
|
|
|
|
Hidden = (1 << 3),
|
|
|
|
Activate = (1 << 4),
|
2016-06-16 12:59:54 +00:00
|
|
|
};
|
2017-08-31 16:28:58 +00:00
|
|
|
using ShadowsChanges = base::flags<ShadowsChange>;
|
|
|
|
friend inline constexpr auto is_flag_type(ShadowsChange) { return true; };
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
bool shadowsWorking() const {
|
|
|
|
return _shadowsWorking;
|
|
|
|
}
|
|
|
|
void shadowsActivate();
|
|
|
|
void shadowsDeactivate();
|
|
|
|
void shadowsUpdate(ShadowsChanges changes, WINDOWPOS *position = nullptr);
|
|
|
|
|
|
|
|
int deltaLeft() const {
|
|
|
|
return _deltaLeft;
|
|
|
|
}
|
|
|
|
int deltaTop() const {
|
|
|
|
return _deltaTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
~MainWindow();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void psShowTrayMenu();
|
|
|
|
|
|
|
|
protected:
|
2016-11-04 11:14:47 +00:00
|
|
|
void initHook() override;
|
|
|
|
int32 screenNameChecksum(const QString &name) const override;
|
2016-11-09 08:34:38 +00:00
|
|
|
void unreadCounterChangedHook() override;
|
2016-11-04 11:14:47 +00:00
|
|
|
|
2017-05-19 14:02:55 +00:00
|
|
|
void stateChangedHook(Qt::WindowState state) override;
|
|
|
|
|
2017-01-01 16:45:20 +00:00
|
|
|
bool hasTrayIcon() const override {
|
2016-06-16 12:59:54 +00:00
|
|
|
return trayIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
QSystemTrayIcon *trayIcon = nullptr;
|
2016-10-26 16:43:13 +00:00
|
|
|
Ui::PopupMenu *trayIconMenu = nullptr;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2017-01-01 16:45:20 +00:00
|
|
|
void showTrayTooltip() override;
|
|
|
|
|
2017-03-04 19:36:59 +00:00
|
|
|
void workmodeUpdated(DBIWorkMode mode) override;
|
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
QTimer psUpdatedPositionTimer;
|
|
|
|
|
|
|
|
private:
|
2016-11-09 08:34:38 +00:00
|
|
|
void updateIconCounters();
|
2016-12-23 13:21:01 +00:00
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
void psDestroyIcons();
|
|
|
|
|
|
|
|
static UINT _taskbarCreatedMsgId;
|
|
|
|
|
|
|
|
bool _shadowsWorking = false;
|
|
|
|
bool _themeInited = false;
|
2018-03-30 15:36:31 +00:00
|
|
|
bool _inUpdateMargins = false;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
HWND ps_hWnd = nullptr;
|
|
|
|
HWND ps_tbHider_hWnd = nullptr;
|
|
|
|
HMENU ps_menu = nullptr;
|
|
|
|
HICON ps_iconBig = nullptr;
|
|
|
|
HICON ps_iconSmall = nullptr;
|
|
|
|
HICON ps_iconOverlay = nullptr;
|
|
|
|
|
|
|
|
int _deltaLeft = 0;
|
|
|
|
int _deltaTop = 0;
|
2018-03-30 15:36:31 +00:00
|
|
|
int _deltaRight = 0;
|
|
|
|
int _deltaBottom = 0;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Platform
|