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