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
label_taskmenu.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
"label_taskmenu.h"
6
#
include
"inplace_editor.h"
7
8
#
include
<
QtDesigner
/
abstractformwindow
.
h
>
9
10
#
include
<
QtWidgets
/
qstyle
.
h
>
11
#
include
<
QtWidgets
/
qstyleoption
.
h
>
12
13
#
include
<
QtGui
/
qaction
.
h
>
14
#
include
<
QtGui
/
qtextdocument
.
h
>
15
16
QT_BEGIN_NAMESPACE
17
18
using
namespace
Qt::StringLiterals;
19
20
static
constexpr
auto
textPropertyC
=
"text"_L1
;
21
22
namespace
qdesigner_internal
{
23
24
// -------- LabelTaskMenuInlineEditor
25
class
LabelTaskMenuInlineEditor
:
public
TaskMenuInlineEditor
26
{
27
public
:
28
LabelTaskMenuInlineEditor
(QLabel *button, QObject *parent);
29
30
protected
:
31
QRect
editRectangle
()
const
override
;
32
};
33
34
LabelTaskMenuInlineEditor
::
LabelTaskMenuInlineEditor
(QLabel *w, QObject *parent) :
35
TaskMenuInlineEditor
(w,
ValidationRichText
, textPropertyC, parent)
36
{
37
}
38
39
QRect
LabelTaskMenuInlineEditor
::
editRectangle
()
const
40
{
41
QStyleOptionButton opt;
42
opt.initFrom(widget());
43
return
opt.rect;
44
}
45
46
// --------------- LabelTaskMenu
47
48
LabelTaskMenu
::LabelTaskMenu(QLabel *label, QObject *parent)
49
: QDesignerTaskMenu(label, parent),
50
m_label(label),
51
m_editRichTextAction(
new
QAction(tr(
"Change rich text..."
),
this
)),
52
m_editPlainTextAction(
new
QAction(tr(
"Change plain text..."
),
this
))
53
{
54
LabelTaskMenuInlineEditor
*editor =
new
LabelTaskMenuInlineEditor
(label,
this
);
55
connect(m_editPlainTextAction, &QAction::triggered, editor, &LabelTaskMenuInlineEditor::editText);
56
m_taskActions.append(m_editPlainTextAction);
57
58
connect(m_editRichTextAction, &QAction::triggered,
this
, &LabelTaskMenu::editRichText);
59
m_taskActions.append(m_editRichTextAction);
60
61
QAction *sep =
new
QAction(
this
);
62
sep->setSeparator(
true
);
63
m_taskActions.append(sep);
64
}
65
66
QAction
*
LabelTaskMenu
::
preferredEditAction
()
const
67
{
68
if
(m_label->textFormat () == Qt::PlainText)
return
m_editPlainTextAction;
69
return
Qt::mightBeRichText(m_label->text()) ? m_editRichTextAction : m_editPlainTextAction;
70
}
71
72
QList
<
QAction
*>
LabelTaskMenu
::
taskActions
()
const
73
{
74
return
m_taskActions + QDesignerTaskMenu::taskActions();
75
}
76
77
void
LabelTaskMenu
::editRichText()
78
{
79
changeTextProperty(textPropertyC, QString(), MultiSelectionMode, m_label->textFormat());
80
}
81
82
}
83
QT_END_NAMESPACE
qdesigner_internal::LabelTaskMenuInlineEditor
Definition
label_taskmenu.cpp:26
qdesigner_internal::LabelTaskMenuInlineEditor::editRectangle
QRect editRectangle() const override
Definition
label_taskmenu.cpp:39
qdesigner_internal::LabelTaskMenuInlineEditor::LabelTaskMenuInlineEditor
LabelTaskMenuInlineEditor(QLabel *button, QObject *parent)
Definition
label_taskmenu.cpp:34
qdesigner_internal::LabelTaskMenu
Definition
label_taskmenu.h:21
qdesigner_internal::LabelTaskMenu::taskActions
QList< QAction * > taskActions() const override
Definition
label_taskmenu.cpp:72
qdesigner_internal::LabelTaskMenu::preferredEditAction
QAction * preferredEditAction() const override
Definition
label_taskmenu.cpp:66
qdesigner_internal::TaskMenuInlineEditor
Definition
inplace_editor.h:42
textPropertyC
static constexpr auto textPropertyC
Definition
label_taskmenu.cpp:20
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
qdesigner_internal::ValidationRichText
@ ValidationRichText
Definition
shared_enums_p.h:30
qttools
src
designer
src
components
taskmenu
label_taskmenu.cpp
Generated on
for Qt by
1.18.0