2017-09-18 14:33:44 +08:00
|
|
|
/*
|
2018-02-07 11:52:47 +08:00
|
|
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
2017-09-18 14:33:44 +08:00
|
|
|
*
|
|
|
|
* Author: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* Maintainer: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
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;
|
2016-06-15 17:44:38 +08:00
|
|
|
class PluginsItem : public DockItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-11-06 17:52:08 +08:00
|
|
|
explicit PluginsItem(PluginsItemInterface *const pluginInter, const QString &itemKey, const QString &plginApi, QWidget *parent = nullptr);
|
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
|
|
|
|
2016-08-15 14:11:19 +08:00
|
|
|
void setInContainer(const bool container);
|
|
|
|
|
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
|
|
|
|
2016-08-18 15:14:50 +08:00
|
|
|
public slots:
|
2017-06-26 15:20:16 +08:00
|
|
|
void refershIcon() override;
|
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;
|
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
|
|
|
|
2020-11-06 17:52:08 +08:00
|
|
|
const QString m_pluginApi;
|
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;
|
2019-08-21 12:52:53 +08:00
|
|
|
QGSettings *m_gsettings;
|
2016-06-15 17:44:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // PLUGINSITEM_H
|