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
combobox_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
"combobox_taskmenu.h"
6
#
include
"listwidgeteditor.h"
7
#
include
"qdesigner_utils_p.h"
8
#
include
<
qdesigner_command_p
.
h
>
9
10
#
include
<
QtDesigner
/
abstractformwindow
.
h
>
11
12
#
include
<
QtWidgets
/
qstyle
.
h
>
13
#
include
<
QtWidgets
/
qlineedit
.
h
>
14
#
include
<
QtWidgets
/
qfontcombobox
.
h
>
15
#
include
<
QtWidgets
/
qstyleoption
.
h
>
16
17
#
include
<
QtGui
/
qaction
.
h
>
18
19
#
include
<
QtCore
/
qcoreevent
.
h
>
20
#
include
<
QtCore
/
qvariant
.
h
>
21
#
include
<
QtCore
/
qdebug
.
h
>
22
23
QT_BEGIN_NAMESPACE
24
25
namespace
qdesigner_internal
{
26
27
ComboBoxTaskMenu
::ComboBoxTaskMenu(QComboBox *button, QObject *parent)
28
: QDesignerTaskMenu(button, parent),
29
m_comboBox(button)
30
{
31
m_editItemsAction =
new
QAction(
this
);
32
m_editItemsAction->setText(tr(
"Edit Items..."
));
33
connect(m_editItemsAction, &QAction::triggered,
this
, &ComboBoxTaskMenu::editItems);
34
m_taskActions.append(m_editItemsAction);
35
36
QAction *sep =
new
QAction(
this
);
37
sep->setSeparator(
true
);
38
m_taskActions.append(sep);
39
}
40
41
ComboBoxTaskMenu
::~
ComboBoxTaskMenu
() =
default
;
42
43
QAction
*
ComboBoxTaskMenu
::
preferredEditAction
()
const
44
{
45
return
m_editItemsAction;
46
}
47
48
QList
<
QAction
*>
ComboBoxTaskMenu
::
taskActions
()
const
49
{
50
return
m_taskActions + QDesignerTaskMenu::taskActions();
51
}
52
53
void
ComboBoxTaskMenu
::editItems()
54
{
55
m_formWindow = QDesignerFormWindowInterface::findFormWindow(m_comboBox);
56
if
(m_formWindow.isNull())
57
return
;
58
59
Q_ASSERT(m_comboBox !=
nullptr
);
60
61
ListWidgetEditor
dlg(m_formWindow, m_comboBox->window());
62
ListContents
oldItems = dlg.fillContentsFromComboBox(m_comboBox);
63
if
(dlg.exec() == QDialog::Accepted) {
64
ListContents
items = dlg.contents();
65
if
(items != oldItems) {
66
ChangeListContentsCommand *cmd =
new
ChangeListContentsCommand(m_formWindow);
67
cmd->init(m_comboBox, oldItems, items);
68
cmd->setText(tr(
"Change Combobox Contents"
));
69
m_formWindow->commandHistory()->push(cmd);
70
}
71
}
72
}
73
74
ComboBoxTaskMenuFactory
::ComboBoxTaskMenuFactory(
const
QString &iid, QExtensionManager *extensionManager) :
75
ExtensionFactory<QDesignerTaskMenuExtension, QComboBox, ComboBoxTaskMenu>(iid, extensionManager)
76
{
77
}
78
79
QComboBox *
ComboBoxTaskMenuFactory
::
checkObject
(QObject *qObject)
const
80
{
81
QComboBox *combo = qobject_cast<QComboBox*>(qObject);
82
if
(!combo)
83
return
nullptr
;
84
if
(qobject_cast<QFontComboBox*>(combo))
85
return
nullptr
;
86
return
combo;
87
}
88
89
void
ComboBoxTaskMenu
::updateSelection()
90
{
91
if
(m_editor)
92
m_editor->deleteLater();
93
}
94
95
}
// namespace qdesigner_internal
96
97
QT_END_NAMESPACE
qdesigner_internal::ComboBoxTaskMenuFactory
Definition
combobox_taskmenu.h:45
qdesigner_internal::ComboBoxTaskMenuFactory::checkObject
QComboBox * checkObject(QObject *qObject) const override
Definition
combobox_taskmenu.cpp:79
qdesigner_internal::ComboBoxTaskMenu
Definition
combobox_taskmenu.h:22
qdesigner_internal::ComboBoxTaskMenu::~ComboBoxTaskMenu
~ComboBoxTaskMenu() override
qdesigner_internal::ComboBoxTaskMenu::taskActions
QList< QAction * > taskActions() const override
Definition
combobox_taskmenu.cpp:48
qdesigner_internal::ComboBoxTaskMenu::preferredEditAction
QAction * preferredEditAction() const override
Definition
combobox_taskmenu.cpp:43
qdesigner_internal::ListWidgetEditor
Definition
listwidgeteditor.h:22
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::ListContents
Definition
qdesigner_command_p.h:841
qttools
src
designer
src
components
taskmenu
combobox_taskmenu.cpp
Generated on
for Qt by
1.18.0