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
|
|
|
|
|
2016-06-15 17:44:38 +08:00
|
|
|
|
#ifndef PLUGINSITEMINTERFACE_H
|
|
|
|
|
#define PLUGINSITEMINTERFACE_H
|
|
|
|
|
|
2016-06-24 11:32:25 +08:00
|
|
|
|
#include "pluginproxyinterface.h"
|
|
|
|
|
|
2022-12-02 15:41:34 +08:00
|
|
|
|
#include <DGuiApplicationHelper>
|
|
|
|
|
|
2016-06-24 11:32:25 +08:00
|
|
|
|
#include <QIcon>
|
2016-06-16 17:48:19 +08:00
|
|
|
|
#include <QtCore>
|
|
|
|
|
|
2022-12-02 15:41:34 +08:00
|
|
|
|
DGUI_USE_NAMESPACE
|
|
|
|
|
|
2022-05-30 20:29:53 +08:00
|
|
|
|
// 任务栏的部件位置
|
|
|
|
|
enum class DockPart {
|
2022-11-18 03:19:58 +00:00
|
|
|
|
QuickShow = 0, // 快捷插件显示区域
|
|
|
|
|
QuickPanel, // 快捷面板区域
|
|
|
|
|
SystemPanel, // 系统插件显示区域
|
|
|
|
|
DCCSetting // 显示在控制中心个性化设置的图标
|
2022-05-30 20:29:53 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-11-28 14:37:54 +08:00
|
|
|
|
enum PluginFlag {
|
|
|
|
|
Type_NoneFlag = 0x1, // 插件类型-没有任何的属性,不在任何地方显示
|
|
|
|
|
Type_Common = 0x2, // 插件类型-快捷插件区
|
|
|
|
|
Type_Tool = 0x4, // 插件类型-工具插件,例如回收站
|
|
|
|
|
Type_System = 0x8, // 插件类型-系统插件,例如关机插件
|
|
|
|
|
Type_Tray = 0x10, // 插件类型-托盘区,例如U盘插件
|
|
|
|
|
Type_Fixed = 0x20, // 插件类型-固定区域,例如多任务视图和显示桌面
|
|
|
|
|
|
|
|
|
|
Quick_Single = 0x40, // 当插件类型为Common时,快捷插件区域只有一列的那种插件
|
|
|
|
|
Quick_Multi = 0x80, // 当插件类型为Common时,快捷插件区占两列的那种插件
|
|
|
|
|
Quick_Full = 0x100, // 当插件类型为Common时,快捷插件区占用4列的那种插件,例如声音、亮度设置和音乐等
|
|
|
|
|
|
|
|
|
|
Attribute_CanDrag = 0x200, // 插件属性-是否支持拖动
|
|
|
|
|
Attribute_CanInsert = 0x400, // 插件属性-是否支持在其前面插入其他的插件,普通的快捷插件是支持的
|
|
|
|
|
Attribute_CanSetting = 0x800, // 插件属性-是否可以在控制中心设置显示或隐藏
|
2022-12-23 17:12:22 +08:00
|
|
|
|
Attribute_ForceDock = 0x1000, // 插件属性-强制显示在任务栏上
|
2022-11-28 14:37:54 +08:00
|
|
|
|
|
|
|
|
|
FlagMask = 0xffffffff // 掩码
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_FLAGS(PluginFlags, PluginFlag)
|
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(PluginFlags)
|
|
|
|
|
|
2022-10-27 07:03:28 +00:00
|
|
|
|
// 快捷面板详情页面的itemWidget对应的itemKey
|
2022-11-04 04:51:48 +00:00
|
|
|
|
#define QUICK_ITEM_KEY "quick_item_key"
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief The PluginsItemInterface class
|
|
|
|
|
/// the dock plugins item interface, all dock plugins should
|
|
|
|
|
/// inheirt this class and override all pure virtual function.
|
|
|
|
|
///
|
2022-05-30 20:29:53 +08:00
|
|
|
|
|
2016-06-15 17:44:38 +08:00
|
|
|
|
class PluginsItemInterface
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-09-03 20:37:30 +08:00
|
|
|
|
enum PluginType {
|
|
|
|
|
Normal,
|
|
|
|
|
Fixed
|
|
|
|
|
};
|
|
|
|
|
|
2020-11-06 17:52:08 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Plugin size policy
|
|
|
|
|
*/
|
|
|
|
|
enum PluginSizePolicy {
|
|
|
|
|
System = 1 << 0, // Follow the system
|
|
|
|
|
Custom = 1 << 1 // The custom
|
|
|
|
|
};
|
|
|
|
|
|
2022-12-02 15:41:34 +08:00
|
|
|
|
enum PluginMode {
|
2022-05-12 17:35:50 +08:00
|
|
|
|
Deactive = 0,
|
|
|
|
|
Active,
|
|
|
|
|
Disabled
|
|
|
|
|
};
|
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief ~PluginsItemInterface
|
2017-04-07 15:10:29 +08:00
|
|
|
|
/// DON'T try to delete m_proxyInter.
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
2016-06-15 17:44:38 +08:00
|
|
|
|
virtual ~PluginsItemInterface() {}
|
2016-06-16 16:56:21 +08:00
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief pluginName
|
|
|
|
|
/// tell dock the unique plugin id
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-06-28 14:23:30 +08:00
|
|
|
|
virtual const QString pluginName() const = 0;
|
2017-10-23 10:06:36 +08:00
|
|
|
|
virtual const QString pluginDisplayName() const { return QString(); }
|
2019-09-03 20:37:30 +08:00
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief init
|
|
|
|
|
/// init your plugins, you need to save proxyInter to m_proxyInter
|
|
|
|
|
/// member variable. but you shouldn't free this pointer.
|
|
|
|
|
/// \param proxyInter
|
2017-04-07 15:10:29 +08:00
|
|
|
|
/// DON'T try to delete this pointer.
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
2016-06-24 11:32:25 +08:00
|
|
|
|
virtual void init(PluginProxyInterface *proxyInter) = 0;
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief itemWidget
|
|
|
|
|
/// your plugin item widget, each item should have a unique key.
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// your widget' unqiue key.
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-07-13 17:16:22 +08:00
|
|
|
|
virtual QWidget *itemWidget(const QString &itemKey) = 0;
|
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief itemTipsWidget
|
|
|
|
|
/// override this function if your item want to have a tips.
|
|
|
|
|
/// the tips will shown when user hover your item.
|
|
|
|
|
/// nullptr will be ignored.
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-07-13 17:16:22 +08:00
|
|
|
|
virtual QWidget *itemTipsWidget(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief itemPopupApplet
|
|
|
|
|
/// override this function if your item wants to have an popup applet.
|
|
|
|
|
/// the popup applet will shown when user click your item.
|
|
|
|
|
///
|
|
|
|
|
/// Tips:
|
|
|
|
|
/// dock should receive mouse press/release event to check user mouse operate,
|
|
|
|
|
/// if your item filter mouse event, this function will not be called.
|
|
|
|
|
/// so if you override mouse event and want to use popup applet, you
|
|
|
|
|
/// should pass event to your parent use QWidget::someEvent(e);
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-07-13 17:16:22 +08:00
|
|
|
|
virtual QWidget *itemPopupApplet(const QString &itemKey) {Q_UNUSED(itemKey); return nullptr;}
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief itemCommand
|
|
|
|
|
/// execute spec command when user clicked your item.
|
|
|
|
|
/// ensure your command do not get user input.
|
|
|
|
|
///
|
|
|
|
|
/// empty string will be ignored.
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-07-13 17:16:22 +08:00
|
|
|
|
virtual const QString itemCommand(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
2016-06-24 11:32:25 +08:00
|
|
|
|
|
2016-09-19 14:11:18 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief itemContextMenu
|
|
|
|
|
/// context menu is shown when RequestPopupMenu called.
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
|
|
|
|
virtual const QString itemContextMenu(const QString &itemKey) {Q_UNUSED(itemKey); return QString();}
|
|
|
|
|
///
|
|
|
|
|
/// \brief invokedMenuItem
|
|
|
|
|
/// call if context menu item is clicked
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \param itemId
|
|
|
|
|
/// menu item id
|
|
|
|
|
/// \param checked
|
|
|
|
|
///
|
|
|
|
|
virtual void invokedMenuItem(const QString &itemKey, const QString &menuId, const bool checked) {Q_UNUSED(itemKey); Q_UNUSED(menuId); Q_UNUSED(checked);}
|
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief itemSortKey
|
|
|
|
|
/// tell dock where your item wants to put on.
|
|
|
|
|
///
|
|
|
|
|
/// this index is start from 1 and
|
|
|
|
|
/// 0 for left side
|
|
|
|
|
/// -1 for right side
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-09-06 14:51:11 +08:00
|
|
|
|
virtual int itemSortKey(const QString &itemKey) {Q_UNUSED(itemKey); return 1;}
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief setSortKey
|
|
|
|
|
/// save your item new position
|
|
|
|
|
/// sort key will be changed when plugins order
|
|
|
|
|
/// changed(by user drag-drop)
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \param order
|
|
|
|
|
///
|
2016-06-30 20:05:51 +08:00
|
|
|
|
virtual void setSortKey(const QString &itemKey, const int order) {Q_UNUSED(itemKey); Q_UNUSED(order);}
|
2016-06-24 14:59:56 +08:00
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief itemAllowContainer
|
|
|
|
|
/// tell dock is your item allow to move into container
|
|
|
|
|
///
|
|
|
|
|
/// if your item placed into container, popup tips and popup
|
|
|
|
|
/// applet will be disabled.
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-08-15 14:11:19 +08:00
|
|
|
|
virtual bool itemAllowContainer(const QString &itemKey) {Q_UNUSED(itemKey); return false;}
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief itemIsInContainer
|
|
|
|
|
/// tell dock your item is in container, this function
|
|
|
|
|
/// called at item init and if your item enable container.
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-08-15 14:11:19 +08:00
|
|
|
|
virtual bool itemIsInContainer(const QString &itemKey) {Q_UNUSED(itemKey); return false;}
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief setItemIsInContainer
|
|
|
|
|
/// save your item new state.
|
|
|
|
|
/// this function called when user drag out your item from
|
|
|
|
|
/// container or user drop item into container(if your item
|
|
|
|
|
/// allow drop into container).
|
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// \param container
|
|
|
|
|
///
|
2016-08-15 14:11:19 +08:00
|
|
|
|
virtual void setItemIsInContainer(const QString &itemKey, const bool container) {Q_UNUSED(itemKey); Q_UNUSED(container);}
|
|
|
|
|
|
2017-10-23 10:06:36 +08:00
|
|
|
|
virtual bool pluginIsAllowDisable() { return false; }
|
|
|
|
|
virtual bool pluginIsDisable() { return false; }
|
|
|
|
|
virtual void pluginStateSwitched() {}
|
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief displayModeChanged
|
|
|
|
|
/// override this function to receive display mode changed signal
|
|
|
|
|
/// \param displayMode
|
|
|
|
|
///
|
2016-07-13 17:16:22 +08:00
|
|
|
|
virtual void displayModeChanged(const Dock::DisplayMode displayMode) {Q_UNUSED(displayMode);}
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief positionChanged
|
|
|
|
|
/// override this function to receive dock position changed signal
|
|
|
|
|
/// \param position
|
|
|
|
|
///
|
2016-07-13 17:16:22 +08:00
|
|
|
|
virtual void positionChanged(const Dock::Position position) {Q_UNUSED(position);}
|
|
|
|
|
|
2017-03-20 10:36:18 +08:00
|
|
|
|
///
|
2018-12-04 16:05:15 +08:00
|
|
|
|
/// \brief refreshIcon
|
|
|
|
|
/// refresh item icon, its triggered when system icon theme changed.
|
2017-03-20 10:36:18 +08:00
|
|
|
|
/// \param itemKey
|
|
|
|
|
/// item key
|
|
|
|
|
///
|
2018-12-04 16:05:15 +08:00
|
|
|
|
virtual void refreshIcon(const QString &itemKey) { Q_UNUSED(itemKey); }
|
2017-03-20 10:36:18 +08:00
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief displayMode
|
|
|
|
|
/// get current dock display mode
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-08-15 14:11:19 +08:00
|
|
|
|
inline Dock::DisplayMode displayMode() const
|
2016-06-28 10:06:04 +08:00
|
|
|
|
{
|
|
|
|
|
return qApp->property(PROP_DISPLAY_MODE).value<Dock::DisplayMode>();
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief position
|
|
|
|
|
/// get current dock position
|
|
|
|
|
/// \return
|
|
|
|
|
///
|
2016-08-15 14:11:19 +08:00
|
|
|
|
inline Dock::Position position() const
|
2016-06-28 10:06:04 +08:00
|
|
|
|
{
|
|
|
|
|
return qApp->property(PROP_POSITION).value<Dock::Position>();
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-30 17:49:17 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief settingsChanged
|
|
|
|
|
/// override this function to receive plugin settings changed signal(DeepinSync)
|
|
|
|
|
///
|
|
|
|
|
virtual void pluginSettingsChanged() {}
|
|
|
|
|
|
2019-09-10 16:20:18 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief type
|
|
|
|
|
/// default plugin add dock right,fixed plugin add to dock fixed area
|
|
|
|
|
///
|
|
|
|
|
virtual PluginType type() { return Normal; }
|
|
|
|
|
|
2020-11-06 17:52:08 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief plugin size policy
|
|
|
|
|
/// default plugin size policy
|
|
|
|
|
///
|
|
|
|
|
virtual PluginSizePolicy pluginSizePolicy() const { return System; }
|
|
|
|
|
|
2022-05-12 17:35:50 +08:00
|
|
|
|
///
|
|
|
|
|
/// the plugin status
|
|
|
|
|
///
|
|
|
|
|
///
|
2022-12-02 15:41:34 +08:00
|
|
|
|
virtual PluginMode status() const { return PluginMode::Deactive; }
|
2022-05-12 17:35:50 +08:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// return the detail value, it will display in the center
|
|
|
|
|
///
|
|
|
|
|
///
|
|
|
|
|
virtual QString description() const { return QString(); }
|
|
|
|
|
|
2022-11-23 05:27:16 +00:00
|
|
|
|
///
|
|
|
|
|
/// the icon for the plugin
|
|
|
|
|
/// themeType {0:UnknownType 1:LightType 2:DarkType}
|
|
|
|
|
///
|
2022-12-02 15:41:34 +08:00
|
|
|
|
virtual QIcon icon(const DockPart &dockPart, DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType()) { return QIcon(); }
|
2022-11-23 05:27:16 +00:00
|
|
|
|
|
2022-11-28 14:37:54 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief m_proxyInter
|
|
|
|
|
/// return the falgs for current plugin
|
|
|
|
|
///
|
|
|
|
|
virtual PluginFlags flags() const { return PluginFlag::Type_Common | PluginFlag::Quick_Single | PluginFlag::Attribute_CanDrag | PluginFlag::Attribute_CanInsert | PluginFlag::Attribute_CanSetting; }
|
|
|
|
|
|
2022-12-02 15:41:34 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief m_proxyInter
|
|
|
|
|
///
|
|
|
|
|
///
|
|
|
|
|
virtual bool eventHandler(QEvent *event) { return false; }
|
|
|
|
|
|
2016-06-24 11:32:25 +08:00
|
|
|
|
protected:
|
2016-09-07 16:45:57 +08:00
|
|
|
|
///
|
|
|
|
|
/// \brief m_proxyInter
|
|
|
|
|
/// NEVER delete this object.
|
|
|
|
|
///
|
2020-11-02 12:12:26 +08:00
|
|
|
|
PluginProxyInterface *m_proxyInter = nullptr;
|
2016-06-15 17:44:38 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
2022-11-11 10:28:12 +08:00
|
|
|
|
#define ModuleInterface_iid "com.deepin.dock.PluginsItemInterface_2_0_0"
|
2016-06-15 17:44:38 +08:00
|
|
|
|
|
|
|
|
|
Q_DECLARE_INTERFACE(PluginsItemInterface, ModuleInterface_iid)
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
#endif // PLUGINSITEMINTERFACE_H
|