2022-09-06 11:36:55 +08:00
|
|
|
// SPDX-FileCopyrightText: 2011 - 2022 UnionTech Software Technology Co., Ltd.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
2017-09-18 14:33:44 +08:00
|
|
|
|
2016-06-02 09:46:43 +08:00
|
|
|
#ifndef DOCKITEM_H
|
|
|
|
#define DOCKITEM_H
|
|
|
|
|
2016-06-16 16:56:21 +08:00
|
|
|
#include "constants.h"
|
2020-12-16 17:38:41 +08:00
|
|
|
#include "dockpopupwindow.h"
|
2016-06-02 09:46:43 +08:00
|
|
|
|
2016-06-16 16:56:21 +08:00
|
|
|
#include <QFrame>
|
2018-01-24 11:18:13 +08:00
|
|
|
#include <QPointer>
|
2018-11-13 16:01:36 +08:00
|
|
|
#include <QGestureEvent>
|
2019-08-22 17:18:30 +08:00
|
|
|
#include <QMenu>
|
2016-06-06 11:37:09 +08:00
|
|
|
|
2016-07-01 10:42:08 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2016-06-21 10:12:43 +08:00
|
|
|
using namespace Dock;
|
|
|
|
|
2016-06-02 09:46:43 +08:00
|
|
|
class DockItem : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2016-06-06 11:37:09 +08:00
|
|
|
public:
|
2016-06-03 16:06:11 +08:00
|
|
|
enum ItemType {
|
|
|
|
Launcher,
|
|
|
|
App,
|
|
|
|
Plugins,
|
2019-09-04 13:16:04 +08:00
|
|
|
FixedPlugin,
|
2017-12-05 18:49:48 +08:00
|
|
|
Placeholder,
|
2018-11-20 14:04:16 +08:00
|
|
|
TrayPlugin,
|
2016-06-03 16:06:11 +08:00
|
|
|
};
|
|
|
|
|
2016-06-02 09:46:43 +08:00
|
|
|
public:
|
2016-08-08 09:52:05 +08:00
|
|
|
explicit DockItem(QWidget *parent = nullptr);
|
2020-09-08 19:34:53 +08:00
|
|
|
~DockItem() override;
|
2016-07-20 16:30:56 +08:00
|
|
|
|
2016-06-21 17:24:03 +08:00
|
|
|
static void setDockPosition(const Position side);
|
2016-06-23 14:28:47 +08:00
|
|
|
static void setDockDisplayMode(const DisplayMode mode);
|
2016-06-06 11:37:09 +08:00
|
|
|
|
2021-08-25 21:03:30 +08:00
|
|
|
inline virtual ItemType itemType() const {return App;}
|
2016-06-03 16:06:11 +08:00
|
|
|
|
2019-08-19 13:40:06 +08:00
|
|
|
QSize sizeHint() const override;
|
2020-03-13 12:59:02 +08:00
|
|
|
virtual QString accessibleName();
|
2019-08-19 13:40:06 +08:00
|
|
|
|
2016-08-18 15:14:50 +08:00
|
|
|
public slots:
|
2021-03-06 18:40:13 +08:00
|
|
|
virtual void refreshIcon() {}
|
2016-08-18 15:14:50 +08:00
|
|
|
|
2019-08-19 13:40:06 +08:00
|
|
|
void showPopupApplet(QWidget *const applet);
|
2018-12-17 14:38:09 +08:00
|
|
|
void hidePopup();
|
2019-08-21 12:52:53 +08:00
|
|
|
virtual void setDraging(bool bDrag);
|
2021-02-01 10:28:22 +08:00
|
|
|
virtual void checkEntry() {}
|
2018-12-17 14:38:09 +08:00
|
|
|
|
2019-12-30 11:10:36 +08:00
|
|
|
bool isDragging();
|
2016-06-20 14:28:25 +08:00
|
|
|
signals:
|
|
|
|
void dragStarted() const;
|
2018-12-10 17:31:02 +08:00
|
|
|
void itemDropped(QObject *destination, const QPoint &dropPoint) const;
|
2016-07-18 09:32:01 +08:00
|
|
|
void requestWindowAutoHide(const bool autoHide) const;
|
2018-12-04 09:50:56 +08:00
|
|
|
void requestRefreshWindowVisible() const;
|
2016-06-20 14:28:25 +08:00
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
protected:
|
2021-05-25 13:05:45 +08:00
|
|
|
bool event(QEvent *event) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void enterEvent(QEvent *e) override;
|
|
|
|
void leaveEvent(QEvent *e) override;
|
2016-06-15 16:17:51 +08:00
|
|
|
|
2016-06-22 11:02:52 +08:00
|
|
|
const QRect perfectIconRect() const;
|
2020-03-12 12:34:09 +08:00
|
|
|
const QPoint popupMarkPoint() ;
|
2017-11-21 14:22:07 +08:00
|
|
|
const QPoint topleftPoint() const;
|
2016-06-22 11:02:52 +08:00
|
|
|
|
2017-12-15 16:47:16 +08:00
|
|
|
void hideNonModel();
|
2016-07-18 09:32:01 +08:00
|
|
|
void popupWindowAccept();
|
2019-08-19 13:40:06 +08:00
|
|
|
virtual void showPopupWindow(QWidget *const content, const bool model = false);
|
2017-04-18 15:07:00 +08:00
|
|
|
virtual void showHoverTips();
|
2016-06-15 16:17:51 +08:00
|
|
|
virtual void invokedMenuItem(const QString &itemId, const bool checked);
|
|
|
|
virtual const QString contextMenu() const;
|
2016-07-13 16:47:59 +08:00
|
|
|
virtual QWidget *popupTips();
|
2016-07-01 10:42:08 +08:00
|
|
|
|
2018-11-13 16:01:36 +08:00
|
|
|
bool checkAndResetTapHoldGestureState();
|
|
|
|
virtual void gestureEvent(QGestureEvent *event);
|
|
|
|
|
2016-08-10 10:15:03 +08:00
|
|
|
protected slots:
|
|
|
|
void showContextMenu();
|
2018-03-01 13:42:05 +08:00
|
|
|
void onContextMenuAccepted();
|
2016-08-10 10:15:03 +08:00
|
|
|
|
2016-07-27 14:08:23 +08:00
|
|
|
private:
|
2016-08-01 14:26:15 +08:00
|
|
|
void updatePopupPosition();
|
2019-08-22 17:18:30 +08:00
|
|
|
void menuActionClicked(QAction *action);
|
2016-07-27 14:08:23 +08:00
|
|
|
|
2016-06-06 11:37:09 +08:00
|
|
|
protected:
|
2016-06-27 20:16:35 +08:00
|
|
|
bool m_hover;
|
2016-07-20 16:30:56 +08:00
|
|
|
bool m_popupShown;
|
2018-11-13 16:01:36 +08:00
|
|
|
bool m_tapAndHold;
|
2019-08-21 12:52:53 +08:00
|
|
|
bool m_draging;
|
2021-11-19 16:12:49 +08:00
|
|
|
QMenu m_contextMenu;
|
2016-06-15 16:17:51 +08:00
|
|
|
|
2018-03-15 11:35:10 +08:00
|
|
|
QPointer<QWidget> m_lastPopupWidget;
|
2018-01-24 11:18:13 +08:00
|
|
|
|
2016-07-01 10:42:08 +08:00
|
|
|
QTimer *m_popupTipsDelayTimer;
|
2017-06-16 10:50:16 +08:00
|
|
|
QTimer *m_popupAdjustDelayTimer;
|
2016-07-01 10:42:08 +08:00
|
|
|
|
2016-06-21 17:24:03 +08:00
|
|
|
static Position DockPosition;
|
2016-06-23 14:28:47 +08:00
|
|
|
static DisplayMode DockDisplayMode;
|
2017-11-08 14:51:11 +08:00
|
|
|
static QPointer<DockPopupWindow> PopupWindow;
|
2016-06-02 09:46:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DOCKITEM_H
|