summaryrefslogtreecommitdiff
path: root/src/VBox/Frontends/VirtualBox/src/settings/editors/UINetworkSettingsEditor.h
blob: 9da436014ce399380ecddc5ca687a1dd6b10389b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/* $Id$ */
/** @file
 * VBox Qt GUI - UINetworkSettingsEditor class declaration.
 */

/*
 * Copyright (C) 2019-2022 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#ifndef FEQT_INCLUDED_SRC_settings_editors_UINetworkSettingsEditor_h
#define FEQT_INCLUDED_SRC_settings_editors_UINetworkSettingsEditor_h
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

/* Qt includes: */
#include <QWidget>

/* GUI includes: */
#include "QIWithRetranslateUI.h"
#include "UILibraryDefs.h"
#include "UIPortForwardingTable.h"

/* COM includes: */
#include "COMEnums.h"

/* Forward declarations: */
class QCheckBox;
class UINetworkAttachmentEditor;
class UINetworkFeaturesEditor;

/** QWidget subclass used as a network settings editor. */
class SHARED_LIBRARY_STUFF UINetworkSettingsEditor : public QIWithRetranslateUI<QWidget>
{
    Q_OBJECT;

signals:

    /** @name Attachment editor stuff
     * @{ */
        /** Notifies about feature state changed. */
        void sigFeatureStateChanged();
        /** Notifies about attachment type changed. */
        void sigAttachmentTypeChanged();
        /** Notifies about alternative name changed. */
        void sigAlternativeNameChanged();
    /** @} */

    /** @name Features editor stuff
     * @{ */
        /** Notifies about the advanced button state change to @a fExpanded. */
        void sigAdvancedButtonStateChange(bool fExpanded);
        /** Notifies about MAC address changed. */
        void sigMACAddressChanged();
    /** @} */

public:

    /** Constructs editor passing @a pParent to the base-class. */
    UINetworkSettingsEditor(QWidget *pParent = 0);

    /** @name General stuff
     * @{ */
        /** Defines whether feature is @a fEnabled. */
        void setFeatureEnabled(bool fEnabled);
        /** Returns whether feature is enabled. */
        bool isFeatureEnabled() const;

        /** Defines whether feature @a fAvailable. */
        void setFeatureAvailable(bool fAvailable);
    /** @} */

    /** @name Attachment editor stuff
     * @{ */
        /** Defines value @a enmType. */
        void setValueType(KNetworkAttachmentType enmType);
        /** Returns value type. */
        KNetworkAttachmentType valueType() const;

        /** Defines value @a names for specified @a enmType. */
        void setValueNames(KNetworkAttachmentType enmType, const QStringList &names);
        /** Defines value @a strName for specified @a enmType. */
        void setValueName(KNetworkAttachmentType enmType, const QString &strName);
        /** Returns current name for specified @a enmType. */
        QString valueName(KNetworkAttachmentType enmType) const;

        /** Defines whether attachment options @a fAvailable. */
        void setAttachmentOptionsAvailable(bool fAvailable);
    /** @} */

    /** @name Features editor stuff
     * @{ */
        /** Defines whether advanced button @a fExpanded. */
        void setAdvancedButtonExpanded(bool fExpanded);
        /** Returns whether advanced button expanded. */
        bool advancedButtonExpanded() const;

        /** Defines adapter @a enmType. */
        void setAdapterType(const KNetworkAdapterType &enmType);
        /** Returns adapter type. */
        KNetworkAdapterType adapterType() const;

        /** Defines promiscuous @a enmMode. */
        void setPromiscuousMode(const KNetworkAdapterPromiscModePolicy &enmMode);
        /** Returns promiscuous mode. */
        KNetworkAdapterPromiscModePolicy promiscuousMode() const;

        /** Defines MAC @a strAddress. */
        void setMACAddress(const QString &strAddress);
        /** Returns MAC address. */
        QString macAddress() const;

        /** Defines generic @a strProperties. */
        void setGenericProperties(const QString &strProperties);
        /** Returns generic properties. */
        QString genericProperties() const;

        /** Defines whether cable is @a fConnected. */
        void setCableConnected(bool fConnected);
        /** Returns whether cable is connected. */
        bool cableConnected() const;

        /** Defines list of port forwarding @a rules. */
        void setPortForwardingRules(const UIPortForwardingDataList &rules);
        /** Returns list of port forwarding rules. */
        UIPortForwardingDataList portForwardingRules() const;

        /** Defines whether advanced options @a fAvailable. */
        void setAdvancedOptionsAvailable(bool fAvailable);
        /** Defines whether adapter options @a fAvailable. */
        void setAdapterOptionsAvailable(bool fAvailable);
        /** Defines whether promiscuous options @a fAvailable. */
        void setPromiscuousOptionsAvailable(bool fAvailable);
        /** Defines whether MAC options @a fAvailable. */
        void setMACOptionsAvailable(bool fAvailable);
        /** Defines whether generic properties @a fAvailable. */
        void setGenericPropertiesAvailable(bool fAvailable);
        /** Defines whether cable options @a fAvailable. */
        void setCableOptionsAvailable(bool fAvailable);
        /** Defines whether forwarding options @a fAvailable. */
        void setForwardingOptionsAvailable(bool fAvailable);
    /** @} */

protected:

    /** Handles translation event. */
    virtual void retranslateUi() RT_OVERRIDE;

private slots:

    /** Handles feature toggling. */
    void sltHandleFeatureToggled();
    /** Handles adapter attachment type change. */
    void sltHandleAttachmentTypeChange();

private:

    /** Prepares all. */
    void prepare();
    /** Prepares widgets. */
    void prepareWidgets();
    /** Prepares connections. */
    void prepareConnections();

    /** Updates feature availability. */
    void updateFeatureAvailability();

    /** @name Values
     * @{ */
        /** Holds whether feature is enabled. */
        bool  m_fFeatureEnabled;
    /** @} */

    /** @name Widgets
     * @{ */
        /** Holds the feature check-box instance. */
        QCheckBox                 *m_pCheckboxFeature;
        /** Holds the settings widget instance. */
        QWidget                   *m_pWidgetSettings;
        /** Holds the network attachment editor instance. */
        UINetworkAttachmentEditor *m_pEditorNetworkAttachment;
        /** Holds the network features editor instance. */
        UINetworkFeaturesEditor   *m_pEditorNetworkFeatures;
    /** @} */
};

#endif /* !FEQT_INCLUDED_SRC_settings_editors_UINetworkSettingsEditor_h */