1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Designer of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#include "signalsloteditor_tool.h"
30#include "signalsloteditor.h"
31
32#include <QtDesigner/private/ui4_p.h>
33#include <QtDesigner/abstractformwindow.h>
34
35#include <QtWidgets/qaction.h>
36#include <QtCore/qdebug.h>
37
38QT_BEGIN_NAMESPACE
39
40using namespace qdesigner_internal;
41
42SignalSlotEditorTool::SignalSlotEditorTool(QDesignerFormWindowInterface *formWindow, QObject *parent)
43 : QDesignerFormWindowToolInterface(parent),
44 m_formWindow(formWindow),
45 m_action(new QAction(tr(s: "Edit Signals/Slots"), this))
46{
47}
48
49SignalSlotEditorTool::~SignalSlotEditorTool() = default;
50
51QDesignerFormEditorInterface *SignalSlotEditorTool::core() const
52{
53 return m_formWindow->core();
54}
55
56QDesignerFormWindowInterface *SignalSlotEditorTool::formWindow() const
57{
58 return m_formWindow;
59}
60
61bool SignalSlotEditorTool::handleEvent(QWidget *widget, QWidget *managedWidget, QEvent *event)
62{
63 Q_UNUSED(widget);
64 Q_UNUSED(managedWidget);
65 Q_UNUSED(event);
66
67 return false;
68}
69
70QWidget *SignalSlotEditorTool::editor() const
71{
72 if (!m_editor) {
73 Q_ASSERT(formWindow() != nullptr);
74 m_editor = new qdesigner_internal::SignalSlotEditor(formWindow(), nullptr);
75 connect(sender: formWindow(), signal: &QDesignerFormWindowInterface::mainContainerChanged,
76 receiver: m_editor.data(), slot: &SignalSlotEditor::setBackground);
77 connect(sender: formWindow(), signal: &QDesignerFormWindowInterface::changed,
78 receiver: m_editor.data(), slot: &SignalSlotEditor::updateBackground);
79 }
80
81 return m_editor;
82}
83
84QAction *SignalSlotEditorTool::action() const
85{
86 return m_action;
87}
88
89void SignalSlotEditorTool::activated()
90{
91 m_editor->enableUpdateBackground(enable: true);
92}
93
94void SignalSlotEditorTool::deactivated()
95{
96 m_editor->enableUpdateBackground(enable: false);
97}
98
99void SignalSlotEditorTool::saveToDom(DomUI *ui, QWidget*)
100{
101 ui->setElementConnections(m_editor->toUi());
102}
103
104void SignalSlotEditorTool::loadFromDom(DomUI *ui, QWidget *mainContainer)
105{
106 m_editor->fromUi(connections: ui->elementConnections(), parent: mainContainer);
107}
108
109QT_END_NAMESPACE
110

source code of qttools/src/designer/src/components/signalsloteditor/signalsloteditor_tool.cpp