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
plaintexteditor.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
"plaintexteditor_p.h"
6
7
#
include
<
QtDesigner
/
abstractsettings
.
h
>
8
#
include
<
QtDesigner
/
abstractformeditor
.
h
>
9
10
#
include
<
QtWidgets
/
qplaintextedit
.
h
>
11
#
include
<
QtWidgets
/
qdialogbuttonbox
.
h
>
12
#
include
<
QtWidgets
/
qboxlayout
.
h
>
13
#
include
<
QtWidgets
/
qpushbutton
.
h
>
14
15
QT_BEGIN_NAMESPACE
16
17
using
namespace
Qt::StringLiterals;
18
19
static
constexpr
auto
PlainTextDialogC
=
"PlainTextDialog"_L1
;
20
static
constexpr
auto
PlainTextEditorGeometryC
=
"Geometry"_L1
;
21
22
namespace
qdesigner_internal
{
23
24
PlainTextEditorDialog
::
PlainTextEditorDialog
(
QDesignerFormEditorInterface
*
core
,
QWidget
*
parent
) :
25
QDialog
(
parent
),
26
m_editor
(
new
QPlainTextEdit
),
27
m_core
(
core
)
28
{
29
setWindowTitle
(
tr
(
"Edit text"
));
30
31
QVBoxLayout
*
vlayout
=
new
QVBoxLayout
(
this
);
32
vlayout
->
addWidget
(
m_editor
);
33
34
QDialogButtonBox
*
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
);
35
QPushButton
*
ok_button
=
buttonBox
->
button
(
QDialogButtonBox
::
Ok
);
36
ok_button
->
setDefault
(
true
);
37
connect
(
buttonBox
, &
QDialogButtonBox
::
accepted
,
this
, &
QDialog
::
accept
);
38
connect
(
buttonBox
, &
QDialogButtonBox
::
rejected
,
this
, &
QDialog
::
reject
);
39
vlayout
->
addWidget
(
buttonBox
);
40
41
QDesignerSettingsInterface
*
settings
=
core
->
settingsManager
();
42
settings
->
beginGroup
(
PlainTextDialogC
);
43
44
if
(
settings
->
contains
(
PlainTextEditorGeometryC
))
45
restoreGeometry
(
settings
->
value
(
PlainTextEditorGeometryC
).
toByteArray
());
46
47
settings
->
endGroup
();
48
}
49
50
PlainTextEditorDialog
::~
PlainTextEditorDialog
()
51
{
52
QDesignerSettingsInterface
*
settings
=
m_core
->
settingsManager
();
53
settings
->
beginGroup
(
PlainTextDialogC
);
54
55
settings
->
setValue
(
PlainTextEditorGeometryC
,
saveGeometry
());
56
settings
->
endGroup
();
57
}
58
59
int
PlainTextEditorDialog
::
showDialog
()
60
{
61
m_editor
->
setFocus
();
62
return
exec
();
63
}
64
65
void
PlainTextEditorDialog
::
setDefaultFont
(
const
QFont
&
font
)
66
{
67
m_editor
->
setFont
(
font
);
68
}
69
70
void
PlainTextEditorDialog
::
setText
(
const
QString
&
text
)
71
{
72
m_editor
->
setPlainText
(
text
);
73
}
74
75
QString
PlainTextEditorDialog
::
text
()
const
76
{
77
return
m_editor
->
toPlainText
();
78
}
79
80
}
// namespace qdesigner_internal
81
82
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qdesigner_internal
Auxiliary methods to store/retrieve settings.
Definition
buddyeditor.cpp:67
PlainTextEditorGeometryC
static constexpr auto PlainTextEditorGeometryC
Definition
plaintexteditor.cpp:20
PlainTextDialogC
static constexpr auto PlainTextDialogC
Definition
plaintexteditor.cpp:19
qttools
src
designer
src
lib
shared
plaintexteditor.cpp
Generated on
for Qt by
1.16.1