mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00

高效模式下和时尚模式下托盘区域共用一个TrayModel,在拖动图标的时候,时尚模式和高效模式保持相同的状态 Log: 实现高效模式下图标的拖动功能 Influence: 高效模式,从托盘或快捷面板拖动图标到任务栏 Task: https://pms.uniontech.com/task-view-112073.html Change-Id: I279b572231ea8efc9bd7f1ee0e628e9ee3eb064e
124 lines
3.5 KiB
C++
124 lines
3.5 KiB
C++
/*
|
|
* Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd.
|
|
*
|
|
* Author: donghualin <donghualin@uniontech.com>
|
|
*
|
|
* Maintainer: donghualin <donghualin@uniontech.com>
|
|
*
|
|
* 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/>.
|
|
*/
|
|
#ifndef QUICKPLUGINWINDOW_H
|
|
#define QUICKPLUGINWINDOW_H
|
|
|
|
#include "constants.h"
|
|
|
|
#include <QWidget>
|
|
|
|
class QuickSettingItem;
|
|
class PluginsItemInterface;
|
|
class QHBoxLayout;
|
|
class QuickSettingContainer;
|
|
class QStandardItemModel;
|
|
class QStandardItem;
|
|
class QMouseEvent;
|
|
class QBoxLayout;
|
|
class QuickDockItem;
|
|
class DockPopupWindow;
|
|
class QMenu;
|
|
enum class DockPart;
|
|
|
|
namespace Dtk { namespace Gui { class DRegionMonitor; }
|
|
namespace Widget { class DListView; class DStandardItem; } }
|
|
|
|
using namespace Dtk::Widget;
|
|
|
|
class QuickPluginWindow : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit QuickPluginWindow(QWidget *parent = nullptr);
|
|
~QuickPluginWindow() override;
|
|
|
|
void setPositon(Dock::Position position);
|
|
void dragPlugin(PluginsItemInterface *item);
|
|
|
|
QSize suitableSize() const;
|
|
QSize suitableSize(const Dock::Position &position) const;
|
|
|
|
Q_SIGNALS:
|
|
void itemCountChanged();
|
|
void requestDrop(QDropEvent *dropEvent);
|
|
|
|
protected:
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
private Q_SLOTS:
|
|
void onRequestUpdate();
|
|
void onPluginDropItem(QDropEvent *event);
|
|
void onPluginDragMove(QDragMoveEvent *event);
|
|
void onUpdatePlugin(PluginsItemInterface *itemInter, const DockPart &dockPart);
|
|
|
|
private:
|
|
void initUi();
|
|
void initConnection();
|
|
void startDrag(PluginsItemInterface *moveItem);
|
|
PluginsItemInterface *findQuickSettingItem(const QPoint &mousePoint, const QList<PluginsItemInterface *> &settingItems);
|
|
int getDropIndex(QPoint point);
|
|
QPoint popupPoint() const;
|
|
QuickDockItem *getDockItemByPlugin(PluginsItemInterface *item);
|
|
QuickDockItem *getActiveDockItem(QPoint point) const;
|
|
|
|
private:
|
|
QBoxLayout *m_mainLayout;
|
|
Dock::Position m_position;
|
|
struct DragInfo *m_dragInfo;
|
|
};
|
|
|
|
// 用于在任务栏上显示的插件
|
|
class QuickDockItem : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit QuickDockItem(PluginsItemInterface *pluginItem, const QJsonObject &metaData, const QString itemKey, QWidget *parent = nullptr);
|
|
~QuickDockItem();
|
|
|
|
void setPositon(Dock::Position position);
|
|
PluginsItemInterface *pluginItem();
|
|
bool isPrimary() const;
|
|
|
|
protected:
|
|
void paintEvent(QPaintEvent *event) override;
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
void enterEvent(QEvent *event) override;
|
|
void leaveEvent(QEvent *event) override;
|
|
|
|
QPixmap iconPixmap() const;
|
|
|
|
private:
|
|
QPoint topleftPoint() const;
|
|
QPoint popupMarkPoint() const;
|
|
|
|
private:
|
|
PluginsItemInterface *m_pluginItem;
|
|
QJsonObject m_metaData;
|
|
QString m_itemKey;
|
|
Dock::Position m_position;
|
|
DockPopupWindow *m_popupWindow;
|
|
QMenu *m_contextMenu;
|
|
};
|
|
|
|
#endif // QUICKPLUGINWINDOW_H
|