DtkWidget 5.6.0.2
DTK Widget module
dabstractdialog.h
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DABSTRACTDIALOG_H
6#define DABSTRACTDIALOG_H
7
8#include <QDialog>
9#include <QPoint>
10
11#include <DObject>
12
13#include <dtkwidget_global.h>
14
15class QMouseEvent;
16class QPushButton;
17class QResizeEvent;
18
19DWIDGET_BEGIN_NAMESPACE
20
21class DAbstractDialogPrivate;
22class LIBDTKWIDGETSHARED_EXPORT DAbstractDialog : public QDialog, public DTK_CORE_NAMESPACE::DObject
23{
24 Q_OBJECT
25
26 Q_PROPERTY(DisplayPosition displayPosition READ displayPosition WRITE setDisplayPosition)
27
28public:
29 enum DisplayPosition {
30 Center,
31 TopRight
32 };
34 DisplayCenter = Center,
35 DisplayTopRight = TopRight
36 };
37
38 Q_ENUMS(DisplayPosition)
39 Q_ENUMS(DisplayPostion)
40
41 DAbstractDialog(QWidget *parent = nullptr);
42 DAbstractDialog(bool blurIfPossible, QWidget *parent = nullptr);
43
44 DisplayPosition displayPosition() const;
45
46 void move(const QPoint &pos);
47 inline void move(int x, int y)
48 { move(QPoint(x, y));}
49
50 void setGeometry(const QRect &rect);
51 inline void setGeometry(int x, int y, int width, int height)
52 { setGeometry(QRect(x, y, width, height));}
53
54public Q_SLOTS:
55 void moveToCenter();
56 void moveToTopRight();
57 void moveToCenterByRect(const QRect &rect);
58 void moveToTopRightByRect(const QRect &rect);
59
60 void setDisplayPosition(DisplayPosition displayPosition);
61
62Q_SIGNALS:
67 void sizeChanged(QSize size);
68
69protected:
70 void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
71 void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
72 void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
73 void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
74 void showEvent(QShowEvent *event) override;
75
76protected:
77 DAbstractDialog(DAbstractDialogPrivate &dd, QWidget *parent = nullptr);
78
79private:
80 D_DECLARE_PRIVATE(DAbstractDialog)
81};
82
83DWIDGET_END_NAMESPACE
84
85#endif // DABSTRACTDIALOG_H
Definition: dabstractdialogprivate_p.h:21
可以使用 DAbstractDialog 类创建符合 DDE 风格的对话框窗口.
Definition: dabstractdialog.h:23
DisplayPostion
Definition: dabstractdialog.h:33
void sizeChanged(QSize size)
sizeChanged is emitted when the size of this dialog changed. size is the target size.