mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00

1、重启AM后,需要重新更新每个子部件的dockInter,因为这些字部件的dockInter是从MultiScreenWorker类中获取的,而MultiScreenWorker类中的dockInter已经被释放重新获取了; 2、重新启动AM后,由于任务栏会重新执行positionChanged的方法,在这个过程中会执行300毫秒的动画,在动画执行完成后,会判断当前服务是否重启过,如果重启过服务,则重新刷新界面 Log: 修复重启AM后任务栏崩溃的问题 Influence: 重启AM服务,观察任务栏是否重启 Task: https://pms.uniontech.com/task-view-225201.html Change-Id: I1d5337fe7a0101450dfce7338d32aad73c14f697
121 lines
4.1 KiB
C++
121 lines
4.1 KiB
C++
/*
|
||
* Copyright (C) 2022 ~ 2022 Deepin Technology Co., Ltd.
|
||
*
|
||
* Author: donghualin <donghualin@uniontech.com>
|
||
*
|
||
* Maintainer: donghualin <donghualin@uniontech.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 MAINWINDOWBASE_H
|
||
#define MAINWINDOWBASE_H
|
||
|
||
#include "constants.h"
|
||
#include "dbusutil.h"
|
||
|
||
#include <DBlurEffectWidget>
|
||
#include <DPlatformWindowHandle>
|
||
#include <DGuiApplicationHelper>
|
||
|
||
#include <QEvent>
|
||
#include <QMouseEvent>
|
||
#include <utils.h>
|
||
|
||
class DragWidget;
|
||
class MultiScreenWorker;
|
||
|
||
DWIDGET_USE_NAMESPACE
|
||
|
||
class MainWindowBase : public DBlurEffectWidget
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
enum class DockWindowType {
|
||
MainWindow, // 主窗口
|
||
TrayWindow // 主窗口之外的其他窗口
|
||
};
|
||
|
||
public:
|
||
explicit MainWindowBase(MultiScreenWorker *multiScreenWorker, QWidget *parent = Q_NULLPTR);
|
||
virtual ~MainWindowBase();
|
||
|
||
void setOrder(int order); // 窗体展示的顺序,按照左到右和上到下
|
||
int order() const;
|
||
|
||
virtual DockWindowType windowType() const = 0;
|
||
virtual void setDisplayMode(const Dock::DisplayMode &displayMode);
|
||
virtual void setPosition(const Dock::Position &position);
|
||
// 用来更新子区域的位置,一般用于在执行动画的过程中,根据当前的位置来更新里面panel的大小
|
||
virtual void updateParentGeometry(const Dock::Position &pos, const QRect &rect) = 0;
|
||
virtual QRect getDockGeometry(QScreen *screen, const Dock::Position &pos, const Dock::DisplayMode &displaymode, const Dock::HideState &hideState, bool withoutScale = false) const;
|
||
QVariantAnimation *createAnimation(QScreen *screen, const Dock::Position &pos, const Dock::AniAction &act);
|
||
virtual void resetPanelGeometry() {} // 重置内部区域,为了让内部区域和当前区域始终保持一致
|
||
virtual int dockSpace() const; // 与后面窗体之间的间隔
|
||
virtual void serviceRestart() {} // 服务重新启动后的操作
|
||
virtual void animationFinished(bool showOrHide) {}
|
||
|
||
Q_SIGNALS:
|
||
void requestUpdate();
|
||
|
||
protected:
|
||
void resizeEvent(QResizeEvent *event) override;
|
||
void moveEvent(QMoveEvent *) override;
|
||
void enterEvent(QEvent *e) override;
|
||
void mousePressEvent(QMouseEvent *event) override;
|
||
void showEvent(QShowEvent *event) override;
|
||
|
||
Dock::DisplayMode displayMode() const;
|
||
Dock::Position position() const;
|
||
|
||
int windowSize() const;
|
||
|
||
bool isDraging() const;
|
||
|
||
virtual void updateRadius(int borderRadius) {}
|
||
virtual QSize suitableSize(const Dock::Position &pos, const int &screenSize, const double &deviceRatio) const = 0;
|
||
|
||
private:
|
||
void initUi();
|
||
void initAttribute();
|
||
void initConnection();
|
||
void initMember();
|
||
void updateDragGeometry();
|
||
|
||
int getBorderRadius() const;
|
||
QRect getAnimationRect(const QRect &sourceRect, const Dock::Position &pos) const;
|
||
|
||
private Q_SLOTS:
|
||
void onMainWindowSizeChanged(QPoint offset);
|
||
void resetDragWindow();
|
||
void touchRequestResizeDock();
|
||
void adjustShadowMask();
|
||
void onCompositeChanged();
|
||
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType);
|
||
|
||
private:
|
||
Dock::DisplayMode m_displayMode;
|
||
Dock::Position m_position;
|
||
DragWidget *m_dragWidget;
|
||
MultiScreenWorker *m_multiScreenWorker;
|
||
QTimer *m_updateDragAreaTimer;
|
||
DPlatformWindowHandle m_platformWindowHandle;
|
||
QTimer *m_shadowMaskOptimizeTimer;
|
||
bool m_isShow;
|
||
int m_borderRadius;
|
||
int m_order;
|
||
};
|
||
|
||
#endif // MAINWINDOWBASE_H
|