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 | #ifndef QDESIGNER_TOOLWINDOW_H |
30 | #define QDESIGNER_TOOLWINDOW_H |
31 | |
32 | #include "mainwindow.h" |
33 | |
34 | #include <QtCore/qpointer.h> |
35 | #include <QtGui/qfontdatabase.h> |
36 | #include <QtWidgets/qmainwindow.h> |
37 | |
38 | QT_BEGIN_NAMESPACE |
39 | |
40 | struct ToolWindowFontSettings { |
41 | bool equals(const ToolWindowFontSettings &) const; |
42 | |
43 | QFont m_font; |
44 | QFontDatabase::WritingSystem m_writingSystem{QFontDatabase::Any}; |
45 | bool m_useFont{false}; |
46 | }; |
47 | |
48 | inline bool operator==(const ToolWindowFontSettings &tw1, const ToolWindowFontSettings &tw2) |
49 | { |
50 | return tw1.equals(tw2); |
51 | } |
52 | |
53 | inline bool operator!=(const ToolWindowFontSettings &tw1, const ToolWindowFontSettings &tw2) |
54 | { |
55 | return !tw1.equals(tw2); |
56 | } |
57 | |
58 | class QDesignerWorkbench; |
59 | |
60 | /* A tool window with an action that activates it. Note that in toplevel mode, |
61 | * the Widget box is a tool window as well as the applications' main window, |
62 | * So, we need to inherit from MainWindowBase. */ |
63 | |
64 | class QDesignerToolWindow : public MainWindowBase |
65 | { |
66 | Q_OBJECT |
67 | protected: |
68 | explicit QDesignerToolWindow(QDesignerWorkbench *workbench, |
69 | QWidget *w, |
70 | const QString &objectName, |
71 | const QString &title, |
72 | const QString &actionObjectName, |
73 | Qt::DockWidgetArea dockAreaHint, |
74 | QWidget *parent = nullptr, |
75 | Qt::WindowFlags flags = Qt::Window); |
76 | |
77 | public: |
78 | // Note: The order influences the dock widget position. |
79 | enum StandardToolWindow { WidgetBox, ObjectInspector, PropertyEditor, |
80 | ResourceEditor, ActionEditor, SignalSlotEditor, |
81 | StandardToolWindowCount }; |
82 | |
83 | static QDesignerToolWindow *createStandardToolWindow(StandardToolWindow which, QDesignerWorkbench *workbench); |
84 | |
85 | QDesignerWorkbench *workbench() const; |
86 | QAction *action() const; |
87 | |
88 | Qt::DockWidgetArea dockWidgetAreaHint() const { return m_dockAreaHint; } |
89 | virtual QRect geometryHint() const; |
90 | |
91 | private slots: |
92 | void showMe(bool); |
93 | |
94 | protected: |
95 | void showEvent(QShowEvent *e) override; |
96 | void hideEvent(QHideEvent *e) override; |
97 | void changeEvent(QEvent *e) override; |
98 | |
99 | QRect availableToolWindowGeometry() const; |
100 | |
101 | private: |
102 | const Qt::DockWidgetArea m_dockAreaHint; |
103 | QDesignerWorkbench *m_workbench; |
104 | QAction *m_action; |
105 | }; |
106 | |
107 | QT_END_NAMESPACE |
108 | |
109 | #endif // QDESIGNER_TOOLWINDOW_H |
110 | |