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"
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2020-01-31 06:34:37 +00:00
|
|
|
#include "ui/widgets/popup_menu.h"
|
|
|
|
|
2020-08-08 12:07:13 +00:00
|
|
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
2020-01-31 06:34:37 +00:00
|
|
|
#include "statusnotifieritem.h"
|
|
|
|
#include <QtCore/QTemporaryFile>
|
2020-03-04 05:45:44 +00:00
|
|
|
#include <QtDBus/QDBusObjectPath>
|
|
|
|
#include <dbusmenuexporter.h>
|
2020-01-31 06:34:37 +00:00
|
|
|
#endif
|
2019-09-13 06:06:02 +00:00
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
namespace Platform {
|
|
|
|
|
|
|
|
class MainWindow : public Window::MainWindow {
|
|
|
|
public:
|
2019-06-06 11:20:21 +00:00
|
|
|
explicit MainWindow(not_null<Window::Controller*> controller);
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2020-01-31 06:34:37 +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
|
|
|
|
|
|
|
void psShowTrayMenu();
|
|
|
|
|
2020-08-28 16:14:19 +00:00
|
|
|
static void LibsLoaded();
|
2020-03-04 05:45:44 +00:00
|
|
|
|
2020-08-28 16:14:19 +00:00
|
|
|
~MainWindow();
|
2020-03-14 12:13:33 +00:00
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
protected:
|
2020-03-03 01:24:13 +00:00
|
|
|
void initHook() override;
|
2016-11-09 08:34:38 +00:00
|
|
|
void unreadCounterChangedHook() override;
|
2020-03-04 05:45:44 +00:00
|
|
|
void updateGlobalMenuHook() override;
|
2020-09-18 09:09:05 +00:00
|
|
|
void handleVisibleChangedHook(bool visible) override;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2020-02-12 08:09:17 +00:00
|
|
|
void initTrayMenuHook() override;
|
2017-01-01 16:45:20 +00:00
|
|
|
bool hasTrayIcon() const override;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2017-03-04 19:36:59 +00:00
|
|
|
void workmodeUpdated(DBIWorkMode mode) override;
|
2020-03-04 05:45:44 +00:00
|
|
|
void createGlobalMenu() override;
|
2017-03-04 19:36:59 +00:00
|
|
|
|
2016-06-16 17:20:58 +00:00
|
|
|
QSystemTrayIcon *trayIcon = nullptr;
|
|
|
|
QMenu *trayIconMenu = nullptr;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
|
|
|
void psTrayMenuUpdated();
|
|
|
|
void psSetupTrayIcon();
|
|
|
|
|
2020-01-31 06:34:37 +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
|
|
|
|
|
|
|
private:
|
2020-01-31 06:34:37 +00:00
|
|
|
Ui::PopupMenu *_trayIconMenuXEmbed = nullptr;
|
|
|
|
|
2016-11-11 07:51:53 +00:00
|
|
|
void updateIconCounters();
|
2020-04-25 04:43:19 +00:00
|
|
|
void updateWaylandDecorationColors();
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2020-08-08 12:07:13 +00:00
|
|
|
#ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
2020-01-31 06:34:37 +00:00
|
|
|
StatusNotifierItem *_sniTrayIcon = nullptr;
|
|
|
|
std::unique_ptr<QTemporaryFile> _trayIconFile = nullptr;
|
2016-06-16 12:59:54 +00:00
|
|
|
|
2020-03-04 05:45:44 +00:00
|
|
|
DBusMenuExporter *_mainMenuExporter = nullptr;
|
|
|
|
QDBusObjectPath _mainMenuPath;
|
|
|
|
|
|
|
|
QMenu *psMainMenu = nullptr;
|
|
|
|
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 *psBold = nullptr;
|
|
|
|
QAction *psItalic = nullptr;
|
|
|
|
QAction *psUnderline = nullptr;
|
|
|
|
QAction *psStrikeOut = nullptr;
|
|
|
|
QAction *psMonospace = nullptr;
|
|
|
|
QAction *psClearFormat = nullptr;
|
|
|
|
|
2020-03-17 19:13:11 +00:00
|
|
|
void setSNITrayIcon(int counter, bool muted);
|
2020-01-31 06:34:37 +00:00
|
|
|
void attachToSNITrayIcon();
|
2020-08-28 16:14:19 +00:00
|
|
|
|
|
|
|
void handleSNIOwnerChanged(
|
|
|
|
const QString &service,
|
|
|
|
const QString &oldOwner,
|
|
|
|
const QString &newOwner);
|
|
|
|
|
|
|
|
void handleAppMenuOwnerChanged(
|
|
|
|
const QString &service,
|
|
|
|
const QString &oldOwner,
|
|
|
|
const QString &newOwner);
|
|
|
|
|
|
|
|
void psLinuxUndo();
|
|
|
|
void psLinuxRedo();
|
|
|
|
void psLinuxCut();
|
|
|
|
void psLinuxCopy();
|
|
|
|
void psLinuxPaste();
|
|
|
|
void psLinuxDelete();
|
|
|
|
void psLinuxSelectAll();
|
|
|
|
|
|
|
|
void psLinuxBold();
|
|
|
|
void psLinuxItalic();
|
|
|
|
void psLinuxUnderline();
|
|
|
|
void psLinuxStrikeOut();
|
|
|
|
void psLinuxMonospace();
|
|
|
|
void psLinuxClearFormat();
|
2020-08-08 12:07:13 +00:00
|
|
|
#endif // !DESKTOP_APP_DISABLE_DBUS_INTEGRATION
|
2016-11-11 07:51:53 +00:00
|
|
|
|
2016-06-16 12:59:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Platform
|