dde-dock/frame/item/components/previewcontainer.h
chenjun cd34f12ac3 fix(appitem): 调整预览界面大小计算规则
调整预览界面大小计算规则.先根据屏幕宽高计算出能预览的最大数量,然后根据数量计算界面宽高,再将计算出相对数量的预览界面添加到布局并显示,其他的暂
时不添加,减少界面刷新次数

Log: 调整预览界面大小计算规则,调整预览界面布局
Bug: https://pms.uniontech.com/zentao/bug-view-110624.html
Influence: 正常显示预览界面布局
Change-Id: I5342099b05d19eae7d019b6540bc69b98867b02e
2022-01-13 15:47:44 +08:00

99 lines
2.5 KiB
C++

/*
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
*
* 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/>.
*/
#ifndef PREVIEWCONTAINER_H
#define PREVIEWCONTAINER_H
#include <QWidget>
#include <QBoxLayout>
#include <QTimer>
#include "constants.h"
#include "appsnapshot.h"
#include "floatingpreview.h"
#include <com_deepin_dde_daemon_dock_entry.h>
#include <DWindowManagerHelper>
DWIDGET_USE_NAMESPACE
class PreviewContainer : public QWidget
{
Q_OBJECT
public:
explicit PreviewContainer(QWidget *parent = 0);
enum TitleDisplayMode {
HoverShow = 0,
AlwaysShow = 1,
AlwaysHide = 2,
};
signals:
void requestActivateWindow(const WId wid) const;
void requestPreviewWindow(const WId wid) const;
void requestCheckWindows() const;
void requestCancelPreviewWindow() const;
void requestHidePopup() const;
public:
void setWindowInfos(const WindowInfoMap &infos, const WindowList &allowClose);
void updateSnapshots();
void setTitleDisplayMode(int mode);
public slots:
void updateLayoutDirection(const Dock::Position dockPos);
void checkMouseLeave();
void prepareHide();
private:
void adjustSize(bool composite);
void appendSnapWidget(const WId wid);
void enterEvent(QEvent *e);
void leaveEvent(QEvent *e);
void dragEnterEvent(QDragEnterEvent *e);
void dragLeaveEvent(QDragLeaveEvent *e);
private slots:
void onSnapshotClicked(const WId wid);
void previewEntered(const WId wid);
void previewFloating();
void onRequestCloseAppSnapshot();
private:
bool m_needActivate;
QMap<WId, AppSnapshot *> m_snapshots;
FloatingPreview *m_floatingPreview;
QBoxLayout *m_windowListLayout;
QTimer *m_mouseLeaveTimer;
DWindowManagerHelper *m_wmHelper;
QTimer *m_waitForShowPreviewTimer;
WId m_currentWId;
TitleDisplayMode m_titleMode;
};
#endif // PREVIEWCONTAINER_H