DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dtitlebareditpanel.h
1// SPDX-FileCopyrightText: 2021 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#pragma once
6
7#include "dtitlebarsettingsimpl.h"
8
9#include <dtkwidget_global.h>
10#include <DObject>
11#include <DBlurEffectWidget>
12#include <DIconButton>
13
14#include <QHBoxLayout>
15#include <QPointer>
16
17class QPushButton;
18class QLabel;
19
20DWIDGET_BEGIN_NAMESPACE
21
22class DTitlebarEditPanel;
23class DFlowLayout;
24class DIconButton;
25
26class PlaceHoderWidget: public QWidget
27{
28 Q_OBJECT
29public:
30 explicit PlaceHoderWidget(QWidget *parent = nullptr);
31protected:
32 void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
33};
34
36{
37 Q_OBJECT
38public:
39 explicit DragDropWidget(const QString &id = "", QWidget *parent = nullptr);
40 virtual~DragDropWidget() Q_DECL_OVERRIDE;
41
42 void setButtonIcon(const QIcon &icon, const QSize &size = QSize(36, 36));
43 QString id() const;
44 void setScreenShotedView(QWidget *view);
45 void screenShot();
46
47protected:
48 virtual void onIgnoreAction();
49 void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
50 void mouseMoveEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
51 void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
52
53private:
54 void startDrag(const QPoint &pos);
55 void gobackDrag(const QPixmap &pixmap, const QPoint &pos);
56
57protected:
58 QString m_mimeDataFormat;
59 DTitlebarEditPanel *m_titleBarEditPanel = nullptr;
60 int m_index = -1;
61 QPixmap m_pixmap;
62 QString m_id; // m_id is key when Type is TITLEBAR_TYPE, m_id is toolId when Type is SELECTZONE_TYPE
63
64private:
65 QPoint m_startDrag;
66 bool m_isClicked = false;
67 QPointer<QWidget> m_view = nullptr;
68};
69
71{
72public:
73 explicit TitlebarZoneWidget(const QString &id = "", QWidget *parent = nullptr);
74 void onIgnoreAction() Q_DECL_OVERRIDE;
75};
76
78{
79public:
80 explicit SelectionZoneWidget(const QString &id = "", QWidget *parent = nullptr);
81};
82
84{
85public:
86 explicit DefaultZoneWidget(const QString &id = "", QWidget *parent = nullptr);
87};
88
89class IconTextWidget : public QWidget {
90 Q_OBJECT
91public:
92 explicit IconTextWidget(DragDropWidget *m_iconWidget, const QString &toolId, QWidget *parent = nullptr);
94
95 void setContent(const QIcon &icon, const QString &text, const QSize &size = QSize(36, 36));
96 void setIconSize(const QSize &size);
97
98private:
99 QString m_toolId;
100 DragDropWidget *m_iconWidget;
101 QLabel *m_titleLabel;
102};
103
104class DCollapseWidget : public QWidget
105{
106 Q_OBJECT
107public:
108 explicit DCollapseWidget(DTitlebarSettingsImpl *settings, QWidget *parent = nullptr);
109 virtual~DCollapseWidget() Q_DECL_OVERRIDE;
110
111 void removeAll();
112 void reloadWidgets();
113 void removePlaceHolder();
114 virtual void addWidget(const QString &key, int index);
115 void removeWidget(int index);
116
117protected:
118 void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
119 void collapse();
120 void expand();
121 void updateMinimumValue();
122 void initExpandButton();
123
124protected:
125 DTitlebarSettingsImpl *m_settingsImpl = nullptr;
126 QHBoxLayout *m_mainHLayout;
127 QVector<QPair<QString, QWidget*>> m_viewsInMenu;
128 DIconButton *m_expandButton = nullptr;
129 QPointer<QWidget> m_placeHolder = nullptr;
130
131private:
132 int m_minimumWidth = 0;
133};
134
136{
137 Q_OBJECT
138public:
139 explicit DTitlebarCustomWidget(DTitlebarSettingsImpl *settings, QWidget *parent = nullptr);
140 bool editMode() const;
141 void setEditMode(bool isEditMode);
142 QWidget *widget(const int index) const;
143 void addWidget(const QString &key, int index) Q_DECL_OVERRIDE;
144 void appendDefaultWidget(const QString &toolId);
145 void insertPlaceHolder(int index, const QSize &size);
146
147protected:
148 void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
149
150private:
151 bool m_isEditMode = false;
152};
153
155{
156 Q_OBJECT
157public:
158 explicit DTitlebarEditPanel(DTitlebarSettingsImpl *settings, DTitlebarCustomWidget *customWidget, QWidget *parent = nullptr);
159 void updateCustomWidget(bool isEditMode = true);
160 void updateScreenShotedViews();
161 void addWidget(const QString &key, int index) Q_DECL_OVERRIDE;
162 bool isFixedTool(const int index);
163 bool dropped() const;
164 void setDropped(bool isDropped);
165 void doStartScreenShot();
166 void replaceOldView(const QString &toolId);
167
168Q_SIGNALS:
169 void addingToolView(const QString &key, const int pos);
170 void removedToolView(const QString &key, const int pos);
171 void movedToolView(const QString &key, const int pos);
172 void resetToolView();
173 void startScreenShot();
174
175protected:
176 void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
177 void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE;
178 void dragLeaveEvent(QDragLeaveEvent *event) Q_DECL_OVERRIDE;
179 void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
180 bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
181 void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
182
183private:
184 bool containsTool(const QString &toolId);
185 void handleTitlebarZoneWidgetMoveEvent(QDropEvent *event);
186 void handleSelectionZoneWidgetMoveEvent(QDropEvent *event);
187 void handleDefaultWidgetDropEvent(QDropEvent *event);
188 void handleTitlebarZoneWidgetDropEvent(QDropEvent *event);
189 void handleSelectionZoneWidgetDropEvent(QDropEvent *event);
190 void positionPlaceHolder(const QPoint &pos, const QPoint &hotSpot, const QSize &size);
191
192private:
193 bool m_isDropped = true;
194 DTitlebarCustomWidget *m_customWidget;
195};
196
198{
199 Q_OBJECT
200public:
201 explicit DToolbarEditPanel(DTitlebarSettingsImpl *settingsImpl, QWidget *parent = Q_NULLPTR);
202 void addWidgetToSelectionZone(const QString &id);
203 void setDefaultView(const QPixmap &pixmap, const QSize &size);
204 void removeAll();
205
206Q_SIGNALS:
207 void confirmBtnClicked();
208
209private Q_SLOTS:
210 void onConfirmBtnClicked();
211
212protected:
213 void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
214
215private:
216 void init();
217
218private:
219 DTitlebarSettingsImpl *m_settingsImpl = nullptr;
220 QWidget *m_selectZoneView;
221 DFlowLayout *m_flowLayout;
222 IconTextWidget *m_defaultToolBarWidget;
223 QPushButton *m_confirmBtn;
224};
225
226DWIDGET_END_NAMESPACE
用于实现主窗口或控件背景的实时模糊效果.
Definition dblureffectwidget.h:17
Definition dtitlebareditpanel.h:105
DFlowLayout 类提供了一个简便的流布局.
Definition dflowlayout.h:20
按钮的图标
Definition diconbutton.h:24
Definition dtitlebareditpanel.h:136
Definition dtitlebareditpanel.h:155
Definition dtitlebarsettingsimpl.h:135
Definition dtitlebareditpanel.h:198
Definition dtitlebareditpanel.h:84
Definition dtitlebareditpanel.h:36
Definition dtitlebareditpanel.h:89
Definition dtitlebareditpanel.h:27
Definition dtitlebareditpanel.h:78
Definition dtitlebareditpanel.h:71