Changeset 93328 in vbox for trunk/src/VBox
- Timestamp:
- Jan 18, 2022 4:33:39 PM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetCloudNetwork.cpp
r93115 r93328 32 32 #include "QILineEdit.h" 33 33 #include "QITabWidget.h" 34 #include " UIIconPool.h"34 #include "QIToolButton.h" 35 35 #include "UICloudNetworkingStuff.h" 36 36 #include "UIDetailsWidgetCloudNetwork.h" 37 #include "UIFormEditorWidget.h" 38 #include "UIIconPool.h" 37 39 #include "UIMessageCenter.h" 38 40 #include "UINetworkManagerUtils.h" 39 41 #include "UINotificationCenter.h" 42 43 44 UISubnetSelectionDialog::UISubnetSelectionDialog(QWidget *pParent, 45 const QString &strShortProviderName, 46 const QString &strProfileName, 47 const QString &strSubnetId) 48 : QIWithRetranslateUI<QDialog>(pParent) 49 , m_strProviderShortName(strShortProviderName) 50 , m_strProfileName(strProfileName) 51 , m_strSubnetId(strSubnetId) 52 , m_pFormEditor(0) 53 , m_pButtonBox(0) 54 , m_pNotificationCenter(0) 55 { 56 prepare(); 57 } 58 59 UISubnetSelectionDialog::~UISubnetSelectionDialog() 60 { 61 cleanup(); 62 } 63 64 void UISubnetSelectionDialog::accept() 65 { 66 /* Get altered description back: */ 67 m_comForm.GetVirtualSystemDescription(); 68 QVector<KVirtualSystemDescriptionType> aTypes; 69 QVector<QString> aRefs, aOVFValues, aVBoxValues, aExtraConfigValues; 70 m_comDescription.GetDescriptionByType(KVirtualSystemDescriptionType_CloudOCISubnet, 71 aTypes, aRefs, aOVFValues, aVBoxValues, aExtraConfigValues); 72 if (!m_comDescription.isOk()) 73 { 74 UINotificationMessage::cannotAcquireVirtualSystemDescriptionParameter(m_comDescription, 75 m_pNotificationCenter); 76 return; 77 } 78 AssertReturnVoid(!aVBoxValues.isEmpty()); 79 m_strSubnetId = aVBoxValues.first(); 80 81 /* Call to base-class: */ 82 return QIWithRetranslateUI<QDialog>::accept(); 83 } 84 85 int UISubnetSelectionDialog::exec() 86 { 87 /* Request to init dialog _after_ being executed: */ 88 QMetaObject::invokeMethod(this, "sltInit", Qt::QueuedConnection); 89 90 /* Call to base-class: */ 91 return QIWithRetranslateUI<QDialog>::exec(); 92 } 93 94 void UISubnetSelectionDialog::retranslateUi() 95 { 96 setWindowTitle(tr("Select Subnet")); 97 } 98 99 void UISubnetSelectionDialog::sltInit() 100 { 101 /* Create description: */ 102 m_comDescription = createVirtualSystemDescription(m_pNotificationCenter); 103 if (m_comDescription.isNull()) 104 return; 105 /* Update it with current subnet value: */ 106 m_comDescription.AddDescription(KVirtualSystemDescriptionType_CloudOCISubnet, m_strSubnetId, QString()); 107 108 /* Create cloud client: */ 109 CCloudClient comCloudClient = cloudClientByName(m_strProviderShortName, m_strProfileName, m_pNotificationCenter); 110 if (comCloudClient.isNull()) 111 return; 112 113 /* Create subnet selection VSD form: */ 114 UINotificationProgressSubnetSelectionVSDFormCreate *pNotification = new UINotificationProgressSubnetSelectionVSDFormCreate(comCloudClient, 115 m_comDescription, 116 m_strProviderShortName, 117 m_strProfileName); 118 connect(pNotification, &UINotificationProgressSubnetSelectionVSDFormCreate::sigVSDFormCreated, 119 this, &UISubnetSelectionDialog::sltHandleVSDFormCreated); 120 m_pNotificationCenter->append(pNotification); 121 } 122 123 void UISubnetSelectionDialog::sltHandleVSDFormCreated(const CVirtualSystemDescriptionForm &comForm) 124 { 125 m_comForm = comForm; 126 m_pFormEditor->setVirtualSystemDescriptionForm(m_comForm); 127 } 128 129 void UISubnetSelectionDialog::prepare() 130 { 131 /* Prepare main layout: */ 132 QVBoxLayout *pLayoutMain = new QVBoxLayout(this); 133 if (pLayoutMain) 134 { 135 /* Prepare form editor: */ 136 m_pFormEditor = new UIFormEditorWidget(this); 137 if (m_pFormEditor) 138 pLayoutMain->addWidget(m_pFormEditor); 139 140 /* Prepare button-box: */ 141 m_pButtonBox = new QIDialogButtonBox(this); 142 if (m_pButtonBox) 143 { 144 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 145 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &QDialog::accept); 146 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &QDialog::reject); 147 148 pLayoutMain->addWidget(m_pButtonBox); 149 } 150 } 151 152 /* Prepare local notification-center: */ 153 m_pNotificationCenter = new UINotificationCenter(this); 154 if (m_pNotificationCenter && m_pFormEditor) 155 m_pFormEditor->setNotificationCenter(m_pNotificationCenter); 156 157 /* Apply language settings: */ 158 retranslateUi(); 159 } 160 161 void UISubnetSelectionDialog::cleanup() 162 { 163 /* Cleanup local notification-center: */ 164 delete m_pNotificationCenter; 165 m_pNotificationCenter = 0; 166 } 40 167 41 168 … … 51 178 , m_pLabelNetworkId(0) 52 179 , m_pEditorNetworkId(0) 180 , m_pButtonNetworkId(0) 53 181 , m_pButtonBoxOptions(0) 54 182 { … … 129 257 if (m_pEditorNetworkId) 130 258 m_pEditorNetworkId->setToolTip(tr("Holds the id for this network.")); 259 if (m_pButtonNetworkId) 260 m_pButtonNetworkId->setToolTip(tr("Selects the id for this network.")); 131 261 if (m_pButtonBoxOptions) 132 262 { … … 179 309 } 180 310 311 void UIDetailsWidgetCloudNetwork::sltNetworkIdListRequested() 312 { 313 /* Create subnet selection dialog: */ 314 QPointer<UISubnetSelectionDialog> pDialog = new UISubnetSelectionDialog(this, 315 m_pComboProviderName->currentData().toString(), 316 m_pComboProfileName->currentData().toString(), 317 m_pEditorNetworkId->text()); 318 319 /* Execute dialog to ask user for subnet: */ 320 if (pDialog->exec() == QDialog::Accepted) 321 m_pEditorNetworkId->setText(pDialog->subnetId()); 322 323 /* Cleanup subnet dialog finally: */ 324 delete pDialog; 325 } 326 181 327 void UIDetailsWidgetCloudNetwork::sltHandleButtonBoxClick(QAbstractButton *pButton) 182 328 { … … 238 384 this, &UIDetailsWidgetCloudNetwork::sltNetworkNameChanged); 239 385 240 pLayout->addWidget(m_pEditorNetworkName, 0, 1 );386 pLayout->addWidget(m_pEditorNetworkName, 0, 1, 1, 2); 241 387 } 242 388 … … 257 403 this, &UIDetailsWidgetCloudNetwork::sltCloudProviderNameChanged); 258 404 259 pLayout->addWidget(m_pComboProviderName, 1, 1 );405 pLayout->addWidget(m_pComboProviderName, 1, 1, 1, 2); 260 406 } 261 407 … … 276 422 this, &UIDetailsWidgetCloudNetwork::sltCloudProfileNameChanged); 277 423 278 pLayout->addWidget(m_pComboProfileName, 2, 1 );424 pLayout->addWidget(m_pComboProfileName, 2, 1, 1, 2); 279 425 } 280 426 … … 292 438 if (m_pLabelNetworkId) 293 439 m_pLabelNetworkId->setBuddy(m_pEditorNetworkId); 294 connect(m_pEditorNetworkId, &QLineEdit::text Edited,440 connect(m_pEditorNetworkId, &QLineEdit::textChanged, 295 441 this, &UIDetailsWidgetCloudNetwork::sltNetworkIdChanged); 296 442 297 443 pLayout->addWidget(m_pEditorNetworkId, 3, 1); 444 } 445 /* Prepare network id button: */ 446 m_pButtonNetworkId = new QIToolButton(this); 447 if (m_pButtonNetworkId) 448 { 449 m_pButtonNetworkId->setIcon(UIIconPool::iconSet(":/subnet_16px.png")); 450 connect(m_pButtonNetworkId, &QIToolButton::clicked, 451 this, &UIDetailsWidgetCloudNetwork::sltNetworkIdListRequested); 452 453 pLayout->addWidget(m_pButtonNetworkId, 3, 2); 298 454 } 299 455 … … 442 598 m_pLabelNetworkId->setEnabled(fIsNetworkExists); 443 599 m_pEditorNetworkId->setEnabled(fIsNetworkExists); 600 m_pButtonNetworkId->setEnabled(fIsNetworkExists); 444 601 445 602 /* Load fields: */ -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetCloudNetwork.h
r93115 r93328 29 29 #include "QIWithRetranslateUI.h" 30 30 #include "UIPortForwardingTable.h" 31 32 /* COM includes: */ 33 #include "CVirtualSystemDescription.h" 34 #include "CVirtualSystemDescriptionForm.h" 31 35 32 36 /* Forward declarations: */ … … 42 46 class QILineEdit; 43 47 class QITabWidget; 48 class QIToolButton; 49 class UIFormEditorWidget; 50 class UINotificationCenter; 51 52 53 /** QDialog subclass for subnet selection functionality. */ 54 class UISubnetSelectionDialog : public QIWithRetranslateUI<QDialog> 55 { 56 Q_OBJECT; 57 58 public: 59 60 /** Constructs dialog passing @a pParent to the base-class. 61 * @param strProviderShortName Brings the short provider name for cloud client being created. 62 * @param strProfileName Brings the profile name for cloud client being created. 63 * @param strSubnetId Brings the initial subnet ID to be cached. */ 64 UISubnetSelectionDialog(QWidget *pParent, 65 const QString &strProviderShortName, 66 const QString &strProfileName, 67 const QString &strSubnetId); 68 /** Destructs dialog. */ 69 virtual ~UISubnetSelectionDialog() override final; 70 71 /** Returns cached subnet ID. */ 72 QString subnetId() const { return m_strSubnetId; } 73 74 public slots: 75 76 /** Accepts dialog. */ 77 virtual void accept() override final; 78 79 /** Executes dialog. */ 80 virtual int exec() override final; 81 82 protected: 83 84 /** Handles translation event. */ 85 virtual void retranslateUi() override final; 86 87 private slots: 88 89 /** Performs dialog initialization. */ 90 void sltInit(); 91 92 /** Handles notification about subnet selection @a comForm being created. */ 93 void sltHandleVSDFormCreated(const CVirtualSystemDescriptionForm &comForm); 94 95 private: 96 97 /** Prepares all. */ 98 void prepare(); 99 /** Cleanups all. */ 100 void cleanup(); 101 102 /** Holds the short provider name for cloud client being created. */ 103 QString m_strProviderShortName; 104 /** Holds the profile name for cloud client being created. */ 105 QString m_strProfileName; 106 /** Holds the cached subnet ID. */ 107 QString m_strSubnetId; 108 109 /** Holds the virtual system description container. */ 110 CVirtualSystemDescription m_comDescription; 111 /** Holds the virtual system description form. */ 112 CVirtualSystemDescriptionForm m_comForm; 113 114 /** Holds the form editor instance. */ 115 UIFormEditorWidget *m_pFormEditor; 116 /** Holds the button-box instance. */ 117 QIDialogButtonBox *m_pButtonBox; 118 119 /** Holds the notification-center instance. */ 120 UINotificationCenter *m_pNotificationCenter; 121 }; 44 122 45 123 … … 145 223 /** Handles network id text change. */ 146 224 void sltNetworkIdChanged(const QString &strText); 225 /** Handles request to list possible network ids. */ 226 void sltNetworkIdListRequested(); 147 227 148 228 /** Handles button-box button click. */ … … 184 264 * @{ */ 185 265 /** Holds the network name label instance. */ 186 QLabel *m_pLabelNetworkName;266 QLabel *m_pLabelNetworkName; 187 267 /** Holds the network name editor instance. */ 188 QLineEdit *m_pEditorNetworkName;268 QLineEdit *m_pEditorNetworkName; 189 269 /** Holds the cloud provider name label instance. */ 190 QLabel *m_pLabelProviderName;270 QLabel *m_pLabelProviderName; 191 271 /** Holds the cloud provider name combo instance. */ 192 QIComboBox *m_pComboProviderName;272 QIComboBox *m_pComboProviderName; 193 273 /** Holds the cloud profile name label instance. */ 194 QLabel *m_pLabelProfileName;274 QLabel *m_pLabelProfileName; 195 275 /** Holds the cloud profile name combo instance. */ 196 QIComboBox *m_pComboProfileName;276 QIComboBox *m_pComboProfileName; 197 277 /** Holds the network id label instance. */ 198 QLabel *m_pLabelNetworkId;278 QLabel *m_pLabelNetworkId; 199 279 /** Holds the network id editor instance. */ 200 QLineEdit *m_pEditorNetworkId; 280 QLineEdit *m_pEditorNetworkId; 281 /** Holds the network id list button instance. */ 282 QIToolButton *m_pButtonNetworkId; 201 283 202 284 /** Holds the 'Options' button-box instance. */ -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.cpp
r93115 r93328 713 713 QApplication::translate("UIMessageCenter", "Failed to acquire display parameter.") + 714 714 UIErrorString::formatErrorInfo(comDisplay)); 715 } 716 717 /* static */ 718 void UINotificationMessage::cannotAcquireVirtualSystemDescriptionParameter(const CVirtualSystemDescription &comVsd, 719 UINotificationCenter *pParent /* = 0 */) 720 { 721 createMessage( 722 QApplication::translate("UIMessageCenter", "VSD failure ..."), 723 QApplication::translate("UIMessageCenter", "Failed to acquire virtual system description parameter.") + 724 UIErrorString::formatErrorInfo(comVsd), 725 QString(), QString(), pParent); 715 726 } 716 727 … … 2434 2445 /* Return progress-wrapper: */ 2435 2446 return comProgress; 2447 } 2448 2449 2450 /********************************************************************************************************************************* 2451 * Class UINotificationProgressSubnetSelectionVSDFormCreate implementation. * 2452 *********************************************************************************************************************************/ 2453 2454 UINotificationProgressSubnetSelectionVSDFormCreate::UINotificationProgressSubnetSelectionVSDFormCreate(const CCloudClient &comClient, 2455 const CVirtualSystemDescription &comVSD, 2456 const QString &strProviderShortName, 2457 const QString &strProfileName) 2458 : m_comClient(comClient) 2459 , m_comVSD(comVSD) 2460 , m_strProviderShortName(strProviderShortName) 2461 , m_strProfileName(strProfileName) 2462 { 2463 connect(this, &UINotificationProgress::sigProgressFinished, 2464 this, &UINotificationProgressSubnetSelectionVSDFormCreate::sltHandleProgressFinished); 2465 } 2466 2467 QString UINotificationProgressSubnetSelectionVSDFormCreate::name() const 2468 { 2469 return UINotificationProgress::tr("Creating subnet selection VSD form ..."); 2470 } 2471 2472 QString UINotificationProgressSubnetSelectionVSDFormCreate::details() const 2473 { 2474 return UINotificationProgress::tr("<b>Provider:</b> %1<br><b>Profile:</b> %2") 2475 .arg(m_strProviderShortName, m_strProfileName); 2476 } 2477 2478 CProgress UINotificationProgressSubnetSelectionVSDFormCreate::createProgress(COMResult &comResult) 2479 { 2480 /* Initialize progress-wrapper: */ 2481 CProgress comProgress = m_comClient.GetSubnetSelectionForm(m_comVSD, m_comVSDForm); 2482 /* Store COM result: */ 2483 comResult = m_comClient; 2484 /* Return progress-wrapper: */ 2485 return comProgress; 2486 } 2487 2488 void UINotificationProgressSubnetSelectionVSDFormCreate::sltHandleProgressFinished() 2489 { 2490 if (m_comVSDForm.isNotNull()) 2491 emit sigVSDFormCreated(m_comVSDForm); 2436 2492 } 2437 2493 -
trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObjects.h
r93115 r93328 300 300 * @param comNetwork Brings the object parameter get acquired from. */ 301 301 static void cannotAcquireDispayParameter(const CDisplay &comDisplay); 302 /** Notifies about inability to acquire IVirtualSystemDescription parameter. 303 * @param comVsd Brings the object parameter get acquired from. */ 304 static void cannotAcquireVirtualSystemDescriptionParameter(const CVirtualSystemDescription &comVsd, 305 UINotificationCenter *pParent = 0); 302 306 /** Notifies about inability to acquire IVirtualSystemDescriptionForm parameter. 303 307 * @param comVsdForm Brings the object parameter get acquired from. */ … … 1169 1173 }; 1170 1174 1175 /** UINotificationProgress extension for subnet selection VSD form create functionality. */ 1176 class SHARED_LIBRARY_STUFF UINotificationProgressSubnetSelectionVSDFormCreate : public UINotificationProgress 1177 { 1178 Q_OBJECT; 1179 1180 signals: 1181 1182 /** Notifies listeners about VSD @a comForm created. 1183 * @param comForm Brings created VSD form. */ 1184 void sigVSDFormCreated(const CVirtualSystemDescriptionForm &comForm); 1185 1186 public: 1187 1188 /** Constructs subnet selection VSD form create notification-progress. 1189 * @param comClient Brings the cloud client being creating VSD form. 1190 * @param comVsd Brings the VSD, form being created for. 1191 * @param strProviderShortName Brings the short provider name. 1192 * @param strProfileName Brings the profile name. */ 1193 UINotificationProgressSubnetSelectionVSDFormCreate(const CCloudClient &comClient, 1194 const CVirtualSystemDescription &comVSD, 1195 const QString &strProviderShortName, 1196 const QString &strProfileName); 1197 1198 protected: 1199 1200 /** Returns object name. */ 1201 virtual QString name() const /* override final */; 1202 /** Returns object details. */ 1203 virtual QString details() const /* override final */; 1204 /** Creates and returns started progress-wrapper. */ 1205 virtual CProgress createProgress(COMResult &comResult) /* override final */; 1206 1207 private slots: 1208 1209 /** Handles signal about progress being finished. */ 1210 void sltHandleProgressFinished(); 1211 1212 private: 1213 1214 /** Holds the cloud client being creating VSD form. */ 1215 CCloudClient m_comClient; 1216 /** Holds the VSD, form being created for. */ 1217 CVirtualSystemDescription m_comVSD; 1218 /** Holds the VSD form being created. */ 1219 CVirtualSystemDescriptionForm m_comVSDForm; 1220 /** Holds the short provider name. */ 1221 QString m_strProviderShortName; 1222 /** Holds the profile name. */ 1223 QString m_strProfileName; 1224 }; 1225 1171 1226 /** UINotificationProgress extension for launch VSD form create functionality. */ 1172 1227 class SHARED_LIBRARY_STUFF UINotificationProgressLaunchVSDFormCreate : public UINotificationProgress
Note:
See TracChangeset
for help on using the changeset viewer.