1 | // Copyright (C) 2016 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the Qt API. It exists for the convenience |
9 | // of Qt Designer. This header |
10 | // file may change from version to version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | // |
14 | |
15 | #ifndef STYLESHEETEDITOR_H |
16 | #define STYLESHEETEDITOR_H |
17 | |
18 | #include <QtWidgets/qtextedit.h> |
19 | #include <QtWidgets/qdialog.h> |
20 | #include <QtWidgets/qlabel.h> |
21 | #include "shared_global_p.h" |
22 | |
23 | QT_BEGIN_NAMESPACE |
24 | |
25 | class QDesignerFormWindowInterface; |
26 | class QDesignerFormEditorInterface; |
27 | class TextEditFindWidget; |
28 | |
29 | class QDialogButtonBox; |
30 | |
31 | namespace qdesigner_internal { |
32 | |
33 | class QDESIGNER_SHARED_EXPORT StyleSheetEditor : public QTextEdit |
34 | { |
35 | Q_OBJECT |
36 | public: |
37 | StyleSheetEditor(QWidget *parent = nullptr); |
38 | }; |
39 | |
40 | // Edit a style sheet. |
41 | class QDESIGNER_SHARED_EXPORT StyleSheetEditorDialog : public QDialog |
42 | { |
43 | Q_OBJECT |
44 | public: |
45 | enum Mode { |
46 | ModeGlobal, // resources are disabled (we don't have current resource set loaded), used e.g. in configuration dialog context |
47 | ModePerForm // resources are available |
48 | }; |
49 | |
50 | StyleSheetEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent, Mode mode = ModePerForm); |
51 | ~StyleSheetEditorDialog(); |
52 | QString text() const; |
53 | void setText(const QString &t); |
54 | |
55 | static bool isStyleSheetValid(const QString &styleSheet); |
56 | |
57 | |
58 | private slots: |
59 | void validateStyleSheet(); |
60 | void slotContextMenuRequested(const QPoint &pos); |
61 | void slotAddResource(const QString &property); |
62 | void slotAddGradient(const QString &property); |
63 | void slotAddColor(const QString &property); |
64 | void slotAddFont(); |
65 | void slotRequestHelp(); |
66 | |
67 | protected: |
68 | void keyPressEvent(QKeyEvent *) override; |
69 | QDialogButtonBox *buttonBox() const; |
70 | void setOkButtonEnabled(bool v); |
71 | |
72 | private: |
73 | void insertCssProperty(const QString &name, const QString &value); |
74 | |
75 | QDialogButtonBox *m_buttonBox; |
76 | StyleSheetEditor *m_editor; |
77 | TextEditFindWidget *m_findWidget; |
78 | QLabel *m_validityLabel; |
79 | QDesignerFormEditorInterface *m_core; |
80 | QAction *m_addResourceAction; |
81 | QAction *m_addGradientAction; |
82 | QAction *m_addColorAction; |
83 | QAction *m_addFontAction; |
84 | QAction *m_findAction; |
85 | }; |
86 | |
87 | // Edit the style sheet property of the designer selection. |
88 | // Provides an "Apply" button. |
89 | |
90 | class QDESIGNER_SHARED_EXPORT StyleSheetPropertyEditorDialog : public StyleSheetEditorDialog |
91 | { |
92 | Q_OBJECT |
93 | public: |
94 | StyleSheetPropertyEditorDialog(QWidget *parent, QDesignerFormWindowInterface *fw, QWidget *widget); |
95 | |
96 | static bool isStyleSheetValid(const QString &styleSheet); |
97 | |
98 | private slots: |
99 | void applyStyleSheet(); |
100 | |
101 | private: |
102 | QDesignerFormWindowInterface *m_fw; |
103 | QWidget *m_widget; |
104 | }; |
105 | |
106 | } // namespace qdesigner_internal |
107 | |
108 | QT_END_NAMESPACE |
109 | |
110 | #endif // STYLESHEETEDITOR_H |
111 |