2022-06-19 16:17:38 +08:00
|
|
|
// SPDX-FileCopyrightText: 2022 Gary Wang <wzc782970009@gmail.com>
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2020-12-29 23:28:17 +08:00
|
|
|
#ifndef FRAMELESSWINDOW_H
|
|
|
|
#define FRAMELESSWINDOW_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
class QVBoxLayout;
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
class FramelessWindow : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit FramelessWindow(QWidget *parent = nullptr);
|
|
|
|
|
|
|
|
void setCentralWidget(QWidget * widget);
|
2023-06-24 14:37:54 +08:00
|
|
|
void installResizeCapture(QObject* widget);
|
2020-12-29 23:28:17 +08:00
|
|
|
|
2021-01-10 14:57:01 +08:00
|
|
|
protected:
|
2023-06-24 14:37:54 +08:00
|
|
|
bool eventFilter(QObject *o, QEvent *e) override;
|
|
|
|
bool mouseHover(QHoverEvent* event, QWidget* wg);
|
|
|
|
bool mousePress(QMouseEvent* event);
|
2020-12-29 23:28:17 +08:00
|
|
|
|
|
|
|
private:
|
2023-06-24 14:37:54 +08:00
|
|
|
Qt::Edges m_oldEdges;
|
|
|
|
Qt::CursorShape m_oldCursorShape;
|
|
|
|
|
|
|
|
Qt::CursorShape getCursorByEdge(const Qt::Edges& edges, Qt::CursorShape default_cursor);
|
|
|
|
Qt::Edges getEdgesByPos(const QPoint pos, const QRect& winrect);
|
|
|
|
|
2020-12-29 23:28:17 +08:00
|
|
|
QVBoxLayout * m_centralLayout = nullptr;
|
|
|
|
QWidget * m_centralWidget = nullptr; // just a pointer, doesn't take the ownership.
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FRAMELESSWINDOW_H
|