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>
|
2018-06-04 21:09:41 +08:00
|
|
|
|
* listenerri <listenerri@gmail.com>
|
2017-09-18 14:33:44 +08:00
|
|
|
|
*
|
|
|
|
|
* 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"
|
2020-12-16 17:38:41 +08:00
|
|
|
|
#include "previewcontainer.h"
|
|
|
|
|
#include "appdrag.h"
|
2018-07-04 16:17:01 +08:00
|
|
|
|
#include "../widgets/tipswidget.h"
|
2022-06-21 17:42:50 +08:00
|
|
|
|
#include "dbusutil.h"
|
2016-06-03 16:06:11 +08:00
|
|
|
|
|
2017-04-26 17:59:35 +08:00
|
|
|
|
#include <QGraphicsView>
|
|
|
|
|
#include <QGraphicsItem>
|
2018-03-09 14:59:33 +08:00
|
|
|
|
#include <QGraphicsItemAnimation>
|
2019-11-07 20:39:09 +08:00
|
|
|
|
#include <DGuiApplicationHelper>
|
2017-04-26 17:59:35 +08:00
|
|
|
|
|
2021-03-20 12:10:45 +08:00
|
|
|
|
class QGSettings;
|
2022-08-12 08:13:00 +00:00
|
|
|
|
class ScreenSpliter;
|
2021-11-26 14:59:36 +08:00
|
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
|
class AppItem : public DockItem
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2022-08-18 15:41:46 +00:00
|
|
|
|
explicit AppItem(DockInter *dockInter, const QGSettings *appSettings, const QGSettings *activeAppSettings, const QGSettings *dockedAppSettings, const QDBusObjectPath &entry, QWidget *parent = nullptr);
|
2020-06-13 19:19:30 +08:00
|
|
|
|
~AppItem() override;
|
2016-06-03 16:06:11 +08:00
|
|
|
|
|
2021-02-01 10:28:22 +08:00
|
|
|
|
void checkEntry() override;
|
2016-06-14 11:22:19 +08:00
|
|
|
|
const QString appId() const;
|
2022-08-18 15:41:46 +00:00
|
|
|
|
QString name() const;
|
2020-05-22 13:10:52 +08:00
|
|
|
|
bool isValid() const;
|
2016-07-22 14:59:43 +08:00
|
|
|
|
void updateWindowIconGeometries();
|
2018-06-04 21:09:41 +08:00
|
|
|
|
void undock();
|
|
|
|
|
QWidget *appDragWidget();
|
|
|
|
|
void setDockInfo(Dock::Position dockPosition, const QRect &dockGeometry);
|
2022-08-12 08:13:00 +00:00
|
|
|
|
void setDraging(bool drag) override;
|
|
|
|
|
|
|
|
|
|
void startSplit(const QRect &rect);
|
|
|
|
|
bool supportSplitWindow();
|
|
|
|
|
bool splitWindowOnScreen(ScreenSpliter::SplitDirection direction);
|
|
|
|
|
int mode() const;
|
2022-08-18 15:41:46 +00:00
|
|
|
|
DockEntryInter *itemEntryInter() const;
|
2020-06-13 19:19:30 +08:00
|
|
|
|
inline ItemType itemType() const override { return App; }
|
2019-09-24 10:47:43 +08:00
|
|
|
|
QPixmap appIcon(){ return m_appIcon; }
|
2020-06-13 19:19:30 +08:00
|
|
|
|
virtual QString accessibleName() override;
|
2022-07-08 09:05:54 +00:00
|
|
|
|
void requestDock();
|
|
|
|
|
bool isDocked() const;
|
|
|
|
|
qint64 appOpenMSecs() const;
|
2022-08-08 01:25:37 +00:00
|
|
|
|
void updateMSecs();
|
2022-08-18 15:41:46 +00:00
|
|
|
|
const WindowInfoMap &windowsMap() const;
|
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;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
void dragReady(QWidget *dragWidget);
|
2017-03-28 16:52:38 +08:00
|
|
|
|
|
2020-10-29 18:08:30 +08:00
|
|
|
|
void requestUpdateEntryGeometries() const;
|
2022-08-18 15:41:46 +00:00
|
|
|
|
void windowCountChanged() const;
|
2022-08-15 18:07:14 +00:00
|
|
|
|
void modeChanged(int) const;
|
2020-10-29 18:08:30 +08:00
|
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
|
private:
|
2018-07-02 16:21:43 +08:00
|
|
|
|
void moveEvent(QMoveEvent *e) override;
|
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
|
void wheelEvent(QWheelEvent *e) override;
|
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
|
void leaveEvent(QEvent *e) override;
|
2018-07-03 12:33:31 +08:00
|
|
|
|
void showEvent(QShowEvent *e) override;
|
2016-06-06 14:28:28 +08:00
|
|
|
|
|
2020-06-13 19:19:30 +08:00
|
|
|
|
void showHoverTips() override;
|
|
|
|
|
void invokedMenuItem(const QString &itemId, const bool checked) override;
|
|
|
|
|
const QString contextMenu() const override;
|
|
|
|
|
QWidget *popupTips() override;
|
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
|
|
|
|
|
2019-01-17 11:00:40 +08:00
|
|
|
|
QPoint appIconPosition() const;
|
|
|
|
|
|
2016-06-14 16:01:01 +08:00
|
|
|
|
private slots:
|
2018-02-22 14:19:52 +08:00
|
|
|
|
void updateWindowInfos(const WindowInfoMap &info);
|
2021-03-06 18:40:13 +08:00
|
|
|
|
void refreshIcon() override;
|
2016-06-23 14:28:47 +08:00
|
|
|
|
void activeChanged();
|
2017-04-25 16:36:58 +08:00
|
|
|
|
void showPreview();
|
2018-02-27 15:25:15 +08:00
|
|
|
|
void playSwingEffect();
|
2018-03-19 11:33:16 +08:00
|
|
|
|
void stopSwingEffect();
|
2018-02-27 15:25:15 +08:00
|
|
|
|
void checkAttentionEffect();
|
2019-08-01 15:59:25 +08:00
|
|
|
|
void onGSettingsChanged(const QString& key);
|
|
|
|
|
bool checkGSettingsControl() const;
|
2019-11-07 20:39:09 +08:00
|
|
|
|
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
|
2016-06-03 16:06:11 +08:00
|
|
|
|
|
2021-08-25 21:03:30 +08:00
|
|
|
|
void onRefreshIcon();
|
|
|
|
|
void onResetPreview();
|
|
|
|
|
|
2016-06-03 16:06:11 +08:00
|
|
|
|
private:
|
2021-03-20 12:10:45 +08:00
|
|
|
|
const QGSettings *m_appSettings;
|
|
|
|
|
const QGSettings *m_activeAppSettings;
|
|
|
|
|
const QGSettings *m_dockedAppSettings;
|
|
|
|
|
|
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
|
|
|
|
|
2018-02-27 15:25:15 +08:00
|
|
|
|
QGraphicsView *m_swingEffectView;
|
2018-07-04 14:18:12 +08:00
|
|
|
|
QGraphicsItemAnimation *m_itemAnimation;
|
2016-06-07 16:01:37 +08:00
|
|
|
|
|
2018-06-04 21:09:41 +08:00
|
|
|
|
DWindowManagerHelper *m_wmHelper;
|
|
|
|
|
|
2019-01-17 11:00:40 +08:00
|
|
|
|
QPointer<AppDrag> m_drag;
|
2018-06-04 21:09:41 +08:00
|
|
|
|
|
2016-06-23 14:28:47 +08:00
|
|
|
|
bool m_active;
|
2018-08-30 12:03:25 +08:00
|
|
|
|
int m_retryTimes;
|
2021-04-22 09:56:28 +08:00
|
|
|
|
bool m_iconValid;
|
2021-11-05 21:46:46 +08:00
|
|
|
|
quint64 m_lastclickTimes;
|
2018-08-30 12:03:25 +08:00
|
|
|
|
|
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;
|
2018-08-30 12:03:25 +08:00
|
|
|
|
QTimer *m_retryObtainIconTimer;
|
2021-05-08 10:00:43 +08:00
|
|
|
|
QTimer *m_refershIconTimer; // 当APP为日历时定时(1S)检测是否刷新ICON
|
2020-05-22 13:10:14 +08:00
|
|
|
|
|
2021-05-08 10:00:43 +08:00
|
|
|
|
QDate m_curDate; // 保存当前icon的日期来判断是否需要更新日历APP的ICON
|
2016-07-22 14:59:43 +08:00
|
|
|
|
|
2019-11-07 20:39:09 +08:00
|
|
|
|
DGuiApplicationHelper::ColorType m_themeType;
|
2022-07-08 09:05:54 +00:00
|
|
|
|
qint64 m_createMSecs;
|
2017-06-16 15:26:20 +08:00
|
|
|
|
|
2016-06-15 16:17:51 +08:00
|
|
|
|
static QPoint MousePressPos;
|
2022-08-12 08:13:00 +00:00
|
|
|
|
|
|
|
|
|
ScreenSpliter *m_screenSpliter;
|
2022-08-18 15:41:46 +00:00
|
|
|
|
DockInter *m_dockInter;
|
2016-06-03 16:06:11 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // APPITEM_H
|