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"
|
|
|
|
|
2019-08-14 15:17:04 +08:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QBoxLayout>
|
2019-09-17 13:14:23 +08:00
|
|
|
#include <QLabel>
|
2019-08-14 15:17:04 +08:00
|
|
|
|
2020-07-27 14:32:49 +08:00
|
|
|
#include <com_deepin_daemon_gesture.h>
|
|
|
|
|
2019-08-28 11:37:19 +08:00
|
|
|
using namespace Dock;
|
2020-07-27 14:32:49 +08:00
|
|
|
using Gesture = com::deepin::daemon::Gesture;
|
2019-08-28 11:37:19 +08:00
|
|
|
|
2019-10-31 15:38:56 +08:00
|
|
|
class TrayPluginItem;
|
|
|
|
class PluginsItem;
|
|
|
|
|
2019-08-29 20:21:36 +08:00
|
|
|
class MainPanelDelegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool appIsOnDock(const QString &appDesktop) = 0;
|
|
|
|
};
|
|
|
|
|
2020-05-29 13:08:42 +08:00
|
|
|
class DesktopWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-06-13 19:19:30 +08:00
|
|
|
explicit DesktopWidget(QWidget *parent) : QWidget(parent){
|
2020-05-29 13:08:42 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-08-17 18:24:24 +08:00
|
|
|
class DockItem;
|
2019-08-29 20:21:36 +08:00
|
|
|
class PlaceholderItem;
|
|
|
|
class AppDragWidget;
|
2019-08-14 15:17:04 +08:00
|
|
|
class MainPanelControl : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2020-06-13 19:19:30 +08:00
|
|
|
explicit MainPanelControl(QWidget *parent = nullptr);
|
|
|
|
~MainPanelControl() override;
|
2019-08-14 15:17:04 +08:00
|
|
|
|
2019-08-30 15:54:19 +08:00
|
|
|
void addFixedAreaItem(int index, QWidget *wdg);
|
|
|
|
void addAppAreaItem(int index, QWidget *wdg);
|
|
|
|
void addTrayAreaItem(int index, QWidget *wdg);
|
|
|
|
void addPluginAreaItem(int index, QWidget *wdg);
|
2019-08-17 18:24:24 +08:00
|
|
|
void removeFixedAreaItem(QWidget *wdg);
|
|
|
|
void removeAppAreaItem(QWidget *wdg);
|
|
|
|
void removeTrayAreaItem(QWidget *wdg);
|
|
|
|
void removePluginAreaItem(QWidget *wdg);
|
2019-08-30 15:54:19 +08:00
|
|
|
void setPositonValue(Position position);
|
|
|
|
void setDisplayMode(DisplayMode m_displayMode);
|
2019-10-31 15:38:56 +08:00
|
|
|
void getTrayVisableItemCount();
|
2019-08-14 15:17:04 +08:00
|
|
|
|
2019-08-29 20:21:36 +08:00
|
|
|
MainPanelDelegate *delegate() const;
|
|
|
|
void setDelegate(MainPanelDelegate *delegate);
|
|
|
|
|
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);
|
2019-08-21 12:52:53 +08:00
|
|
|
|
2019-08-14 15:17:04 +08:00
|
|
|
private:
|
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
|
|
|
|
|
|
|
void init();
|
|
|
|
void updateAppAreaSonWidgetSize();
|
|
|
|
void updateMainPanelLayout();
|
2019-08-30 11:41:52 +08:00
|
|
|
void updateDisplayMode();
|
2019-09-04 10:31:37 +08:00
|
|
|
void moveAppSonWidget();
|
2019-08-14 15:17:04 +08:00
|
|
|
|
2019-08-21 12:52:53 +08:00
|
|
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
2019-09-03 10:22:27 +08:00
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
2019-08-29 20:21:36 +08:00
|
|
|
void dropEvent(QDropEvent *) override;
|
2019-08-21 12:52:53 +08:00
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
2019-09-24 19:17:51 +08:00
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
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);
|
2019-09-17 13:14:23 +08:00
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2019-10-28 14:42:56 +08:00
|
|
|
void resizeDockIcon();
|
2020-06-05 16:16:59 +08:00
|
|
|
void calcuDockIconSize(int w, int h, PluginsItem *trashPlugin, PluginsItem *shutdownPlugin, PluginsItem *keyboardPlugin, PluginsItem *notificationPlugin);
|
2020-06-28 19:57:46 +08:00
|
|
|
void resizeDesktopWidget();
|
2020-07-28 14:42:16 +08:00
|
|
|
bool checkNeedShowDesktop();
|
2020-06-28 19:57:46 +08:00
|
|
|
|
2019-08-19 13:40:06 +08:00
|
|
|
public slots:
|
2019-08-19 15:17:56 +08:00
|
|
|
void insertItem(const int index, DockItem *item);
|
|
|
|
void removeItem(DockItem *item);
|
2019-09-06 14:44:07 +08:00
|
|
|
void itemUpdated(DockItem *item);
|
2019-08-17 18:24:24 +08:00
|
|
|
|
2020-03-13 12:59:02 +08:00
|
|
|
// void
|
2020-02-14 23:25:09 +08:00
|
|
|
void onGSettingsChanged(const QString &key);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void showEvent(QShowEvent *event) override;
|
2019-08-14 15:17:04 +08:00
|
|
|
private:
|
|
|
|
QBoxLayout *m_mainPanelLayout;
|
|
|
|
QWidget *m_fixedAreaWidget;
|
|
|
|
QWidget *m_appAreaWidget;
|
|
|
|
QWidget *m_trayAreaWidget;
|
|
|
|
QWidget *m_pluginAreaWidget;
|
2020-05-29 13:08:42 +08:00
|
|
|
DesktopWidget *m_desktopWidget;
|
2019-08-14 15:17:04 +08:00
|
|
|
QBoxLayout *m_fixedAreaLayout;
|
|
|
|
QBoxLayout *m_trayAreaLayout;
|
|
|
|
QBoxLayout *m_pluginLayout;
|
|
|
|
QWidget *m_appAreaSonWidget;
|
|
|
|
QBoxLayout *m_appAreaSonLayout;
|
2020-03-13 12:59:02 +08:00
|
|
|
// QBoxLayout *m_appAreaLayout;
|
2019-08-30 13:58:58 +08:00
|
|
|
Position m_position;
|
2019-08-29 20:21:36 +08:00
|
|
|
QPointer<PlaceholderItem> m_placeholderItem;
|
|
|
|
MainPanelDelegate *m_delegate;
|
|
|
|
QString m_draggingMimeKey;
|
|
|
|
AppDragWidget *m_appDragWidget;
|
2019-08-30 11:41:52 +08:00
|
|
|
DisplayMode m_dislayMode;
|
2019-09-17 13:14:23 +08:00
|
|
|
QLabel *m_fixedSpliter;
|
|
|
|
QLabel *m_appSpliter;
|
|
|
|
QLabel *m_traySpliter;
|
2019-09-24 19:17:51 +08:00
|
|
|
QPoint m_mousePressPos;
|
2019-10-31 15:38:56 +08:00
|
|
|
int m_trayIconCount;
|
|
|
|
TrayPluginItem *m_tray = nullptr;
|
2019-12-23 13:48:11 +08:00
|
|
|
bool m_isHover;//判断鼠标是否移到desktop区域
|
2020-07-28 14:42:16 +08:00
|
|
|
bool m_needRecoveryWin; // 判断鼠标移出desktop区域是否恢复之前窗口
|
2020-02-14 23:25:09 +08:00
|
|
|
bool m_isEnableLaunch;//判断是否使能了com.deepin.dde.dock.module.launcher
|
2019-08-14 15:17:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINPANELCONTROL_H
|