Debian Codegraph @

kysdk-qtwidgets/src/kcustomdateedit.h

raw
1 /*
2 * libkysdk-qtwidgets's Library
3 *
4 * Copyright (C) 2024, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Zhen Sun <[email protected]>
20 *
21 */
22
23 #ifndef KCUSTOMDATEEDIT_H
24 #define KCUSTOMDATEEDIT_H
25
26 #include "gui_g.h"
27 #include "kminicalendarwidget.h"
28 #include <QDateTimeEdit>
29 #include <QMouseEvent>
30
31 namespace kdk
32 {
33 class KCustomDateEditPrivate;
34
35 /**
36 * @defgroup KCustomDateEdit
37 * @since 2.5.2.0
38 */
39
40 class GUI_EXPORT KCustomDateEdit : public QDateTimeEdit
41 {
42 Q_OBJECT
43 public:
44 KCustomDateEdit(QWidget *parent = nullptr);
45
46 /**
47 * @brief 触发日历控件显示
48 */
49 void showCalendar();
50
51 /**
52 * @brief 是否显示农历
53 * @param showLunar
54 */
55 void setShowLunar(bool showLunar);
56
57 /**
58 * @brief 适应系统风格
59 * @param isDark:是否深色模式
60 */
61 void updateStyle(bool isDark);
62
63 signals:
64 void changeDate();
65
66 protected:
67 void mousePressEvent(QMouseEvent *event) override;
68 void paintEvent(QPaintEvent *e) override;
69 bool eventFilter(QObject *obj, QEvent *event) override;
70
71 private:
72 Q_DECLARE_PRIVATE(KCustomDateEdit)
73 KCustomDateEditPrivate *const d_ptr;
74 };
75 }
76
77 #endif // KCUSTOMDATEEDIT_H