Changeset 48458 in vbox
- Timestamp:
- Sep 12, 2013 4:26:07 PM (11 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 7 edited
- 3 copied
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r48273 r48458 351 351 src/settings/global/UIGlobalSettingsDisplay.h \ 352 352 src/settings/global/UIGlobalSettingsNetwork.h \ 353 src/settings/global/UIGlobalSettingsNetworkDetails.h \ 353 src/settings/global/UIGlobalSettingsNetworkDetailsNAT.h \ 354 src/settings/global/UIGlobalSettingsNetworkDetailsHost.h \ 354 355 src/settings/global/UIGlobalSettingsProxy.h \ 355 356 src/settings/global/UIGlobalSettingsUpdate.h \ … … 604 605 src/settings/global/UIGlobalSettingsDisplay.cpp \ 605 606 src/settings/global/UIGlobalSettingsNetwork.cpp \ 606 src/settings/global/UIGlobalSettingsNetworkDetails.cpp \ 607 src/settings/global/UIGlobalSettingsNetworkDetailsNAT.cpp \ 608 src/settings/global/UIGlobalSettingsNetworkDetailsHost.cpp \ 607 609 src/settings/global/UIGlobalSettingsProxy.cpp \ 608 610 src/settings/global/UIGlobalSettingsUpdate.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/VBoxUI.pro
r45212 r48458 34 34 src/settings/global/UIGlobalSettingsDisplay.ui \ 35 35 src/settings/global/UIGlobalSettingsNetwork.ui \ 36 src/settings/global/UIGlobalSettingsNetworkDetails.ui \ 36 src/settings/global/UIGlobalSettingsNetworkDetailsNAT.ui \ 37 src/settings/global/UIGlobalSettingsNetworkDetailsHost.ui \ 37 38 src/settings/global/UIGlobalSettingsExtension.ui \ 38 39 src/settings/global/UIGlobalSettingsProxy.ui \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r48316 r48458 884 884 } 885 885 886 bool UIMessageCenter::confirmHostInterfaceRemoval(const QString &strName, QWidget *pParent /*= 0*/) const 886 bool UIMessageCenter::confirmNATNetworkRemoval(const QString &strName, QWidget *pParent /*= 0*/) const 887 { 888 return questionBinary(pParent, MessageType_Question, 889 tr("<p>Do you want to remove the NAT network <nobr><b>%1</b>?</nobr></p>" 890 "<p><b>Note:</b> this network may be in use by one or more " 891 "virtual network adapters belonging to one of your VMs. " 892 "After it is removed, these adapters will no longer be usable until " 893 "you correct their settings by either choosing a different network " 894 "name or a different adapter attachment type.</p>") 895 .arg(strName), 896 0 /* auto-confirm id */, 897 tr("Remove")); 898 } 899 900 bool UIMessageCenter::confirmHostOnlyInterfaceRemoval(const QString &strName, QWidget *pParent /*= 0*/) const 887 901 { 888 902 return questionBinary(pParent, MessageType_Question, … … 898 912 0 /* auto-confirm id */, 899 913 tr("Remove")); 914 } 915 916 void UIMessageCenter::cannotCreateNATNetwork(const CVirtualBox &vbox, QWidget *pParent /*= 0*/) 917 { 918 error(pParent, MessageType_Error, 919 tr("Failed to create NAT network."), 920 formatErrorInfo(vbox)); 921 } 922 923 void UIMessageCenter::cannotRemoveNATNetwork(const CVirtualBox &vbox, const QString &strNetworkName, QWidget *pParent /*= 0*/) 924 { 925 error(pParent, MessageType_Error, 926 tr("Failed to remove NAT network <b>%1</b>.") 927 .arg(strNetworkName), 928 formatErrorInfo(vbox)); 929 } 930 931 void UIMessageCenter::cannotCreateDHCPServer(const CVirtualBox &vbox, QWidget *pParent /*= 0*/) 932 { 933 error(pParent, MessageType_Error, 934 tr("Failed to create DHCP server."), 935 formatErrorInfo(vbox)); 936 } 937 938 void UIMessageCenter::cannotRemoveDHCPServer(const CVirtualBox &vbox, const QString &strInterfaceName, QWidget *pParent /*= 0*/) 939 { 940 error(pParent, MessageType_Error, 941 tr("Failed to remove DHCP server for network interface <b>%1</b>.") 942 .arg(strInterfaceName), 943 formatErrorInfo(vbox)); 900 944 } 901 945 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r48022 r48458 211 211 212 212 /* API: Global settings warnings: */ 213 bool confirmHostInterfaceRemoval(const QString &strName, QWidget *pParent = 0) const; 213 bool confirmNATNetworkRemoval(const QString &strName, QWidget *pParent = 0) const; 214 bool confirmHostOnlyInterfaceRemoval(const QString &strName, QWidget *pParent = 0) const; 215 void cannotCreateNATNetwork(const CVirtualBox &vbox, QWidget *pParent = 0); 216 void cannotRemoveNATNetwork(const CVirtualBox &vbox, const QString &strNetworkName, QWidget *pParent = 0); 217 void cannotCreateDHCPServer(const CVirtualBox &vbox, QWidget *pParent = 0); 218 void cannotRemoveDHCPServer(const CVirtualBox &vbox, const QString &strInterfaceName, QWidget *pParent = 0); 214 219 void cannotCreateHostInterface(const CHost &host, QWidget *pParent = 0); 215 220 void cannotCreateHostInterface(const CProgress &progress, QWidget *pParent = 0); -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.cpp
r47944 r48458 7 7 8 8 /* 9 * Copyright (C) 2009-201 2Oracle Corporation9 * Copyright (C) 2009-2013 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 23 23 24 24 /* GUI includes: */ 25 #include " QIWidgetValidator.h"25 #include "VBoxGlobal.h" 26 26 #include "UIIconPool.h" 27 #include "UIMessageCenter.h" 27 28 #include "UIGlobalSettingsNetwork.h" 28 #include "UIGlobalSettingsNetworkDetails.h" 29 #include "VBoxGlobal.h" 30 #include "UIMessageCenter.h" 29 #include "UIGlobalSettingsNetworkDetailsNAT.h" 30 #include "UIGlobalSettingsNetworkDetailsHost.h" 31 31 32 32 /* COM includes: */ 33 #include "CNATNetwork.h" 33 34 #include "CHostNetworkInterface.h" 34 35 #include "CDHCPServer.h" 35 36 36 /* Host-network item constructor: */ 37 UIHostInterfaceItem::UIHostInterfaceItem() 37 /* Other VBox includes: */ 38 #include "iprt/cidr.h" 39 40 41 /* Global settings / Network page / NAT network item: */ 42 class UIItemNetworkNAT : public QTreeWidgetItem 43 { 44 public: 45 46 /* Constructor: */ 47 UIItemNetworkNAT(); 48 49 /* API: Get/return data to/form items: */ 50 void fetchNetworkData(const UIDataNetworkNAT &data); 51 void uploadNetworkData(UIDataNetworkNAT &data); 52 53 /* API: Validation stuff: */ 54 bool validate(UIValidationMessage &message); 55 56 /* API: Update stuff: */ 57 void updateInfo(); 58 59 /* API: Network item getters: */ 60 QString name() const { return m_data.m_strName; } 61 QString newName() const { return m_data.m_strNewName; } 62 63 private: 64 65 /* Variable: Network data: */ 66 UIDataNetworkNAT m_data; 67 }; 68 69 70 /* Global settings / Network page / Host network item: */ 71 class UIItemNetworkHost : public QTreeWidgetItem 72 { 73 public: 74 75 /* Constructor: */ 76 UIItemNetworkHost(); 77 78 /* API: Get/return data to/form items: */ 79 void fetchNetworkData(const UIDataNetworkHost &data); 80 void uploadNetworkData(UIDataNetworkHost &data); 81 82 /* API: Validation stuff: */ 83 bool validate(UIValidationMessage &message); 84 85 /* API: Update stuff: */ 86 void updateInfo(); 87 88 /* API: Network item getters: */ 89 QString name() const { return m_data.m_interface.m_strName; } 90 91 private: 92 93 /* Variable: Network data: */ 94 UIDataNetworkHost m_data; 95 }; 96 97 98 UIItemNetworkNAT::UIItemNetworkNAT() 38 99 : QTreeWidgetItem() 39 100 { 40 101 } 41 102 42 /* Get data to item: */ 43 void UIHostInterfaceItem::fetchNetworkData(const UIHostNetworkData &data) 44 { 45 /* Fetch from cache: */ 103 void UIItemNetworkNAT::fetchNetworkData(const UIDataNetworkNAT &data) 104 { 105 /* Get from cache: */ 46 106 m_data = data; 47 107 48 /* Update tool-tip: */108 /* Fetch info: */ 49 109 updateInfo(); 50 110 } 51 111 52 /* Return data from item: */ 53 void UIHostInterfaceItem::uploadNetworkData(UIHostNetworkData &data) 54 { 55 /* Upload to cache: */ 112 void UIItemNetworkNAT::uploadNetworkData(UIDataNetworkNAT &data) 113 { 114 /* Put to cache: */ 56 115 data = m_data; 57 116 } 58 117 59 /* Validation stuff: */ 60 bool UIHostInterfaceItem::validate(QList<UIValidationMessage> &messages) 118 bool UIItemNetworkNAT::validate(UIValidationMessage &message) 61 119 { 62 120 /* Pass by default: */ 63 121 bool fPass = true; 64 122 65 /* Prepare message: */ 66 UIValidationMessage message; 67 68 /* Host-only interface validation: */ 123 /* NAT network name validation: */ 124 bool fNameValid = true; 125 if (m_data.m_strNewName.isEmpty()) 126 { 127 /* Emptiness validation: */ 128 message.second << UIGlobalSettingsNetwork::tr("The new name for NAT network previously called <b>%1</b> is empty.").arg(m_data.m_strName); 129 fNameValid = false; 130 fPass = false; 131 } 132 133 /* NAT network CIDR validation: */ 134 if (m_data.m_strCIDR.isEmpty()) 135 { 136 /* Emptiness validation: */ 137 if (fNameValid) 138 message.second << UIGlobalSettingsNetwork::tr("The CIDR for NAT network <b>%1</b> is empty.").arg(m_data.m_strNewName); 139 else 140 message.second << UIGlobalSettingsNetwork::tr("The CIDR for NAT network previously called <b>%1</b> is empty.").arg(m_data.m_strName); 141 fPass = false; 142 } 143 else 144 { 145 /* Correctness validation: */ 146 RTNETADDRIPV4 network, mask; 147 int rc = RTCidrStrToIPv4(m_data.m_strCIDR.toAscii().constData(), &network, &mask); 148 if (RT_FAILURE(rc)) 149 { 150 if (fNameValid) 151 message.second << UIGlobalSettingsNetwork::tr("The CIDR <i>%1</i> for NAT network <b>%2</b> is invalid.") 152 .arg(m_data.m_strCIDR, m_data.m_strNewName); 153 else 154 message.second << UIGlobalSettingsNetwork::tr("The CIDR <i>%1</i> for NAT network previously called <b>%2</b> is invalid.") 155 .arg(m_data.m_strCIDR, m_data.m_strName); 156 fPass = false; 157 } 158 } 159 160 /* Return result: */ 161 return fPass; 162 } 163 164 void UIItemNetworkNAT::updateInfo() 165 { 166 /* Compose item name/tool-tip: */ 167 QString strHeader("<tr><td><nobr>%1: </nobr></td><td><nobr>%2</nobr></td></tr>"); 168 QString strSubHeader("<tr><td><nobr> %1: </nobr></td><td><nobr>%2</nobr></td></tr>"); 169 QString strToolTip; 170 171 /* Item name was not changed: */ 172 if (m_data.m_strNewName == m_data.m_strName) 173 { 174 /* Just use the old one: */ 175 setText(0, m_data.m_strName); 176 strToolTip += strHeader.arg(UIGlobalSettingsNetwork::tr("Network Name"), m_data.m_strName); 177 } 178 /* If name was changed: */ 179 else 180 { 181 /* We should explain that: */ 182 const QString oldName = m_data.m_strName; 183 const QString newName = m_data.m_strNewName.isEmpty() ? UIGlobalSettingsNetwork::tr("[empty]") : m_data.m_strNewName; 184 setText(0, UIGlobalSettingsNetwork::tr("%1 (renamed from %2)").arg(newName, oldName)); 185 strToolTip += strHeader.arg(UIGlobalSettingsNetwork::tr("Old Network Name"), m_data.m_strName); 186 strToolTip += strHeader.arg(UIGlobalSettingsNetwork::tr("New Network Name"), m_data.m_strNewName); 187 } 188 189 /* Other tool-tip information: */ 190 strToolTip += strHeader.arg(UIGlobalSettingsNetwork::tr("Network CIDR"), m_data.m_strCIDR); 191 strToolTip += strHeader.arg(UIGlobalSettingsNetwork::tr("Supports DHCP"), 192 m_data.m_fSupportsDHCP ? UIGlobalSettingsNetwork::tr("yes") : UIGlobalSettingsNetwork::tr("no")); 193 strToolTip += strHeader.arg(UIGlobalSettingsNetwork::tr("Supports IPv6"), 194 m_data.m_fSupportsIPv6 ? UIGlobalSettingsNetwork::tr("yes") : UIGlobalSettingsNetwork::tr("no")); 195 if (m_data.m_fSupportsIPv6 && m_data.m_fAdvertiseDefaultIPv6Route) 196 strToolTip += strSubHeader.arg(UIGlobalSettingsNetwork::tr("Default IPv6 route"), UIGlobalSettingsNetwork::tr("yes")); 197 198 /* Assign tool-tip finally: */ 199 setToolTip(0, strToolTip); 200 } 201 202 203 UIItemNetworkHost::UIItemNetworkHost() 204 : QTreeWidgetItem() 205 { 206 } 207 208 void UIItemNetworkHost::fetchNetworkData(const UIDataNetworkHost &data) 209 { 210 /* Get from cache: */ 211 m_data = data; 212 213 /* Fetch info: */ 214 updateInfo(); 215 } 216 217 void UIItemNetworkHost::uploadNetworkData(UIDataNetworkHost &data) 218 { 219 /* Put to cache: */ 220 data = m_data; 221 } 222 223 bool UIItemNetworkHost::validate(UIValidationMessage &message) 224 { 225 /* Pass by default: */ 226 bool fPass = true; 227 228 /* Host interface validation: */ 69 229 if (!m_data.m_interface.m_fDhcpClientEnabled) 70 230 { … … 124 284 } 125 285 126 /* Serialize message: */127 if (!message.second.isEmpty())128 messages << message;129 130 286 /* Return result: */ 131 287 return fPass; 132 288 } 133 289 134 QString UIHostInterfaceItem::updateInfo()135 { 136 /* Update text: */290 void UIItemNetworkHost::updateInfo() 291 { 292 /* Compose item name/tool-tip: */ 137 293 setText(0, m_data.m_interface.m_strName); 138 139 /* Update information label: */140 294 QString strHeader("<tr><td><nobr>%1: </nobr></td><td><nobr>%2</nobr></td></tr>"); 141 295 QString strSubHeader("<tr><td><nobr> %1: </nobr></td><td><nobr>%2</nobr></td></tr>"); 142 QString strData, strToolTip, strBuffer; 143 144 /* Host-only interface information: */ 145 strBuffer = strHeader.arg(UIGlobalSettingsNetwork::tr("Adapter")) 146 .arg(m_data.m_interface.m_fDhcpClientEnabled ? UIGlobalSettingsNetwork::tr("Automatically configured", "interface") 147 : UIGlobalSettingsNetwork::tr("Manually configured", "interface")); 148 strData += strBuffer; 149 strToolTip += strBuffer; 296 QString strToolTip; 297 298 /* Host interface information: */ 299 strToolTip += strHeader.arg(UIGlobalSettingsNetwork::tr("Adapter")) 300 .arg(m_data.m_interface.m_fDhcpClientEnabled ? 301 UIGlobalSettingsNetwork::tr("Automatically configured", "interface") : 302 UIGlobalSettingsNetwork::tr("Manually configured", "interface")); 150 303 if (!m_data.m_interface.m_fDhcpClientEnabled) 151 304 { 152 strBuffer = strSubHeader.arg(UIGlobalSettingsNetwork::tr("IPv4 Address")) 153 .arg(m_data.m_interface.m_strInterfaceAddress.isEmpty() ? 154 UIGlobalSettingsNetwork::tr ("Not set", "address") : 155 m_data.m_interface.m_strInterfaceAddress) + 156 strSubHeader.arg(UIGlobalSettingsNetwork::tr("IPv4 Network Mask")) 157 .arg(m_data.m_interface.m_strInterfaceMask.isEmpty() ? 158 UIGlobalSettingsNetwork::tr ("Not set", "mask") : 159 m_data.m_interface.m_strInterfaceMask); 160 strToolTip += strBuffer; 305 strToolTip += strSubHeader.arg(UIGlobalSettingsNetwork::tr("IPv4 Address")) 306 .arg(m_data.m_interface.m_strInterfaceAddress.isEmpty() ? 307 UIGlobalSettingsNetwork::tr ("Not set", "address") : 308 m_data.m_interface.m_strInterfaceAddress) + 309 strSubHeader.arg(UIGlobalSettingsNetwork::tr("IPv4 Network Mask")) 310 .arg(m_data.m_interface.m_strInterfaceMask.isEmpty() ? 311 UIGlobalSettingsNetwork::tr ("Not set", "mask") : 312 m_data.m_interface.m_strInterfaceMask); 161 313 if (m_data.m_interface.m_fIpv6Supported) 162 314 { 163 strBuffer = strSubHeader.arg(UIGlobalSettingsNetwork::tr("IPv6 Address")) 164 .arg(m_data.m_interface.m_strInterfaceAddress6.isEmpty() ? 165 UIGlobalSettingsNetwork::tr("Not set", "address") : 166 m_data.m_interface.m_strInterfaceAddress6) + 167 strSubHeader.arg(UIGlobalSettingsNetwork::tr("IPv6 Network Mask Length")) 168 .arg(m_data.m_interface.m_strInterfaceMaskLength6.isEmpty() ? 169 UIGlobalSettingsNetwork::tr("Not set", "length") : 170 m_data.m_interface.m_strInterfaceMaskLength6); 171 strToolTip += strBuffer; 315 strToolTip += strSubHeader.arg(UIGlobalSettingsNetwork::tr("IPv6 Address")) 316 .arg(m_data.m_interface.m_strInterfaceAddress6.isEmpty() ? 317 UIGlobalSettingsNetwork::tr("Not set", "address") : 318 m_data.m_interface.m_strInterfaceAddress6) + 319 strSubHeader.arg(UIGlobalSettingsNetwork::tr("IPv6 Network Mask Length")) 320 .arg(m_data.m_interface.m_strInterfaceMaskLength6.isEmpty() ? 321 UIGlobalSettingsNetwork::tr("Not set", "length") : 322 m_data.m_interface.m_strInterfaceMaskLength6); 172 323 } 173 324 } 174 325 175 326 /* DHCP server information: */ 176 strBuffer = strHeader.arg(UIGlobalSettingsNetwork::tr("DHCP Server")) 177 .arg(m_data.m_dhcpserver.m_fDhcpServerEnabled ? 178 UIGlobalSettingsNetwork::tr("Enabled", "server") : 179 UIGlobalSettingsNetwork::tr("Disabled", "server")); 180 strData += strBuffer; 181 strToolTip += strBuffer; 327 strToolTip += strHeader.arg(UIGlobalSettingsNetwork::tr("DHCP Server")) 328 .arg(m_data.m_dhcpserver.m_fDhcpServerEnabled ? 329 UIGlobalSettingsNetwork::tr("Enabled", "server") : 330 UIGlobalSettingsNetwork::tr("Disabled", "server")); 182 331 if (m_data.m_dhcpserver.m_fDhcpServerEnabled) 183 332 { 184 str Buffer= strSubHeader.arg(UIGlobalSettingsNetwork::tr("Address"))185 .arg(m_data.m_dhcpserver.m_strDhcpServerAddress.isEmpty() ?186 UIGlobalSettingsNetwork::tr("Not set", "address") :187 m_data.m_dhcpserver.m_strDhcpServerAddress) +188 strSubHeader.arg(UIGlobalSettingsNetwork::tr("Network Mask"))189 .arg(m_data.m_dhcpserver.m_strDhcpServerMask.isEmpty() ?190 UIGlobalSettingsNetwork::tr("Not set", "mask") :191 m_data.m_dhcpserver.m_strDhcpServerMask) +192 strSubHeader.arg(UIGlobalSettingsNetwork::tr("Lower Bound"))193 .arg(m_data.m_dhcpserver.m_strDhcpLowerAddress.isEmpty() ?194 UIGlobalSettingsNetwork::tr("Not set", "bound") :195 m_data.m_dhcpserver.m_strDhcpLowerAddress) +196 strSubHeader.arg(UIGlobalSettingsNetwork::tr("Upper Bound"))197 .arg(m_data.m_dhcpserver.m_strDhcpUpperAddress.isEmpty() ?198 UIGlobalSettingsNetwork::tr("Not set", "bound") :199 m_data.m_dhcpserver.m_strDhcpUpperAddress);200 strToolTip += strBuffer;201 } 202 333 strToolTip += strSubHeader.arg(UIGlobalSettingsNetwork::tr("Address")) 334 .arg(m_data.m_dhcpserver.m_strDhcpServerAddress.isEmpty() ? 335 UIGlobalSettingsNetwork::tr("Not set", "address") : 336 m_data.m_dhcpserver.m_strDhcpServerAddress) + 337 strSubHeader.arg(UIGlobalSettingsNetwork::tr("Network Mask")) 338 .arg(m_data.m_dhcpserver.m_strDhcpServerMask.isEmpty() ? 339 UIGlobalSettingsNetwork::tr("Not set", "mask") : 340 m_data.m_dhcpserver.m_strDhcpServerMask) + 341 strSubHeader.arg(UIGlobalSettingsNetwork::tr("Lower Bound")) 342 .arg(m_data.m_dhcpserver.m_strDhcpLowerAddress.isEmpty() ? 343 UIGlobalSettingsNetwork::tr("Not set", "bound") : 344 m_data.m_dhcpserver.m_strDhcpLowerAddress) + 345 strSubHeader.arg(UIGlobalSettingsNetwork::tr("Upper Bound")) 346 .arg(m_data.m_dhcpserver.m_strDhcpUpperAddress.isEmpty() ? 347 UIGlobalSettingsNetwork::tr("Not set", "bound") : 348 m_data.m_dhcpserver.m_strDhcpUpperAddress); 349 } 350 351 /* Assign tool-tip finally: */ 203 352 setToolTip(0, strToolTip); 204 205 return QString("<table>") + strData + QString("</table>"); 206 } 207 208 /* Network page constructor: */ 353 } 354 355 209 356 UIGlobalSettingsNetwork::UIGlobalSettingsNetwork() 210 : m_pAddAction(0), m_pDelAction(0), m_pEditAction(0) 357 : m_pActionAddNetworkNAT(0), m_pActionDelNetworkNAT(0), m_pActionEditNetworkNAT(0) 358 , m_pActionAddNetworkHost(0), m_pActionDelNetworkHost(0), m_pActionEditNetworkHost(0) 211 359 , m_fChanged(false) 212 360 { 213 361 /* Apply UI decorations: */ 214 Ui::UIGlobalSettingsNetwork::setupUi (this); 215 216 /* Setup tree-widget: */ 217 m_pInterfacesTree->header()->hide(); 218 m_pInterfacesTree->setContextMenuPolicy(Qt::CustomContextMenu); 219 220 /* Prepare toolbar: */ 221 m_pAddAction = new QAction(m_pInterfacesTree); 222 m_pDelAction = new QAction(m_pInterfacesTree); 223 m_pEditAction = new QAction(m_pInterfacesTree); 224 225 m_pAddAction->setShortcuts(QList<QKeySequence>() << QKeySequence("Ins") << QKeySequence("Ctrl+N")); 226 m_pDelAction->setShortcuts(QList<QKeySequence>() << QKeySequence("Del") << QKeySequence("Ctrl+R")); 227 m_pEditAction->setShortcuts(QList<QKeySequence>() << QKeySequence("Space") << QKeySequence("F2")); 228 229 m_pAddAction->setIcon(UIIconPool::iconSet(":/add_host_iface_16px.png", 230 ":/add_host_iface_disabled_16px.png")); 231 m_pDelAction->setIcon(UIIconPool::iconSet(":/remove_host_iface_16px.png", 232 ":/remove_host_iface_disabled_16px.png")); 233 m_pEditAction->setIcon(UIIconPool::iconSet(":/guesttools_16px.png", 234 ":/guesttools_disabled_16px.png")); 235 236 m_pActionsToolbar->setUsesTextLabel(false); 237 m_pActionsToolbar->setIconSize(QSize(16, 16)); 238 m_pActionsToolbar->setOrientation(Qt::Vertical); 239 m_pActionsToolbar->addAction(m_pAddAction); 240 m_pActionsToolbar->addAction(m_pDelAction); 241 m_pActionsToolbar->addAction(m_pEditAction); 242 243 /* Setup connections: */ 244 connect(m_pAddAction, SIGNAL(triggered(bool)), this, SLOT(sltAddInterface())); 245 connect(m_pDelAction, SIGNAL(triggered(bool)), this, SLOT(sltDelInterface())); 246 connect(m_pEditAction, SIGNAL(triggered(bool)), this, SLOT(sltEditInterface())); 247 connect(m_pInterfacesTree, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 248 this, SLOT(sltUpdateCurrentItem())); 249 connect(m_pInterfacesTree, SIGNAL(customContextMenuRequested(const QPoint&)), 250 this, SLOT(sltChowContextMenu(const QPoint&))); 251 connect(m_pInterfacesTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 252 this, SLOT(sltEditInterface())); 362 Ui::UIGlobalSettingsNetwork::setupUi(this); 363 364 /* Prepare NAT network tree-widget: */ 365 { 366 m_pTreeNetworkNAT->header()->hide(); 367 m_pTreeNetworkNAT->setContextMenuPolicy(Qt::CustomContextMenu); 368 connect(m_pTreeNetworkNAT, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 369 this, SLOT(sltHandleCurrentItemChangeNetworkNAT())); 370 connect(m_pTreeNetworkNAT, SIGNAL(customContextMenuRequested(const QPoint&)), 371 this, SLOT(sltShowContextMenuNetworkNAT(const QPoint&))); 372 connect(m_pTreeNetworkNAT, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 373 this, SLOT(sltEditNetworkNAT())); 374 } 375 /* Prepare Host network tree-widget: */ 376 { 377 m_pTreeNetworkHost->header()->hide(); 378 m_pTreeNetworkHost->setContextMenuPolicy(Qt::CustomContextMenu); 379 connect(m_pTreeNetworkHost, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), 380 this, SLOT(sltHandleCurrentItemChangeNetworkHost())); 381 connect(m_pTreeNetworkHost, SIGNAL(customContextMenuRequested(const QPoint&)), 382 this, SLOT(sltShowContextMenuNetworkHost(const QPoint&))); 383 connect(m_pTreeNetworkHost, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 384 this, SLOT(sltEditNetworkHost())); 385 } 386 387 /* Prepare actions: */ 388 m_pActionAddNetworkNAT = new QAction(m_pTreeNetworkNAT); 389 { 390 m_pActionAddNetworkNAT->setShortcutContext(Qt::WidgetWithChildrenShortcut); 391 m_pActionAddNetworkNAT->setShortcuts(QList<QKeySequence>() << QKeySequence("Ins") << QKeySequence("Ctrl+N")); 392 m_pActionAddNetworkNAT->setIcon(UIIconPool::iconSet(":/add_host_iface_16px.png", 393 ":/add_host_iface_disabled_16px.png")); 394 connect(m_pActionAddNetworkNAT, SIGNAL(triggered(bool)), this, SLOT(sltAddNetworkNAT())); 395 } 396 m_pActionDelNetworkNAT = new QAction(m_pTreeNetworkNAT); 397 { 398 m_pActionDelNetworkNAT->setShortcutContext(Qt::WidgetWithChildrenShortcut); 399 m_pActionDelNetworkNAT->setShortcuts(QList<QKeySequence>() << QKeySequence("Del") << QKeySequence("Ctrl+R")); 400 m_pActionDelNetworkNAT->setIcon(UIIconPool::iconSet(":/remove_host_iface_16px.png", 401 ":/remove_host_iface_disabled_16px.png")); 402 connect(m_pActionDelNetworkNAT, SIGNAL(triggered(bool)), this, SLOT(sltDelNetworkNAT())); 403 } 404 m_pActionEditNetworkNAT = new QAction(m_pTreeNetworkNAT); 405 { 406 m_pActionEditNetworkNAT->setShortcutContext(Qt::WidgetWithChildrenShortcut); 407 m_pActionEditNetworkNAT->setShortcuts(QList<QKeySequence>() << QKeySequence("Space") << QKeySequence("F2")); 408 m_pActionEditNetworkNAT->setIcon(UIIconPool::iconSet(":/guesttools_16px.png", 409 ":/guesttools_disabled_16px.png")); 410 connect(m_pActionEditNetworkNAT, SIGNAL(triggered(bool)), this, SLOT(sltEditNetworkNAT())); 411 } 412 m_pActionAddNetworkHost = new QAction(m_pTreeNetworkHost); 413 { 414 m_pActionAddNetworkHost->setShortcutContext(Qt::WidgetWithChildrenShortcut); 415 m_pActionAddNetworkHost->setShortcuts(QList<QKeySequence>() << QKeySequence("Ins") << QKeySequence("Ctrl+N")); 416 m_pActionAddNetworkHost->setIcon(UIIconPool::iconSet(":/add_host_iface_16px.png", 417 ":/add_host_iface_disabled_16px.png")); 418 connect(m_pActionAddNetworkHost, SIGNAL(triggered(bool)), this, SLOT(sltAddNetworkHost())); 419 } 420 m_pActionDelNetworkHost = new QAction(m_pTreeNetworkHost); 421 { 422 m_pActionDelNetworkHost->setShortcutContext(Qt::WidgetWithChildrenShortcut); 423 m_pActionDelNetworkHost->setShortcuts(QList<QKeySequence>() << QKeySequence("Del") << QKeySequence("Ctrl+R")); 424 m_pActionDelNetworkHost->setIcon(UIIconPool::iconSet(":/remove_host_iface_16px.png", 425 ":/remove_host_iface_disabled_16px.png")); 426 connect(m_pActionDelNetworkHost, SIGNAL(triggered(bool)), this, SLOT(sltDelNetworkHost())); 427 } 428 m_pActionEditNetworkHost = new QAction(m_pTreeNetworkHost); 429 { 430 m_pActionEditNetworkHost->setShortcutContext(Qt::WidgetWithChildrenShortcut); 431 m_pActionEditNetworkHost->setShortcuts(QList<QKeySequence>() << QKeySequence("Space") << QKeySequence("F2")); 432 m_pActionEditNetworkHost->setIcon(UIIconPool::iconSet(":/guesttools_16px.png", 433 ":/guesttools_disabled_16px.png")); 434 connect(m_pActionEditNetworkHost, SIGNAL(triggered(bool)), this, SLOT(sltEditNetworkHost())); 435 } 436 437 /* Prepare NAT network toolbar: */ 438 { 439 m_pToolbarNetworkNAT->setUsesTextLabel(false); 440 m_pToolbarNetworkNAT->setIconSize(QSize(16, 16)); 441 m_pToolbarNetworkNAT->setOrientation(Qt::Vertical); 442 m_pToolbarNetworkNAT->addAction(m_pActionAddNetworkNAT); 443 m_pToolbarNetworkNAT->addAction(m_pActionDelNetworkNAT); 444 m_pToolbarNetworkNAT->addAction(m_pActionEditNetworkNAT); 445 } 446 /* Prepare Host network toolbar: */ 447 { 448 m_pToolbarNetworkHost->setUsesTextLabel(false); 449 m_pToolbarNetworkHost->setIconSize(QSize(16, 16)); 450 m_pToolbarNetworkHost->setOrientation(Qt::Vertical); 451 m_pToolbarNetworkHost->addAction(m_pActionAddNetworkHost); 452 m_pToolbarNetworkHost->addAction(m_pActionDelNetworkHost); 453 m_pToolbarNetworkHost->addAction(m_pActionEditNetworkHost); 454 } 253 455 254 456 /* Apply language settings: */ … … 256 458 } 257 459 258 /* Load data to cache from corresponding external object(s),259 * this task COULD be performed in other than GUI thread: */260 460 void UIGlobalSettingsNetwork::loadToCacheFrom(QVariant &data) 261 461 { … … 263 463 UISettingsPageGlobal::fetchData(data); 264 464 265 /* Load to cache: */ 465 /* Load NAT networks to cache: */ 466 m_cache.m_networksNAT.clear(); 467 const CNATNetworkVector &networks = vboxGlobal().virtualBox().GetNATNetworks(); 468 foreach (const CNATNetwork &network, networks) 469 m_cache.m_networksNAT << generateDataNetworkNAT(network); 470 471 /* Load Host networks to cache: */ 472 m_cache.m_networksHost.clear(); 266 473 const CHostNetworkInterfaceVector &interfaces = vboxGlobal().host().GetNetworkInterfaces(); 267 for (int iNetworkIndex = 0; iNetworkIndex < interfaces.size(); ++iNetworkIndex) 268 { 269 const CHostNetworkInterface &iface = interfaces[iNetworkIndex]; 474 foreach (const CHostNetworkInterface &iface, interfaces) 270 475 if (iface.GetInterfaceType() == KHostNetworkInterfaceType_HostOnly) 271 appendCacheItem(iface); 272 } 476 m_cache.m_networksHost << generateDataNetworkHost(iface); 273 477 274 478 /* Upload properties & settings to data: */ … … 276 480 } 277 481 278 /* Load data to corresponding widgets from cache,279 * this task SHOULD be performed in GUI thread only: */280 482 void UIGlobalSettingsNetwork::getFromCache() 281 483 { 282 /* Fetch from cache: */ 283 for (int iNetworkIndex = 0; iNetworkIndex < m_cache.m_items.size(); ++iNetworkIndex) 284 appendListItem(m_cache.m_items[iNetworkIndex]); 285 /* Set first list item as current: */ 286 m_pInterfacesTree->setCurrentItem(m_pInterfacesTree->topLevelItem(0)); 287 sltUpdateCurrentItem(); 484 /* Fetch NAT networks from cache: */ 485 foreach (const UIDataNetworkNAT &network, m_cache.m_networksNAT) 486 createTreeItemNetworkNAT(network); 487 m_pTreeNetworkNAT->setCurrentItem(m_pTreeNetworkNAT->topLevelItem(0)); 488 sltHandleCurrentItemChangeNetworkNAT(); 489 490 /* Fetch Host networks from cache: */ 491 foreach (const UIDataNetworkHost &network, m_cache.m_networksHost) 492 createTreeItemNetworkHost(network); 493 m_pTreeNetworkHost->setCurrentItem(m_pTreeNetworkHost->topLevelItem(0)); 494 sltHandleCurrentItemChangeNetworkHost(); 288 495 289 496 /* Revalidate: */ … … 291 498 } 292 499 293 /* Save data from corresponding widgets to cache,294 * this task SHOULD be performed in GUI thread only: */295 500 void UIGlobalSettingsNetwork::putToCache() 296 501 { 297 /* Eraze cache: */ 298 m_cache.m_items.clear(); 299 /* Upload to cache: */ 300 for (int iNetworkIndex = 0; iNetworkIndex < m_pInterfacesTree->topLevelItemCount(); ++iNetworkIndex) 301 { 302 UIHostNetworkData data; 303 UIHostInterfaceItem *pItem = static_cast<UIHostInterfaceItem*>(m_pInterfacesTree->topLevelItem(iNetworkIndex)); 502 /* Upload NAT networks to cache: */ 503 m_cache.m_networksNAT.clear(); 504 for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkNAT->topLevelItemCount(); ++iNetworkIndex) 505 { 506 UIDataNetworkNAT data; 507 UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(iNetworkIndex)); 304 508 pItem->uploadNetworkData(data); 305 m_cache.m_items << data; 306 } 307 } 308 309 /* Save data from cache to corresponding external object(s), 310 * this task COULD be performed in other than GUI thread: */ 509 m_cache.m_networksNAT << data; 510 } 511 512 /* Upload Host networks to cache: */ 513 m_cache.m_networksHost.clear(); 514 for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkHost->topLevelItemCount(); ++iNetworkIndex) 515 { 516 UIDataNetworkHost data; 517 UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->topLevelItem(iNetworkIndex)); 518 pItem->uploadNetworkData(data); 519 m_cache.m_networksHost << data; 520 } 521 } 522 311 523 void UIGlobalSettingsNetwork::saveFromCacheTo(QVariant &data) 312 524 { … … 318 530 UISettingsPageGlobal::fetchData(data); 319 531 532 /* Save NAT networks from cache: */ 533 foreach (const UIDataNetworkNAT &data, m_cache.m_networksNAT) 534 saveCacheItemNetworkNAT(data); 535 536 /* Save Host networks from cache: */ 537 foreach (const UIDataNetworkHost &data, m_cache.m_networksHost) 538 saveCacheItemNetworkHost(data); 539 540 /* Upload properties & settings to data: */ 541 UISettingsPageGlobal::uploadData(data); 542 } 543 544 bool UIGlobalSettingsNetwork::validate(QList<UIValidationMessage> &messages) 545 { 546 /* Pass by default: */ 547 bool fPass = true; 548 549 /* Validate NAT network items: */ 550 { 551 /* Prepare message: */ 552 UIValidationMessage message; 553 message.first = VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(0)); 554 555 /* Validate items first: */ 556 for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkNAT->topLevelItemCount(); ++iNetworkIndex) 557 { 558 UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(iNetworkIndex)); 559 if (!pItem->validate(message)) 560 fPass = false; 561 } 562 563 /* And make sure item names are unique: */ 564 QList<QString> names; 565 for (int iItemIndex = 0; iItemIndex < m_pTreeNetworkNAT->topLevelItemCount(); ++iItemIndex) 566 { 567 UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(iItemIndex)); 568 const QString strItemName(pItem->newName()); 569 if (strItemName.isEmpty()) 570 continue; 571 if (!names.contains(strItemName)) 572 names << strItemName; 573 else 574 { 575 message.second << UIGlobalSettingsNetwork::tr("The name <b>%1</b> for NAT network on position <b>%2</b> is already in use.") 576 .arg(strItemName).arg(iItemIndex + 1); 577 fPass = false; 578 } 579 } 580 581 /* Serialize message: */ 582 if (!message.second.isEmpty()) 583 messages << message; 584 } 585 586 /* Validate Host network items: */ 587 { 588 /* Prepare message: */ 589 UIValidationMessage message; 590 message.first = VBoxGlobal::removeAccelMark(m_pTabWidget->tabText(1)); 591 592 /* Validate items only: */ 593 for (int iNetworkIndex = 0; iNetworkIndex < m_pTreeNetworkHost->topLevelItemCount(); ++iNetworkIndex) 594 { 595 UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->topLevelItem(iNetworkIndex)); 596 if (!pItem->validate(message)) 597 fPass = false; 598 } 599 600 /* Serialize message: */ 601 if (!message.second.isEmpty()) 602 messages << message; 603 } 604 605 /* Return result: */ 606 return fPass; 607 } 608 609 void UIGlobalSettingsNetwork::setOrderAfter(QWidget *pWidget) 610 { 611 setTabOrder(pWidget, m_pTabWidget->focusProxy()); 612 setTabOrder(m_pTabWidget->focusProxy(), m_pTreeNetworkNAT); 613 setTabOrder(m_pTreeNetworkNAT, m_pTreeNetworkHost); 614 } 615 616 void UIGlobalSettingsNetwork::retranslateUi() 617 { 618 /* Translate uic generated strings: */ 619 Ui::UIGlobalSettingsNetwork::retranslateUi(this); 620 621 /* NAT network actions: */ 622 { 623 /* Translate text: */ 624 m_pActionAddNetworkNAT->setText(tr("&Add NAT network")); 625 m_pActionDelNetworkNAT->setText(tr("&Remove NAT network")); 626 m_pActionEditNetworkNAT->setText(tr("&Edit NAT network")); 627 628 /* Recompose tool-tips: */ 629 m_pActionAddNetworkNAT->setToolTip(m_pActionAddNetworkNAT->text().remove('&') + 630 QString(" (%1)").arg(m_pActionAddNetworkNAT->shortcut().toString())); 631 m_pActionDelNetworkNAT->setToolTip(m_pActionDelNetworkNAT->text().remove('&') + 632 QString(" (%1)").arg(m_pActionDelNetworkNAT->shortcut().toString())); 633 m_pActionEditNetworkNAT->setToolTip(m_pActionEditNetworkNAT->text().remove('&') + 634 QString(" (%1)").arg(m_pActionEditNetworkNAT->shortcut().toString())); 635 } 636 637 /* Host network actions: */ 638 { 639 /* Translate text: */ 640 m_pActionAddNetworkHost->setText(tr("&Add host-only network")); 641 m_pActionDelNetworkHost->setText(tr("&Remove host-only network")); 642 m_pActionEditNetworkHost->setText(tr("&Edit host-only network")); 643 644 /* Recompose tool-tips: */ 645 m_pActionAddNetworkHost->setToolTip(m_pActionAddNetworkHost->text().remove('&') + 646 QString(" (%1)").arg(m_pActionAddNetworkHost->shortcut().toString())); 647 m_pActionDelNetworkHost->setToolTip(m_pActionDelNetworkHost->text().remove('&') + 648 QString(" (%1)").arg(m_pActionDelNetworkHost->shortcut().toString())); 649 m_pActionEditNetworkHost->setToolTip(m_pActionEditNetworkHost->text().remove('&') + 650 QString(" (%1)").arg(m_pActionEditNetworkHost->shortcut().toString())); 651 } 652 } 653 654 void UIGlobalSettingsNetwork::sltAddNetworkNAT() 655 { 656 /* Prepare useful variables: */ 657 CVirtualBox vbox = vboxGlobal().virtualBox(); 658 659 /* Compose a pool of busy names: */ 660 QList<QString> names; 661 for (int iItemIndex = 0; iItemIndex < m_pTreeNetworkNAT->topLevelItemCount(); ++iItemIndex) 662 { 663 UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->topLevelItem(iItemIndex)); 664 if (!names.contains(pItem->name())) 665 names << pItem->name(); 666 } 667 /* Search for the name with maximum index: */ 668 int iMaximumIndex = -1; 669 const QString strNameTemplate("NatNetwork%1"); 670 foreach (const QString &strName, names) 671 { 672 QRegExp regExp(strNameTemplate.arg("([\\d]*)")); 673 if (regExp.indexIn(strName) != -1) 674 iMaximumIndex = qMax(iMaximumIndex, regExp.cap(1).toInt()); 675 } 676 677 /* Create NAT network: */ 678 QString strIndex(iMaximumIndex == -1 ? QString() : QString::number(iMaximumIndex + 1)); 679 CNATNetwork network = vbox.CreateNATNetwork(strNameTemplate.arg(strIndex)); 680 if (!vbox.isOk()) 681 return msgCenter().cannotCreateNATNetwork(vbox, this); 682 AssertReturnVoid(!network.isNull()); 683 684 /* Update tree: */ 685 createTreeItemNetworkNAT(generateDataNetworkNAT(network), true); 686 } 687 688 void UIGlobalSettingsNetwork::sltDelNetworkNAT() 689 { 690 /* Get network item: */ 691 UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->currentItem()); 692 AssertMsg(pItem, ("Current item should present!\n")); 693 /* Get network name: */ 694 const QString strNetworkName(pItem->name()); 695 696 /* Confirm NAT network removal: */ 697 if (!msgCenter().confirmNATNetworkRemoval(strNetworkName, this)) 698 return; 699 700 /* Prepare useful variables: */ 701 CVirtualBox vbox = vboxGlobal().virtualBox(); 702 703 /* Find corresponding interface: */ 704 const CNATNetwork &network = vbox.FindNATNetworkByName(strNetworkName); 705 AssertReturnVoid(vbox.isOk() && !network.isNull()); 706 707 /* Remove NAT network: */ 708 vbox.RemoveNATNetwork(network); 709 if (!vbox.isOk()) 710 return msgCenter().cannotRemoveNATNetwork(vbox, strNetworkName, this); 711 712 /* Update tree: */ 713 removeTreeItemNetworkNAT(pItem); 714 } 715 716 void UIGlobalSettingsNetwork::sltEditNetworkNAT() 717 { 718 /* Get network item: */ 719 UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->currentItem()); 720 AssertMsg(pItem, ("Current item should present!\n")); 721 722 /* Edit current item data: */ 723 UIDataNetworkNAT data; 724 pItem->uploadNetworkData(data); 725 UIGlobalSettingsNetworkDetailsNAT details(this, data); 726 if (details.exec() == QDialog::Accepted) 727 { 728 /* Put data back: */ 729 pItem->fetchNetworkData(data); 730 sltHandleCurrentItemChangeNetworkNAT(); 731 m_fChanged = true; 732 /* Revalidate: */ 733 revalidate(); 734 } 735 } 736 737 void UIGlobalSettingsNetwork::sltAddNetworkHost() 738 { 320 739 /* Prepare useful variables: */ 321 740 CVirtualBox vbox = vboxGlobal().virtualBox(); 322 741 CHost host = vboxGlobal().host(); 323 742 324 /* Update all the host-only interfaces: */ 325 for (int iNetworkIndex = 0; iNetworkIndex < m_cache.m_items.size(); ++iNetworkIndex) 326 { 327 /* Get iterated data: */ 328 const UIHostNetworkData &data = m_cache.m_items[iNetworkIndex]; 329 /* Find corresponding interface: */ 330 CHostNetworkInterface iface = host.FindHostNetworkInterfaceByName(data.m_interface.m_strName); 331 if (!iface.isNull()) 332 { 333 /* Host-only interface configuring: */ 334 if (data.m_interface.m_fDhcpClientEnabled) 335 { 336 iface.EnableDynamicIPConfig(); 337 } 338 else 339 { 340 AssertMsg(data.m_interface.m_strInterfaceAddress.isEmpty() || 341 QHostAddress(data.m_interface.m_strInterfaceAddress).protocol() == QAbstractSocket::IPv4Protocol, 342 ("Interface IPv4 address must be empty or IPv4-valid!\n")); 343 AssertMsg(data.m_interface.m_strInterfaceMask.isEmpty() || 344 QHostAddress(data.m_interface.m_strInterfaceMask).protocol() == QAbstractSocket::IPv4Protocol, 345 ("Interface IPv4 network mask must be empty or IPv4-valid!\n")); 346 iface.EnableStaticIPConfig(data.m_interface.m_strInterfaceAddress, data.m_interface.m_strInterfaceMask); 347 if (iface.GetIPV6Supported()) 348 { 349 AssertMsg(data.m_interface.m_strInterfaceAddress6.isEmpty() || 350 QHostAddress(data.m_interface.m_strInterfaceAddress6).protocol() == QAbstractSocket::IPv6Protocol, 351 ("Interface IPv6 address must be empty or IPv6-valid!\n")); 352 iface.EnableStaticIPConfigV6(data.m_interface.m_strInterfaceAddress6, data.m_interface.m_strInterfaceMaskLength6.toULong()); 353 } 354 } 355 356 /* Find corresponding DHCP server: */ 357 CDHCPServer dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName()); 358 if (!dhcp.isNull()) 359 { 360 /* DHCP server configuring: */ 361 dhcp.SetEnabled(data.m_dhcpserver.m_fDhcpServerEnabled); 362 AssertMsg(QHostAddress(data.m_dhcpserver.m_strDhcpServerAddress).protocol() == QAbstractSocket::IPv4Protocol, 363 ("DHCP server IPv4 address must be IPv4-valid!\n")); 364 AssertMsg(QHostAddress(data.m_dhcpserver.m_strDhcpServerMask).protocol() == QAbstractSocket::IPv4Protocol, 365 ("DHCP server IPv4 network mask must be IPv4-valid!\n")); 366 AssertMsg(QHostAddress(data.m_dhcpserver.m_strDhcpLowerAddress).protocol() == QAbstractSocket::IPv4Protocol, 367 ("DHCP server IPv4 lower bound must be IPv4-valid!\n")); 368 AssertMsg(QHostAddress(data.m_dhcpserver.m_strDhcpUpperAddress).protocol() == QAbstractSocket::IPv4Protocol, 369 ("DHCP server IPv4 upper bound must be IPv4-valid!\n")); 370 if (QHostAddress(data.m_dhcpserver.m_strDhcpServerAddress).protocol() == QAbstractSocket::IPv4Protocol && 371 QHostAddress(data.m_dhcpserver.m_strDhcpServerMask).protocol() == QAbstractSocket::IPv4Protocol && 372 QHostAddress(data.m_dhcpserver.m_strDhcpLowerAddress).protocol() == QAbstractSocket::IPv4Protocol && 373 QHostAddress(data.m_dhcpserver.m_strDhcpUpperAddress).protocol() == QAbstractSocket::IPv4Protocol) 374 dhcp.SetConfiguration(data.m_dhcpserver.m_strDhcpServerAddress, data.m_dhcpserver.m_strDhcpServerMask, 375 data.m_dhcpserver.m_strDhcpLowerAddress, data.m_dhcpserver.m_strDhcpUpperAddress); 376 } 377 } 378 } 379 380 /* Upload properties & settings to data: */ 381 UISettingsPageGlobal::uploadData(data); 382 } 383 384 /* Validation processing: */ 385 bool UIGlobalSettingsNetwork::validate(QList<UIValidationMessage> &messages) 386 { 387 /* Redirect validation to items: */ 388 UIHostInterfaceItem *pItem = static_cast<UIHostInterfaceItem*>(m_pInterfacesTree->currentItem()); 389 return pItem ? pItem->validate(messages) : true; 390 } 391 392 /* Navigation stuff: */ 393 void UIGlobalSettingsNetwork::setOrderAfter(QWidget *pWidget) 394 { 395 setTabOrder(pWidget, m_pInterfacesTree); 396 } 397 398 /* Translation stuff: */ 399 void UIGlobalSettingsNetwork::retranslateUi() 400 { 401 /* Translate uic generated strings: */ 402 Ui::UIGlobalSettingsNetwork::retranslateUi(this); 403 404 /* Translate action tool-tips: */ 405 m_pAddAction->setText(tr("&Add host-only network")); 406 m_pDelAction->setText(tr("&Remove host-only network")); 407 m_pEditAction->setText(tr("&Edit host-only network")); 408 409 /* Assign tool-tips: */ 410 m_pAddAction->setToolTip(m_pAddAction->text().remove('&') + 411 QString(" (%1)").arg(m_pAddAction->shortcut().toString())); 412 m_pDelAction->setToolTip(m_pDelAction->text().remove('&') + 413 QString(" (%1)").arg(m_pDelAction->shortcut().toString())); 414 m_pEditAction->setToolTip(m_pEditAction->text().remove('&') + 415 QString(" (%1)").arg(m_pEditAction->shortcut().toString())); 416 } 417 418 /* Adds new network interface: */ 419 void UIGlobalSettingsNetwork::sltAddInterface() 420 { 743 /* Create Host interface: */ 744 CHostNetworkInterface iface; 745 CProgress progress = host.CreateHostOnlyNetworkInterface(iface); 746 if (!host.isOk()) 747 return msgCenter().cannotCreateHostInterface(host, this); 748 msgCenter().showModalProgressDialog(progress, tr("Networking"), ":/nw_32px.png", this, 0); // TODO: Change icon! 749 if (!progress.isOk() || progress.GetResultCode() != 0) 750 return msgCenter().cannotCreateHostInterface(progress, this); 751 752 /* Make sure DHCP server is created too: */ 753 CDHCPServer dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName()); 754 if (dhcp.isNull()) 755 { 756 vbox.CreateDHCPServer(iface.GetNetworkName()); 757 if (!vbox.isOk()) 758 return msgCenter().cannotCreateDHCPServer(vbox, this); 759 dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName()); 760 } 761 AssertReturnVoid(!dhcp.isNull()); 762 763 /* Update tree: */ 764 createTreeItemNetworkHost(generateDataNetworkHost(iface), true); 765 } 766 767 void UIGlobalSettingsNetwork::sltDelNetworkHost() 768 { 769 /* Get network item: */ 770 UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->currentItem()); 771 AssertMsg(pItem, ("Current item should present!\n")); 772 /* Get interface name: */ 773 const QString strInterfaceName(pItem->name()); 774 775 /* Confirm Host network removal: */ 776 if (!msgCenter().confirmHostOnlyInterfaceRemoval(strInterfaceName, this)) 777 return; 778 421 779 /* Prepare useful variables: */ 422 780 CVirtualBox vbox = vboxGlobal().virtualBox(); 423 781 CHost host = vboxGlobal().host(); 424 782 425 /* Create new host-only interface: */426 CHostNetworkInterface iface;427 CProgress progress = host.CreateHostOnlyNetworkInterface(iface);428 if (host.isOk())429 {430 msgCenter().showModalProgressDialog(progress, tr("Networking"), ":/nw_32px.png", this, 0);431 if (progress.isOk() && progress.GetResultCode() == 0)432 {433 /* Create DHCP server: */434 CDHCPServer dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName());435 if (dhcp.isNull())436 {437 vbox.CreateDHCPServer(iface.GetNetworkName());438 dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName());439 }440 AssertMsg(!dhcp.isNull(), ("DHCP server creation failed!\n"));441 /* Append cache with new item: */442 appendCacheItem(iface);443 /* Append list with new item: */444 appendListItem(m_cache.m_items.last(), true);445 }446 else447 msgCenter().cannotCreateHostInterface(progress, this);448 }449 else450 msgCenter().cannotCreateHostInterface(host, this);451 }452 453 /* Removes selected network interface: */454 void UIGlobalSettingsNetwork::sltDelInterface()455 {456 /* Get interface item: */457 UIHostInterfaceItem *pItem = static_cast<UIHostInterfaceItem*>(m_pInterfacesTree->currentItem());458 AssertMsg(pItem, ("Current item should present!\n"));459 /* Get interface name: */460 QString strInterfaceName(pItem->name());461 /* Asking user about deleting selected network interface: */462 if (!msgCenter().confirmHostInterfaceRemoval(strInterfaceName, this))463 return;464 465 /* Prepare useful variables: */466 CVirtualBox vbox = vboxGlobal().virtualBox();467 CHost host = vboxGlobal().host();468 469 783 /* Find corresponding interface: */ 470 784 const CHostNetworkInterface &iface = host.FindHostNetworkInterfaceByName(strInterfaceName); 471 472 /* Remove DHCP server first: */ 473 CDHCPServer dhcp = vboxGlobal().virtualBox().FindDHCPServerByNetworkName(iface.GetNetworkName()); 474 if (!dhcp.isNull()) 785 AssertReturnVoid(host.isOk() && !iface.isNull()); 786 787 /* Remove DHCP server if any: */ 788 CDHCPServer dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName()); 789 if (vbox.isOk() && !dhcp.isNull()) 790 { 475 791 vbox.RemoveDHCPServer(dhcp); 792 if (!vbox.isOk()) 793 return msgCenter().cannotRemoveDHCPServer(vbox, strInterfaceName, this); 794 } 476 795 477 796 /* Remove interface finally: */ 478 797 CProgress progress = host.RemoveHostOnlyNetworkInterface(iface.GetId()); 479 if (host.isOk()) 480 { 481 msgCenter().showModalProgressDialog(progress, tr("Networking"), ":/nw_32px.png", this, 0); 482 if (progress.isOk() && progress.GetResultCode() == 0) 483 { 484 /* Remove list item: */ 485 removeListItem(pItem); 486 /* Remove cache item: */ 487 removeCacheItem(strInterfaceName); 488 } 489 else 490 msgCenter().cannotRemoveHostInterface(progress, strInterfaceName, this); 491 } 492 else 493 msgCenter().cannotRemoveHostInterface(host, strInterfaceName, this); 494 } 495 496 /* Edits selected network interface: */ 497 void UIGlobalSettingsNetwork::sltEditInterface() 498 { 499 /* Check interface presence */ 500 UIHostInterfaceItem *pItem = static_cast<UIHostInterfaceItem*>(m_pInterfacesTree->currentItem()); 501 AssertMsg(pItem, ("Current item should be selected!\n")); 502 /* Edit current item data */ 503 UIGlobalSettingsNetworkDetails details(this); 504 details.getFromItem(pItem); 798 if (!host.isOk()) 799 return msgCenter().cannotRemoveHostInterface(host, strInterfaceName, this); 800 msgCenter().showModalProgressDialog(progress, tr("Networking"), ":/nw_32px.png", this, 0); // TODO: Change icon! 801 if (!progress.isOk() || progress.GetResultCode() != 0) 802 return msgCenter().cannotRemoveHostInterface(progress, strInterfaceName, this); 803 804 /* Update tree: */ 805 removeTreeItemNetworkHost(pItem); 806 } 807 808 void UIGlobalSettingsNetwork::sltEditNetworkHost() 809 { 810 /* Get network item: */ 811 UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->currentItem()); 812 AssertMsg(pItem, ("Current item should present!\n")); 813 814 /* Edit current item data: */ 815 UIDataNetworkHost data; 816 pItem->uploadNetworkData(data); 817 UIGlobalSettingsNetworkDetailsHost details(this, data); 505 818 if (details.exec() == QDialog::Accepted) 506 819 { 507 details.putBackToItem();508 pItem-> updateInfo();509 slt UpdateCurrentItem();820 /* Put data back: */ 821 pItem->fetchNetworkData(data); 822 sltHandleCurrentItemChangeNetworkHost(); 510 823 m_fChanged = true; 511 512 824 /* Revalidate: */ 513 825 revalidate(); … … 515 827 } 516 828 517 /* Update current network interface data relations: */ 518 void UIGlobalSettingsNetwork::sltUpdateCurrentItem() 829 void UIGlobalSettingsNetwork::sltHandleCurrentItemChangeNetworkNAT() 519 830 { 520 831 /* Get current item: */ 521 UI HostInterfaceItem *pItem = static_cast<UIHostInterfaceItem*>(m_pInterfacesTree->currentItem());832 UIItemNetworkNAT *pItem = static_cast<UIItemNetworkNAT*>(m_pTreeNetworkNAT->currentItem()); 522 833 /* Update availability: */ 523 m_pDelAction->setEnabled(pItem); 524 m_pEditAction->setEnabled(pItem); 525 } 526 527 /* Show network interface context-menu: */ 528 void UIGlobalSettingsNetwork::sltChowContextMenu(const QPoint &pos) 529 { 834 m_pActionDelNetworkNAT->setEnabled(pItem); 835 m_pActionEditNetworkNAT->setEnabled(pItem); 836 } 837 838 void UIGlobalSettingsNetwork::sltHandleCurrentItemChangeNetworkHost() 839 { 840 /* Get current item: */ 841 UIItemNetworkHost *pItem = static_cast<UIItemNetworkHost*>(m_pTreeNetworkHost->currentItem()); 842 /* Update availability: */ 843 m_pActionDelNetworkHost->setEnabled(pItem); 844 m_pActionEditNetworkHost->setEnabled(pItem); 845 } 846 847 void UIGlobalSettingsNetwork::sltShowContextMenuNetworkNAT(const QPoint &pos) 848 { 849 /* Compose temporary context-menu: */ 530 850 QMenu menu; 531 if (m_p InterfacesTree->itemAt(pos))532 { 533 menu.addAction(m_p EditAction);534 menu.addAction(m_p DelAction);851 if (m_pTreeNetworkNAT->itemAt(pos)) 852 { 853 menu.addAction(m_pActionEditNetworkNAT); 854 menu.addAction(m_pActionDelNetworkNAT); 535 855 } 536 856 else 537 857 { 538 menu.addAction(m_pAddAction); 539 } 540 menu.exec(m_pInterfacesTree->mapToGlobal(pos)); 541 } 542 543 void UIGlobalSettingsNetwork::appendCacheItem(const CHostNetworkInterface &iface) 544 { 858 menu.addAction(m_pActionAddNetworkNAT); 859 } 860 /* And show it: */ 861 menu.exec(m_pTreeNetworkNAT->mapToGlobal(pos)); 862 } 863 864 void UIGlobalSettingsNetwork::sltShowContextMenuNetworkHost(const QPoint &pos) 865 { 866 /* Compose temporary context-menu: */ 867 QMenu menu; 868 if (m_pTreeNetworkHost->itemAt(pos)) 869 { 870 menu.addAction(m_pActionEditNetworkHost); 871 menu.addAction(m_pActionDelNetworkHost); 872 } 873 else 874 { 875 menu.addAction(m_pActionAddNetworkHost); 876 } 877 /* And show it: */ 878 menu.exec(m_pTreeNetworkHost->mapToGlobal(pos)); 879 } 880 881 UIDataNetworkNAT UIGlobalSettingsNetwork::generateDataNetworkNAT(const CNATNetwork &network) 882 { 883 /* Prepare data: */ 884 UIDataNetworkNAT data; 885 886 /* Load NAT network settings: */ 887 data.m_fEnabled = network.GetEnabled(); 888 data.m_strName = network.GetNetworkName(); 889 data.m_strNewName = data.m_strName; 890 data.m_strCIDR = network.GetNetwork(); 891 data.m_fSupportsDHCP = network.GetNeedDhcpServer(); 892 data.m_fSupportsIPv6 = network.GetIPv6Enabled(); 893 data.m_fAdvertiseDefaultIPv6Route = network.GetAdvertiseDefaultIPv6RouteEnabled(); 894 895 /* Return data: */ 896 return data; 897 } 898 899 void UIGlobalSettingsNetwork::saveCacheItemNetworkNAT(const UIDataNetworkNAT &data) 900 { 901 /* Make sure corresponding NAT network exists: */ 902 CVirtualBox vbox = vboxGlobal().virtualBox(); 903 CNATNetwork network = vbox.FindNATNetworkByName(data.m_strName); 904 AssertReturnVoid(vbox.isOk() && !network.isNull()); 905 906 /* Save NAT network options: */ 907 network.SetEnabled(data.m_fEnabled); 908 network.SetNetworkName(data.m_strNewName); 909 network.SetNetwork(data.m_strCIDR); 910 network.SetNeedDhcpServer(data.m_fSupportsDHCP); 911 network.SetIPv6Enabled(data.m_fSupportsIPv6); 912 network.SetAdvertiseDefaultIPv6RouteEnabled(data.m_fAdvertiseDefaultIPv6Route); 913 } 914 915 void UIGlobalSettingsNetwork::createTreeItemNetworkNAT(const UIDataNetworkNAT &data, bool fChooseItem) 916 { 917 /* Add new item to the tree: */ 918 UIItemNetworkNAT *pItem = new UIItemNetworkNAT; 919 pItem->fetchNetworkData(data); 920 m_pTreeNetworkNAT->addTopLevelItem(pItem); 921 /* And choose it as current if necessary: */ 922 if (fChooseItem) 923 m_pTreeNetworkNAT->setCurrentItem(pItem); 924 } 925 926 void UIGlobalSettingsNetwork::removeTreeItemNetworkNAT(UIItemNetworkNAT *pItem) 927 { 928 /* Delete passed item: */ 929 delete pItem; 930 } 931 932 UIDataNetworkHost UIGlobalSettingsNetwork::generateDataNetworkHost(const CHostNetworkInterface &iface) 933 { 934 /* Prepare data: */ 935 UIDataNetworkHost data; 936 545 937 /* Get DHCP server (create if necessary): */ 546 938 CDHCPServer dhcp = vboxGlobal().virtualBox().FindDHCPServerByNetworkName(iface.GetNetworkName()); 547 939 if (dhcp.isNull()) 548 940 { 549 vboxGlobal().virtualBox().CreateDHCPServer(iface.GetNetworkName()); 941 CVirtualBox vbox = vboxGlobal().virtualBox(); 942 vbox.CreateDHCPServer(iface.GetNetworkName()); 943 if (!vbox.isOk()) 944 { 945 msgCenter().cannotCreateDHCPServer(vbox, this); 946 return data; 947 } 550 948 dhcp = vboxGlobal().virtualBox().FindDHCPServerByNetworkName(iface.GetNetworkName()); 551 949 } 552 AssertMsg(!dhcp.isNull(), ("DHCP server creation failed!\n")); 553 554 /* Prepare cache item: */ 555 UIHostNetworkData data; 556 557 /* Host-only interface settings */ 950 Assert(!dhcp.isNull()); 951 if (dhcp.isNull()) 952 return data; 953 954 /* Host interface settings: */ 558 955 data.m_interface.m_strName = iface.GetName(); 559 956 data.m_interface.m_fDhcpClientEnabled = iface.GetDHCPEnabled(); … … 571 968 data.m_dhcpserver.m_strDhcpUpperAddress = dhcp.GetUpperIP(); 572 969 573 /* Append cache item: */ 574 m_cache.m_items << data; 575 } 576 577 void UIGlobalSettingsNetwork::removeCacheItem(const QString &strInterfaceName) 578 { 579 /* Search for invalidated cache item: */ 580 for (int iNetworkIndex = 0; iNetworkIndex < m_cache.m_items.size(); ++iNetworkIndex) 581 { 582 /* Get iterated data: */ 583 const UIHostNetworkData &data = m_cache.m_items[iNetworkIndex]; 584 if (data.m_interface.m_strName == strInterfaceName) 585 { 586 m_cache.m_items.removeAll(data); 587 break; 588 } 589 } 590 } 591 592 void UIGlobalSettingsNetwork::appendListItem(const UIHostNetworkData &data, bool fChooseItem) 593 { 594 /* Add new item to the list: */ 595 UIHostInterfaceItem *pItem = new UIHostInterfaceItem; 970 /* Return data: */ 971 return data; 972 } 973 974 void UIGlobalSettingsNetwork::saveCacheItemNetworkHost(const UIDataNetworkHost &data) 975 { 976 /* Make sure corresponding Host interface exists: */ 977 CHost host = vboxGlobal().host(); 978 CHostNetworkInterface iface = host.FindHostNetworkInterfaceByName(data.m_interface.m_strName); 979 AssertReturnVoid(host.isOk() && !iface.isNull()); 980 981 /* Automatic host interface configuration: */ 982 if (data.m_interface.m_fDhcpClientEnabled) 983 { 984 iface.EnableDynamicIPConfig(); 985 } 986 /* Manual host interface configuration: */ 987 else 988 { 989 AssertMsg(data.m_interface.m_strInterfaceAddress.isEmpty() || 990 QHostAddress(data.m_interface.m_strInterfaceAddress).protocol() == QAbstractSocket::IPv4Protocol, 991 ("Interface IPv4 address must be empty or IPv4-valid!\n")); 992 AssertMsg(data.m_interface.m_strInterfaceMask.isEmpty() || 993 QHostAddress(data.m_interface.m_strInterfaceMask).protocol() == QAbstractSocket::IPv4Protocol, 994 ("Interface IPv4 network mask must be empty or IPv4-valid!\n")); 995 iface.EnableStaticIPConfig(data.m_interface.m_strInterfaceAddress, data.m_interface.m_strInterfaceMask); 996 if (iface.GetIPV6Supported()) 997 { 998 AssertMsg(data.m_interface.m_strInterfaceAddress6.isEmpty() || 999 QHostAddress(data.m_interface.m_strInterfaceAddress6).protocol() == QAbstractSocket::IPv6Protocol, 1000 ("Interface IPv6 address must be empty or IPv6-valid!\n")); 1001 iface.EnableStaticIPConfigV6(data.m_interface.m_strInterfaceAddress6, data.m_interface.m_strInterfaceMaskLength6.toULong()); 1002 } 1003 } 1004 1005 /* Make sure corresponding DHCP server exists: */ 1006 CVirtualBox vbox = vboxGlobal().virtualBox(); 1007 CDHCPServer dhcp = vbox.FindDHCPServerByNetworkName(iface.GetNetworkName()); 1008 AssertReturnVoid(vbox.isOk() && !dhcp.isNull()); 1009 1010 /* Save DHCP server configuration: */ 1011 dhcp.SetEnabled(data.m_dhcpserver.m_fDhcpServerEnabled); 1012 AssertMsg(QHostAddress(data.m_dhcpserver.m_strDhcpServerAddress).protocol() == QAbstractSocket::IPv4Protocol, 1013 ("DHCP server IPv4 address must be IPv4-valid!\n")); 1014 AssertMsg(QHostAddress(data.m_dhcpserver.m_strDhcpServerMask).protocol() == QAbstractSocket::IPv4Protocol, 1015 ("DHCP server IPv4 network mask must be IPv4-valid!\n")); 1016 AssertMsg(QHostAddress(data.m_dhcpserver.m_strDhcpLowerAddress).protocol() == QAbstractSocket::IPv4Protocol, 1017 ("DHCP server IPv4 lower bound must be IPv4-valid!\n")); 1018 AssertMsg(QHostAddress(data.m_dhcpserver.m_strDhcpUpperAddress).protocol() == QAbstractSocket::IPv4Protocol, 1019 ("DHCP server IPv4 upper bound must be IPv4-valid!\n")); 1020 if (QHostAddress(data.m_dhcpserver.m_strDhcpServerAddress).protocol() == QAbstractSocket::IPv4Protocol && 1021 QHostAddress(data.m_dhcpserver.m_strDhcpServerMask).protocol() == QAbstractSocket::IPv4Protocol && 1022 QHostAddress(data.m_dhcpserver.m_strDhcpLowerAddress).protocol() == QAbstractSocket::IPv4Protocol && 1023 QHostAddress(data.m_dhcpserver.m_strDhcpUpperAddress).protocol() == QAbstractSocket::IPv4Protocol) 1024 dhcp.SetConfiguration(data.m_dhcpserver.m_strDhcpServerAddress, data.m_dhcpserver.m_strDhcpServerMask, 1025 data.m_dhcpserver.m_strDhcpLowerAddress, data.m_dhcpserver.m_strDhcpUpperAddress); 1026 } 1027 1028 void UIGlobalSettingsNetwork::createTreeItemNetworkHost(const UIDataNetworkHost &data, bool fChooseItem) 1029 { 1030 /* Add new item to the tree: */ 1031 UIItemNetworkHost *pItem = new UIItemNetworkHost; 596 1032 pItem->fetchNetworkData(data); 597 m_p InterfacesTree->addTopLevelItem(pItem);1033 m_pTreeNetworkHost->addTopLevelItem(pItem); 598 1034 /* And choose it as current if necessary: */ 599 1035 if (fChooseItem) 600 m_p InterfacesTree->setCurrentItem(pItem);601 } 602 603 void UIGlobalSettingsNetwork::remove ListItem(UIHostInterfaceItem*pItem)1036 m_pTreeNetworkHost->setCurrentItem(pItem); 1037 } 1038 1039 void UIGlobalSettingsNetwork::removeTreeItemNetworkHost(UIItemNetworkHost *pItem) 604 1040 { 605 1041 /* Delete passed item: */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.h
r47944 r48458 6 6 7 7 /* 8 * Copyright (C) 2009-201 2Oracle Corporation8 * Copyright (C) 2009-2013 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #define __UIGlobalSettingsNetwork_h__ 21 21 22 /* Local includes*/22 /* GUI includes: */ 23 23 #include "UISettingsPage.h" 24 24 #include "UIGlobalSettingsNetwork.gen.h" 25 25 26 /* Forward declarations: */ 27 class UIItemNetworkNAT; 28 class UIItemNetworkHost; 29 30 31 /* Global settings / Network page / NAT network data: */ 32 struct UIDataNetworkNAT 33 { 34 /* NAT Network: */ 35 bool m_fEnabled; 36 QString m_strName; 37 QString m_strNewName; 38 QString m_strCIDR; 39 bool m_fSupportsDHCP; 40 bool m_fSupportsIPv6; 41 bool m_fAdvertiseDefaultIPv6Route; 42 bool operator==(const UIDataNetworkNAT &other) const 43 { 44 return m_fEnabled == other.m_fEnabled && 45 m_strName == other.m_strName && 46 m_strNewName == other.m_strNewName && 47 m_strCIDR == other.m_strCIDR && 48 m_fSupportsDHCP == other.m_fSupportsDHCP && 49 m_fSupportsIPv6 == other.m_fSupportsIPv6 && 50 m_fAdvertiseDefaultIPv6Route == other.m_fAdvertiseDefaultIPv6Route; 51 } 52 }; 53 54 26 55 /* Global settings / Network page / Host interface data: */ 27 struct UI HostInterfaceData28 { 29 /* Host -onlyInterface: */56 struct UIDataNetworkHostInterface 57 { 58 /* Host Interface: */ 30 59 QString m_strName; 31 60 bool m_fDhcpClientEnabled; … … 35 64 QString m_strInterfaceAddress6; 36 65 QString m_strInterfaceMaskLength6; 37 bool operator==(const UI HostInterfaceData&other) const66 bool operator==(const UIDataNetworkHostInterface &other) const 38 67 { 39 68 return m_strName == other.m_strName && … … 47 76 }; 48 77 49 /* Global settings / Network page / DHCP server data: */50 struct UID HCPServerData51 { 52 /* DHCP Server */78 /* Global settings / Network page / Host DHCP server data: */ 79 struct UIDataNetworkDHCPServer 80 { 81 /* DHCP Server: */ 53 82 bool m_fDhcpServerEnabled; 54 83 QString m_strDhcpServerAddress; … … 56 85 QString m_strDhcpLowerAddress; 57 86 QString m_strDhcpUpperAddress; 58 bool operator==(const UID HCPServerData&other) const87 bool operator==(const UIDataNetworkDHCPServer &other) const 59 88 { 60 89 return m_fDhcpServerEnabled == other.m_fDhcpServerEnabled && … … 66 95 }; 67 96 68 /* Global settings / Network page / Fullnetwork data: */69 struct UI HostNetworkData70 { 71 UI HostInterfaceDatam_interface;72 UID HCPServerDatam_dhcpserver;73 bool operator==(const UI HostNetworkData&other) const97 /* Global settings / Network page / Host network data: */ 98 struct UIDataNetworkHost 99 { 100 UIDataNetworkHostInterface m_interface; 101 UIDataNetworkDHCPServer m_dhcpserver; 102 bool operator==(const UIDataNetworkHost &other) const 74 103 { 75 104 return m_interface == other.m_interface && … … 78 107 }; 79 108 80 /* Global settings / Network page / Cache: */ 109 110 /* Global settings / Network page / Global network cache: */ 81 111 struct UISettingsCacheGlobalNetwork 82 112 { 83 QList<UIHostNetworkData> m_items; 84 }; 85 86 /* Global settings / Network page / Host interface item: */ 87 class UIHostInterfaceItem : public QTreeWidgetItem 88 { 113 QList<UIDataNetworkNAT> m_networksNAT; 114 QList<UIDataNetworkHost> m_networksHost; 115 }; 116 117 118 /* Global settings / Network page: */ 119 class UIGlobalSettingsNetwork : public UISettingsPageGlobal, public Ui::UIGlobalSettingsNetwork 120 { 121 Q_OBJECT; 122 89 123 public: 90 124 91 125 /* Constructor: */ 92 UIHostInterfaceItem(); 93 94 /* API: Get/return data to/form items: */ 95 void fetchNetworkData(const UIHostNetworkData &data); 96 void uploadNetworkData(UIHostNetworkData &data); 126 UIGlobalSettingsNetwork(); 127 128 protected: 129 130 /* API: 131 * Load data to cache from corresponding external object(s), 132 * this task COULD be performed in other than GUI thread: */ 133 void loadToCacheFrom(QVariant &data); 134 /* API: 135 * Load data to corresponding widgets from cache, 136 * this task SHOULD be performed in GUI thread only: */ 137 void getFromCache(); 138 139 /* API: 140 * Save data from corresponding widgets to cache, 141 * this task SHOULD be performed in GUI thread only: */ 142 void putToCache(); 143 /* API: 144 * Save data from cache to corresponding external object(s), 145 * this task COULD be performed in other than GUI thread: */ 146 void saveFromCacheTo(QVariant &data); 97 147 98 148 /* API: Validation stuff: */ 99 149 bool validate(QList<UIValidationMessage> &messages); 100 150 101 /* API: Update stuff: */ 102 QString updateInfo(); 103 104 /* API: Network item getters: */ 105 QString name() const { return m_data.m_interface.m_strName; } 106 bool isDhcpClientEnabled() const { return m_data.m_interface.m_fDhcpClientEnabled; } 107 QString interfaceAddress() const { return m_data.m_interface.m_strInterfaceAddress; } 108 QString interfaceMask() const { return m_data.m_interface.m_strInterfaceMask; } 109 bool isIpv6Supported() const { return m_data.m_interface.m_fIpv6Supported; } 110 QString interfaceAddress6() const { return m_data.m_interface.m_strInterfaceAddress6; } 111 QString interfaceMaskLength6() const { return m_data.m_interface.m_strInterfaceMaskLength6; } 112 113 bool isDhcpServerEnabled() const { return m_data.m_dhcpserver.m_fDhcpServerEnabled; } 114 QString dhcpServerAddress() const { return m_data.m_dhcpserver.m_strDhcpServerAddress; } 115 QString dhcpServerMask() const { return m_data.m_dhcpserver.m_strDhcpServerMask; } 116 QString dhcpLowerAddress() const { return m_data.m_dhcpserver.m_strDhcpLowerAddress; } 117 QString dhcpUpperAddress() const { return m_data.m_dhcpserver.m_strDhcpUpperAddress; } 118 119 /* API: Network item setters */ 120 void setDhcpClientEnabled(bool fEnabled) { m_data.m_interface.m_fDhcpClientEnabled = fEnabled; } 121 void setInterfaceAddress (const QString &strValue) { m_data.m_interface.m_strInterfaceAddress = strValue; } 122 void setInterfaceMask (const QString &strValue) { m_data.m_interface.m_strInterfaceMask = strValue; } 123 void setIp6Supported (bool fSupported) { m_data.m_interface.m_fIpv6Supported = fSupported; } 124 void setInterfaceAddress6 (const QString &strValue) { m_data.m_interface.m_strInterfaceAddress6 = strValue; } 125 void setInterfaceMaskLength6 (const QString &strValue) { m_data.m_interface.m_strInterfaceMaskLength6 = strValue; } 126 127 void setDhcpServerEnabled (bool fEnabled) { m_data.m_dhcpserver.m_fDhcpServerEnabled = fEnabled; } 128 void setDhcpServerAddress (const QString &sttValue) { m_data.m_dhcpserver.m_strDhcpServerAddress = sttValue; } 129 void setDhcpServerMask (const QString &strValue) { m_data.m_dhcpserver.m_strDhcpServerMask = strValue; } 130 void setDhcpLowerAddress (const QString &strValue) { m_data.m_dhcpserver.m_strDhcpLowerAddress = strValue; } 131 void setDhcpUpperAddress (const QString &strValue) { m_data.m_dhcpserver.m_strDhcpUpperAddress = strValue; } 151 /* API: Navigation stuff: */ 152 void setOrderAfter(QWidget *pWidget); 153 154 /* API: Translation stuff: */ 155 void retranslateUi(); 156 157 private slots: 158 159 /* Handlers: NAT network stuff: */ 160 void sltAddNetworkNAT(); 161 void sltDelNetworkNAT(); 162 void sltEditNetworkNAT(); 163 void sltHandleCurrentItemChangeNetworkNAT(); 164 void sltShowContextMenuNetworkNAT(const QPoint &pos); 165 166 /* Handlers: Host network stuff: */ 167 void sltAddNetworkHost(); 168 void sltDelNetworkHost(); 169 void sltEditNetworkHost(); 170 void sltHandleCurrentItemChangeNetworkHost(); 171 void sltShowContextMenuNetworkHost(const QPoint &pos); 132 172 133 173 private: 134 174 135 /* Network data: */ 136 UIHostNetworkData m_data; 137 }; 138 139 /* Global settings / Network page: */ 140 class UIGlobalSettingsNetwork : public UISettingsPageGlobal, public Ui::UIGlobalSettingsNetwork 141 { 142 Q_OBJECT; 143 144 public: 145 146 /* Constructor: */ 147 UIGlobalSettingsNetwork(); 148 149 protected: 150 151 /* Load data to cache from corresponding external object(s), 152 * this task COULD be performed in other than GUI thread: */ 153 void loadToCacheFrom(QVariant &data); 154 /* Load data to corresponding widgets from cache, 155 * this task SHOULD be performed in GUI thread only: */ 156 void getFromCache(); 157 158 /* Save data from corresponding widgets to cache, 159 * this task SHOULD be performed in GUI thread only: */ 160 void putToCache(); 161 /* Save data from cache to corresponding external object(s), 162 * this task COULD be performed in other than GUI thread: */ 163 void saveFromCacheTo(QVariant &data); 164 165 /* API: Validation stuff: */ 166 bool validate(QList<UIValidationMessage> &messages); 167 168 /* Navigation stuff: */ 169 void setOrderAfter (QWidget *aWidget); 170 171 /* Translation stuff: */ 172 void retranslateUi(); 173 174 private slots: 175 176 /* Helper slots: */ 177 void sltAddInterface(); 178 void sltDelInterface(); 179 void sltEditInterface(); 180 void sltUpdateCurrentItem(); 181 void sltChowContextMenu(const QPoint &pos); 182 183 private: 184 185 /* Helper members: */ 186 void appendCacheItem(const CHostNetworkInterface &iface); 187 void removeCacheItem(const QString &strInterfaceName); 188 void appendListItem(const UIHostNetworkData &data, bool fChooseItem = false); 189 void removeListItem(UIHostInterfaceItem *pItem); 190 191 /* Helper actions: */ 192 QAction *m_pAddAction; 193 QAction *m_pDelAction; 194 QAction *m_pEditAction; 195 196 /* Editness flag: */ 175 /* Helpers: NAT network cache stuff: */ 176 UIDataNetworkNAT generateDataNetworkNAT(const CNATNetwork &network); 177 void saveCacheItemNetworkNAT(const UIDataNetworkNAT &data); 178 179 /* Helpers: NAT network tree stuff: */ 180 void createTreeItemNetworkNAT(const UIDataNetworkNAT &data, bool fChooseItem = false); 181 void removeTreeItemNetworkNAT(UIItemNetworkNAT *pItem); 182 183 /* Helpers: Host network cache stuff: */ 184 UIDataNetworkHost generateDataNetworkHost(const CHostNetworkInterface &iface); 185 void saveCacheItemNetworkHost(const UIDataNetworkHost &data); 186 187 /* Helpers: Host network tree stuff: */ 188 void createTreeItemNetworkHost(const UIDataNetworkHost &data, bool fChooseItem = false); 189 void removeTreeItemNetworkHost(UIItemNetworkHost *pItem); 190 191 /* Variables: NAT network actions: */ 192 QAction *m_pActionAddNetworkNAT; 193 QAction *m_pActionDelNetworkNAT; 194 QAction *m_pActionEditNetworkNAT; 195 196 /* Variables: Host network actions: */ 197 QAction *m_pActionAddNetworkHost; 198 QAction *m_pActionDelNetworkHost; 199 QAction *m_pActionEditNetworkHost; 200 201 /* Variable: Editness flag: */ 197 202 bool m_fChanged; 198 203 199 /* Cache: */204 /* Variable: Cache: */ 200 205 UISettingsCacheGlobalNetwork m_cache; 201 206 }; 202 207 203 208 #endif // __UIGlobalSettingsNetwork_h__ 204 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetwork.ui
r47193 r48458 15 15 <class>UIGlobalSettingsNetwork</class> 16 16 <widget class="QWidget" name="UIGlobalSettingsNetwork"> 17 <layout class="QGridLayout"> 18 <property name="margin"> 19 <number>0</number> 20 </property> 21 <item row="0" column="0"> 22 <widget class="QILabelSeparator" native="1" name="m_pNetworkLabel"> 23 <property name="text"> 24 <string>&Host-only Networks</string> 25 </property> 26 <property name="buddy"> 27 <cstring>m_pInterfacesTree</cstring> 28 </property> 29 </widget> 30 </item> 31 <item row="1" column="0"> 32 <widget class="QWidget" native="1" name="m_pNetworkSettingsContainer" > 33 <layout class="QHBoxLayout" name="m_pLayout1"> 34 <property name="spacing"> 35 <number>3</number> 36 </property> 37 <property name="margin"> 38 <number>0</number> 39 </property> 40 <item> 41 <widget class="QTreeWidget" name="m_pInterfacesTree"> 42 <property name="sizePolicy"> 43 <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> 44 <horstretch>0</horstretch> 45 <verstretch>0</verstretch> 46 </sizepolicy> 47 </property> 48 <property name="minimumSize"> 49 <size> 50 <width>0</width> 51 <height>150</height> 52 </size> 53 </property> 54 <property name="whatsThis"> 55 <string>Lists all available host-only networks.</string> 56 </property> 57 <property name="rootIsDecorated"> 58 <bool>false</bool> 59 </property> 60 <column> 61 <property name="text"> 62 <string>Name</string> 17 <layout class="QVBoxLayout"> 18 <item> 19 <widget class="QITabWidget" name="m_pTabWidget"> 20 <widget class="QWidget" name="m_pTabNAT"> 21 <attribute name="title"> 22 <string>&NAT Networks</string> 23 </attribute> 24 <layout class="QHBoxLayout"> 25 <property name="margin"> 26 <number>0</number> 27 </property> 28 <property name="spacing"> 29 <number>3</number> 30 </property> 31 <item> 32 <widget class="QTreeWidget" name="m_pTreeNetworkNAT"> 33 <property name="sizePolicy"> 34 <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> 35 <horstretch>0</horstretch> 36 <verstretch>0</verstretch> 37 </sizepolicy> 63 38 </property> 64 </column> 65 </widget> 66 </item> 67 <item> 68 <widget class="UIToolBar" name="m_pActionsToolbar"/> 69 </item> 70 </layout> 39 <property name="minimumSize"> 40 <size> 41 <width>0</width> 42 <height>150</height> 43 </size> 44 </property> 45 <property name="whatsThis"> 46 <string>Lists all available NAT networks.</string> 47 </property> 48 <property name="rootIsDecorated"> 49 <bool>false</bool> 50 </property> 51 <column> 52 <property name="text"> 53 <string>Name</string> 54 </property> 55 </column> 56 </widget> 57 </item> 58 <item> 59 <widget class="UIToolBar" name="m_pToolbarNetworkNAT"/> 60 </item> 61 </layout> 62 </widget> 63 <widget class="QWidget" name="m_pTabHostOnly"> 64 <attribute name="title"> 65 <string>&Host-only Networks</string> 66 </attribute> 67 <layout class="QHBoxLayout"> 68 <property name="margin"> 69 <number>0</number> 70 </property> 71 <property name="spacing"> 72 <number>3</number> 73 </property> 74 <item> 75 <widget class="QTreeWidget" name="m_pTreeNetworkHost"> 76 <property name="sizePolicy"> 77 <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> 78 <horstretch>0</horstretch> 79 <verstretch>0</verstretch> 80 </sizepolicy> 81 </property> 82 <property name="minimumSize"> 83 <size> 84 <width>0</width> 85 <height>150</height> 86 </size> 87 </property> 88 <property name="whatsThis"> 89 <string>Lists all available host-only networks.</string> 90 </property> 91 <property name="rootIsDecorated"> 92 <bool>false</bool> 93 </property> 94 <column> 95 <property name="text"> 96 <string>Name</string> 97 </property> 98 </column> 99 </widget> 100 </item> 101 <item> 102 <widget class="UIToolBar" name="m_pToolbarNetworkHost"/> 103 </item> 104 </layout> 105 </widget> 71 106 </widget> 72 107 </item> … … 75 110 <customwidgets> 76 111 <customwidget> 77 <class>QILabelSeparator</class>78 <extends>QLabel</extends>79 <header>QILabelSeparator.h</header>80 </customwidget>81 <customwidget>82 112 <class>UIToolBar</class> 83 113 <extends>QToolBar</extends> 84 114 <header>UIToolBar.h</header> 115 </customwidget> 116 <customwidget> 117 <class>QITabWidget</class> 118 <extends>QTabWidget</extends> 119 <header>QITabWidget.h</header> 85 120 </customwidget> 86 121 </customwidgets> -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsHost.cpp
r48400 r48458 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIGlobalSettingsNetworkDetails class implementation5 * UIGlobalSettingsNetworkDetailsHost class implementation 6 6 */ 7 7 8 8 /* 9 * Copyright (C) 2009-201 0Oracle Corporation9 * Copyright (C) 2009-2013 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Global includes */ 21 #include <QHostAddress> 20 /* Qt includes: */ 22 21 #include <QRegExpValidator> 23 22 24 /* Local includes*/23 /* GUI includes: */ 25 24 #include "UIGlobalSettingsNetwork.h" 26 #include "UIGlobalSettingsNetworkDetails.h" 27 28 /* Network page details constructor: */ 29 UIGlobalSettingsNetworkDetails::UIGlobalSettingsNetworkDetails(QWidget *pParent) 30 : QIWithRetranslateUI2<QIDialog>(pParent 31 #ifdef Q_WS_MAC 32 ,Qt::Sheet 33 #endif /* Q_WS_MAC */ 34 ) 35 , m_pItem(0) 25 #include "UIGlobalSettingsNetworkDetailsHost.h" 26 27 UIGlobalSettingsNetworkDetailsHost::UIGlobalSettingsNetworkDetailsHost(QWidget *pParent, UIDataNetworkHost &data) 28 : QIWithRetranslateUI2<QIDialog>(pParent) 29 , m_data(data) 36 30 { 37 31 /* Apply UI decorations: */ 38 Ui::UIGlobalSettingsNetworkDetails ::setupUi(this);32 Ui::UIGlobalSettingsNetworkDetailsHost::setupUi(this); 39 33 40 34 /* Setup dialog: */ … … 46 40 "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\." 47 41 "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"); 48 QString strTemplateIPv6("[0-9a-fA- Z]{1,4}:{1,2}[0-9a-fA-Z]{1,4}:{1,2}"49 "[0-9a-fA- Z]{1,4}:{1,2}[0-9a-fA-Z]{1,4}:{1,2}"50 "[0-9a-fA- Z]{1,4}:{1,2}[0-9a-fA-Z]{1,4}:{1,2}"51 "[0-9a-fA- Z]{1,4}:{1,2}[0-9a-fA-Z]{1,4}");42 QString strTemplateIPv6("[0-9a-fA-F]{1,4}:{1,2}[0-9a-fA-F]{1,4}:{1,2}" 43 "[0-9a-fA-F]{1,4}:{1,2}[0-9a-fA-F]{1,4}:{1,2}" 44 "[0-9a-fA-F]{1,4}:{1,2}[0-9a-fA-F]{1,4}:{1,2}" 45 "[0-9a-fA-F]{1,4}:{1,2}[0-9a-fA-F]{1,4}"); 52 46 53 47 m_pIPv4Editor->setValidator(new QRegExpValidator(QRegExp(strTemplateIPv4), this)); … … 92 86 retranslateUi(); 93 87 88 /* Load: */ 89 load(); 90 94 91 /* Fix minimum possible size: */ 95 92 resize(minimumSizeHint()); 96 qApp->processEvents();97 93 setFixedSize(minimumSizeHint()); 98 94 } 99 95 100 /* Get data to details sub-dialog: */ 101 void UIGlobalSettingsNetworkDetails::getFromItem(UIHostInterfaceItem *pItem) 102 { 103 m_pItem = pItem; 104 105 /* Host-only Interface: */ 106 m_pEnableManualCheckbox->setChecked(!m_pItem->isDhcpClientEnabled()); 96 void UIGlobalSettingsNetworkDetailsHost::retranslateUi() 97 { 98 /* Translate uic generated strings: */ 99 Ui::UIGlobalSettingsNetworkDetailsHost::retranslateUi(this); 100 } 101 102 void UIGlobalSettingsNetworkDetailsHost::accept() 103 { 104 /* Save before accept: */ 105 save(); 106 /* Call to base-class: */ 107 QIDialog::accept(); 108 } 109 110 void UIGlobalSettingsNetworkDetailsHost::load() 111 { 112 /* Host Interface: */ 113 m_pEnableManualCheckbox->setChecked(!m_data.m_interface.m_fDhcpClientEnabled); 107 114 #if !0 /* !defined (Q_WS_WIN) */ 108 115 /* Disable automatic for all hosts for now: */ … … 110 117 m_pEnableManualCheckbox->setEnabled(false); 111 118 #endif 112 sltDhcpClientStatusChanged();119 loadClientStuff(); 113 120 114 121 /* DHCP Server: */ 115 m_pEnabledDhcpServerCheckbox->setChecked(m_pItem->isDhcpServerEnabled()); 116 sltDhcpServerStatusChanged(); 117 } 118 119 /* Return data from details sub-dialog: */ 120 void UIGlobalSettingsNetworkDetails::putBackToItem() 121 { 122 /* Host-only Interface: */ 123 m_pItem->setDhcpClientEnabled(!m_pEnableManualCheckbox->isChecked()); 124 if (m_pEnableManualCheckbox->isChecked()) 125 { 126 m_pItem->setInterfaceAddress(m_pIPv4Editor->text()); 127 m_pItem->setInterfaceMask(m_pNMv4Editor->text()); 128 if (m_pItem->isIpv6Supported()) 129 { 130 m_pItem->setInterfaceAddress6(m_pIPv6Editor->text()); 131 m_pItem->setInterfaceMaskLength6(m_pNMv6Editor->text()); 132 } 133 } 134 135 /* DHCP Server: */ 136 m_pItem->setDhcpServerEnabled(m_pEnabledDhcpServerCheckbox->isChecked()); 137 if (m_pEnabledDhcpServerCheckbox->isChecked()) 138 { 139 m_pItem->setDhcpServerAddress(m_pDhcpAddressEditor->text()); 140 m_pItem->setDhcpServerMask(m_pDhcpMaskEditor->text()); 141 m_pItem->setDhcpLowerAddress(m_pDhcpLowerAddressEditor->text()); 142 m_pItem->setDhcpUpperAddress(m_pDhcpUpperAddressEditor->text()); 143 } 144 } 145 146 /* Validation stuff: */ 147 void UIGlobalSettingsNetworkDetails::retranslateUi() 148 { 149 /* Translate uic generated strings: */ 150 Ui::UIGlobalSettingsNetworkDetails::retranslateUi(this); 151 } 152 153 /* Handler for DHCP client settings change: */ 154 void UIGlobalSettingsNetworkDetails::sltDhcpClientStatusChanged() 155 { 122 m_pEnabledDhcpServerCheckbox->setChecked(m_data.m_dhcpserver.m_fDhcpServerEnabled); 123 loadServerStuff(); 124 } 125 126 void UIGlobalSettingsNetworkDetailsHost::loadClientStuff() 127 { 128 /* Adjust network interface fields: */ 156 129 bool fIsManual = m_pEnableManualCheckbox->isChecked(); 157 bool fIsIpv6Supported = fIsManual && m_ pItem->isIpv6Supported();130 bool fIsIpv6Supported = fIsManual && m_data.m_interface.m_fIpv6Supported; 158 131 159 132 m_pIPv4Editor->clear(); … … 173 146 if (fIsManual) 174 147 { 175 m_pIPv4Editor->setText(m_ pItem->interfaceAddress());176 m_pNMv4Editor->setText(m_ pItem->interfaceMask());148 m_pIPv4Editor->setText(m_data.m_interface.m_strInterfaceAddress); 149 m_pNMv4Editor->setText(m_data.m_interface.m_strInterfaceMask); 177 150 if (fIsIpv6Supported) 178 151 { 179 m_pIPv6Editor->setText(m_ pItem->interfaceAddress6());180 m_pNMv6Editor->setText(m_ pItem->interfaceMaskLength6());152 m_pIPv6Editor->setText(m_data.m_interface.m_strInterfaceAddress6); 153 m_pNMv6Editor->setText(m_data.m_interface.m_strInterfaceMaskLength6); 181 154 } 182 155 } 183 156 } 184 157 185 /* Handler for DHCP server settings change: */ 186 void UIGlobalSettingsNetworkDetails::sltDhcpServerStatusChanged() 187 { 158 void UIGlobalSettingsNetworkDetailsHost::loadServerStuff() 159 { 160 /* Adjust dhcp server fields: */ 188 161 bool fIsManual = m_pEnabledDhcpServerCheckbox->isChecked(); 189 162 … … 204 177 if (fIsManual) 205 178 { 206 m_pDhcpAddressEditor->setText(m_pItem->dhcpServerAddress()); 207 m_pDhcpMaskEditor->setText(m_pItem->dhcpServerMask()); 208 m_pDhcpLowerAddressEditor->setText(m_pItem->dhcpLowerAddress()); 209 m_pDhcpUpperAddressEditor->setText(m_pItem->dhcpUpperAddress()); 210 } 211 } 212 179 m_pDhcpAddressEditor->setText(m_data.m_dhcpserver.m_strDhcpServerAddress); 180 m_pDhcpMaskEditor->setText(m_data.m_dhcpserver.m_strDhcpServerMask); 181 m_pDhcpLowerAddressEditor->setText(m_data.m_dhcpserver.m_strDhcpLowerAddress); 182 m_pDhcpUpperAddressEditor->setText(m_data.m_dhcpserver.m_strDhcpUpperAddress); 183 } 184 } 185 186 void UIGlobalSettingsNetworkDetailsHost::save() 187 { 188 /* Host Interface: */ 189 m_data.m_interface.m_fDhcpClientEnabled = !m_pEnableManualCheckbox->isChecked(); 190 if (m_pEnableManualCheckbox->isChecked()) 191 { 192 m_data.m_interface.m_strInterfaceAddress = m_pIPv4Editor->text(); 193 m_data.m_interface.m_strInterfaceMask = m_pNMv4Editor->text(); 194 if (m_data.m_interface.m_fIpv6Supported) 195 { 196 m_data.m_interface.m_strInterfaceAddress6 = m_pIPv6Editor->text(); 197 m_data.m_interface.m_strInterfaceMaskLength6 = m_pNMv6Editor->text(); 198 } 199 } 200 201 /* DHCP Server: */ 202 m_data.m_dhcpserver.m_fDhcpServerEnabled = m_pEnabledDhcpServerCheckbox->isChecked(); 203 if (m_pEnabledDhcpServerCheckbox->isChecked()) 204 { 205 m_data.m_dhcpserver.m_strDhcpServerAddress = m_pDhcpAddressEditor->text(); 206 m_data.m_dhcpserver.m_strDhcpServerMask = m_pDhcpMaskEditor->text(); 207 m_data.m_dhcpserver.m_strDhcpLowerAddress = m_pDhcpLowerAddressEditor->text(); 208 m_data.m_dhcpserver.m_strDhcpUpperAddress = m_pDhcpUpperAddressEditor->text(); 209 } 210 } 211 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsHost.h
r48400 r48458 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIGlobalSettingsNetworkDetails class declaration4 * UIGlobalSettingsNetworkDetailsHost class declaration 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 2009-201 0Oracle Corporation8 * Copyright (C) 2009-2013 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 */ 18 18 19 #ifndef __UIGlobalSettingsNetworkDetails _h__20 #define __UIGlobalSettingsNetworkDetails _h__19 #ifndef __UIGlobalSettingsNetworkDetailsHost_h__ 20 #define __UIGlobalSettingsNetworkDetailsHost_h__ 21 21 22 22 /* Local includes */ 23 23 #include "QIDialog.h" 24 24 #include "QIWithRetranslateUI.h" 25 #include "UIGlobalSettingsNetworkDetails .gen.h"25 #include "UIGlobalSettingsNetworkDetailsHost.gen.h" 26 26 27 27 /* Forward decalrations: */ 28 class UI HostInterfaceItem;28 class UIDataNetworkHost; 29 29 30 30 /* Global settings / Network page / Details sub-dialog: */ 31 class UIGlobalSettingsNetworkDetails : public QIWithRetranslateUI2<QIDialog>, public Ui::UIGlobalSettingsNetworkDetails31 class UIGlobalSettingsNetworkDetailsHost : public QIWithRetranslateUI2<QIDialog>, public Ui::UIGlobalSettingsNetworkDetailsHost 32 32 { 33 33 Q_OBJECT; … … 36 36 37 37 /* Constructor: */ 38 UIGlobalSettingsNetworkDetails(QWidget *pParent); 39 40 /* Get/return data to/from details sub-dialog: */ 41 void getFromItem(UIHostInterfaceItem *aItem); 42 void putBackToItem(); 38 UIGlobalSettingsNetworkDetailsHost(QWidget *pParent, UIDataNetworkHost &data); 43 39 44 40 protected: 45 41 46 /* Validation stuff: */42 /* Handler: Translation stuff: */ 47 43 void retranslateUi(); 48 44 49 45 private slots: 50 46 51 /* Various helper slots: */ 52 void sltDhcpClientStatusChanged(); 53 void sltDhcpServerStatusChanged(); 47 /* Handlers: [Re]load stuff: */ 48 void sltDhcpClientStatusChanged() { loadClientStuff(); } 49 void sltDhcpServerStatusChanged() { loadServerStuff(); } 50 51 /* Handler: Dialog stuff: */ 52 void accept(); 54 53 55 54 private: 56 55 57 UIHostInterfaceItem *m_pItem; 56 /* Helpers: Load/Save stuff: */ 57 void load(); 58 void loadClientStuff(); 59 void loadServerStuff(); 60 void save(); 61 62 /* Variable: External data reference: */ 63 UIDataNetworkHost &m_data; 58 64 }; 59 65 60 #endif // __UIGlobalSettingsNetworkDetails_h__ 61 66 #endif /* __UIGlobalSettingsNetworkDetailsHost_h__ */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsHost.ui
r48400 r48458 13 13 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 14 14 </comment> 15 <class>UIGlobalSettingsNetworkDetails </class>16 <widget class="QWidget" name="UIGlobalSettingsNetworkDetails ">15 <class>UIGlobalSettingsNetworkDetailsHost</class> 16 <widget class="QWidget" name="UIGlobalSettingsNetworkDetailsHost"> 17 17 <property name="geometry"> 18 18 <rect> … … 342 342 <sender>m_pButtonBox</sender> 343 343 <signal>accepted()</signal> 344 <receiver>UIGlobalSettingsNetworkDetails </receiver>344 <receiver>UIGlobalSettingsNetworkDetailsHost</receiver> 345 345 <slot>accept()</slot> 346 346 <hints> … … 358 358 <sender>m_pButtonBox</sender> 359 359 <signal>rejected()</signal> 360 <receiver>UIGlobalSettingsNetworkDetails </receiver>360 <receiver>UIGlobalSettingsNetworkDetailsHost</receiver> 361 361 <slot>reject()</slot> 362 362 <hints> -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsNAT.cpp
r48400 r48458 3 3 * 4 4 * VBox frontends: Qt4 GUI ("VirtualBox"): 5 * UIGlobalSettingsNetworkDetails class implementation5 * UIGlobalSettingsNetworkDetailsNAT class implementation 6 6 */ 7 7 8 8 /* 9 * Copyright (C) 2009-201 0Oracle Corporation9 * Copyright (C) 2009-2013 Oracle Corporation 10 10 * 11 11 * This file is part of VirtualBox Open Source Edition (OSE), as … … 18 18 */ 19 19 20 /* Global includes */ 21 #include <QHostAddress> 20 /* Qt includes: */ 22 21 #include <QRegExpValidator> 23 22 24 /* Local includes*/23 /* GUI includes: */ 25 24 #include "UIGlobalSettingsNetwork.h" 26 #include "UIGlobalSettingsNetworkDetails .h"25 #include "UIGlobalSettingsNetworkDetailsNAT.h" 27 26 28 /* Network page details constructor: */ 29 UIGlobalSettingsNetworkDetails::UIGlobalSettingsNetworkDetails(QWidget *pParent) 30 : QIWithRetranslateUI2<QIDialog>(pParent 31 #ifdef Q_WS_MAC 32 ,Qt::Sheet 33 #endif /* Q_WS_MAC */ 34 ) 35 , m_pItem(0) 27 UIGlobalSettingsNetworkDetailsNAT::UIGlobalSettingsNetworkDetailsNAT(QWidget *pParent, UIDataNetworkNAT &data) 28 : QIWithRetranslateUI2<QIDialog>(pParent) 29 , m_data(data) 36 30 { 37 31 /* Apply UI decorations: */ 38 Ui::UIGlobalSettingsNetworkDetails ::setupUi(this);32 Ui::UIGlobalSettingsNetworkDetailsNAT::setupUi(this); 39 33 40 34 /* Setup dialog: */ … … 42 36 43 37 /* Setup validators: */ 44 QString strTemplateIPv4("([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\." 45 "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\." 46 "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\." 47 "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"); 48 QString strTemplateIPv6("[0-9a-fA-Z]{1,4}:{1,2}[0-9a-fA-Z]{1,4}:{1,2}" 49 "[0-9a-fA-Z]{1,4}:{1,2}[0-9a-fA-Z]{1,4}:{1,2}" 50 "[0-9a-fA-Z]{1,4}:{1,2}[0-9a-fA-Z]{1,4}:{1,2}" 51 "[0-9a-fA-Z]{1,4}:{1,2}[0-9a-fA-Z]{1,4}"); 52 53 m_pIPv4Editor->setValidator(new QRegExpValidator(QRegExp(strTemplateIPv4), this)); 54 m_pNMv4Editor->setValidator(new QRegExpValidator(QRegExp(strTemplateIPv4), this)); 55 m_pIPv6Editor->setValidator(new QRegExpValidator(QRegExp(strTemplateIPv6), this)); 56 m_pNMv6Editor->setValidator(new QRegExpValidator(QRegExp("[1-9][0-9]|1[0-1][0-9]|12[0-8]"), this)); 57 m_pDhcpAddressEditor->setValidator(new QRegExpValidator(QRegExp(strTemplateIPv4), this)); 58 m_pDhcpMaskEditor->setValidator(new QRegExpValidator(QRegExp(strTemplateIPv4), this)); 59 m_pDhcpLowerAddressEditor->setValidator(new QRegExpValidator(QRegExp(strTemplateIPv4), this)); 60 m_pDhcpUpperAddressEditor->setValidator(new QRegExpValidator(QRegExp(strTemplateIPv4), this)); 61 62 /* Setup widgets */ 63 m_pIPv6Editor->setFixedWidthByText(QString().fill('X', 32) + QString().fill(':', 7)); 64 65 #if 0 /* defined (Q_WS_WIN) */ 66 QStyleOption options1; 67 options1.initFrom(m_pEnableManualCheckbox); 68 QGridLayout *playout1 = qobject_cast<QGridLayout*>(m_pDetailsTabWidget->widget(0)->layout()); 69 int iWid1 = m_pEnableManualCheckbox->style()->pixelMetric(QStyle::PM_IndicatorWidth, &options1, m_pEnableManualCheckbox) + 70 m_pEnableManualCheckbox->style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &options1, m_pEnableManualCheckbox) - 71 playout1->spacing() - 1; 72 QSpacerItem *spacer1 = new QSpacerItem(iWid1, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 73 playout1->addItem(spacer1, 1, 0, 4); 74 #else 75 m_pEnableManualCheckbox->setVisible(false); 76 #endif 77 78 QStyleOption options2; 79 options2.initFrom(m_pEnabledDhcpServerCheckbox); 80 QGridLayout *pLayout2 = qobject_cast<QGridLayout*>(m_pDetailsTabWidget->widget(1)->layout()); 81 int wid2 = m_pEnabledDhcpServerCheckbox->style()->pixelMetric(QStyle::PM_IndicatorWidth, &options2, m_pEnabledDhcpServerCheckbox) + 82 m_pEnabledDhcpServerCheckbox->style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &options2, m_pEnabledDhcpServerCheckbox) - 83 pLayout2->spacing() - 1; 84 QSpacerItem *pSpacer2 = new QSpacerItem(wid2, 0, QSizePolicy::Fixed, QSizePolicy::Fixed); 85 pLayout2->addItem(pSpacer2, 1, 0, 4); 86 87 /* Setup connections: */ 88 connect(m_pEnableManualCheckbox, SIGNAL(stateChanged(int)), this, SLOT (sltDhcpClientStatusChanged())); 89 connect(m_pEnabledDhcpServerCheckbox, SIGNAL(stateChanged (int)), this, SLOT(sltDhcpServerStatusChanged())); 38 const QString strTemplateName("\\S+"); 39 const QString strTemplateCIDRPrefix1("([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"); 40 const QString strTemplateCIDRPrefix2("([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"); 41 const QString strTemplateCIDRPostfix("([1-9]|1[0-9]|2[0-9]|3[0-2])"); 42 const QString strTemplateCIDR("%1(\\.%2(\\.%2(\\.%2)?)?)?/%3"); 43 const QString strTemplateCIDRFull = strTemplateCIDR.arg(strTemplateCIDRPrefix1, strTemplateCIDRPrefix2, strTemplateCIDRPostfix); 44 m_pEditorNetworkName->setValidator(new QRegExpValidator(QRegExp(strTemplateName), this)); 45 m_pEditorNetworkCIDR->setValidator(new QRegExpValidator(QRegExp(strTemplateCIDRFull), this)); 90 46 91 47 /* Apply language settings: */ 92 48 retranslateUi(); 93 49 50 /* Load: */ 51 load(); 52 94 53 /* Fix minimum possible size: */ 95 54 resize(minimumSizeHint()); 96 qApp->processEvents();97 55 setFixedSize(minimumSizeHint()); 98 56 } 99 57 100 /* Get data to details sub-dialog: */ 101 void UIGlobalSettingsNetworkDetails::getFromItem(UIHostInterfaceItem *pItem) 58 void UIGlobalSettingsNetworkDetailsNAT::retranslateUi() 102 59 { 103 m_pItem = pItem; 104 105 /* Host-only Interface: */ 106 m_pEnableManualCheckbox->setChecked(!m_pItem->isDhcpClientEnabled()); 107 #if !0 /* !defined (Q_WS_WIN) */ 108 /* Disable automatic for all hosts for now: */ 109 m_pEnableManualCheckbox->setChecked(true); 110 m_pEnableManualCheckbox->setEnabled(false); 111 #endif 112 sltDhcpClientStatusChanged(); 113 114 /* DHCP Server: */ 115 m_pEnabledDhcpServerCheckbox->setChecked(m_pItem->isDhcpServerEnabled()); 116 sltDhcpServerStatusChanged(); 60 /* Translate uic generated strings: */ 61 Ui::UIGlobalSettingsNetworkDetailsNAT::retranslateUi(this); 117 62 } 118 63 119 /* Return data from details sub-dialog: */ 120 void UIGlobalSettingsNetworkDetails::putBackToItem() 64 void UIGlobalSettingsNetworkDetailsNAT::polishEvent(QShowEvent*) 121 65 { 122 /* Host-only Interface: */ 123 m_pItem->setDhcpClientEnabled(!m_pEnableManualCheckbox->isChecked()); 124 if (m_pEnableManualCheckbox->isChecked()) 125 { 126 m_pItem->setInterfaceAddress(m_pIPv4Editor->text()); 127 m_pItem->setInterfaceMask(m_pNMv4Editor->text()); 128 if (m_pItem->isIpv6Supported()) 129 { 130 m_pItem->setInterfaceAddress6(m_pIPv6Editor->text()); 131 m_pItem->setInterfaceMaskLength6(m_pNMv6Editor->text()); 132 } 133 } 134 135 /* DHCP Server: */ 136 m_pItem->setDhcpServerEnabled(m_pEnabledDhcpServerCheckbox->isChecked()); 137 if (m_pEnabledDhcpServerCheckbox->isChecked()) 138 { 139 m_pItem->setDhcpServerAddress(m_pDhcpAddressEditor->text()); 140 m_pItem->setDhcpServerMask(m_pDhcpMaskEditor->text()); 141 m_pItem->setDhcpLowerAddress(m_pDhcpLowerAddressEditor->text()); 142 m_pItem->setDhcpUpperAddress(m_pDhcpUpperAddressEditor->text()); 143 } 66 /* Update availability: */ 67 m_pCheckboxAdvertiseDefaultIPv6Route->setEnabled(m_pCheckboxSupportsIPv6->isChecked()); 68 m_pContainerOptions->setEnabled(m_pCheckboxNetwork->isChecked()); 144 69 } 145 70 146 /* Validation stuff: */ 147 void UIGlobalSettingsNetworkDetails::retranslateUi() 71 void UIGlobalSettingsNetworkDetailsNAT::accept() 148 72 { 149 /* Translate uic generated strings: */ 150 Ui::UIGlobalSettingsNetworkDetails::retranslateUi(this); 73 /* Save before accept: */ 74 save(); 75 /* Call to base-class: */ 76 QIDialog::accept(); 151 77 } 152 78 153 /* Handler for DHCP client settings change: */ 154 void UIGlobalSettingsNetworkDetails::sltDhcpClientStatusChanged() 79 void UIGlobalSettingsNetworkDetailsNAT::load() 155 80 { 156 bool fIsManual = m_pEnableManualCheckbox->isChecked(); 157 bool fIsIpv6Supported = fIsManual && m_pItem->isIpv6Supported(); 158 159 m_pIPv4Editor->clear(); 160 m_pNMv4Editor->clear(); 161 m_pIPv6Editor->clear(); 162 m_pNMv6Editor->clear(); 163 164 m_pIPv4Label->setEnabled(fIsManual); 165 m_pNMv4Label->setEnabled(fIsManual); 166 m_pIPv4Editor->setEnabled(fIsManual); 167 m_pNMv4Editor->setEnabled(fIsManual); 168 m_pIPv6Label->setEnabled(fIsIpv6Supported); 169 m_pNMv6Label->setEnabled(fIsIpv6Supported); 170 m_pIPv6Editor->setEnabled(fIsIpv6Supported); 171 m_pNMv6Editor->setEnabled(fIsIpv6Supported); 172 173 if (fIsManual) 174 { 175 m_pIPv4Editor->setText(m_pItem->interfaceAddress()); 176 m_pNMv4Editor->setText(m_pItem->interfaceMask()); 177 if (fIsIpv6Supported) 178 { 179 m_pIPv6Editor->setText(m_pItem->interfaceAddress6()); 180 m_pNMv6Editor->setText(m_pItem->interfaceMaskLength6()); 181 } 182 } 81 /* NAT Network: */ 82 m_pCheckboxNetwork->setChecked(m_data.m_fEnabled); 83 m_pEditorNetworkName->setText(m_data.m_strNewName); 84 m_pEditorNetworkCIDR->setText(m_data.m_strCIDR); 85 m_pCheckboxSupportsDHCP->setChecked(m_data.m_fSupportsDHCP); 86 m_pCheckboxSupportsIPv6->setChecked(m_data.m_fSupportsIPv6); 87 m_pCheckboxAdvertiseDefaultIPv6Route->setChecked(m_data.m_fAdvertiseDefaultIPv6Route); 183 88 } 184 89 185 /* Handler for DHCP server settings change: */ 186 void UIGlobalSettingsNetworkDetails::sltDhcpServerStatusChanged() 90 void UIGlobalSettingsNetworkDetailsNAT::save() 187 91 { 188 bool fIsManual = m_pEnabledDhcpServerCheckbox->isChecked(); 189 190 m_pDhcpAddressEditor->clear(); 191 m_pDhcpMaskEditor->clear(); 192 m_pDhcpLowerAddressEditor->clear(); 193 m_pDhcpUpperAddressEditor->clear(); 194 195 m_pDhcpAddressLabel->setEnabled(fIsManual); 196 m_pDhcpMaskLabel->setEnabled(fIsManual); 197 m_pDhcpLowerAddressLabel->setEnabled(fIsManual); 198 m_pDhcpUpperAddressLabel->setEnabled(fIsManual); 199 m_pDhcpAddressEditor->setEnabled(fIsManual); 200 m_pDhcpMaskEditor->setEnabled(fIsManual); 201 m_pDhcpLowerAddressEditor->setEnabled(fIsManual); 202 m_pDhcpUpperAddressEditor->setEnabled(fIsManual); 203 204 if (fIsManual) 205 { 206 m_pDhcpAddressEditor->setText(m_pItem->dhcpServerAddress()); 207 m_pDhcpMaskEditor->setText(m_pItem->dhcpServerMask()); 208 m_pDhcpLowerAddressEditor->setText(m_pItem->dhcpLowerAddress()); 209 m_pDhcpUpperAddressEditor->setText(m_pItem->dhcpUpperAddress()); 210 } 92 /* NAT Network: */ 93 m_data.m_fEnabled = m_pCheckboxNetwork->isChecked(); 94 m_data.m_strNewName = m_pEditorNetworkName->text(); 95 m_data.m_strCIDR = m_pEditorNetworkCIDR->text(); 96 m_data.m_fSupportsDHCP = m_pCheckboxSupportsDHCP->isChecked(); 97 m_data.m_fSupportsIPv6 = m_pCheckboxSupportsIPv6->isChecked(); 98 m_data.m_fAdvertiseDefaultIPv6Route = m_pCheckboxAdvertiseDefaultIPv6Route->isChecked(); 211 99 } 212 100 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsNAT.h
r48400 r48458 2 2 * 3 3 * VBox frontends: Qt4 GUI ("VirtualBox"): 4 * UIGlobalSettingsNetworkDetails class declaration4 * UIGlobalSettingsNetworkDetailsNAT class declaration 5 5 */ 6 6 7 7 /* 8 * Copyright (C) 2009-201 0Oracle Corporation8 * Copyright (C) 2009-2013 Oracle Corporation 9 9 * 10 10 * This file is part of VirtualBox Open Source Edition (OSE), as … … 17 17 */ 18 18 19 #ifndef __UIGlobalSettingsNetworkDetails _h__20 #define __UIGlobalSettingsNetworkDetails _h__19 #ifndef __UIGlobalSettingsNetworkDetailsNAT_h__ 20 #define __UIGlobalSettingsNetworkDetailsNAT_h__ 21 21 22 22 /* Local includes */ 23 23 #include "QIDialog.h" 24 24 #include "QIWithRetranslateUI.h" 25 #include "UIGlobalSettingsNetworkDetails .gen.h"25 #include "UIGlobalSettingsNetworkDetailsNAT.gen.h" 26 26 27 27 /* Forward decalrations: */ 28 class UIHostInterfaceItem;28 struct UIDataNetworkNAT; 29 29 30 30 /* Global settings / Network page / Details sub-dialog: */ 31 class UIGlobalSettingsNetworkDetails : public QIWithRetranslateUI2<QIDialog>, public Ui::UIGlobalSettingsNetworkDetails31 class UIGlobalSettingsNetworkDetailsNAT : public QIWithRetranslateUI2<QIDialog>, public Ui::UIGlobalSettingsNetworkDetailsNAT 32 32 { 33 33 Q_OBJECT; … … 36 36 37 37 /* Constructor: */ 38 UIGlobalSettingsNetworkDetails(QWidget *pParent); 39 40 /* Get/return data to/from details sub-dialog: */ 41 void getFromItem(UIHostInterfaceItem *aItem); 42 void putBackToItem(); 38 UIGlobalSettingsNetworkDetailsNAT(QWidget *pParent, UIDataNetworkNAT &data); 43 39 44 40 protected: 45 41 46 /* Validation stuff: */42 /* Handler: Translation stuff: */ 47 43 void retranslateUi(); 44 45 /* Handler: Polish event: */ 46 void polishEvent(QShowEvent *pEvent); 48 47 49 48 private slots: 50 49 51 /* Various helper slots: */ 52 void sltDhcpClientStatusChanged(); 53 void sltDhcpServerStatusChanged(); 50 /* Handler: Dialog stuff: */ 51 void accept(); 54 52 55 53 private: 56 54 57 UIHostInterfaceItem *m_pItem; 55 /* Helpers: Load/Save stuff: */ 56 void load(); 57 void save(); 58 59 /* Variable: External data reference: */ 60 UIDataNetworkNAT &m_data; 58 61 }; 59 62 60 #endif // __UIGlobalSettingsNetworkDetails_h__ 61 63 #endif /* __UIGlobalSettingsNetworkDetailsNAT_h__ */ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/global/UIGlobalSettingsNetworkDetailsNAT.ui
r48400 r48458 3 3 VBox frontends: Qt4 GUI ("VirtualBox"): 4 4 5 Copyright (C) 2009-201 2Oracle Corporation5 Copyright (C) 2009-2013 Oracle Corporation 6 6 7 7 This file is part of VirtualBox Open Source Edition (OSE), as … … 13 13 hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 14 14 </comment> 15 <class>UIGlobalSettingsNetworkDetails</class> 16 <widget class="QWidget" name="UIGlobalSettingsNetworkDetails"> 17 <property name="geometry"> 18 <rect> 19 <x>0</x> 20 <y>0</y> 21 <width>402</width> 22 <height>255</height> 23 </rect> 15 <class>UIGlobalSettingsNetworkDetailsNAT</class> 16 <widget class="QWidget" name="UIGlobalSettingsNetworkDetailsNAT"> 17 <property name="windowTitle"> 18 <string>NAT Network Details</string> 24 19 </property> 25 <property name="windowTitle"> 26 <string>Host-only Network Details</string> 27 </property> 28 <layout class="QVBoxLayout"> 29 <item> 30 <widget class="QITabWidget" name="m_pDetailsTabWidget"> 31 <property name="sizePolicy"> 32 <sizepolicy vsizetype="Expanding" hsizetype="Preferred"> 33 <horstretch>0</horstretch> 34 <verstretch>0</verstretch> 35 </sizepolicy> 20 <layout class="QGridLayout"> 21 <item row="0" column="0"> 22 <widget class="QCheckBox" name="m_pCheckboxNetwork"> 23 <property name="text"> 24 <string>Network &Enabled</string> 36 25 </property> 37 <property name=" currentIndex">38 < number>0</number>26 <property name="toolTip"> 27 <string>Enable this NAT network.</string> 39 28 </property> 40 <widget class="QWidget" name="m_pInterfaceTab">41 <attribute name="title">42 <string>&Adapter</string>43 </attribute>44 <layout class="QGridLayout">45 <item row="0" column="0" colspan="3">46 <widget class="QCheckBox" name="m_pEnableManualCheckbox">47 <property name="text">48 <string>Manual &Configuration</string>49 </property>50 <property name="checked">51 <bool>true</bool>52 </property>53 <property name="toolTip">54 <string>Use manual configuration for this host-only network adapter.</string>55 </property>56 </widget>57 </item>58 <item row="1" column="1">59 <widget class="QLabel" name="m_pIPv4Label">60 <property name="text">61 <string>&IPv4 Address:</string>62 </property>63 <property name="alignment">64 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>65 </property>66 <property name="buddy">67 <cstring>m_pIPv4Editor</cstring>68 </property>69 </widget>70 </item>71 <item row="1" column="2">72 <widget class="QILineEdit" name="m_pIPv4Editor">73 <property name="sizePolicy">74 <sizepolicy vsizetype="Fixed" hsizetype="Expanding">75 <horstretch>0</horstretch>76 <verstretch>0</verstretch>77 </sizepolicy>78 </property>79 <property name="toolTip">80 <string>Displays the host IPv4 address for this adapter.</string>81 </property>82 </widget>83 </item>84 <item row="2" column="1">85 <widget class="QLabel" name="m_pNMv4Label">86 <property name="text">87 <string>IPv4 Network &Mask:</string>88 </property>89 <property name="alignment">90 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>91 </property>92 <property name="buddy">93 <cstring>m_pNMv4Editor</cstring>94 </property>95 </widget>96 </item>97 <item row="2" column="2">98 <widget class="QILineEdit" name="m_pNMv4Editor">99 <property name="sizePolicy">100 <sizepolicy vsizetype="Fixed" hsizetype="Expanding">101 <horstretch>0</horstretch>102 <verstretch>0</verstretch>103 </sizepolicy>104 </property>105 <property name="toolTip">106 <string>Displays the host IPv4 network mask for this adapter.</string>107 </property>108 </widget>109 </item>110 <item row="3" column="1">111 <widget class="QLabel" name="m_pIPv6Label">112 <property name="text">113 <string>I&Pv6 Address:</string>114 </property>115 <property name="alignment">116 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>117 </property>118 <property name="buddy">119 <cstring>m_pIPv6Editor</cstring>120 </property>121 </widget>122 </item>123 <item row="3" column="2">124 <widget class="QILineEdit" name="m_pIPv6Editor">125 <property name="sizePolicy">126 <sizepolicy vsizetype="Fixed" hsizetype="Expanding">127 <horstretch>0</horstretch>128 <verstretch>0</verstretch>129 </sizepolicy>130 </property>131 <property name="toolTip">132 <string>Displays the host IPv6 address for this adapter if IPv6 is supported.</string>133 </property>134 </widget>135 </item>136 <item row="4" column="1">137 <widget class="QLabel" name="m_pNMv6Label">138 <property name="text">139 <string>IPv6 Network Mask &Length:</string>140 </property>141 <property name="alignment">142 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>143 </property>144 <property name="buddy">145 <cstring>m_pNMv6Editor</cstring>146 </property>147 </widget>148 </item>149 <item row="4" column="2">150 <widget class="QILineEdit" name="m_pNMv6Editor">151 <property name="sizePolicy">152 <sizepolicy vsizetype="Fixed" hsizetype="Expanding">153 <horstretch>0</horstretch>154 <verstretch>0</verstretch>155 </sizepolicy>156 </property>157 <property name="toolTip">158 <string>Displays the host IPv6 network mask prefix length for this adapter if IPv6 is supported.</string>159 </property>160 </widget>161 </item>162 <item row="5" column="0" colspan="3">163 <spacer name="verticalSpacer1">164 <property name="orientation">165 <enum>Qt::Vertical</enum>166 </property>167 <property name="sizeHint" stdset="0">168 <size>169 <width>0</width>170 <height>0</height>171 </size>172 </property>173 </spacer>174 </item>175 </layout>176 </widget>177 <widget class="QWidget" name="m_pDhcpServerTab">178 <attribute name="title">179 <string>&DHCP Server</string>180 </attribute>181 <layout class="QGridLayout">182 <item row="0" column="0" colspan="3">183 <widget class="QCheckBox" name="m_pEnabledDhcpServerCheckbox">184 <property name="text">185 <string>&Enable Server</string>186 </property>187 <property name="toolTip">188 <string>Indicates whether the DHCP Server is enabled on machine startup or not.</string>189 </property>190 </widget>191 </item>192 <item row="1" column="1">193 <widget class="QLabel" name="m_pDhcpAddressLabel">194 <property name="text">195 <string>Server Add&ress:</string>196 </property>197 <property name="alignment">198 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>199 </property>200 <property name="buddy">201 <cstring>m_pDhcpAddressEditor</cstring>202 </property>203 </widget>204 </item>205 <item row="1" column="2">206 <widget class="QILineEdit" name="m_pDhcpAddressEditor">207 <property name="sizePolicy">208 <sizepolicy vsizetype="Fixed" hsizetype="Expanding">209 <horstretch>0</horstretch>210 <verstretch>0</verstretch>211 </sizepolicy>212 </property>213 <property name="toolTip">214 <string>Displays the address of the DHCP server servicing the network associated with this host-only adapter.</string>215 </property>216 </widget>217 </item>218 <item row="2" column="1">219 <widget class="QLabel" name="m_pDhcpMaskLabel">220 <property name="text">221 <string>Server &Mask:</string>222 </property>223 <property name="alignment">224 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>225 </property>226 <property name="buddy">227 <cstring>m_pDhcpMaskEditor</cstring>228 </property>229 </widget>230 </item>231 <item row="2" column="2">232 <widget class="QILineEdit" name="m_pDhcpMaskEditor">233 <property name="sizePolicy">234 <sizepolicy vsizetype="Fixed" hsizetype="Expanding">235 <horstretch>0</horstretch>236 <verstretch>0</verstretch>237 </sizepolicy>238 </property>239 <property name="toolTip">240 <string>Displays the network mask of the DHCP server servicing the network associated with this host-only adapter.</string>241 </property>242 </widget>243 </item>244 <item row="3" column="1">245 <widget class="QLabel" name="m_pDhcpLowerAddressLabel">246 <property name="text">247 <string>&Lower Address Bound:</string>248 </property>249 <property name="alignment">250 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>251 </property>252 <property name="buddy">253 <cstring>m_pDhcpLowerAddressEditor</cstring>254 </property>255 </widget>256 </item>257 <item row="3" column="2">258 <widget class="QILineEdit" name="m_pDhcpLowerAddressEditor">259 <property name="sizePolicy">260 <sizepolicy vsizetype="Fixed" hsizetype="Expanding">261 <horstretch>0</horstretch>262 <verstretch>0</verstretch>263 </sizepolicy>264 </property>265 <property name="toolTip">266 <string>Displays the lower address bound offered by the DHCP server servicing the network associated with this host-only adapter.</string>267 </property>268 </widget>269 </item>270 <item row="4" column="1">271 <widget class="QLabel" name="m_pDhcpUpperAddressLabel">272 <property name="text">273 <string>&Upper Address Bound:</string>274 </property>275 <property name="alignment">276 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>277 </property>278 <property name="buddy">279 <cstring>m_pDhcpUpperAddressEditor</cstring>280 </property>281 </widget>282 </item>283 <item row="4" column="2">284 <widget class="QILineEdit" name="m_pDhcpUpperAddressEditor">285 <property name="sizePolicy">286 <sizepolicy vsizetype="Fixed" hsizetype="Expanding">287 <horstretch>0</horstretch>288 <verstretch>0</verstretch>289 </sizepolicy>290 </property>291 <property name="toolTip">292 <string>Displays the upper address bound offered by the DHCP server servicing the network associated with this host-only adapter.</string>293 </property>294 </widget>295 </item>296 <item row="5" column="0" colspan="3">297 <spacer name="verticalSpacer2">298 <property name="orientation">299 <enum>Qt::Vertical</enum>300 </property>301 <property name="sizeHint" stdset="0">302 <size>303 <width>0</width>304 <height>0</height>305 </size>306 </property>307 </spacer>308 </item>309 </layout>310 </widget>311 29 </widget> 312 30 </item> 313 <item> 31 <item row="1" column="0" colspan="2"> 32 <widget class="QWidget" name="m_pContainerOptions"> 33 <layout class="QGridLayout"> 34 <item row="0" column="0" rowspan="3"> 35 <spacer> 36 <property name="orientation"> 37 <enum>Qt::Horizontal</enum> 38 </property> 39 <property name="sizeType"> 40 <enum>QSizePolicy::Fixed</enum> 41 </property> 42 <property name="sizeHint" stdset="0"> 43 <size> 44 <width>20</width> 45 <height>0</height> 46 </size> 47 </property> 48 </spacer> 49 </item> 50 <item row="0" column="1"> 51 <widget class="QLabel" name="m_pLabelNetworkName"> 52 <property name="text"> 53 <string>Network &Name:</string> 54 </property> 55 <property name="alignment"> 56 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 57 </property> 58 <property name="buddy"> 59 <cstring>m_pEditorNetworkName</cstring> 60 </property> 61 </widget> 62 </item> 63 <item row="0" column="2" colspan="2"> 64 <widget class="QLineEdit" name="m_pEditorNetworkName"> 65 <property name="toolTip"> 66 <string>Displays the name for this network.</string> 67 </property> 68 </widget> 69 </item> 70 <item row="1" column="1"> 71 <widget class="QLabel" name="m_pLabelNetworkCIDR"> 72 <property name="text"> 73 <string>Network &CIDR:</string> 74 </property> 75 <property name="alignment"> 76 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 77 </property> 78 <property name="buddy"> 79 <cstring>m_pEditorNetworkCIDR</cstring> 80 </property> 81 </widget> 82 </item> 83 <item row="1" column="2" colspan="2"> 84 <widget class="QLineEdit" name="m_pEditorNetworkCIDR"> 85 <property name="toolTip"> 86 <string>Displays the CIDR for this network.</string> 87 </property> 88 </widget> 89 </item> 90 <item row="2" column="1"> 91 <widget class="QLabel" name="m_pLabelOptionsAdvanced"> 92 <property name="alignment"> 93 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignTop</set> 94 </property> 95 <property name="text"> 96 <string>Network Options:</string> 97 </property> 98 </widget> 99 </item> 100 <item row="2" column="2"> 101 <widget class="QCheckBox" name="m_pCheckboxSupportsDHCP"> 102 <property name="text"> 103 <string>Supports &DHCP</string> 104 </property> 105 <property name="toolTip"> 106 <string>Determines whether this network supports DHCP.</string> 107 </property> 108 </widget> 109 </item> 110 <item row="3" column="2"> 111 <widget class="QCheckBox" name="m_pCheckboxSupportsIPv6"> 112 <property name="text"> 113 <string>Supports &IPv6</string> 114 </property> 115 <property name="toolTip"> 116 <string>Determines whether this network supports IPv6.</string> 117 </property> 118 </widget> 119 </item> 120 <item row="4" column="2"> 121 <widget class="QCheckBox" name="m_pCheckboxAdvertiseDefaultIPv6Route"> 122 <property name="text"> 123 <string>Advertise Default IPv6 &Route</string> 124 </property> 125 <property name="toolTip"> 126 <string>Determines whether default IPv6 route should be advertised for this network.</string> 127 </property> 128 </widget> 129 </item> 130 </layout> 131 </widget> 132 </item> 133 <item row="2" column="0" colspan="2"> 134 <spacer> 135 <property name="orientation"> 136 <enum>Qt::Vertical</enum> 137 </property> 138 <property name="sizeHint" stdset="0"> 139 <size> 140 <width>0</width> 141 <height>0</height> 142 </size> 143 </property> 144 </spacer> 145 </item> 146 <item row="3" column="0" colspan="2"> 314 147 <widget class="QIDialogButtonBox" name="m_pButtonBox"> 315 148 <property name="standardButtons"> … … 322 155 <customwidgets> 323 156 <customwidget> 324 <class>QILineEdit</class>325 <extends>QLineEdit</extends>326 <header>QILineEdit.h</header>327 </customwidget>328 <customwidget>329 157 <class>QIDialogButtonBox</class> 330 158 <extends>QDialogButtonBox</extends> 331 159 <header>QIDialogButtonBox.h</header> 332 </customwidget>333 <customwidget>334 <class>QITabWidget</class>335 <extends>QTabWidget</extends>336 <header>QITabWidget.h</header>337 160 </customwidget> 338 161 </customwidgets> … … 340 163 <connections> 341 164 <connection> 165 <sender>m_pCheckboxNetwork</sender> 166 <signal>toggled(bool)</signal> 167 <receiver>m_pContainerOptions</receiver> 168 <slot>setEnabled(bool)</slot> 169 </connection> 170 <connection> 171 <sender>m_pCheckboxSupportsIPv6</sender> 172 <signal>toggled(bool)</signal> 173 <receiver>m_pCheckboxAdvertiseDefaultIPv6Route</receiver> 174 <slot>setEnabled(bool)</slot> 175 </connection> 176 <connection> 342 177 <sender>m_pButtonBox</sender> 343 178 <signal>accepted()</signal> 344 <receiver>UIGlobalSettingsNetworkDetails </receiver>179 <receiver>UIGlobalSettingsNetworkDetailsNAT</receiver> 345 180 <slot>accept()</slot> 346 <hints>347 <hint type="sourcelabel">348 <x>162</x>349 <y>339</y>350 </hint>351 <hint type="destinationlabel">352 <x>162</x>353 <y>179</y>354 </hint>355 </hints>356 181 </connection> 357 182 <connection> 358 183 <sender>m_pButtonBox</sender> 359 184 <signal>rejected()</signal> 360 <receiver>UIGlobalSettingsNetworkDetails </receiver>185 <receiver>UIGlobalSettingsNetworkDetailsNAT</receiver> 361 186 <slot>reject()</slot> 362 <hints>363 <hint type="sourcelabel">364 <x>162</x>365 <y>339</y>366 </hint>367 <hint type="destinationlabel">368 <x>162</x>369 <y>179</y>370 </hint>371 </hints>372 187 </connection> 373 188 </connections>
Note:
See TracChangeset
for help on using the changeset viewer.