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-08-28 11:37:19 +08:00
|
|
|
using namespace Dock;
|
|
|
|
|
2019-08-29 20:21:36 +08:00
|
|
|
class MainPanelDelegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool appIsOnDock(const QString &appDesktop) = 0;
|
|
|
|
};
|
|
|
|
|
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:
|
|
|
|
MainPanelControl(QWidget *parent = 0);
|
|
|
|
~MainPanelControl();
|
|
|
|
|
2019-08-19 15:17:56 +08:00
|
|
|
void addFixedAreaItem(const int index, QWidget *wdg);
|
|
|
|
void addAppAreaItem(const int index, QWidget *wdg);
|
|
|
|
void addTrayAreaItem(const int index, QWidget *wdg);
|
|
|
|
void addPluginAreaItem(const 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-14 15:17:04 +08:00
|
|
|
void setPositonValue(const Qt::Edge val);
|
2019-08-30 11:41:52 +08:00
|
|
|
void setDisplayMode(const DisplayMode m_displayMode);
|
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-30 11:41:52 +08:00
|
|
|
void displayModeChanged();
|
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-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-08-29 20:21:36 +08:00
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e);
|
|
|
|
void dropEvent(QDropEvent *) override;
|
2019-08-21 12:52:53 +08:00
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
|
|
|
|
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-08-21 12:52:53 +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-08-30 11:41:52 +08:00
|
|
|
void onDisplayModeChanged();
|
2019-08-17 18:24:24 +08:00
|
|
|
|
2019-08-14 15:17:04 +08:00
|
|
|
private:
|
|
|
|
QBoxLayout *m_mainPanelLayout;
|
|
|
|
QWidget *m_fixedAreaWidget;
|
|
|
|
QWidget *m_appAreaWidget;
|
|
|
|
QWidget *m_trayAreaWidget;
|
|
|
|
QWidget *m_pluginAreaWidget;
|
|
|
|
QBoxLayout *m_fixedAreaLayout;
|
|
|
|
QBoxLayout *m_trayAreaLayout;
|
|
|
|
QBoxLayout *m_pluginLayout;
|
|
|
|
QWidget *m_appAreaSonWidget;
|
|
|
|
QBoxLayout *m_appAreaSonLayout;
|
|
|
|
Qt::Edge 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-08-14 15:17:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MAINPANELCONTROL_H
|