2017-09-18 14:33:44 +08:00
|
|
|
/*
|
2018-02-07 11:52:47 +08:00
|
|
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
2017-09-18 14:33:44 +08:00
|
|
|
*
|
|
|
|
* Author: sbw <sbw@sbw.so>
|
|
|
|
*
|
|
|
|
* Maintainer: sbw <sbw@sbw.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/>.
|
|
|
|
*/
|
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
#ifndef APPITEM_H
|
|
|
|
#define APPITEM_H
|
|
|
|
|
|
|
|
#include "dockitem.h"
|
2017-07-31 17:06:10 +08:00
|
|
|
#include "components/previewcontainer.h"
|
2016-06-06 14:57:07 +08:00
|
|
|
#include "dbus/dbusclientmanager.h"
|
2016-06-03 16:06:11 +08:00
|
|
|
|
2017-04-26 17:59:35 +08:00
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QGraphicsItem>
|
|
|
|
|
2018-02-22 11:44:57 +08:00
|
|
|
#include <com_deepin_dde_daemon_dock_entry.h>
|
|
|
|
|
|
|
|
using DockEntryInter = com::deepin::dde::daemon::dock::Entry;
|
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
class AppItem : public DockItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit AppItem(const QDBusObjectPath &entry, QWidget *parent = nullptr);
|
2017-04-12 15:31:36 +08:00
|
|
|
~AppItem();
|
2016-06-03 16:06:11 +08:00
|
|
|
|
2016-06-14 11:22:19 +08:00
|
|
|
const QString appId() const;
|
2016-07-22 14:59:43 +08:00
|
|
|
void updateWindowIconGeometries();
|
2016-06-21 17:24:03 +08:00
|
|
|
static void setIconBaseSize(const int size);
|
|
|
|
static int iconBaseSize();
|
|
|
|
static int itemBaseHeight();
|
|
|
|
static int itemBaseWidth();
|
2016-06-14 11:22:19 +08:00
|
|
|
|
2017-12-05 18:49:48 +08:00
|
|
|
inline ItemType itemType() const { return App; }
|
2016-08-08 09:52:05 +08:00
|
|
|
|
2017-03-28 16:52:38 +08:00
|
|
|
signals:
|
|
|
|
void requestActivateWindow(const WId wid) const;
|
2017-04-25 20:28:11 +08:00
|
|
|
void requestPreviewWindow(const WId wid) const;
|
|
|
|
void requestCancelPreview() const;
|
2017-03-28 16:52:38 +08:00
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
private:
|
2017-06-08 16:19:12 +08:00
|
|
|
void moveEvent(QMoveEvent *e);
|
2016-06-03 16:06:11 +08:00
|
|
|
void paintEvent(QPaintEvent *e);
|
2016-06-06 14:28:28 +08:00
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
2016-06-07 14:40:45 +08:00
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
2016-08-30 16:34:02 +08:00
|
|
|
void wheelEvent(QWheelEvent *e);
|
2016-06-15 11:20:05 +08:00
|
|
|
void resizeEvent(QResizeEvent *e);
|
2016-06-23 14:45:57 +08:00
|
|
|
void dragEnterEvent(QDragEnterEvent *e);
|
2017-04-25 20:28:11 +08:00
|
|
|
void dragMoveEvent(QDragMoveEvent *e);
|
2016-06-23 15:30:06 +08:00
|
|
|
void dropEvent(QDropEvent *e);
|
2017-08-18 13:13:56 +08:00
|
|
|
void leaveEvent(QEvent *e);
|
2016-06-06 14:28:28 +08:00
|
|
|
|
2017-05-04 10:39:03 +08:00
|
|
|
void showHoverTips();
|
2016-06-15 16:17:51 +08:00
|
|
|
void invokedMenuItem(const QString &itemId, const bool checked);
|
|
|
|
const QString contextMenu() const;
|
2016-07-18 14:13:36 +08:00
|
|
|
QWidget *popupTips();
|
2016-06-15 16:17:51 +08:00
|
|
|
|
2016-06-07 14:40:45 +08:00
|
|
|
void startDrag();
|
2018-02-22 14:19:52 +08:00
|
|
|
bool hasAttention() const;
|
2016-06-14 16:01:01 +08:00
|
|
|
|
|
|
|
private slots:
|
2018-02-22 14:19:52 +08:00
|
|
|
void updateWindowInfos(const WindowInfoMap &info);
|
2017-03-13 08:02:33 +08:00
|
|
|
void refershIcon();
|
2016-06-23 14:28:47 +08:00
|
|
|
void activeChanged();
|
2017-04-25 16:36:58 +08:00
|
|
|
void showPreview();
|
2017-11-20 14:46:56 +08:00
|
|
|
void cancelAndHidePreview();
|
2016-06-03 16:06:11 +08:00
|
|
|
|
|
|
|
private:
|
2016-07-18 14:13:36 +08:00
|
|
|
QLabel *m_appNameTips;
|
2017-07-31 17:06:10 +08:00
|
|
|
PreviewContainer *m_appPreviewTips;
|
2018-02-22 11:44:57 +08:00
|
|
|
DockEntryInter *m_itemEntryInter;
|
2016-06-06 14:28:28 +08:00
|
|
|
|
2017-04-26 17:59:35 +08:00
|
|
|
QGraphicsView *m_itemView;
|
|
|
|
QGraphicsScene *m_itemScene;
|
2016-06-07 16:01:37 +08:00
|
|
|
|
2017-04-26 17:59:35 +08:00
|
|
|
bool m_draging;
|
2016-06-23 14:28:47 +08:00
|
|
|
bool m_active;
|
2018-02-22 11:44:57 +08:00
|
|
|
WindowInfoMap m_windowInfos;
|
2016-06-14 11:22:19 +08:00
|
|
|
QString m_id;
|
2017-12-28 16:21:10 +08:00
|
|
|
QPixmap m_appIcon;
|
2016-07-12 16:33:01 +08:00
|
|
|
QPixmap m_horizontalIndicator;
|
|
|
|
QPixmap m_verticalIndicator;
|
|
|
|
QPixmap m_activeHorizontalIndicator;
|
|
|
|
QPixmap m_activeVerticalIndicator;
|
2016-06-06 14:57:07 +08:00
|
|
|
|
2016-09-08 15:53:51 +08:00
|
|
|
QTimer *m_updateIconGeometryTimer;
|
2016-07-22 14:59:43 +08:00
|
|
|
|
2017-06-16 15:26:20 +08:00
|
|
|
QFutureWatcher<QPixmap> *m_smallWatcher;
|
|
|
|
QFutureWatcher<QPixmap> *m_largeWatcher;
|
|
|
|
|
2016-06-21 17:24:03 +08:00
|
|
|
static int IconBaseSize;
|
2016-06-15 16:17:51 +08:00
|
|
|
static QPoint MousePressPos;
|
2016-06-03 16:06:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // APPITEM_H
|