2019-08-14 15:17:04 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 ~ 2019 Deepin Technology Co., Ltd.
|
|
|
|
*
|
|
|
|
* Author: xuwenw <xuwenw@xuwenw.so>
|
|
|
|
*
|
|
|
|
* Maintainer: <@xuwenw.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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MAINPANELCONTROL_H
|
|
|
|
#define MAINPANELCONTROL_H
|
|
|
|
|
2019-08-28 11:37:19 +08:00
|
|
|
#include "constants.h"
|
2022-08-15 18:07:14 +00:00
|
|
|
#include "dbusutil.h"
|
2019-08-28 11:37:19 +08:00
|
|
|
|
2019-08-14 15:17:04 +08:00
|
|
|
#include <QWidget>
|
|
|
|
|
2019-08-28 11:37:19 +08:00
|
|
|
using namespace Dock;
|
|
|
|
|
2021-09-22 13:12:27 +08:00
|
|
|
class QBoxLayout;
|
|
|
|
class QLabel;
|
2019-10-31 15:38:56 +08:00
|
|
|
class TrayPluginItem;
|
|
|
|
class PluginsItem;
|
2019-08-17 18:24:24 +08:00
|
|
|
class DockItem;
|
2019-08-29 20:21:36 +08:00
|
|
|
class PlaceholderItem;
|
|
|
|
class AppDragWidget;
|
2021-09-22 13:12:27 +08:00
|
|
|
class DesktopWidget;
|
2022-07-08 09:05:54 +00:00
|
|
|
class RecentAppHelper;
|
2022-07-11 03:18:24 +00:00
|
|
|
class ToolAppHelper;
|
2022-08-18 15:41:46 +00:00
|
|
|
class MultiWindowHelper;
|
2022-05-12 16:24:54 +08:00
|
|
|
|
2019-08-14 15:17:04 +08:00
|
|
|
class MainPanelControl : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-07-08 09:05:54 +00:00
|
|
|
|
2019-08-14 15:17:04 +08:00
|
|
|
public:
|
2022-08-25 19:31:31 +00:00
|
|
|
explicit MainPanelControl(DockInter *dockInter, QWidget *parent = nullptr);
|
2019-08-14 15:17:04 +08:00
|
|
|
|
2019-08-30 15:54:19 +08:00
|
|
|
void setPositonValue(Position position);
|
2020-10-28 11:30:50 +08:00
|
|
|
void setDisplayMode(DisplayMode dislayMode);
|
2021-09-22 13:12:27 +08:00
|
|
|
void resizeDockIcon();
|
2021-01-07 21:56:53 +08:00
|
|
|
void updatePluginsLayout();
|
2022-05-27 17:34:02 +08:00
|
|
|
|
2022-08-25 19:31:31 +00:00
|
|
|
QSize suitableSize(const Position &position, int screenSize, double deviceRatio) const;
|
2019-08-14 15:17:04 +08:00
|
|
|
|
2020-10-28 11:30:50 +08:00
|
|
|
public slots:
|
|
|
|
void insertItem(const int index, DockItem *item);
|
|
|
|
void removeItem(DockItem *item);
|
|
|
|
void itemUpdated(DockItem *item);
|
|
|
|
|
2019-08-21 12:52:53 +08:00
|
|
|
signals:
|
|
|
|
void itemMoved(DockItem *sourceItem, DockItem *targetItem);
|
2019-08-29 20:21:36 +08:00
|
|
|
void itemAdded(const QString &appDesktop, int idx);
|
2022-06-20 15:03:35 +08:00
|
|
|
void requestUpdate();
|
2019-08-21 12:52:53 +08:00
|
|
|
|
2020-10-28 11:30:50 +08:00
|
|
|
private:
|
2021-09-22 13:12:27 +08:00
|
|
|
void initUI();
|
2022-06-20 15:03:35 +08:00
|
|
|
void initConnection();
|
2019-08-14 15:17:04 +08:00
|
|
|
void updateAppAreaSonWidgetSize();
|
|
|
|
void updateMainPanelLayout();
|
2019-08-30 11:41:52 +08:00
|
|
|
void updateDisplayMode();
|
2019-09-04 10:31:37 +08:00
|
|
|
void moveAppSonWidget();
|
2022-05-12 16:24:54 +08:00
|
|
|
void updateModeChange();
|
2019-08-14 15:17:04 +08:00
|
|
|
|
2020-10-28 11:30:50 +08:00
|
|
|
void addFixedAreaItem(int index, QWidget *wdg);
|
|
|
|
void removeFixedAreaItem(QWidget *wdg);
|
|
|
|
void removeAppAreaItem(QWidget *wdg);
|
|
|
|
void addTrayAreaItem(int index, QWidget *wdg);
|
|
|
|
void removeTrayAreaItem(QWidget *wdg);
|
2022-05-27 17:34:02 +08:00
|
|
|
int getScreenSize() const;
|
2019-08-21 12:52:53 +08:00
|
|
|
|
2021-09-22 13:12:27 +08:00
|
|
|
// 拖拽相关
|
2019-08-21 12:52:53 +08:00
|
|
|
void startDrag(DockItem *);
|
|
|
|
DockItem *dropTargetItem(DockItem *sourceItem, QPoint point);
|
|
|
|
void moveItem(DockItem *sourceItem, DockItem *targetItem);
|
2019-08-29 20:21:36 +08:00
|
|
|
void handleDragMove(QDragMoveEvent *e, bool isFilter);
|
2021-09-27 16:47:23 +08:00
|
|
|
void calcuDockIconSize(int w, int h, int traySize);
|
2020-06-28 19:57:46 +08:00
|
|
|
void resizeDesktopWidget();
|
2020-07-28 14:42:16 +08:00
|
|
|
bool checkNeedShowDesktop();
|
2021-04-16 11:19:56 +08:00
|
|
|
bool appIsOnDock(const QString &appDesktop);
|
2022-07-08 09:05:54 +00:00
|
|
|
void dockRecentApp(DockItem *dockItem);
|
2022-05-25 09:42:01 +08:00
|
|
|
|
2022-06-20 15:03:35 +08:00
|
|
|
private Q_SLOTS:
|
|
|
|
void onRequestUpdate();
|
2022-07-08 09:05:54 +00:00
|
|
|
void onRecentVisibleChanged(bool visible);
|
2022-08-08 01:25:37 +00:00
|
|
|
void onDockAppVisibleChanged(bool visible);
|
2022-07-11 03:18:24 +00:00
|
|
|
void onToolVisibleChanged(bool visible);
|
2022-06-20 15:03:35 +08:00
|
|
|
|
2021-09-22 13:12:27 +08:00
|
|
|
protected:
|
|
|
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *) override;
|
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
2021-11-05 21:29:32 +08:00
|
|
|
void enterEvent(QEvent *event) override;
|
2021-09-22 13:12:27 +08:00
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
2019-08-14 15:17:04 +08:00
|
|
|
private:
|
|
|
|
QBoxLayout *m_mainPanelLayout;
|
2020-10-28 11:30:50 +08:00
|
|
|
|
|
|
|
QWidget *m_fixedAreaWidget; // 固定区域
|
2022-07-08 09:05:54 +00:00
|
|
|
QBoxLayout *m_fixedAreaLayout; // 固定区域布局
|
2020-10-28 11:30:50 +08:00
|
|
|
QLabel *m_fixedSpliter; // 固定区域与应用区域间的分割线
|
|
|
|
QWidget *m_appAreaWidget; // 应用区域
|
2021-07-26 14:28:10 +08:00
|
|
|
QWidget *m_appAreaSonWidget; // 子应用区域,所在位置根据显示模式手动指定
|
2022-07-08 09:05:54 +00:00
|
|
|
QBoxLayout *m_appAreaSonLayout; // 子应用区域布局
|
2020-10-28 11:30:50 +08:00
|
|
|
QLabel *m_appSpliter; // 应用区域与托盘区域间的分割线
|
|
|
|
QWidget *m_trayAreaWidget; // 托盘区域
|
2022-07-08 09:05:54 +00:00
|
|
|
QBoxLayout *m_trayAreaLayout; // 托盘区域布局
|
2020-10-28 11:30:50 +08:00
|
|
|
QLabel *m_traySpliter; // 托盘区域与插件区域间的分割线
|
|
|
|
QWidget *m_pluginAreaWidget; // 插件区域
|
2022-07-08 09:05:54 +00:00
|
|
|
QWidget *m_recentAreaWidget; // 最近打开应用
|
|
|
|
QBoxLayout *m_recentLayout;
|
2022-07-11 03:18:24 +00:00
|
|
|
QLabel *m_recentSpliter; // 最近打开应用区域分割线
|
2022-08-18 15:41:46 +00:00
|
|
|
QWidget *m_toolAreaWidget; // 工具区域,用来存放多开窗口和回收站等
|
|
|
|
QBoxLayout *m_toolAreaLayout; // 工具区域的布局
|
|
|
|
QWidget *m_multiWindowWidget; // 多开窗口区域,用来存放多开窗口
|
|
|
|
QBoxLayout *m_multiWindowLayout;// 用来存放多开窗口的布局
|
|
|
|
QWidget *m_toolSonAreaWidget; // 工具区域,用来存放回收站等工具
|
|
|
|
QBoxLayout *m_toolSonLayout; // 工具区域布局
|
2022-07-08 09:05:54 +00:00
|
|
|
|
|
|
|
QBoxLayout *m_pluginLayout; // 插件区域布局
|
2020-10-28 11:30:50 +08:00
|
|
|
DesktopWidget *m_desktopWidget; // 桌面预览区域
|
|
|
|
|
2019-08-30 13:58:58 +08:00
|
|
|
Position m_position;
|
2019-08-29 20:21:36 +08:00
|
|
|
QPointer<PlaceholderItem> m_placeholderItem;
|
|
|
|
QString m_draggingMimeKey;
|
|
|
|
AppDragWidget *m_appDragWidget;
|
2022-07-08 09:05:54 +00:00
|
|
|
DisplayMode m_displayMode;
|
2019-09-24 19:17:51 +08:00
|
|
|
QPoint m_mousePressPos;
|
2021-05-25 13:05:45 +08:00
|
|
|
TrayPluginItem *m_tray;
|
2022-07-08 09:05:54 +00:00
|
|
|
int m_dragIndex = -1; // 记录应用区域被拖拽图标的位置
|
2021-05-18 20:49:27 +08:00
|
|
|
|
2022-08-15 18:07:14 +00:00
|
|
|
DockInter *m_dockInter;
|
2022-07-08 09:05:54 +00:00
|
|
|
RecentAppHelper *m_recentHelper;
|
2022-07-11 03:18:24 +00:00
|
|
|
ToolAppHelper *m_toolHelper;
|
2022-08-18 15:41:46 +00:00
|
|
|
MultiWindowHelper *m_multiHelper;
|
2019-08-14 15:17:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINPANELCONTROL_H
|