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 PLUGINSITEM_H
|
|
|
|
#define PLUGINSITEM_H
|
|
|
|
|
|
|
|
#include "dockitem.h"
|
2016-06-24 11:32:25 +08:00
|
|
|
#include "pluginsiteminterface.h"
|
2016-06-15 17:44:38 +08:00
|
|
|
|
2019-08-01 15:59:25 +08:00
|
|
|
class QGSettings;
|
2022-10-19 03:50:12 +00:00
|
|
|
|
2016-06-15 17:44:38 +08:00
|
|
|
class PluginsItem : public DockItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2022-10-19 03:50:12 +00:00
|
|
|
friend class QuickSettingController;
|
|
|
|
|
2016-06-15 17:44:38 +08:00
|
|
|
public:
|
2019-10-17 19:52:55 +08:00
|
|
|
~PluginsItem() override;
|
2016-06-16 16:56:21 +08:00
|
|
|
|
2016-06-24 14:59:56 +08:00
|
|
|
int itemSortKey() const;
|
2016-08-08 20:52:19 +08:00
|
|
|
void setItemSortKey(const int order) const;
|
2016-06-28 19:35:19 +08:00
|
|
|
void detachPluginWidget();
|
2016-06-24 14:59:56 +08:00
|
|
|
|
2018-10-16 14:33:06 +08:00
|
|
|
QString pluginName() const;
|
2020-11-06 17:52:08 +08:00
|
|
|
PluginsItemInterface::PluginSizePolicy pluginSizePolicy() const;
|
2018-10-16 14:33:06 +08:00
|
|
|
|
2016-08-08 19:19:11 +08:00
|
|
|
using DockItem::showContextMenu;
|
2017-02-15 17:34:45 +08:00
|
|
|
using DockItem::hidePopup;
|
2016-08-08 19:19:11 +08:00
|
|
|
|
2019-09-06 15:28:22 +08:00
|
|
|
ItemType itemType() const override;
|
2017-06-26 15:20:16 +08:00
|
|
|
QSize sizeHint() const override;
|
2016-08-08 09:52:05 +08:00
|
|
|
|
2018-10-31 15:46:22 +08:00
|
|
|
QWidget *centralWidget() const;
|
|
|
|
|
2019-10-17 19:52:55 +08:00
|
|
|
virtual void setDraging(bool bDrag) override;
|
2019-08-21 12:52:53 +08:00
|
|
|
|
2022-05-12 17:35:50 +08:00
|
|
|
PluginsItemInterface *pluginItem() const;
|
|
|
|
|
2016-08-18 15:14:50 +08:00
|
|
|
public slots:
|
2021-03-06 18:40:13 +08:00
|
|
|
void refreshIcon() override;
|
2021-03-20 12:10:45 +08:00
|
|
|
|
2022-10-19 03:50:12 +00:00
|
|
|
protected:
|
|
|
|
explicit PluginsItem(PluginsItemInterface *const pluginInter, const QString &itemKey, const QJsonObject &jsonData, QWidget *parent = nullptr);
|
|
|
|
|
2021-03-20 12:10:45 +08:00
|
|
|
private slots:
|
2019-08-21 12:52:53 +08:00
|
|
|
void onGSettingsChanged(const QString &key);
|
2016-08-18 15:14:50 +08:00
|
|
|
|
2018-12-06 10:06:53 +08:00
|
|
|
protected:
|
2017-06-26 15:20:16 +08:00
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
2020-06-13 19:19:30 +08:00
|
|
|
void enterEvent(QEvent *event) override;
|
|
|
|
void leaveEvent(QEvent *event) override;
|
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
2019-08-21 12:52:53 +08:00
|
|
|
void showEvent(QShowEvent *event) override;
|
2017-06-26 15:20:16 +08:00
|
|
|
|
|
|
|
void invokedMenuItem(const QString &itemId, const bool checked) override;
|
2019-08-21 12:52:53 +08:00
|
|
|
void showPopupWindow(QWidget *const content, const bool model = false) override;
|
2017-06-26 15:20:16 +08:00
|
|
|
const QString contextMenu() const override;
|
|
|
|
QWidget *popupTips() override;
|
2019-09-04 13:18:05 +08:00
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
2016-07-01 11:07:20 +08:00
|
|
|
|
2016-06-27 10:50:00 +08:00
|
|
|
private:
|
|
|
|
void startDrag();
|
|
|
|
void mouseClicked();
|
2019-08-01 15:59:25 +08:00
|
|
|
bool checkGSettingsControl() const;
|
2022-07-11 03:18:24 +00:00
|
|
|
QString pluginApi() const;
|
2016-06-27 10:50:00 +08:00
|
|
|
|
2016-06-16 16:56:21 +08:00
|
|
|
private:
|
2019-08-21 12:52:53 +08:00
|
|
|
PluginsItemInterface *const m_pluginInter;
|
2017-02-06 22:25:47 +08:00
|
|
|
QWidget *m_centralWidget;
|
2018-10-16 14:33:06 +08:00
|
|
|
|
2022-07-11 03:18:24 +00:00
|
|
|
QJsonObject m_jsonData;
|
2016-06-24 11:32:25 +08:00
|
|
|
const QString m_itemKey;
|
2018-03-20 15:32:33 +08:00
|
|
|
bool m_dragging;
|
2016-06-24 11:32:25 +08:00
|
|
|
|
2016-06-27 10:50:00 +08:00
|
|
|
static QPoint MousePressPoint;
|
2021-03-20 12:10:45 +08:00
|
|
|
const QGSettings *m_gsettings;
|
2016-06-15 17:44:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLUGINSITEM_H
|