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 QTRESOURCEVIEW_H |
41 | #define QTRESOURCEVIEW_H |
42 | |
43 | #include "shared_global_p.h" |
44 | #include <QtWidgets/qwidget.h> |
45 | #include <QtWidgets/qdialog.h> |
46 | |
47 | QT_BEGIN_NAMESPACE |
48 | |
49 | class QtResourceModel; |
50 | class QtResourceSet; |
51 | class QDesignerFormEditorInterface; |
52 | class QMimeData; |
53 | |
54 | class QDESIGNER_SHARED_EXPORT QtResourceView : public QWidget |
55 | { |
56 | Q_OBJECT |
57 | public: |
58 | explicit QtResourceView(QDesignerFormEditorInterface *core, QWidget *parent = nullptr); |
59 | ~QtResourceView(); |
60 | |
61 | void setDragEnabled(bool dragEnabled); |
62 | bool dragEnabled() const; |
63 | |
64 | QtResourceModel *model() const; |
65 | void setResourceModel(QtResourceModel *model); |
66 | |
67 | QString selectedResource() const; |
68 | void selectResource(const QString &resource); |
69 | |
70 | QString settingsKey() const; |
71 | void setSettingsKey(const QString &key); |
72 | |
73 | bool isResourceEditingEnabled() const; |
74 | void setResourceEditingEnabled(bool enable); |
75 | |
76 | // Helpers for handling the drag originating in QtResourceView (Xml/text) |
77 | enum ResourceType { ResourceImage, ResourceStyleSheet, ResourceOther }; |
78 | static QString encodeMimeData(ResourceType resourceType, const QString &path); |
79 | |
80 | static bool decodeMimeData(const QMimeData *md, ResourceType *t = nullptr, QString *file = nullptr); |
81 | static bool decodeMimeData(const QString &text, ResourceType *t = nullptr, QString *file = nullptr); |
82 | |
83 | signals: |
84 | void resourceSelected(const QString &resource); |
85 | void resourceActivated(const QString &resource); |
86 | |
87 | protected: |
88 | bool event(QEvent *event) override; |
89 | |
90 | private: |
91 | |
92 | QScopedPointer<class QtResourceViewPrivate> d_ptr; |
93 | Q_DECLARE_PRIVATE(QtResourceView) |
94 | Q_DISABLE_COPY_MOVE(QtResourceView) |
95 | Q_PRIVATE_SLOT(d_func(), void slotResourceSetActivated(QtResourceSet *)) |
96 | Q_PRIVATE_SLOT(d_func(), void slotCurrentPathChanged(QTreeWidgetItem *)) |
97 | Q_PRIVATE_SLOT(d_func(), void slotCurrentResourceChanged(QListWidgetItem *)) |
98 | Q_PRIVATE_SLOT(d_func(), void slotResourceActivated(QListWidgetItem *)) |
99 | Q_PRIVATE_SLOT(d_func(), void slotEditResources()) |
100 | Q_PRIVATE_SLOT(d_func(), void slotReloadResources()) |
101 | #if QT_CONFIG(clipboard) |
102 | Q_PRIVATE_SLOT(d_func(), void slotCopyResourcePath()) |
103 | #endif |
104 | Q_PRIVATE_SLOT(d_func(), void slotListWidgetContextMenuRequested(const QPoint &pos)) |
105 | Q_PRIVATE_SLOT(d_func(), void slotFilterChanged(const QString &pattern)) |
106 | }; |
107 | |
108 | class QDESIGNER_SHARED_EXPORT QtResourceViewDialog : public QDialog |
109 | { |
110 | Q_OBJECT |
111 | public: |
112 | explicit QtResourceViewDialog(QDesignerFormEditorInterface *core, QWidget *parent = nullptr); |
113 | ~QtResourceViewDialog() override; |
114 | |
115 | QString selectedResource() const; |
116 | void selectResource(const QString &path); |
117 | |
118 | bool isResourceEditingEnabled() const; |
119 | void setResourceEditingEnabled(bool enable); |
120 | |
121 | private: |
122 | QScopedPointer<class QtResourceViewDialogPrivate> d_ptr; |
123 | Q_DECLARE_PRIVATE(QtResourceViewDialog) |
124 | Q_DISABLE_COPY_MOVE(QtResourceViewDialog) |
125 | Q_PRIVATE_SLOT(d_func(), void slotResourceSelected(const QString &)) |
126 | }; |
127 | |
128 | QT_END_NAMESPACE |
129 | |
130 | #endif |
131 | |