Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
zoomwidget_p.h
Go to the documentation of this file.
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
// Qt-Security score:significant reason:default
4
5
//
6
// W A R N I N G
7
// -------------
8
//
9
// This file is not part of the Qt API. It exists for the convenience
10
// of Qt Designer. This header
11
// file may change from version to version without notice, or even be removed.
12
//
13
// We mean it.
14
//
15
16
#
ifndef
ZOOMWIDGET_H
17
#
define
ZOOMWIDGET_H
18
19
#
include
"shared_global_p.h"
20
21
#
include
<
QtWidgets
/
qgraphicsview
.
h
>
22
#
include
<
QtWidgets
/
qgraphicsproxywidget
.
h
>
23
24
#
include
<
QtCore
/
qlist
.
h
>
25
26
QT_BEGIN_NAMESPACE
27
28
class
QGraphicsScene;
29
class
QMenu;
30
class
QAction;
31
class
QActionGroup;
32
33
namespace
qdesigner_internal
{
34
35
// A checkable zoom menu action group. Operates in percent.
36
37
class
QDESIGNER_SHARED_EXPORT
ZoomMenu
:
public
QObject
{
38
Q_OBJECT
39
Q_DISABLE_COPY_MOVE
(
ZoomMenu
)
40
41
public
:
42
ZoomMenu
(
QObject
*
parent
=
nullptr
);
43
void
addActions
(
QMenu
*
m
);
44
45
int
zoom
()
const
;
46
47
// Return a list of available zoom values.
48
static
QList
<
int
>
zoomValues
();
49
50
public
slots
:
51
void
setZoom
(
int
percent
);
52
53
signals
:
54
void
zoomChanged
(
int
);
55
56
private
slots
:
57
void
slotZoomMenu
(
QAction
*);
58
59
private
:
60
static
int
zoomOf
(
const
QAction
*
a
);
61
62
QActionGroup
*
m_menuActions
;
63
};
64
65
/* Zoom view: A QGraphicsView with a zoom menu */
66
67
class
QDESIGNER_SHARED_EXPORT
ZoomView
:
public
QGraphicsView
68
{
69
Q_PROPERTY
(
int
zoom
READ
zoom
WRITE
setZoom
DESIGNABLE
true
SCRIPTABLE
true
)
70
Q_PROPERTY
(
bool
zoomContextMenuEnabled
READ
isZoomContextMenuEnabled
WRITE
setZoomContextMenuEnabled
DESIGNABLE
true
SCRIPTABLE
true
)
71
Q_OBJECT
72
Q_DISABLE_COPY_MOVE
(
ZoomView
)
73
public
:
74
ZoomView
(
QWidget
*
parent
=
nullptr
);
75
76
/* Zoom in percent (for easily implementing menus) and qreal zoomFactor
77
* in sync */
78
int
zoom
()
const
;
// in percent
79
qreal
zoomFactor
()
const
;
80
81
// Zoom Menu on QGraphicsView.
82
bool
isZoomContextMenuEnabled
()
const
;
83
void
setZoomContextMenuEnabled
(
bool
e
);
84
85
QGraphicsScene
&
scene
() {
return
*
m_scene
; }
86
const
QGraphicsScene
&
scene
()
const
{
return
*
m_scene
; }
87
88
// Helpers for menu
89
ZoomMenu
*
zoomMenu
();
90
91
QPoint
scrollPosition
()
const
;
92
void
setScrollPosition
(
const
QPoint
&
pos
);
93
void
scrollToOrigin
();
94
95
public
slots
:
96
void
setZoom
(
int
percent
);
97
void
showContextMenu
(
const
QPoint
&
globalPos
);
98
99
protected
:
100
void
contextMenuEvent
(
QContextMenuEvent
*
event
)
override
;
101
102
// Overwrite for implementing additional behaviour when doing setZoom();
103
virtual
void
applyZoom
();
104
105
private
:
106
QGraphicsScene
*
m_scene
;
107
int
m_zoom
= 100;
108
qreal
m_zoomFactor
= 1;
109
110
bool
m_zoomContextMenuEnabled
=
false
;
111
ZoomMenu
*
m_zoomMenu
=
nullptr
;
112
};
113
114
/* The proxy widget used in ZoomWidget. It refuses to move away from 0,0,
115
* This behaviour is required for Windows only. */
116
117
class
QDESIGNER_SHARED_EXPORT
ZoomProxyWidget
:
public
QGraphicsProxyWidget
{
118
Q_DISABLE_COPY_MOVE
(
ZoomProxyWidget
)
119
public
:
120
explicit
ZoomProxyWidget
(
QGraphicsItem
*
parent
=
nullptr
,
Qt
::
WindowFlags
wFlags
= {});
121
122
protected
:
123
QVariant
itemChange
(
GraphicsItemChange
change
,
const
QVariant
&
value
)
override
;
124
};
125
126
/* Zoom widget: A QGraphicsView-based container for a widget that allows for
127
* zooming it. Communicates changes in size in the following ways:
128
* 1) Embedded widget wants to resize: Listen for its resize in event filter
129
* and resize
130
* 2) Zoom is changed: resize to fully display the embedded widget
131
* 3) Outer widget changes (by manually resizing the window:
132
* Pass the scaled change on to the embedded widget.
133
* Provides helper functions for a zoom context menu on the widget. */
134
135
class
QDESIGNER_SHARED_EXPORT
ZoomWidget
:
public
ZoomView
136
{
137
Q_PROPERTY
(
bool
widgetZoomContextMenuEnabled
READ
isWidgetZoomContextMenuEnabled
WRITE
setWidgetZoomContextMenuEnabled
DESIGNABLE
true
SCRIPTABLE
true
)
138
Q_PROPERTY
(
bool
itemAcceptDrops
READ
itemAcceptDrops
WRITE
setItemAcceptDrops
DESIGNABLE
true
SCRIPTABLE
true
)
139
Q_OBJECT
140
Q_DISABLE_COPY_MOVE
(
ZoomWidget
)
141
142
public
:
143
ZoomWidget
(
QWidget
*
parent
=
nullptr
);
144
void
setWidget
(
QWidget
*
w
,
Qt
::
WindowFlags
wFlags
= {});
145
146
const
QGraphicsProxyWidget
*
proxy
()
const
{
return
m_proxy
; }
147
QGraphicsProxyWidget
*
proxy
() {
return
m_proxy
; }
148
149
/* Enable the zoom Menu on the Widget (as opposed ZoomView's menu which
150
* is on the canvas). */
151
bool
isWidgetZoomContextMenuEnabled
()
const
;
152
void
setWidgetZoomContextMenuEnabled
(
bool
e
);
153
154
void
setItemAcceptDrops
(
bool
);
155
bool
itemAcceptDrops
()
const
;
156
157
QSize
minimumSizeHint
()
const
override
;
158
QSize
sizeHint
()
const
override
;
159
160
bool
zoomedEventFilter
(
QObject
*
watched
,
QEvent
*
event
);
161
162
public
slots
:
163
// debug state
164
void
dump
()
const
;
165
166
protected
:
167
void
resizeEvent
(
QResizeEvent
*
event
)
override
;
168
169
// Overwritten from ZoomView
170
void
applyZoom
()
override
;
171
// Overwrite to actually perform a resize. This is required if we are in a layout. Default does resize().
172
virtual
void
doResize
(
const
QSize
&
s
);
173
174
private
:
175
// Factory function for QGraphicsProxyWidgets which can be overwritten. Default creates a ZoomProxyWidget
176
virtual
QGraphicsProxyWidget
*
createProxyWidget
(
QGraphicsItem
*
parent
=
nullptr
,
177
Qt
::
WindowFlags
wFlags
= {})
const
;
178
QSize
widgetSizeToViewSize
(
const
QSize
&
s
,
bool
*
ptrToValid
=
nullptr
)
const
;
179
180
void
resizeToWidgetSize
();
181
QSize
viewPortMargin
()
const
;
182
QSize
widgetSize
()
const
;
183
QSizeF
widgetDecorationSizeF
()
const
;
184
185
QGraphicsProxyWidget
*
m_proxy
=
nullptr
;
186
bool
m_viewResizeBlocked
=
false
;
187
bool
m_widgetResizeBlocked
=
false
;
188
bool
m_widgetZoomContextMenuEnabled
=
false
;
189
};
190
191
}
// namespace qdesigner_internal
192
193
QT_END_NAMESPACE
194
195
#
endif
QPaintEngine::QPainter
friend class QPainter
Definition
qpaintengine.h:220
QPainter::QWidget
friend class QWidget
Definition
qpainter.h:432
qdesigner_internal::FormEditorOptionsPage
Definition
formeditor_optionspage.h:23
qdesigner_internal::FormEditorOptionsPage::FormEditorOptionsPage
FormEditorOptionsPage(QDesignerFormEditorInterface *core)
Definition
formeditor_optionspage.cpp:80
qdesigner_internal::FormEditorOptionsPage::name
QString name() const override
Definition
formeditor_optionspage.cpp:85
qdesigner_internal::FormEditorOptionsPage::finish
void finish() override
Definition
formeditor_optionspage.cpp:170
qdesigner_internal::FormEditorOptionsPage::apply
void apply() override
Definition
formeditor_optionspage.cpp:137
qdesigner_internal::GridPanel
Definition
gridpanel_p.h:34
qdesigner_internal::Grid
Definition
grid_p.h:34
qdesigner_internal::PreviewConfigurationWidget
Definition
previewconfigurationwidget_p.h:34
qdesigner_internal::QDesignerSharedSettings
Definition
shared_settings_p.h:43
qdesigner_internal::ZoomMenu
Definition
zoomwidget_p.h:37
qdesigner_internal::ZoomProxyWidget
Definition
zoomwidget_p.h:117
qdesigner_internal::ZoomSettingsWidget
Definition
formeditor_optionspage.cpp:32
qdesigner_internal::ZoomSettingsWidget::fromSettings
void fromSettings(const QDesignerSharedSettings &s)
Definition
formeditor_optionspage.cpp:63
qdesigner_internal::ZoomSettingsWidget::toSettings
void toSettings(QDesignerSharedSettings &s) const
Definition
formeditor_optionspage.cpp:70
qdesigner_internal::ZoomView
Definition
zoomwidget_p.h:68
qdesigner_internal::ZoomWidget
Definition
zoomwidget_p.h:136
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qdesigner_internal::Ui
Definition
templateoptionspage.h:21
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:67
qdesigner_internal::ObjectNamingMode
ObjectNamingMode
Definition
shared_enums_p.h:58
QDESIGNER_SHARED_EXPORT
#define QDESIGNER_SHARED_EXPORT
Definition
shared_global_p.h:33
qttools
src
designer
src
lib
shared
zoomwidget_p.h
Generated on
for Qt by
1.16.1