2023-02-16 13:51:55 +08:00
|
|
|
// Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
|
|
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
2022-09-06 11:36:55 +08:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2017-09-18 14:33:44 +08:00
|
|
|
|
2018-11-13 20:07:52 +08:00
|
|
|
#ifndef TRAYPLUGIN_H
|
|
|
|
#define TRAYPLUGIN_H
|
2016-06-28 14:23:30 +08:00
|
|
|
|
|
|
|
#include "pluginsiteminterface.h"
|
|
|
|
#include "dbus/dbustraymanager.h"
|
2019-01-15 18:03:43 +08:00
|
|
|
#include "xembedtraywidget.h"
|
2018-07-24 19:55:39 +08:00
|
|
|
#include "indicatortray.h"
|
2017-12-28 19:23:50 +08:00
|
|
|
#include "indicatortraywidget.h"
|
2019-01-03 20:29:09 +08:00
|
|
|
#include "snitraywidget.h"
|
2018-11-13 20:07:52 +08:00
|
|
|
#include "system-trays/systemtrayscontroller.h"
|
2018-11-29 10:24:58 +08:00
|
|
|
#include "dbus/sni/statusnotifierwatcher_interface.h"
|
2017-12-28 19:23:50 +08:00
|
|
|
|
2016-08-15 14:11:19 +08:00
|
|
|
#include <QSettings>
|
2016-09-20 14:34:38 +08:00
|
|
|
#include <QLabel>
|
2021-11-05 21:25:06 +08:00
|
|
|
|
2020-09-09 13:07:05 +08:00
|
|
|
#include <mutex>
|
2021-11-05 21:25:06 +08:00
|
|
|
#include <xcb/xcb.h>
|
2016-08-15 14:11:19 +08:00
|
|
|
|
2016-06-29 11:02:08 +08:00
|
|
|
class FashionTrayItem;
|
2020-06-29 15:35:51 +08:00
|
|
|
namespace Dock {
|
2018-07-04 16:17:01 +08:00
|
|
|
class TipsWidget;
|
2020-06-29 15:35:51 +08:00
|
|
|
}
|
2021-11-05 21:25:06 +08:00
|
|
|
|
|
|
|
typedef struct _XDisplay Display;
|
|
|
|
|
2018-11-13 20:07:52 +08:00
|
|
|
class TrayPlugin : public QObject, PluginsItemInterface
|
2016-06-28 14:23:30 +08:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_INTERFACES(PluginsItemInterface)
|
2018-11-13 20:07:52 +08:00
|
|
|
Q_PLUGIN_METADATA(IID "com.deepin.dock.PluginsItemInterface" FILE "tray.json")
|
2016-06-28 14:23:30 +08:00
|
|
|
|
|
|
|
public:
|
2021-05-31 17:37:21 +08:00
|
|
|
explicit TrayPlugin(QObject *parent = nullptr);
|
2016-06-28 14:23:30 +08:00
|
|
|
|
2020-06-13 19:19:30 +08:00
|
|
|
const QString pluginName() const override;
|
|
|
|
void init(PluginProxyInterface *proxyInter) override;
|
2019-01-30 18:00:46 +08:00
|
|
|
bool pluginIsDisable() override;
|
2020-06-13 19:19:30 +08:00
|
|
|
void displayModeChanged(const Dock::DisplayMode mode) override;
|
|
|
|
void positionChanged(const Dock::Position position) override;
|
|
|
|
QWidget *itemWidget(const QString &itemKey) override;
|
|
|
|
QWidget *itemTipsWidget(const QString &itemKey) override;
|
|
|
|
QWidget *itemPopupApplet(const QString &itemKey) override;
|
|
|
|
int itemSortKey(const QString &itemKey) override;
|
|
|
|
void setSortKey(const QString &itemKey, const int order) override;
|
|
|
|
void refreshIcon(const QString &itemKey) override;
|
2019-01-30 18:00:46 +08:00
|
|
|
void pluginSettingsChanged() override;
|
2016-08-15 14:11:19 +08:00
|
|
|
|
2018-11-21 15:11:01 +08:00
|
|
|
Dock::Position dockPosition() const;
|
2018-11-27 11:37:39 +08:00
|
|
|
bool traysSortedInFashionMode();
|
2018-12-28 17:00:29 +08:00
|
|
|
void saveValue(const QString &itemKey, const QString &key, const QVariant &value);
|
|
|
|
const QVariant getValue(const QString &itemKey, const QString &key, const QVariant& fallback = QVariant());
|
2018-11-21 15:11:01 +08:00
|
|
|
|
2016-07-11 10:19:21 +08:00
|
|
|
private:
|
2017-12-28 19:23:50 +08:00
|
|
|
void loadIndicator();
|
2018-11-21 17:14:07 +08:00
|
|
|
bool isSystemTrayItem(const QString &itemKey);
|
2018-12-03 18:16:39 +08:00
|
|
|
QString itemKeyOfTrayWidget(AbstractTrayWidget *trayWidget);
|
2019-08-27 19:31:49 +08:00
|
|
|
Dock::DisplayMode displayMode();
|
2016-06-28 17:11:29 +08:00
|
|
|
|
|
|
|
private slots:
|
2019-01-15 18:03:43 +08:00
|
|
|
void initXEmbed();
|
|
|
|
void initSNI();
|
2018-10-23 20:06:46 +08:00
|
|
|
void addTrayWidget(const QString &itemKey, AbstractTrayWidget *trayWidget);
|
2018-08-16 10:05:16 +08:00
|
|
|
void sniItemsChanged();
|
2019-01-15 18:03:43 +08:00
|
|
|
void xembedItemsChanged();
|
|
|
|
void trayXEmbedAdded(const QString &itemKey, quint32 winId);
|
2019-01-03 14:46:19 +08:00
|
|
|
void traySNIAdded(const QString &itemKey, const QString &sniServicePath);
|
2019-03-18 16:11:02 +08:00
|
|
|
void trayIndicatorAdded(const QString &itemKey, const QString &indicatorName);
|
2019-01-03 20:29:09 +08:00
|
|
|
void trayRemoved(const QString &itemKey, const bool deleteObject = true);
|
2019-01-15 18:03:43 +08:00
|
|
|
void xembedItemChanged(quint32 winId);
|
2016-06-28 19:35:19 +08:00
|
|
|
void switchToMode(const Dock::DisplayMode mode);
|
2018-12-03 18:16:39 +08:00
|
|
|
void onRequestWindowAutoHide(const bool autoHide);
|
|
|
|
void onRequestRefershWindowVisible();
|
2019-01-03 20:29:09 +08:00
|
|
|
void onSNIItemStatusChanged(SNITrayWidget::ItemStatus status);
|
2016-06-28 14:23:30 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
DBusTrayManager *m_trayInter;
|
2018-11-29 10:24:58 +08:00
|
|
|
org::kde::StatusNotifierWatcher *m_sniWatcher;
|
2016-06-29 11:02:08 +08:00
|
|
|
FashionTrayItem *m_fashionItem;
|
2018-11-13 20:07:52 +08:00
|
|
|
SystemTraysController *m_systemTraysController;
|
2019-01-15 18:03:43 +08:00
|
|
|
QTimer *m_refreshXEmbedItemsTimer;
|
|
|
|
QTimer *m_refreshSNIItemsTimer;
|
2018-10-23 20:06:46 +08:00
|
|
|
|
|
|
|
QMap<QString, AbstractTrayWidget *> m_trayMap;
|
2021-05-14 17:43:58 +08:00
|
|
|
QMap<QString, SNITrayWidget *> m_passiveSNITrayMap; //这个目前好像无用了
|
|
|
|
QMap<QString, IndicatorTray*> m_indicatorMap; //这个有键盘跟license
|
2021-12-01 12:22:31 +08:00
|
|
|
QMap<uint, char> m_registertedPID;
|
2016-07-11 10:19:21 +08:00
|
|
|
|
2019-11-22 13:09:58 +08:00
|
|
|
bool m_pluginLoaded;
|
2021-05-25 13:05:45 +08:00
|
|
|
std::mutex m_sniMutex;
|
2021-11-05 21:25:06 +08:00
|
|
|
|
|
|
|
xcb_connection_t *xcb_connection;
|
|
|
|
Display *m_display;
|
2016-06-28 14:23:30 +08:00
|
|
|
};
|
|
|
|
|
2018-11-13 20:07:52 +08:00
|
|
|
#endif // TRAYPLUGIN_H
|