dde-dock/frame/item/appitem.h
donghualin 56c3019a5c feat: 增加窗口多开的功能
增加窗口多开的窗口类,用于绘制应用图标和打开窗口的图标,根据实际情况让其显示到正确的位置

Log: 增加窗口多开的功能
Influence: 控制中心开启多开窗口显示,观察应用打开的窗口是否在对应的位置显示
Task: https://pms.uniontech.com/task-view-170977.html
Change-Id: I96371b1304f5373f17dad95893ee656056e5f457
2022-08-18 15:41:57 +00:00

172 lines
5.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
*
* Author: sbw <sbw@sbw.so>
*
* Maintainer: sbw <sbw@sbw.so>
* listenerri <listenerri@gmail.com>
*
* 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 APPITEM_H
#define APPITEM_H
#include "dockitem.h"
#include "previewcontainer.h"
#include "appdrag.h"
#include "dbusclientmanager.h"
#include "../widgets/tipswidget.h"
#include "dbusutil.h"
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QGraphicsItemAnimation>
#include <DGuiApplicationHelper>
class QGSettings;
class ScreenSpliter;
class AppItem : public DockItem
{
Q_OBJECT
public:
explicit AppItem(DockInter *dockInter, const QGSettings *appSettings, const QGSettings *activeAppSettings, const QGSettings *dockedAppSettings, const QDBusObjectPath &entry, QWidget *parent = nullptr);
~AppItem() override;
void checkEntry() override;
const QString appId() const;
QString name() const;
bool isValid() const;
void updateWindowIconGeometries();
void undock();
QWidget *appDragWidget();
void setDockInfo(Dock::Position dockPosition, const QRect &dockGeometry);
void setDraging(bool drag) override;
void startSplit(const QRect &rect);
bool supportSplitWindow();
bool splitWindowOnScreen(ScreenSpliter::SplitDirection direction);
#ifdef USE_AM
int mode() const;
#endif
DockEntryInter *itemEntryInter() const;
inline ItemType itemType() const override { return App; }
QPixmap appIcon(){ return m_appIcon; }
virtual QString accessibleName() override;
void requestDock();
bool isDocked() const;
qint64 appOpenMSecs() const;
void updateMSecs();
const WindowInfoMap &windowsMap() const;
signals:
void requestActivateWindow(const WId wid) const;
void requestPreviewWindow(const WId wid) const;
void requestCancelPreview() const;
void dragReady(QWidget *dragWidget);
void requestUpdateEntryGeometries() const;
void windowCountChanged() const;
#ifdef USE_AM
void modeChanged(int) const;
#else
void isDockChanged(bool) const;
#endif
private:
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;
void showEvent(QShowEvent *e) override;
void showHoverTips() override;
void invokedMenuItem(const QString &itemId, const bool checked) override;
const QString contextMenu() const override;
QWidget *popupTips() override;
void startDrag();
bool hasAttention() const;
QPoint appIconPosition() const;
private slots:
void updateWindowInfos(const WindowInfoMap &info);
void refreshIcon() override;
void activeChanged();
void showPreview();
void playSwingEffect();
void stopSwingEffect();
void checkAttentionEffect();
void onGSettingsChanged(const QString& key);
bool checkGSettingsControl() const;
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
void onRefreshIcon();
void onResetPreview();
private:
const QGSettings *m_appSettings;
const QGSettings *m_activeAppSettings;
const QGSettings *m_dockedAppSettings;
PreviewContainer *m_appPreviewTips;
DockEntryInter *m_itemEntryInter;
QGraphicsView *m_swingEffectView;
QGraphicsItemAnimation *m_itemAnimation;
DWindowManagerHelper *m_wmHelper;
QPointer<AppDrag> m_drag;
bool m_dragging;
bool m_active;
int m_retryTimes;
bool m_iconValid;
quint64 m_lastclickTimes;
WindowInfoMap m_windowInfos;
QString m_id;
QPixmap m_appIcon;
QPixmap m_horizontalIndicator;
QPixmap m_verticalIndicator;
QPixmap m_activeHorizontalIndicator;
QPixmap m_activeVerticalIndicator;
QTimer *m_updateIconGeometryTimer;
QTimer *m_retryObtainIconTimer;
QTimer *m_refershIconTimer; // 当APP为日历时定时1S检测是否刷新ICON
QDate m_curDate; // 保存当前icon的日期来判断是否需要更新日历APP的ICON
DGuiApplicationHelper::ColorType m_themeType;
qint64 m_createMSecs;
static QPoint MousePressPos;
ScreenSpliter *m_screenSpliter;
DockInter *m_dockInter;
};
#endif // APPITEM_H