1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Designer of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29//
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt API. It exists for the convenience
34// of Qt Designer. This header
35// file may change from version to version without notice, or even be removed.
36//
37// We mean it.
38//
39
40#ifndef STYLESHEETEDITOR_H
41#define STYLESHEETEDITOR_H
42
43#include <QtWidgets/qtextedit.h>
44#include <QtWidgets/qdialog.h>
45#include <QtWidgets/qlabel.h>
46#include "shared_global_p.h"
47
48QT_BEGIN_NAMESPACE
49
50class QDesignerFormWindowInterface;
51class QDesignerFormEditorInterface;
52class TextEditFindWidget;
53
54class QDialogButtonBox;
55
56namespace qdesigner_internal {
57
58class QDESIGNER_SHARED_EXPORT StyleSheetEditor : public QTextEdit
59{
60 Q_OBJECT
61public:
62 StyleSheetEditor(QWidget *parent = nullptr);
63};
64
65// Edit a style sheet.
66class QDESIGNER_SHARED_EXPORT StyleSheetEditorDialog : public QDialog
67{
68 Q_OBJECT
69public:
70 enum Mode {
71 ModeGlobal, // resources are disabled (we don't have current resource set loaded), used e.g. in configuration dialog context
72 ModePerForm // resources are available
73 };
74
75 StyleSheetEditorDialog(QDesignerFormEditorInterface *core, QWidget *parent, Mode mode = ModePerForm);
76 ~StyleSheetEditorDialog();
77 QString text() const;
78 void setText(const QString &t);
79
80 static bool isStyleSheetValid(const QString &styleSheet);
81
82
83private slots:
84 void validateStyleSheet();
85 void slotContextMenuRequested(const QPoint &pos);
86 void slotAddResource(const QString &property);
87 void slotAddGradient(const QString &property);
88 void slotAddColor(const QString &property);
89 void slotAddFont();
90 void slotRequestHelp();
91
92protected:
93 void keyPressEvent(QKeyEvent *) override;
94 QDialogButtonBox *buttonBox() const;
95 void setOkButtonEnabled(bool v);
96
97private:
98 void insertCssProperty(const QString &name, const QString &value);
99
100 QDialogButtonBox *m_buttonBox;
101 StyleSheetEditor *m_editor;
102 TextEditFindWidget *m_findWidget;
103 QLabel *m_validityLabel;
104 QDesignerFormEditorInterface *m_core;
105 QAction *m_addResourceAction;
106 QAction *m_addGradientAction;
107 QAction *m_addColorAction;
108 QAction *m_addFontAction;
109 QAction *m_findAction;
110};
111
112// Edit the style sheet property of the designer selection.
113// Provides an "Apply" button.
114
115class QDESIGNER_SHARED_EXPORT StyleSheetPropertyEditorDialog : public StyleSheetEditorDialog
116{
117 Q_OBJECT
118public:
119 StyleSheetPropertyEditorDialog(QWidget *parent, QDesignerFormWindowInterface *fw, QWidget *widget);
120
121 static bool isStyleSheetValid(const QString &styleSheet);
122
123private slots:
124 void applyStyleSheet();
125
126private:
127 QDesignerFormWindowInterface *m_fw;
128 QWidget *m_widget;
129};
130
131} // namespace qdesigner_internal
132
133QT_END_NAMESPACE
134
135#endif // STYLESHEETEDITOR_H
136