Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qdesigner_dockwidget.cpp
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
#
include
"qdesigner_dockwidget_p.h"
6
#
include
"layoutinfo_p.h"
7
8
#
include
<
QtDesigner
/
abstractformwindow
.
h
>
9
#
include
<
QtDesigner
/
abstractformeditor
.
h
>
10
#
include
<
QtDesigner
/
container
.
h
>
11
#
include
<
QtDesigner
/
qextensionmanager
.
h
>
12
#
include
<
QtDesigner
/
abstractformwindowcursor
.
h
>
13
14
#
include
<
qdesigner_propertysheet_p
.
h
>
15
16
#
include
<
QtWidgets
/
qmainwindow
.
h
>
17
#
include
<
QtWidgets
/
qlayout
.
h
>
18
19
QT_BEGIN_NAMESPACE
20
21
using
namespace
Qt::StringLiterals;
22
23
bool
QDockWidgetPropertySheet::isEnabled(
int
index)
const
24
{
25
const
QString &name = propertyName(index);
26
if
(name ==
"dockWidgetArea"_L1
)
27
return
static_cast
<
const
QDesignerDockWidget *>(object())->docked();
28
if
(name ==
"docked"_L1
)
29
return
static_cast
<
const
QDesignerDockWidget *>(object())->inMainWindow();
30
return
QDesignerPropertySheet::isEnabled(index);
31
}
32
33
QDesignerDockWidget::QDesignerDockWidget(QWidget *parent)
34
: QDockWidget(parent)
35
{
36
}
37
38
QDesignerDockWidget::~QDesignerDockWidget() =
default
;
39
40
bool
QDesignerDockWidget::docked()
const
41
{
42
return
qobject_cast<QMainWindow*>(parentWidget()) != 0;
43
}
44
45
void
QDesignerDockWidget::setDocked(
bool
b)
46
{
47
if
(QMainWindow *mainWindow = findMainWindow()) {
48
QDesignerFormEditorInterface *core = formWindow()->core();
49
QDesignerContainerExtension *c;
50
c = qt_extension<QDesignerContainerExtension*>(core->extensionManager(), mainWindow);
51
if
(b && !docked()) {
52
// Dock it
53
// ### undo/redo stack
54
setParent(
nullptr
);
55
c->addWidget(
this
);
56
formWindow()->selectWidget(
this
, formWindow()->cursor()->isWidgetSelected(
this
));
57
}
else
if
(!b && docked()) {
58
// Undock it
59
for
(
int
i = 0; i < c->count(); ++i) {
60
if
(c->widget(i) ==
this
) {
61
c->remove(i);
62
break
;
63
}
64
}
65
// #### restore the position
66
setParent(mainWindow->centralWidget());
67
show();
68
formWindow()->selectWidget(
this
, formWindow()->cursor()->isWidgetSelected(
this
));
69
}
70
}
71
}
72
73
Qt::DockWidgetArea QDesignerDockWidget::dockWidgetArea()
const
74
{
75
if
(QMainWindow *mainWindow = qobject_cast<QMainWindow*>(parentWidget()))
76
return
mainWindow->dockWidgetArea(
const_cast
<QDesignerDockWidget*>(
this
));
77
78
return
Qt::LeftDockWidgetArea;
79
}
80
81
void
QDesignerDockWidget::setDockWidgetArea(Qt::DockWidgetArea dockWidgetArea)
82
{
83
if
(QMainWindow *mainWindow = qobject_cast<QMainWindow*>(parentWidget())) {
84
if
((dockWidgetArea != Qt::NoDockWidgetArea)
85
&& isAreaAllowed(dockWidgetArea)) {
86
mainWindow->addDockWidget(dockWidgetArea,
this
);
87
}
88
}
89
}
90
91
bool
QDesignerDockWidget::inMainWindow()
const
92
{
93
QMainWindow *mw = findMainWindow();
94
if
(mw && !mw->centralWidget()->layout()) {
95
if
(mw == parentWidget())
96
return
true
;
97
if
(mw->centralWidget() == parentWidget())
98
return
true
;
99
}
100
return
false
;
101
}
102
103
QDesignerFormWindowInterface *QDesignerDockWidget::formWindow()
const
104
{
105
return
QDesignerFormWindowInterface::findFormWindow(
const_cast
<QDesignerDockWidget*>(
this
));
106
}
107
108
QMainWindow *QDesignerDockWidget::findMainWindow()
const
109
{
110
if
(QDesignerFormWindowInterface *fw = formWindow())
111
return
qobject_cast<QMainWindow*>(fw->mainContainer());
112
return
nullptr
;
113
}
114
115
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qttools
src
designer
src
lib
shared
qdesigner_dockwidget.cpp
Generated on
for Qt by
1.18.0