2022-09-06 11:36:55 +08:00
|
|
|
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2018-08-16 10:05:16 +08:00
|
|
|
|
|
|
|
#ifndef SNITRAYWIDGET_H
|
|
|
|
#define SNITRAYWIDGET_H
|
|
|
|
|
2019-10-25 10:04:25 +08:00
|
|
|
#include "constants.h"
|
2018-08-16 10:05:16 +08:00
|
|
|
#include "abstracttraywidget.h"
|
2019-10-23 11:32:55 +08:00
|
|
|
#include "util/dockpopupwindow.h"
|
2018-08-16 10:05:16 +08:00
|
|
|
|
2019-02-18 14:58:48 +08:00
|
|
|
#include <org_kde_statusnotifieritem.h>
|
2018-08-16 10:05:16 +08:00
|
|
|
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QDBusObjectPath>
|
2019-10-23 11:32:55 +08:00
|
|
|
DWIDGET_USE_NAMESPACE
|
|
|
|
DGUI_USE_NAMESPACE
|
2020-03-13 12:59:02 +08:00
|
|
|
class DBusMenuImporter;
|
2020-06-29 15:35:51 +08:00
|
|
|
namespace Dock {
|
|
|
|
class TipsWidget;
|
|
|
|
}
|
2019-02-18 14:58:48 +08:00
|
|
|
//using namespace com::deepin::dde;
|
|
|
|
using namespace org::kde;
|
2018-08-16 10:05:16 +08:00
|
|
|
|
2021-05-14 17:43:58 +08:00
|
|
|
/**
|
|
|
|
* @brief The SNITrayWidget class
|
|
|
|
* @note 系统托盘第三方程序窗口
|
|
|
|
*/
|
2018-08-16 10:05:16 +08:00
|
|
|
class SNITrayWidget : public AbstractTrayWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2019-01-03 20:29:09 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
enum ItemCategory {UnknownCategory = -1, ApplicationStatus, Communications, SystemServices, Hardware};
|
|
|
|
enum ItemStatus {Passive, Active, NeedsAttention};
|
|
|
|
enum IconType {UnknownIconType = -1, Icon, OverlayIcon, AttentionIcon, AttentionMovieIcon};
|
|
|
|
|
2018-08-16 10:05:16 +08:00
|
|
|
public:
|
|
|
|
SNITrayWidget(const QString &sniServicePath, QWidget *parent = Q_NULLPTR);
|
|
|
|
|
2019-03-18 20:15:32 +08:00
|
|
|
QString itemKeyForConfig() override;
|
2020-06-13 19:19:30 +08:00
|
|
|
void updateIcon() override;
|
|
|
|
void sendClick(uint8_t mouseButton, int x, int y) override;
|
2018-08-16 10:05:16 +08:00
|
|
|
|
2020-06-13 19:19:30 +08:00
|
|
|
bool isValid() override;
|
2019-01-03 20:29:09 +08:00
|
|
|
SNITrayWidget::ItemStatus status();
|
|
|
|
SNITrayWidget::ItemCategory category();
|
2018-08-16 10:05:16 +08:00
|
|
|
|
2019-01-03 14:46:19 +08:00
|
|
|
static QString toSNIKey(const QString &sniServicePath);
|
|
|
|
static bool isSNIKey(const QString &itemKey);
|
|
|
|
static QPair<QString, QString> serviceAndPath(const QString &servicePath);
|
2021-11-29 15:46:12 +08:00
|
|
|
static uint servicePID(const QString &servicePath);
|
2018-08-16 10:05:16 +08:00
|
|
|
|
2019-10-23 11:32:55 +08:00
|
|
|
void showHoverTips();
|
|
|
|
const QPoint topleftPoint() const;
|
2020-06-29 15:35:51 +08:00
|
|
|
void showPopupWindow(QWidget *const content, const bool model = false);
|
2019-10-25 10:04:25 +08:00
|
|
|
const QPoint popupMarkPoint() const;
|
|
|
|
|
|
|
|
static void setDockPostion(const Dock::Position pos) { DockPosition = pos; }
|
|
|
|
|
2019-01-03 20:29:09 +08:00
|
|
|
Q_SIGNALS:
|
|
|
|
void statusChanged(SNITrayWidget::ItemStatus status);
|
2022-12-30 15:50:31 +08:00
|
|
|
void requestShowMenu(int x, int y);
|
2019-01-03 20:29:09 +08:00
|
|
|
|
2018-08-16 10:05:16 +08:00
|
|
|
private Q_SLOTS:
|
2019-02-18 14:58:48 +08:00
|
|
|
void initSNIPropertys();
|
2018-12-05 18:06:18 +08:00
|
|
|
void initMenu();
|
2018-08-16 10:05:16 +08:00
|
|
|
void refreshIcon();
|
|
|
|
void refreshOverlayIcon();
|
|
|
|
void refreshAttentionIcon();
|
2018-11-08 20:17:36 +08:00
|
|
|
void showContextMenu(int x, int y);
|
2019-02-18 14:58:48 +08:00
|
|
|
// SNI property change slot
|
2020-06-29 15:35:51 +08:00
|
|
|
void onSNIAttentionIconNameChanged(const QString &value);
|
2019-02-18 14:58:48 +08:00
|
|
|
void onSNIAttentionIconPixmapChanged(DBusImageList value);
|
2020-06-29 15:35:51 +08:00
|
|
|
void onSNIAttentionMovieNameChanged(const QString &value);
|
|
|
|
void onSNICategoryChanged(const QString &value);
|
|
|
|
void onSNIIconNameChanged(const QString &value);
|
2019-02-18 14:58:48 +08:00
|
|
|
void onSNIIconPixmapChanged(DBusImageList value);
|
2020-06-29 15:35:51 +08:00
|
|
|
void onSNIIconThemePathChanged(const QString &value);
|
|
|
|
void onSNIIdChanged(const QString &value);
|
|
|
|
void onSNIMenuChanged(const QDBusObjectPath &value);
|
|
|
|
void onSNIOverlayIconNameChanged(const QString &value);
|
2019-02-18 14:58:48 +08:00
|
|
|
void onSNIOverlayIconPixmapChanged(DBusImageList value);
|
2021-06-01 10:14:15 +08:00
|
|
|
void onSNIStatusChanged(const QString &status);
|
2019-10-23 11:32:55 +08:00
|
|
|
void hidePopup();
|
|
|
|
void hideNonModel();
|
|
|
|
void popupWindowAccept();
|
2021-11-19 16:12:49 +08:00
|
|
|
void enterEvent(QEvent *event) override;
|
|
|
|
void leaveEvent(QEvent *event) override;
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
2018-08-16 10:05:16 +08:00
|
|
|
|
|
|
|
private:
|
2020-06-13 19:19:30 +08:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
2018-08-16 10:05:16 +08:00
|
|
|
QPixmap newIconPixmap(IconType iconType);
|
2020-08-10 20:20:42 +08:00
|
|
|
void setMouseData(QMouseEvent *e);
|
|
|
|
void handleMouseRelease();
|
2018-08-16 10:05:16 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
StatusNotifierItem *m_sniInter;
|
|
|
|
|
|
|
|
DBusMenuImporter *m_dbusMenuImporter;
|
|
|
|
|
|
|
|
QMenu *m_menu;
|
2019-02-18 14:58:48 +08:00
|
|
|
QTimer *m_updateIconTimer;
|
|
|
|
QTimer *m_updateOverlayIconTimer;
|
|
|
|
QTimer *m_updateAttentionIconTimer;
|
2018-08-16 10:05:16 +08:00
|
|
|
|
2019-03-18 20:15:32 +08:00
|
|
|
QString m_sniServicePath;
|
2018-12-05 18:06:18 +08:00
|
|
|
QString m_dbusService;
|
|
|
|
QString m_dbusPath;
|
|
|
|
|
2018-08-16 10:05:16 +08:00
|
|
|
QPixmap m_pixmap;
|
|
|
|
QPixmap m_overlayPixmap;
|
2019-02-18 14:58:48 +08:00
|
|
|
|
|
|
|
// SNI propertys
|
|
|
|
QString m_sniAttentionIconName;
|
|
|
|
DBusImageList m_sniAttentionIconPixmap;
|
|
|
|
QString m_sniAttentionMovieName;
|
|
|
|
QString m_sniCategory;
|
|
|
|
QString m_sniIconName;
|
|
|
|
DBusImageList m_sniIconPixmap;
|
|
|
|
QString m_sniIconThemePath;
|
|
|
|
QString m_sniId;
|
|
|
|
QDBusObjectPath m_sniMenuPath;
|
|
|
|
QString m_sniOverlayIconName;
|
|
|
|
DBusImageList m_sniOverlayIconPixmap;
|
|
|
|
QString m_sniStatus;
|
2020-08-10 19:45:23 +08:00
|
|
|
QTimer *m_popupTipsDelayTimer;
|
2020-08-10 20:20:42 +08:00
|
|
|
QTimer *m_handleMouseReleaseTimer;
|
|
|
|
QPair<QPoint, Qt::MouseButton> m_lastMouseReleaseData;
|
2019-10-25 10:04:25 +08:00
|
|
|
static Dock::Position DockPosition;
|
2019-10-23 11:32:55 +08:00
|
|
|
static QPointer<DockPopupWindow> PopupWindow;
|
2020-06-29 15:35:51 +08:00
|
|
|
Dock::TipsWidget *m_tipsLabel;
|
2019-10-23 11:32:55 +08:00
|
|
|
bool m_popupShown;
|
2018-08-16 10:05:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SNIWIDGET_H */
|