Changeset 85389 in vbox
- Timestamp:
- Jul 20, 2020 12:42:14 PM (5 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 deleted
- 9 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r85297 r85389 257 257 VBOX_GUI_INC_DIRS = \ 258 258 ./src \ 259 ./src/cloud/consolemanager \ 259 260 ./src/cloud/machinesettings \ 260 261 ./src/cloud/profilemanager \ … … 568 569 # 569 570 VirtualBox_QT_MOCHDRS = \ 571 src/cloud/consolemanager/UICloudConsoleDetailsWidget.h \ 572 src/cloud/consolemanager/UICloudConsoleManager.h \ 570 573 src/cloud/machinesettings/UICloudMachineSettingsDialog.h \ 571 574 src/cloud/machinesettings/UICloudMachineSettingsDialogPage.h \ … … 924 927 # 925 928 VirtualBox_QT_MOCSRCS = \ 929 src/cloud/consolemanager/UICloudConsoleManager.cpp \ 926 930 src/cloud/profilemanager/UICloudProfileManager.cpp \ 927 931 src/hostnetwork/UIHostNetworkManager.cpp \ … … 1030 1034 VirtualBox_SOURCES = \ 1031 1035 src/main.cpp \ 1036 src/cloud/consolemanager/UICloudConsoleDetailsWidget.cpp \ 1037 src/cloud/consolemanager/UICloudConsoleManager.cpp \ 1032 1038 src/cloud/machinesettings/UICloudMachineSettingsDialog.cpp \ 1033 1039 src/cloud/machinesettings/UICloudMachineSettingsDialogPage.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/consolemanager/UICloudConsoleDetailsWidget.cpp
r85388 r85389 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UICloud ProfileDetailsWidget class implementation.3 * VBox Qt GUI - UICloudConsoleDetailsWidget class implementation. 4 4 */ 5 5 … … 18 18 /* Qt includes: */ 19 19 #include <QGridLayout> 20 #include <QHeaderView>21 20 #include <QLabel> 22 21 #include <QLineEdit> 23 22 #include <QPushButton> 24 #include <QTableWidget> 23 #include <QStackedLayout> 24 #include <QStyle> 25 25 #include <QVBoxLayout> 26 26 27 27 /* GUI includes: */ 28 28 #include "QIDialogButtonBox.h" 29 #include "UICloud ProfileDetailsWidget.h"29 #include "UICloudConsoleDetailsWidget.h" 30 30 31 31 /* Other VBox includes: */ … … 33 33 34 34 35 UICloud ProfileDetailsWidget::UICloudProfileDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */)35 UICloudConsoleDetailsWidget::UICloudConsoleDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */) 36 36 : QIWithRetranslateUI<QWidget>(pParent) 37 37 , m_enmEmbedding(enmEmbedding) 38 , m_pLabelName(0) 39 , m_pEditorName(0) 40 , m_pLabelTableWidget(0) 41 , m_pTableWidget(0) 38 , m_pStackedLayout(0) 39 , m_pLabelApplicationName(0) 40 , m_pEditorApplicationName(0) 41 , m_pLabelApplicationPath(0) 42 , m_pEditorApplicationPath(0) 43 , m_pLabelProfileName(0) 44 , m_pEditorProfileName(0) 45 , m_pLabelProfileArgument(0) 46 , m_pEditorProfileArgument(0) 42 47 , m_pButtonBox(0) 43 48 { … … 45 50 } 46 51 47 void UICloudProfileDetailsWidget::setData(const UIDataCloudProfile &data) 48 { 52 void UICloudConsoleDetailsWidget::setApplicationData(const UIDataCloudConsoleApplication &data) 53 { 54 /* Clear all data first: */ 55 clearData(); 56 49 57 /* Cache old/new data: */ 50 m_oldData = data; 51 m_newData = m_oldData; 58 m_oldApplicationData = data; 59 m_newApplicationData = m_oldApplicationData; 60 61 /* Switch to proper stack: */ 62 m_pStackedLayout->setCurrentIndex(0); 52 63 53 64 /* Load data: */ … … 59 70 } 60 71 61 void UICloudProfileDetailsWidget::retranslateUi() 62 { 63 /// @todo add description tool-tips 64 65 /* Translate name-editor label: */ 66 m_pLabelName->setText(tr("Name:")); 72 void UICloudConsoleDetailsWidget::setProfileData(const UIDataCloudConsoleProfile &data) 73 { 74 /* Clear all data first: */ 75 clearData(); 76 77 /* Cache old/new data: */ 78 m_oldProfileData = data; 79 m_newProfileData = m_oldProfileData; 80 81 /* Switch to proper stack: */ 82 m_pStackedLayout->setCurrentIndex(1); 83 84 /* Load data: */ 85 loadData(); 86 87 /* Translate linked widgets: */ 88 retranslateEditor(); 89 retranslateButtons(); 90 } 91 92 void UICloudConsoleDetailsWidget::clearData() 93 { 94 /* Clear widgets: */ 95 m_pEditorApplicationName->setText(QString()); 96 m_pEditorApplicationPath->setText(QString()); 97 m_pEditorProfileName->setText(QString()); 98 m_pEditorProfileArgument->setText(QString()); 99 100 /* Clear data: */ 101 m_oldApplicationData = UIDataCloudConsoleApplication(); 102 m_newApplicationData = m_oldApplicationData; 103 m_oldProfileData = UIDataCloudConsoleProfile(); 104 m_newProfileData = m_oldProfileData; 105 } 106 107 void UICloudConsoleDetailsWidget::retranslateUi() 108 { 109 /* Translate name-editor labels: */ 110 m_pLabelApplicationName->setText(tr("Name:")); 111 m_pLabelApplicationPath->setText(tr("Path:")); 112 m_pLabelProfileName->setText(tr("Name:")); 113 m_pLabelProfileArgument->setText(tr("Argument:")); 67 114 /* Translate name-editor: */ 68 115 retranslateEditor(); 69 116 70 /* Translate table-widget label: */71 m_pLabelTableWidget->setText(tr("Properties:"));72 /* Translate table-widget: */73 m_pTableWidget->setToolTip(tr("Contains cloud profile settings"));74 75 117 /* Translate buttons: */ 76 118 retranslateButtons(); … … 78 120 /* Retranslate validation: */ 79 121 retranslateValidation(); 80 81 /* Update table tool-tips: */ 82 updateTableToolTips(); 83 } 84 85 void UICloudProfileDetailsWidget::retranslateEditor() 122 } 123 124 void UICloudConsoleDetailsWidget::retranslateEditor() 86 125 { 87 126 /* Translate placeholders: */ 88 m_pEditorName->setPlaceholderText( m_oldData.m_strName.isNull() 89 ? tr("Enter a name for the new profile...") 90 : tr("Enter a name for this profile...")); 91 } 92 93 void UICloudProfileDetailsWidget::retranslateButtons() 127 m_pEditorApplicationName->setPlaceholderText(tr("Enter a name for this console application...")); 128 m_pEditorApplicationPath->setPlaceholderText(tr("Enter a path for this console application...")); 129 m_pEditorProfileName->setPlaceholderText(tr("Enter a name for this console profile...")); 130 m_pEditorProfileArgument->setPlaceholderText(tr("Enter an argument for this console profile...")); 131 } 132 133 void UICloudConsoleDetailsWidget::retranslateButtons() 94 134 { 95 135 /* Translate button-box: */ … … 98 138 /* Common: 'Reset' button: */ 99 139 m_pButtonBox->button(QDialogButtonBox::Cancel)->setText(tr("Reset")); 100 m_pButtonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Reset changes in current profile details"));140 m_pButtonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Reset changes in current console details")); 101 141 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 102 142 m_pButtonBox->button(QDialogButtonBox::Cancel)-> 103 143 setToolTip(tr("Reset Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Cancel)->shortcut().toString())); 104 144 105 if (m_oldData.m_strName.isNull()) 106 { 107 /* Provider: 'Add' button: */ 108 m_pButtonBox->button(QDialogButtonBox::Ok)->setText(tr("Add")); 109 m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Add a new profile with following name")); 110 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return")); 111 m_pButtonBox->button(QDialogButtonBox::Ok)-> 112 setToolTip(tr("Add Profile (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString())); 113 } 114 else 115 { 116 /* Profile: 'Apply' button: */ 117 m_pButtonBox->button(QDialogButtonBox::Ok)->setText(tr("Apply")); 118 m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current profile details")); 119 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return")); 120 m_pButtonBox->button(QDialogButtonBox::Ok)-> 121 setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString())); 122 } 123 } 124 } 125 126 void UICloudProfileDetailsWidget::sltNameChanged(const QString &strName) 145 /* Common: 'Apply' button: */ 146 m_pButtonBox->button(QDialogButtonBox::Ok)->setText(tr("Apply")); 147 m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current console details")); 148 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return")); 149 m_pButtonBox->button(QDialogButtonBox::Ok)-> 150 setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString())); 151 } 152 } 153 154 void UICloudConsoleDetailsWidget::sltApplicationNameChanged(const QString &strName) 127 155 { 128 156 /* Push changes back: */ 129 m_new Data.m_strName = strName;157 m_newApplicationData.m_strName = strName; 130 158 131 159 /* Revalidate: */ 132 revalidate(m_pEditor Name);160 revalidate(m_pEditorApplicationName); 133 161 /* Update button states: */ 134 162 updateButtonStates(); 135 163 } 136 164 137 void UICloudProfileDetailsWidget::sltTableChanged(QTableWidgetItem *pItem) 138 { 139 /* Make sure item is valid: */ 140 AssertPtrReturnVoid(pItem); 141 const int iRow = pItem->row(); 142 AssertReturnVoid(iRow >= 0); 143 144 /* Skip if one of items isn't yet created. 145 * This can happen when 1st is already while 2nd isn't yet. */ 146 QTableWidgetItem *pItemK = m_pTableWidget->item(iRow, 0); 147 QTableWidgetItem *pItemV = m_pTableWidget->item(iRow, 1); 148 if (!pItemK || !pItemV) 149 return; 150 165 void UICloudConsoleDetailsWidget::sltApplicationPathChanged(const QString &strPath) 166 { 151 167 /* Push changes back: */ 152 const QString strKey = pItemK->text(); 153 const QString strValue = pItemV->text(); 154 m_newData.m_data[strKey] = qMakePair(strValue, m_newData.m_data.value(strKey).second); 168 m_newApplicationData.m_strPath = strPath; 155 169 156 170 /* Revalidate: */ 157 revalidate(m_p TableWidget);171 revalidate(m_pEditorApplicationPath); 158 172 /* Update button states: */ 159 173 updateButtonStates(); 160 174 } 161 175 162 void UICloudProfileDetailsWidget::sltHandleButtonBoxClick(QAbstractButton *pButton) 176 void UICloudConsoleDetailsWidget::sltProfileNameChanged(const QString &strName) 177 { 178 /* Push changes back: */ 179 m_newProfileData.m_strName = strName; 180 181 /* Revalidate: */ 182 revalidate(m_pEditorProfileName); 183 /* Update button states: */ 184 updateButtonStates(); 185 } 186 187 void UICloudConsoleDetailsWidget::sltProfileArgumentChanged(const QString &strArgument) 188 { 189 /* Push changes back: */ 190 m_newProfileData.m_strArgument = strArgument; 191 192 /* Revalidate: */ 193 revalidate(m_pEditorProfileArgument); 194 /* Update button states: */ 195 updateButtonStates(); 196 } 197 198 void UICloudConsoleDetailsWidget::sltHandleButtonBoxClick(QAbstractButton *pButton) 163 199 { 164 200 /* Make sure button-box exists: */ … … 177 213 } 178 214 179 void UICloud ProfileDetailsWidget::prepare()215 void UICloudConsoleDetailsWidget::prepare() 180 216 { 181 217 /* Prepare widgets: */ … … 189 225 } 190 226 191 void UICloudProfileDetailsWidget::prepareWidgets() 192 { 193 /* Create layout: */ 194 QGridLayout *pLayout = new QGridLayout(this); 195 if (pLayout) 196 { 197 if (m_enmEmbedding == EmbedTo_Dialog) 227 void UICloudConsoleDetailsWidget::prepareWidgets() 228 { 229 /* Create main layout: */ 230 QVBoxLayout *pMainLayout = new QVBoxLayout(this); 231 if (pMainLayout) 232 { 233 pMainLayout->setContentsMargins(0, 0, 0, 0); 234 235 /* Create stacked layout: */ 236 m_pStackedLayout = new QStackedLayout; 237 if (m_pStackedLayout) 198 238 { 199 pLayout->setContentsMargins(0, 0, 0, 0); 239 /* Create application widget: */ 240 QWidget *pWidgetApplication = new QWidget; 241 if (pWidgetApplication) 242 { 243 /* Create application layout: */ 244 QGridLayout *pLayoutApplication = new QGridLayout(pWidgetApplication); 245 if (pLayoutApplication) 246 { 247 pLayoutApplication->setContentsMargins(0, 0, 0, 0); 248 pLayoutApplication->setRowStretch(2, 1); 249 250 if (m_enmEmbedding == EmbedTo_Dialog) 251 { 252 pLayoutApplication->setContentsMargins(0, 0, 0, 0); 200 253 #ifdef VBOX_WS_MAC 201 pLayout->setSpacing(10);254 pLayoutApplication->setSpacing(10); 202 255 #else 203 pLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2);256 pLayoutApplication->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2); 204 257 #endif 205 }206 else207 {258 } 259 else 260 { 208 261 #ifdef VBOX_WS_MAC 209 pLayout->setContentsMargins(13, 0, 13, 13);210 pLayout->setSpacing(10);262 pLayoutApplication->setContentsMargins(13, 0, 13, 13); 263 pLayoutApplication->setSpacing(10); 211 264 #else 212 const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) * 1.5;213 const int iT = qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin) * 1.5;214 const int iR = qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) * 1.5;215 const int iB = qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) * 1.5;216 pLayout->setContentsMargins(iL, iT, iR, iB);265 const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) * 1.5; 266 const int iT = qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin) * 1.5; 267 const int iR = qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) * 1.5; 268 const int iB = qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) * 1.5; 269 pLayoutApplication->setContentsMargins(iL, iT, iR, iB); 217 270 #endif 218 } 219 220 /* Create name editor: */ 221 m_pEditorName = new QLineEdit; 222 if (m_pEditorName) 223 { 224 connect(m_pEditorName, &QLineEdit::textChanged, this, &UICloudProfileDetailsWidget::sltNameChanged); 271 } 272 273 /* Create name editor: */ 274 m_pEditorApplicationName = new QLineEdit(pWidgetApplication); 275 if (m_pEditorApplicationName) 276 { 277 connect(m_pEditorApplicationName, &QLineEdit::textChanged, 278 this, &UICloudConsoleDetailsWidget::sltApplicationNameChanged); 279 280 /* Add into layout: */ 281 pLayoutApplication->addWidget(m_pEditorApplicationName, 0, 1); 282 } 283 /* Create name label: */ 284 m_pLabelApplicationName = new QLabel(pWidgetApplication); 285 if (m_pLabelApplicationName) 286 { 287 m_pLabelApplicationName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 288 m_pLabelApplicationName->setBuddy(m_pEditorApplicationName); 289 290 /* Add into layout: */ 291 pLayoutApplication->addWidget(m_pLabelApplicationName, 0, 0); 292 } 293 294 /* Create path editor: */ 295 m_pEditorApplicationPath = new QLineEdit(pWidgetApplication); 296 if (m_pEditorApplicationPath) 297 { 298 connect(m_pEditorApplicationPath, &QLineEdit::textChanged, 299 this, &UICloudConsoleDetailsWidget::sltApplicationPathChanged); 300 301 /* Add into layout: */ 302 pLayoutApplication->addWidget(m_pEditorApplicationPath, 1, 1); 303 } 304 /* Create path label: */ 305 m_pLabelApplicationPath = new QLabel(pWidgetApplication); 306 if (m_pLabelApplicationPath) 307 { 308 m_pLabelApplicationPath->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 309 m_pLabelApplicationPath->setBuddy(m_pEditorApplicationPath); 310 311 /* Add into layout: */ 312 pLayoutApplication->addWidget(m_pLabelApplicationPath, 1, 0); 313 } 314 } 315 316 /* Add into layout: */ 317 m_pStackedLayout->addWidget(pWidgetApplication); 318 } 319 320 /* Create profile widget: */ 321 QWidget *pWidgetProfile = new QWidget; 322 if (pWidgetProfile) 323 { 324 /* Create profile layout: */ 325 QGridLayout *pLayoutProfile = new QGridLayout(pWidgetProfile); 326 if (pLayoutProfile) 327 { 328 pLayoutProfile->setContentsMargins(0, 0, 0, 0); 329 pLayoutProfile->setRowStretch(2, 1); 330 331 if (m_enmEmbedding == EmbedTo_Dialog) 332 { 333 pLayoutProfile->setContentsMargins(0, 0, 0, 0); 334 #ifdef VBOX_WS_MAC 335 pLayoutProfile->setSpacing(10); 336 #else 337 pLayoutProfile->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2); 338 #endif 339 } 340 else 341 { 342 #ifdef VBOX_WS_MAC 343 pLayoutProfile->setContentsMargins(13, 0, 13, 13); 344 pLayoutProfile->setSpacing(10); 345 #else 346 const int iL = qApp->style()->pixelMetric(QStyle::PM_LayoutLeftMargin) * 1.5; 347 const int iT = qApp->style()->pixelMetric(QStyle::PM_LayoutTopMargin) * 1.5; 348 const int iR = qApp->style()->pixelMetric(QStyle::PM_LayoutRightMargin) * 1.5; 349 const int iB = qApp->style()->pixelMetric(QStyle::PM_LayoutBottomMargin) * 1.5; 350 pLayoutProfile->setContentsMargins(iL, iT, iR, iB); 351 #endif 352 } 353 354 /* Create name editor: */ 355 m_pEditorProfileName = new QLineEdit(pWidgetProfile); 356 if (m_pEditorProfileName) 357 { 358 connect(m_pEditorProfileName, &QLineEdit::textChanged, 359 this, &UICloudConsoleDetailsWidget::sltProfileNameChanged); 360 361 /* Add into layout: */ 362 pLayoutProfile->addWidget(m_pEditorProfileName, 0, 1); 363 } 364 /* Create name label: */ 365 m_pLabelProfileName = new QLabel(pWidgetProfile); 366 if (m_pLabelProfileName) 367 { 368 m_pLabelProfileName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 369 m_pLabelProfileName->setBuddy(m_pEditorProfileName); 370 371 /* Add into layout: */ 372 pLayoutProfile->addWidget(m_pLabelProfileName, 0, 0); 373 } 374 375 /* Create argument editor: */ 376 m_pEditorProfileArgument = new QLineEdit(pWidgetProfile); 377 if (m_pEditorProfileArgument) 378 { 379 connect(m_pEditorProfileArgument, &QLineEdit::textChanged, 380 this, &UICloudConsoleDetailsWidget::sltProfileArgumentChanged); 381 382 /* Add into layout: */ 383 pLayoutProfile->addWidget(m_pEditorProfileArgument, 1, 1); 384 } 385 /* Create name label: */ 386 m_pLabelProfileArgument = new QLabel(pWidgetProfile); 387 if (m_pLabelProfileArgument) 388 { 389 m_pLabelProfileArgument->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 390 m_pLabelProfileArgument->setBuddy(m_pEditorProfileArgument); 391 392 /* Add into layout: */ 393 pLayoutProfile->addWidget(m_pLabelProfileArgument, 1, 0); 394 } 395 } 396 397 /* Add into layout: */ 398 m_pStackedLayout->addWidget(pWidgetProfile); 399 } 225 400 226 401 /* Add into layout: */ 227 pLayout->addWidget(m_pEditorName, 0, 1); 228 } 229 /* Create name label: */ 230 m_pLabelName = new QLabel; 231 if (m_pLabelName) 232 { 233 m_pLabelName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 234 m_pLabelName->setBuddy(m_pEditorName); 235 236 /* Add into layout: */ 237 pLayout->addWidget(m_pLabelName, 0, 0); 238 } 239 240 /* Create tab-widget: */ 241 m_pTableWidget = new QTableWidget; 242 if (m_pTableWidget) 243 { 244 m_pTableWidget->setAlternatingRowColors(true); 245 m_pTableWidget->horizontalHeader()->setVisible(false); 246 m_pTableWidget->verticalHeader()->setVisible(false); 247 m_pTableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); 248 connect(m_pTableWidget, &QTableWidget::itemChanged, this, &UICloudProfileDetailsWidget::sltTableChanged); 249 250 /* Add into layout: */ 251 pLayout->addWidget(m_pTableWidget, 1, 1); 252 } 253 /* Create tab-widget label: */ 254 m_pLabelTableWidget = new QLabel; 255 if (m_pLabelTableWidget) 256 { 257 m_pLabelTableWidget->setAlignment(Qt::AlignRight | Qt::AlignTop); 258 m_pLabelTableWidget->setBuddy(m_pTableWidget); 259 260 /* Add into layout: */ 261 pLayout->addWidget(m_pLabelTableWidget, 1, 0); 402 pMainLayout->addLayout(m_pStackedLayout); 262 403 } 263 404 … … 270 411 { 271 412 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 272 connect(m_pButtonBox, &QIDialogButtonBox::clicked, this, &UICloud ProfileDetailsWidget::sltHandleButtonBoxClick);413 connect(m_pButtonBox, &QIDialogButtonBox::clicked, this, &UICloudConsoleDetailsWidget::sltHandleButtonBoxClick); 273 414 274 415 /* Add into layout: */ 275 p Layout->addWidget(m_pButtonBox, 2, 0, 1, 2);416 pMainLayout->addWidget(m_pButtonBox); 276 417 } 277 418 } … … 279 420 } 280 421 281 void UICloudProfileDetailsWidget::loadData() 282 { 283 /* Clear table initially: */ 284 m_pTableWidget->clear(); 285 286 /* Fill name editor: */ 287 m_pEditorName->setText(m_oldData.m_strName); 288 289 /* Configure table: */ 290 m_pTableWidget->setRowCount(m_oldData.m_data.keys().size()); 291 m_pTableWidget->setColumnCount(2); 292 293 /* Push acquired keys/values to data fields: */ 294 for (int i = 0; i < m_pTableWidget->rowCount(); ++i) 295 { 296 /* Gather values: */ 297 const QString strKey = m_oldData.m_data.keys().at(i); 298 const QString strValue = m_oldData.m_data.value(strKey).first; 299 const QString strToolTip = m_oldData.m_data.value(strKey).second; 300 301 /* Create key item: */ 302 QTableWidgetItem *pItemK = new QTableWidgetItem(strKey); 303 if (pItemK) 304 { 305 /* Non-editable for sure, but non-selectable? */ 306 pItemK->setFlags(pItemK->flags() & ~Qt::ItemIsEditable); 307 /* Use non-translated description as tool-tip: */ 308 pItemK->setData(Qt::UserRole, strToolTip); 309 310 /* Insert into table: */ 311 m_pTableWidget->setItem(i, 0, pItemK); 312 } 313 314 /* Create value item: */ 315 QTableWidgetItem *pItemV = new QTableWidgetItem(strValue); 316 if (pItemV) 317 { 318 /* Use the value as tool-tip, there can be quite long values: */ 319 pItemV->setToolTip(strValue); 320 321 /* Insert into table: */ 322 m_pTableWidget->setItem(i, 1, pItemV); 323 } 324 } 325 326 /* Update table tooltips: */ 327 updateTableToolTips(); 328 /* Adjust table contents: */ 329 adjustTableContents(); 330 } 331 332 void UICloudProfileDetailsWidget::revalidate(QWidget *pWidget /* = 0 */) 333 { 334 /// @todo validate profile settings table! 422 void UICloudConsoleDetailsWidget::loadData() 423 { 424 /* If application pane is selected: */ 425 if (m_pStackedLayout->currentIndex() == 0) 426 { 427 m_pEditorApplicationName->setText(m_oldApplicationData.m_strName); 428 m_pEditorApplicationPath->setText(m_oldApplicationData.m_strPath); 429 } 430 /* If profile pane is selected: */ 431 else 432 { 433 m_pEditorProfileName->setText(m_oldProfileData.m_strName); 434 m_pEditorProfileArgument->setText(m_oldProfileData.m_strArgument); 435 } 436 } 437 438 void UICloudConsoleDetailsWidget::revalidate(QWidget *pWidget /* = 0 */) 439 { 440 /// @todo validate application/profile details! 335 441 336 442 /* Retranslate validation: */ … … 338 444 } 339 445 340 void UICloud ProfileDetailsWidget::retranslateValidation(QWidget *pWidget /* = 0 */)446 void UICloudConsoleDetailsWidget::retranslateValidation(QWidget *pWidget /* = 0 */) 341 447 { 342 448 Q_UNUSED(pWidget); … … 345 451 } 346 452 347 void UICloudProfileDetailsWidget::updateTableToolTips() 348 { 349 /* Iterate through all the key items: */ 350 for (int i = 0; i < m_pTableWidget->rowCount(); ++i) 351 { 352 /* Acquire current key item: */ 353 QTableWidgetItem *pItemK = m_pTableWidget->item(i, 0); 354 if (pItemK) 355 { 356 const QString strToolTip = pItemK->data(Qt::UserRole).toString(); 357 pItemK->setToolTip(tr(strToolTip.toUtf8().constData())); 358 } 359 } 360 } 361 362 void UICloudProfileDetailsWidget::adjustTableContents() 363 { 364 /* Disable last column stretching temporary: */ 365 m_pTableWidget->horizontalHeader()->setStretchLastSection(false); 366 367 /* Resize both columns to contents: */ 368 m_pTableWidget->resizeColumnsToContents(); 369 /* Then acquire full available width: */ 370 const int iFullWidth = m_pTableWidget->viewport()->width(); 371 /* First column should not be less than it's minimum size, last gets the rest: */ 372 const int iMinimumWidth0 = qMin(m_pTableWidget->horizontalHeader()->sectionSize(0), iFullWidth / 2); 373 m_pTableWidget->horizontalHeader()->resizeSection(0, iMinimumWidth0); 374 375 /* Enable last column stretching again: */ 376 m_pTableWidget->horizontalHeader()->setStretchLastSection(true); 377 } 378 379 void UICloudProfileDetailsWidget::updateButtonStates() 453 void UICloudConsoleDetailsWidget::updateButtonStates() 380 454 { 381 455 #if 0 … … 400 474 #endif 401 475 402 /* Update 'Apply' / 'Reset' button states: */ 403 if (m_pButtonBox) 404 { 405 m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData); 406 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData); 407 } 408 409 /* Notify listeners as well: */ 410 emit sigDataChanged(m_oldData != m_newData); 411 } 476 /* If application pane is selected: */ 477 if (m_pStackedLayout->currentIndex() == 0) 478 { 479 /* Update 'Apply' / 'Reset' button states: */ 480 if (m_pButtonBox) 481 { 482 m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(m_oldApplicationData != m_newApplicationData); 483 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_oldApplicationData != m_newApplicationData); 484 } 485 486 /* Notify listeners as well: */ 487 emit sigDataChanged(m_oldApplicationData != m_newApplicationData); 488 } 489 /* If profile pane is selected: */ 490 else 491 { 492 /* Update 'Apply' / 'Reset' button states: */ 493 if (m_pButtonBox) 494 { 495 m_pButtonBox->button(QDialogButtonBox::Cancel)->setEnabled(m_oldProfileData != m_newProfileData); 496 m_pButtonBox->button(QDialogButtonBox::Ok)->setEnabled(m_oldProfileData != m_newProfileData); 497 } 498 499 /* Notify listeners as well: */ 500 emit sigDataChanged(m_oldProfileData != m_newProfileData); 501 } 502 } -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/consolemanager/UICloudConsoleDetailsWidget.h
r85388 r85389 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UICloud ProfileDetailsWidget class declaration.3 * VBox Qt GUI - UICloudConsoleDetailsWidget class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_cloud_ profilemanager_UICloudProfileDetailsWidget_h19 #define FEQT_INCLUDED_SRC_cloud_ profilemanager_UICloudProfileDetailsWidget_h18 #ifndef FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleDetailsWidget_h 19 #define FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleDetailsWidget_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 24 24 /* Qt includes: */ 25 25 #include <QMap> 26 #include <QUuid>27 26 #include <QWidget> 28 27 … … 35 34 class QLabel; 36 35 class QLineEdit; 37 class QTableWidget; 38 class QTableWidgetItem; 36 class QStackedLayout; 39 37 class QIDialogButtonBox; 40 38 41 39 42 /** Cloud Providerdata structure. */43 struct UIDataCloud Provider40 /** Cloud Console Application data structure. */ 41 struct UIDataCloudConsoleApplication 44 42 { 45 43 /** Constructs data. */ 46 UIDataCloud Provider()44 UIDataCloudConsoleApplication() 47 45 : m_fRestricted(false) 48 46 {} 49 47 50 48 /** Returns whether the @a other passed data is equal to this one. */ 51 bool equal(const UIDataCloud Provider&other) const49 bool equal(const UIDataCloudConsoleApplication &other) const 52 50 { 53 51 return true 54 && (m_uId == other.m_uId) 55 && (m_strShortName == other.m_strShortName) 52 && (m_strId == other.m_strId) 56 53 && (m_strName == other.m_strName) 54 && (m_strPath == other.m_strPath) 57 55 && (m_fRestricted == other.m_fRestricted) 58 56 ; … … 60 58 61 59 /** Returns whether the @a other passed data is equal to this one. */ 62 bool operator==(const UIDataCloud Provider&other) const { return equal(other); }60 bool operator==(const UIDataCloudConsoleApplication &other) const { return equal(other); } 63 61 /** Returns whether the @a other passed data is different from this one. */ 64 bool operator!=(const UIDataCloudProvider &other) const { return !equal(other); } 65 66 /** Holds the provider ID. */ 67 QUuid m_uId; 68 /** Holds the provider short name. */ 69 QString m_strShortName; 70 /** Holds the provider name. */ 62 bool operator!=(const UIDataCloudConsoleApplication &other) const { return !equal(other); } 63 64 /** Holds the console application ID. */ 65 QString m_strId; 66 /** Holds the console application name. */ 71 67 QString m_strName; 72 /** Holds whether provider is restricted. */ 68 /** Holds the console application path. */ 69 QString m_strPath; 70 /** Holds whether console application is restricted. */ 73 71 bool m_fRestricted; 74 75 /** Holds the profile supported property descriptions. */76 QMap<QString, QString> m_propertyDescriptions;77 72 }; 78 73 79 /** Cloud Profile data structure. */80 struct UIDataCloud Profile74 /** Cloud Console Profile data structure. */ 75 struct UIDataCloudConsoleProfile 81 76 { 82 77 /** Constructs data. */ 83 UIDataCloud Profile()78 UIDataCloudConsoleProfile() 84 79 : m_fRestricted(false) 85 80 {} 86 81 87 82 /** Returns whether the @a other passed data is equal to this one. */ 88 bool equal(const UIDataCloud Profile &other) const83 bool equal(const UIDataCloudConsoleProfile &other) const 89 84 { 90 85 return true 91 && (m_strProviderShortName == other.m_strProviderShortName) 86 && (m_strApplicationId == other.m_strApplicationId) 87 && (m_strId == other.m_strId) 92 88 && (m_strName == other.m_strName) 89 && (m_strArgument == other.m_strArgument) 93 90 && (m_fRestricted == other.m_fRestricted) 94 && (m_data == other.m_data)95 91 ; 96 92 } 97 93 98 94 /** Returns whether the @a other passed data is equal to this one. */ 99 bool operator==(const UIDataCloud Profile &other) const { return equal(other); }95 bool operator==(const UIDataCloudConsoleProfile &other) const { return equal(other); } 100 96 /** Returns whether the @a other passed data is different from this one. */ 101 bool operator!=(const UIDataCloudProfile &other) const { return !equal(other); } 102 103 /** Holds the provider short name. */ 104 QString m_strProviderShortName; 105 /** Holds the profile name. */ 97 bool operator!=(const UIDataCloudConsoleProfile &other) const { return !equal(other); } 98 99 /** Holds the console profile application ID. */ 100 QString m_strApplicationId; 101 /** Holds the console profile ID. */ 102 QString m_strId; 103 /** Holds the console profile name. */ 106 104 QString m_strName; 107 /** Holds whether profile is restricted. */ 105 /** Holds the console profile argument. */ 106 QString m_strArgument; 107 /** Holds whether console profile is restricted. */ 108 108 bool m_fRestricted; 109 110 /** Holds the profile data. */111 QMap<QString, QPair<QString, QString> > m_data;112 109 }; 113 110 114 111 115 /** Cloud Profile details widget. */116 class UICloud ProfileDetailsWidget : public QIWithRetranslateUI<QWidget>112 /** Cloud Console details widget. */ 113 class UICloudConsoleDetailsWidget : public QIWithRetranslateUI<QWidget> 117 114 { 118 115 Q_OBJECT; … … 130 127 public: 131 128 132 /** Constructs cloud profile details widget passing @a pParent to the base-class.129 /** Constructs cloud console details widget passing @a pParent to the base-class. 133 130 * @param enmEmbedding Brings embedding type. */ 134 UICloudProfileDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent = 0); 135 136 /** Returns the cloud profile data. */ 137 const UIDataCloudProfile &data() const { return m_newData; } 138 /** Defines the cloud profile @a data. */ 139 void setData(const UIDataCloudProfile &data); 131 UICloudConsoleDetailsWidget(EmbedTo enmEmbedding, QWidget *pParent = 0); 132 133 /** Returns the cloud console application data. */ 134 const UIDataCloudConsoleApplication &applicationData() const { return m_newApplicationData; } 135 /** Returns the cloud console profile data. */ 136 const UIDataCloudConsoleProfile &profileData() const { return m_newProfileData; } 137 /** Defines the cloud console application @a data. */ 138 void setApplicationData(const UIDataCloudConsoleApplication &data); 139 /** Defines the cloud console profile @a data. */ 140 void setProfileData(const UIDataCloudConsoleProfile &data); 141 /** Clears all the console data. */ 142 void clearData(); 140 143 141 144 protected: … … 152 155 /** @name Change handling stuff. 153 156 * @{ */ 154 /** Handles name change. */ 155 void sltNameChanged(const QString &strName); 156 /** Handles table change. */ 157 void sltTableChanged(QTableWidgetItem *pItem); 157 /** Handles console application name change. */ 158 void sltApplicationNameChanged(const QString &strName); 159 /** Handles console application path change. */ 160 void sltApplicationPathChanged(const QString &strPath); 161 /** Handles console profile name change. */ 162 void sltProfileNameChanged(const QString &strName); 163 /** Handles console profile argument change. */ 164 void sltProfileArgumentChanged(const QString &strArgument); 158 165 159 166 /** Handles button-box button click. */ … … 185 192 void retranslateValidation(QWidget *pWidget = 0); 186 193 187 /** Updates table tooltips. */188 void updateTableToolTips();189 /** Adjusts table contents. */190 void adjustTableContents();191 192 194 /** Updates button states. */ 193 195 void updateButtonStates(); … … 199 201 const EmbedTo m_enmEmbedding; 200 202 201 /** Holds the old data copy. */ 202 UIDataCloudProfile m_oldData; 203 /** Holds the new data copy. */ 204 UIDataCloudProfile m_newData; 203 /** Holds the old console application data copy. */ 204 UIDataCloudConsoleApplication m_oldApplicationData; 205 /** Holds the new console application data copy. */ 206 UIDataCloudConsoleApplication m_newApplicationData; 207 208 /** Holds the old console profile data copy. */ 209 UIDataCloudConsoleProfile m_oldProfileData; 210 /** Holds the new console profile data copy. */ 211 UIDataCloudConsoleProfile m_newProfileData; 205 212 /** @} */ 206 213 207 214 /** @name Widget variables. 208 215 * @{ */ 209 /** Holds the name label instance. */ 210 QLabel *m_pLabelName; 211 /** Holds the name editor instance. */ 212 QLineEdit *m_pEditorName; 213 214 /** Holds the table-widget label instance. */ 215 QLabel *m_pLabelTableWidget; 216 /** Holds the table-widget instance. */ 217 QTableWidget *m_pTableWidget; 216 /** Holds the stacked layout isntance. */ 217 QStackedLayout *m_pStackedLayout; 218 219 /** Holds the application name label instance. */ 220 QLabel *m_pLabelApplicationName; 221 /** Holds the application name editor instance. */ 222 QLineEdit *m_pEditorApplicationName; 223 /** Holds the application path label instance. */ 224 QLabel *m_pLabelApplicationPath; 225 /** Holds the application path editor instance. */ 226 QLineEdit *m_pEditorApplicationPath; 227 228 /** Holds the profile name label instance. */ 229 QLabel *m_pLabelProfileName; 230 /** Holds the profile name editor instance. */ 231 QLineEdit *m_pEditorProfileName; 232 /** Holds the profile argument label instance. */ 233 QLabel *m_pLabelProfileArgument; 234 /** Holds the profile argument editor instance. */ 235 QLineEdit *m_pEditorProfileArgument; 218 236 219 237 /** Holds the button-box instance. */ … … 223 241 224 242 225 #endif /* !FEQT_INCLUDED_SRC_cloud_ profilemanager_UICloudProfileDetailsWidget_h */243 #endif /* !FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleDetailsWidget_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/consolemanager/UICloudConsoleManager.cpp
r85388 r85389 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UICloud ProfileManager class implementation.3 * VBox Qt GUI - UICloudConsoleManager class implementation. 4 4 */ 5 5 … … 17 17 18 18 /* Qt includes: */ 19 #include <QDialog> 20 #include <QGridLayout> 19 21 #include <QHeaderView> 22 #include <QLabel> 23 #include <QLineEdit> 20 24 #include <QPushButton> 25 #include <QUuid> 21 26 #include <QVBoxLayout> 22 27 23 28 /* GUI includes: */ 24 29 #include "QIDialogButtonBox.h" 25 #include "QIInputDialog.h"26 30 #include "QITreeWidget.h" 27 31 #include "UICommon.h" 28 32 #include "UIActionPoolManager.h" 29 #include "UICloudNetworkingStuff.h"30 33 #include "UIExtraDataManager.h" 31 34 #include "UIIconPool.h" 32 #include "UICloud ProfileDetailsWidget.h"33 #include "UICloud ProfileManager.h"35 #include "UICloudConsoleDetailsWidget.h" 36 #include "UICloudConsoleManager.h" 34 37 #include "UIMessageCenter.h" 35 38 #include "UIToolBar.h" 36 39 37 /* COM includes: */38 #include "CCloudProfile.h"39 #include "CCloudProvider.h"40 #include "CCloudProviderManager.h"41 42 40 43 41 /** Tree-widget item types. */ 44 enum Cloud ItemType45 { 46 Cloud ItemType_Invalid= 0,47 Cloud ItemType_Provider= 1,48 Cloud ItemType_Profile= 242 enum CloudConsoleItemType 43 { 44 CloudConsoleItemType_Invalid = 0, 45 CloudConsoleItemType_Application = 1, 46 CloudConsoleItemType_Profile = 2 49 47 }; 50 Q_DECLARE_METATYPE(Cloud ItemType);48 Q_DECLARE_METATYPE(CloudConsoleItemType); 51 49 52 50 /** Tree-widget data types. */ … … 54 52 { 55 53 Data_ItemType = Qt::UserRole + 1, 56 Data_ ProviderID= Qt::UserRole + 2,54 Data_ItemID = Qt::UserRole + 2, 57 55 Data_Definition = Qt::UserRole + 3, 58 56 }; … … 62 60 { 63 61 Column_Name, 64 Column_List VMs,62 Column_ListInMenu, 65 63 Column_Max 66 64 }; 67 65 68 66 69 /** Cloud Profile Manager provider's tree-widget item. */70 class UIItemCloud Provider : public QITreeWidgetItem, public UIDataCloudProvider67 /** Cloud Console Manager application's tree-widget item. */ 68 class UIItemCloudConsoleApplication : public QITreeWidgetItem, public UIDataCloudConsoleApplication 71 69 { 72 70 Q_OBJECT; … … 75 73 76 74 /** Constructs item. */ 77 UIItemCloud Provider();75 UIItemCloudConsoleApplication(); 78 76 79 77 /** Updates item fields from base-class data. */ 80 78 void updateFields(); 81 79 80 /** Returns item id. */ 81 QString id() const { return m_strId; } 82 82 /** Returns item name. */ 83 83 QString name() const { return m_strName; } 84 /** Returns item path. */ 85 QString path() const { return m_strPath; } 84 86 }; 85 87 86 /** Cloud Profile Manager profile's tree-widget item. */87 class UIItemCloud Profile : public QITreeWidgetItem, public UIDataCloudProfile88 /** Cloud Console Manager profile's tree-widget item. */ 89 class UIItemCloudConsoleProfile : public QITreeWidgetItem, public UIDataCloudConsoleProfile 88 90 { 89 91 Q_OBJECT; … … 92 94 93 95 /** Constructs item. */ 94 UIItemCloud Profile();96 UIItemCloudConsoleProfile(); 95 97 96 98 /** Updates item fields from base-class data. */ 97 99 void updateFields(); 98 100 101 /** Returns item application id. */ 102 QString applicationId() const { return m_strApplicationId; } 103 /** Returns item id. */ 104 QString id() const { return m_strId; } 99 105 /** Returns item name. */ 100 106 QString name() const { return m_strName; } 107 /** Returns item argument. */ 108 QString argument() const { return m_strArgument; } 101 109 }; 102 110 111 /** QDialog extension used to acquire newly created console application parameters. */ 112 class UIInputDialogCloudConsoleApplication : public QIWithRetranslateUI<QDialog> 113 { 114 Q_OBJECT; 115 116 public: 117 118 /** Constructs dialog passing @a pParent to the base-class. */ 119 UIInputDialogCloudConsoleApplication(QWidget *pParent); 120 121 /** Returns application name. */ 122 QString name() const; 123 /** Returns application path. */ 124 QString path() const; 125 126 protected: 127 128 /** Handles translation event. */ 129 virtual void retranslateUi() /* override */; 130 131 private: 132 133 /** Prepares all. */ 134 void prepare(); 135 136 /** Holds the name label instance. */ 137 QLabel *m_pLabelName; 138 /** Holds the name editor instance. */ 139 QLineEdit *m_pEditorName; 140 /** Holds the path label instance. */ 141 QLabel *m_pLabelPath; 142 /** Holds the path editor instance. */ 143 QLineEdit *m_pEditorPath; 144 145 /** Holds the button-box instance. */ 146 QIDialogButtonBox *m_pButtonBox; 147 }; 148 149 /** QDialog extension used to acquire newly created console profile parameters. */ 150 class UIInputDialogCloudConsoleProfile : public QIWithRetranslateUI<QDialog> 151 { 152 Q_OBJECT; 153 154 public: 155 156 /** Constructs dialog passing @a pParent to the base-class. */ 157 UIInputDialogCloudConsoleProfile(QWidget *pParent); 158 159 /** Returns profile name. */ 160 QString name() const; 161 /** Returns profile argument. */ 162 QString argument() const; 163 164 protected: 165 166 /** Handles translation event. */ 167 virtual void retranslateUi() /* override */; 168 169 private: 170 171 /** Prepares all. */ 172 void prepare(); 173 174 /** Holds the name label instance. */ 175 QLabel *m_pLabelName; 176 /** Holds the name editor instance. */ 177 QLineEdit *m_pEditorName; 178 /** Holds the argument label instance. */ 179 QLabel *m_pLabelArgument; 180 /** Holds the argument editor instance. */ 181 QLineEdit *m_pEditorArgument; 182 183 /** Holds the button-box instance. */ 184 QIDialogButtonBox *m_pButtonBox; 185 }; 186 103 187 104 188 /********************************************************************************************************************************* 105 * Class UIItemCloud Provider implementation.*189 * Class UIItemCloudConsoleApplication implementation. * 106 190 *********************************************************************************************************************************/ 107 191 108 UIItemCloud Provider::UIItemCloudProvider()192 UIItemCloudConsoleApplication::UIItemCloudConsoleApplication() 109 193 { 110 194 /* Assign icon: */ 111 setIcon(Column_Name, UIIconPool::iconSet(":/ provider_oracle_16px.png"));112 /* Assign item type: */113 setData(Column_Name, Data_ItemType, QVariant::fromValue(Cloud ItemType_Provider));114 } 115 116 void UIItemCloud Provider::updateFields()195 setIcon(Column_Name, UIIconPool::iconSet(":/cloud_console_application_16px.png")); /// @todo use proper icon 196 /* Assign item data: */ 197 setData(Column_Name, Data_ItemType, QVariant::fromValue(CloudConsoleItemType_Application)); 198 } 199 200 void UIItemCloudConsoleApplication::updateFields() 117 201 { 118 202 /* Update item fields: */ 119 203 setText(Column_Name, m_strName); 120 setData(Column_Name, Data_ ProviderID, m_uId);121 setData(Column_Name, Data_Definition, QVariant::fromValue(QString("/%1").arg(m_str ShortName)));122 setCheckState(Column_List VMs, m_fRestricted ? Qt::Unchecked : Qt::Checked);204 setData(Column_Name, Data_ItemID, m_strId); 205 setData(Column_Name, Data_Definition, QVariant::fromValue(QString("/%1").arg(m_strId))); 206 setCheckState(Column_ListInMenu, m_fRestricted ? Qt::Unchecked : Qt::Checked); 123 207 } 124 208 125 209 126 210 /********************************************************************************************************************************* 127 * Class UIItemCloud Profile implementation.*211 * Class UIItemCloudConsoleProfile implementation. * 128 212 *********************************************************************************************************************************/ 129 213 130 UIItemCloud Profile::UIItemCloudProfile()214 UIItemCloudConsoleProfile::UIItemCloudConsoleProfile() 131 215 { 132 216 /* Assign icon: */ 133 setIcon(Column_Name, UIIconPool::iconSet(":/ profile_16px.png"));134 /* Assign item type: */135 setData(Column_Name, Data_ItemType, QVariant::fromValue(Cloud ItemType_Profile));136 } 137 138 void UIItemCloud Profile::updateFields()217 setIcon(Column_Name, UIIconPool::iconSet(":/cloud_console_profile_16px.png")); /// @todo use proper icon 218 /* Assign item data: */ 219 setData(Column_Name, Data_ItemType, QVariant::fromValue(CloudConsoleItemType_Profile)); 220 } 221 222 void UIItemCloudConsoleProfile::updateFields() 139 223 { 140 224 /* Update item fields: */ 141 225 setText(Column_Name, m_strName); 142 setData(Column_Name, Data_Definition, QVariant::fromValue(QString("/%1/%2").arg(m_strProviderShortName, m_strName))); 143 setCheckState(Column_ListVMs, m_fRestricted ? Qt::Unchecked : Qt::Checked); 226 setData(Column_Name, Data_ItemID, m_strId); 227 setData(Column_Name, Data_Definition, QVariant::fromValue(QString("/%1/%2").arg(m_strApplicationId, m_strId))); 228 setCheckState(Column_ListInMenu, m_fRestricted ? Qt::Unchecked : Qt::Checked); 144 229 } 145 230 146 231 147 232 /********************************************************************************************************************************* 148 * Class UI CloudProfileManagerWidget implementation.*233 * Class UIInputDialogCloudConsoleApplication implementation. * 149 234 *********************************************************************************************************************************/ 150 235 151 UICloudProfileManagerWidget::UICloudProfileManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool, 236 UIInputDialogCloudConsoleApplication::UIInputDialogCloudConsoleApplication(QWidget *pParent) 237 : QIWithRetranslateUI<QDialog>(pParent) 238 , m_pLabelName(0) 239 , m_pEditorName(0) 240 , m_pLabelPath(0) 241 , m_pEditorPath(0) 242 , m_pButtonBox(0) 243 { 244 prepare(); 245 } 246 247 QString UIInputDialogCloudConsoleApplication::name() const 248 { 249 return m_pEditorName->text(); 250 } 251 252 QString UIInputDialogCloudConsoleApplication::path() const 253 { 254 return m_pEditorPath->text(); 255 } 256 257 void UIInputDialogCloudConsoleApplication::retranslateUi() 258 { 259 setWindowTitle(tr("Add Application")); 260 m_pLabelName->setText(tr("Name:")); 261 m_pLabelPath->setText(tr("Path:")); 262 } 263 264 void UIInputDialogCloudConsoleApplication::prepare() 265 { 266 /* Configure self: */ 267 setWindowIcon(UIIconPool::iconSet(":/cloud_console_application_add_16px.png")); /// @todo use proper icon 268 269 /* Prepare main layout: */ 270 QGridLayout *pMainLayout = new QGridLayout(this); 271 if (pMainLayout) 272 { 273 pMainLayout->setRowStretch(0, 0); 274 pMainLayout->setRowStretch(1, 0); 275 pMainLayout->setRowStretch(2, 1); 276 pMainLayout->setRowStretch(3, 0); 277 278 /* Prepare name editor: */ 279 m_pEditorName = new QLineEdit(this); 280 if (m_pEditorName) 281 { 282 pMainLayout->addWidget(m_pEditorName, 0, 1); 283 } 284 /* Prepare name editor label: */ 285 m_pLabelName = new QLabel(this); 286 if (m_pLabelName) 287 { 288 m_pLabelName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 289 m_pLabelName->setBuddy(m_pEditorName); 290 pMainLayout->addWidget(m_pLabelName, 0, 0); 291 } 292 293 /* Prepare path editor: */ 294 m_pEditorPath = new QLineEdit(this); 295 if (m_pEditorPath) 296 { 297 pMainLayout->addWidget(m_pEditorPath, 1, 1); 298 } 299 /* Prepare path editor label: */ 300 m_pLabelPath = new QLabel(this); 301 if (m_pLabelPath) 302 { 303 m_pLabelPath->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 304 m_pLabelPath->setBuddy(m_pEditorPath); 305 pMainLayout->addWidget(m_pLabelPath, 1, 0); 306 } 307 308 /* Prepare button-box: */ 309 m_pButtonBox = new QIDialogButtonBox(this); 310 if (m_pButtonBox) 311 { 312 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 313 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIInputDialogCloudConsoleApplication::reject); 314 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIInputDialogCloudConsoleApplication::accept); 315 pMainLayout->addWidget(m_pButtonBox, 3, 0, 1, 2); 316 } 317 } 318 319 /* Apply language settings: */ 320 retranslateUi(); 321 322 /* Resize to suitable size: */ 323 const int iMinimumHeightHint = minimumSizeHint().height(); 324 resize(iMinimumHeightHint * 3, iMinimumHeightHint); 325 } 326 327 328 /********************************************************************************************************************************* 329 * Class UIInputDialogCloudConsoleProfile implementation. * 330 *********************************************************************************************************************************/ 331 332 UIInputDialogCloudConsoleProfile::UIInputDialogCloudConsoleProfile(QWidget *pParent) 333 : QIWithRetranslateUI<QDialog>(pParent) 334 , m_pLabelName(0) 335 , m_pEditorName(0) 336 , m_pLabelArgument(0) 337 , m_pEditorArgument(0) 338 , m_pButtonBox(0) 339 { 340 prepare(); 341 } 342 343 QString UIInputDialogCloudConsoleProfile::name() const 344 { 345 return m_pEditorName->text(); 346 } 347 348 QString UIInputDialogCloudConsoleProfile::argument() const 349 { 350 return m_pEditorArgument->text(); 351 } 352 353 void UIInputDialogCloudConsoleProfile::retranslateUi() 354 { 355 setWindowTitle(tr("Add Profile")); 356 m_pLabelName->setText(tr("Name:")); 357 m_pLabelArgument->setText(tr("Argument:")); 358 } 359 360 void UIInputDialogCloudConsoleProfile::prepare() 361 { 362 /* Configure self: */ 363 setWindowIcon(UIIconPool::iconSet(":/cloud_console_profile_add_16px.png")); /// @todo use proper icon 364 365 /* Prepare main layout: */ 366 QGridLayout *pMainLayout = new QGridLayout(this); 367 if (pMainLayout) 368 { 369 pMainLayout->setRowStretch(0, 0); 370 pMainLayout->setRowStretch(1, 0); 371 pMainLayout->setRowStretch(2, 1); 372 pMainLayout->setRowStretch(3, 0); 373 374 /* Prepare name editor: */ 375 m_pEditorName = new QLineEdit(this); 376 if (m_pEditorName) 377 { 378 pMainLayout->addWidget(m_pEditorName, 0, 1); 379 } 380 /* Prepare name editor label: */ 381 m_pLabelName = new QLabel(this); 382 if (m_pLabelName) 383 { 384 m_pLabelName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 385 m_pLabelName->setBuddy(m_pEditorName); 386 pMainLayout->addWidget(m_pLabelName, 0, 0); 387 } 388 389 /* Prepare argument editor: */ 390 m_pEditorArgument = new QLineEdit(this); 391 if (m_pEditorArgument) 392 { 393 pMainLayout->addWidget(m_pEditorArgument, 1, 1); 394 } 395 /* Prepare argument editor label: */ 396 m_pLabelArgument = new QLabel(this); 397 if (m_pLabelArgument) 398 { 399 m_pLabelArgument->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 400 m_pLabelArgument->setBuddy(m_pEditorArgument); 401 pMainLayout->addWidget(m_pLabelArgument, 1, 0); 402 } 403 404 /* Prepare button-box: */ 405 m_pButtonBox = new QIDialogButtonBox(this); 406 if (m_pButtonBox) 407 { 408 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok); 409 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UIInputDialogCloudConsoleApplication::reject); 410 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UIInputDialogCloudConsoleApplication::accept); 411 pMainLayout->addWidget(m_pButtonBox, 3, 0, 1, 2); 412 } 413 } 414 415 /* Apply language settings: */ 416 retranslateUi(); 417 418 /* Resize to suitable size: */ 419 const int iMinimumHeightHint = minimumSizeHint().height(); 420 resize(iMinimumHeightHint * 3, iMinimumHeightHint); 421 } 422 423 424 /********************************************************************************************************************************* 425 * Class UICloudConsoleManagerWidget implementation. * 426 *********************************************************************************************************************************/ 427 428 UICloudConsoleManagerWidget::UICloudConsoleManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool, 152 429 bool fShowToolbar /* = true */, QWidget *pParent /* = 0 */) 153 430 : QIWithRetranslateUI<QWidget>(pParent) … … 162 439 } 163 440 164 QMenu *UICloud ProfileManagerWidget::menu() const165 { 166 return m_pActionPool->action(UIActionIndexST_M_Cloud Window)->menu();167 } 168 169 void UICloud ProfileManagerWidget::retranslateUi()441 QMenu *UICloudConsoleManagerWidget::menu() const 442 { 443 return m_pActionPool->action(UIActionIndexST_M_CloudConsoleWindow)->menu(); 444 } 445 446 void UICloudConsoleManagerWidget::retranslateUi() 170 447 { 171 448 /* Adjust toolbar: */ … … 182 459 /* Translate tree-widget: */ 183 460 m_pTreeWidget->setHeaderLabels( QStringList() 184 << tr(" Source")185 << tr("List VMs"));186 } 187 188 void UICloud ProfileManagerWidget::sltResetCloudProfileDetailsChanges()461 << tr("Application") 462 << tr("List in Menu")); 463 } 464 465 void UICloudConsoleManagerWidget::sltResetCloudConsoleDetailsChanges() 189 466 { 190 467 /* Just push the current-item data there again: */ … … 192 469 } 193 470 194 void UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges() 195 { 196 /* It can be that there is provider item, not profile item currently selected. 197 * In such case we are not applying parameters, we are creating new one profile. */ 471 void UICloudConsoleManagerWidget::sltApplyCloudConsoleDetailsChanges() 472 { 473 /* Check current-item type: */ 198 474 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 199 UIItemCloudProvider *pMaybeProviderItem = qobject_cast<UIItemCloudProvider*>(pItem); 200 if (pMaybeProviderItem) 201 return sltAddCloudProfile(); 202 203 /* Get profile item: */ 204 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pItem); 205 AssertMsgReturnVoid(pProfileItem, ("Current item must not be null!\n")); 206 207 /* Get item data: */ 208 UIDataCloudProfile oldData = *pProfileItem; 209 UIDataCloudProfile newData = m_pDetailsWidget->data(); 210 211 /* Get VirtualBox for further activities: */ 212 const CVirtualBox comVBox = uiCommon().virtualBox(); 213 214 /* Get CloudProviderManager for further activities: */ 215 CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 216 /* Show error message if necessary: */ 217 if (!comVBox.isOk()) 218 msgCenter().cannotAcquireCloudProviderManager(comVBox, this); 219 else 220 { 221 /* Get provider item: */ 222 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pProfileItem->parentItem()); 223 /* Acquire provider ID: */ 224 const QUuid uId = pProviderItem->data(Column_Name, Data_ProviderID).toUuid(); 225 226 /* Look for corresponding provider: */ 227 CCloudProvider comCloudProvider = comCloudProviderManager.GetProviderById(uId); 228 /* Show error message if necessary: */ 229 if (!comCloudProviderManager.isOk()) 230 msgCenter().cannotFindCloudProvider(comCloudProviderManager, uId, this); 231 else 232 { 233 /* Look for corresponding profile: */ 234 CCloudProfile comCloudProfile = comCloudProvider.GetProfileByName(oldData.m_strName); 235 /* Show error message if necessary: */ 236 if (!comCloudProvider.isOk()) 237 msgCenter().cannotFindCloudProfile(comCloudProvider, oldData.m_strName, this); 238 else 239 { 240 /* Set profile name, if necessary: */ 241 if (newData.m_strName != oldData.m_strName) 242 comCloudProfile.SetName(newData.m_strName); 243 /* Show error message if necessary: */ 244 if (!comCloudProfile.isOk()) 245 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 246 else 247 { 248 /* Iterate through old/new data: */ 249 foreach (const QString &strKey, oldData.m_data.keys()) 250 { 251 /* Get values: */ 252 const QString strOldValue = oldData.m_data.value(strKey).first; 253 const QString strNewValue = newData.m_data.value(strKey).first; 254 if (strNewValue != strOldValue) 255 { 256 /* Apply property: */ 257 comCloudProfile.SetProperty(strKey, strNewValue); 258 /* Show error message if necessary: */ 259 if (!comCloudProfile.isOk()) 260 { 261 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 262 break; 263 } 264 } 265 } 266 } 267 268 /* If profile is Ok finally: */ 269 if (comCloudProfile.isOk()) 270 { 271 /* Update profile in the tree: */ 272 UIDataCloudProfile data; 273 loadCloudProfile(comCloudProfile, *pProviderItem, data); 274 updateItemForCloudProfile(data, true, pProfileItem); 275 276 /* Make sure current-item fetched: */ 277 sltHandleCurrentItemChange(); 278 279 /* Save profile changes: */ 280 comCloudProvider.SaveProfiles(); 281 /* Show error message if necessary: */ 282 if (!comCloudProvider.isOk()) 283 msgCenter().cannotSaveCloudProfiles(comCloudProvider, this); 284 } 285 } 286 } 287 } 288 289 /* Notify listeners: */ 290 emit sigChange(); 291 } 292 293 void UICloudProfileManagerWidget::sltAddCloudProfile() 294 { 295 /* Get provider item: */ 475 AssertMsgReturnVoid(pItem, ("Current item must not be null!\n")); 476 switch (pItem->data(Column_Name, Data_ItemType).value<CloudConsoleItemType>()) 477 { 478 case CloudConsoleItemType_Application: 479 { 480 /* Save application changes: */ 481 UIItemCloudConsoleApplication *pItemApplication = qobject_cast<UIItemCloudConsoleApplication*>(pItem); 482 AssertPtrReturnVoid(pItemApplication); 483 const UIDataCloudConsoleApplication oldData = *pItemApplication; 484 const UIDataCloudConsoleApplication newData = m_pDetailsWidget->applicationData(); 485 /* Save application settings if changed: */ 486 if (newData != oldData) 487 gEDataManager->setCloudConsoleManagerApplication(newData.m_strId, 488 QString("%1,%2").arg(newData.m_strName, newData.m_strPath)); 489 break; 490 } 491 case CloudConsoleItemType_Profile: 492 { 493 /* Save profile changes: */ 494 UIItemCloudConsoleProfile *pItemProfile = qobject_cast<UIItemCloudConsoleProfile*>(pItem); 495 AssertPtrReturnVoid(pItemProfile); 496 const UIDataCloudConsoleProfile oldData = *pItemProfile; 497 const UIDataCloudConsoleProfile newData = m_pDetailsWidget->profileData(); 498 /* Save profile settings if changed: */ 499 if (newData != oldData) 500 gEDataManager->setCloudConsoleManagerProfile(newData.m_strApplicationId, 501 newData.m_strId, 502 QString("%1,%2").arg(newData.m_strName, newData.m_strArgument)); 503 break; 504 } 505 case CloudConsoleItemType_Invalid: 506 break; 507 } 508 } 509 510 void UICloudConsoleManagerWidget::sltAddCloudConsoleApplication() 511 { 512 /* Acquire application attributes: */ 513 QString strId; 514 QString strApplicationName; 515 QString strApplicationPath; 516 bool fCancelled = true; 517 QPointer<UIInputDialogCloudConsoleApplication> pDialog = new UIInputDialogCloudConsoleApplication(this); 518 if (pDialog) 519 { 520 if (pDialog->exec() == QDialog::Accepted) 521 { 522 strId = QUuid::createUuid().toString().remove(QRegExp("[{}]")); 523 strApplicationName = pDialog->name(); 524 strApplicationPath = pDialog->path(); 525 fCancelled = false; 526 } 527 delete pDialog; 528 } 529 if (fCancelled) 530 return; 531 532 /* Update current-item definition: */ 533 m_strDefinition = QString("/%1").arg(strId); 534 /* Compose extra-data superset: */ 535 const QString strValue = QString("%1,%2").arg(strApplicationName, strApplicationPath); 536 537 /* Save new console application to extra-data: */ 538 gEDataManager->setCloudConsoleManagerApplication(strId, strValue); 539 } 540 541 void UICloudConsoleManagerWidget::sltRemoveCloudConsoleApplication() 542 { 543 /* Get console application item: */ 296 544 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 297 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pItem); 298 AssertMsgReturnVoid(pProviderItem, ("Current item must not be null!\n")); 299 300 /* Acquire profile name if not proposed by details widget: */ 301 QString strProfileName = m_pDetailsWidget->data().m_strName; 302 if (strProfileName.isEmpty()) 303 { 304 bool fCancelled = true; 305 QISafePointerInputDialog pDialog = new QIInputDialog(this); 306 if (pDialog) 307 { 308 pDialog->setWindowIcon(UIIconPool::iconSet(":/cloud_profile_add_16px.png")); 309 pDialog->setWindowTitle(UICloudProfileManager::tr("Add Profile")); 310 if (pDialog->exec() == QDialog::Accepted) 311 { 312 strProfileName = pDialog->textValue(); 313 fCancelled = false; 314 } 315 delete pDialog; 316 } 317 if (fCancelled) 318 return; 319 } 320 321 /* Get VirtualBox for further activities: */ 322 const CVirtualBox comVBox = uiCommon().virtualBox(); 323 324 /* Get CloudProviderManager for further activities: */ 325 CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 326 /* Show error message if necessary: */ 327 if (!comVBox.isOk()) 328 msgCenter().cannotAcquireCloudProviderManager(comVBox, this); 329 else 330 { 331 /* Acquire provider ID: */ 332 const QUuid uId = pProviderItem->data(Column_Name, Data_ProviderID).toUuid(); 333 334 /* Look for corresponding provider: */ 335 CCloudProvider comCloudProvider = comCloudProviderManager.GetProviderById(uId); 336 /* Show error message if necessary: */ 337 if (!comCloudProviderManager.isOk()) 338 msgCenter().cannotFindCloudProvider(comCloudProviderManager, uId, this); 339 else 340 { 341 /* Create new profile: */ 342 const QVector<QString> keys = pProviderItem->m_propertyDescriptions.keys().toVector(); 343 const QVector<QString> values(keys.size()); 344 comCloudProvider.CreateProfile(strProfileName, keys, values); 345 346 /* Show error message if necessary: */ 347 if (!comCloudProvider.isOk()) 348 msgCenter().cannotCreateCloudProfle(comCloudProvider, this); 349 else 350 { 351 /* Look for corresponding profile: */ 352 CCloudProfile comCloudProfile = comCloudProvider.GetProfileByName(strProfileName); 353 /* Show error message if necessary: */ 354 if (!comCloudProvider.isOk()) 355 msgCenter().cannotFindCloudProfile(comCloudProvider, strProfileName, this); 356 else 357 { 358 /* Add profile to the tree: */ 359 UIDataCloudProfile data; 360 loadCloudProfile(comCloudProfile, *pProviderItem, data); 361 createItemForCloudProfile(pProviderItem, data, true); 362 363 /* Save profile changes: */ 364 comCloudProvider.SaveProfiles(); 365 /* Show error message if necessary: */ 366 if (!comCloudProvider.isOk()) 367 msgCenter().cannotSaveCloudProfiles(comCloudProvider, this); 368 } 369 } 370 } 371 } 372 373 /* Notify listeners: */ 374 emit sigChange(); 375 } 376 377 void UICloudProfileManagerWidget::sltImportCloudProfiles() 378 { 379 /* Get provider item: */ 545 UIItemCloudConsoleApplication *pItemApplication = qobject_cast<UIItemCloudConsoleApplication*>(pItem); 546 AssertMsgReturnVoid(pItemApplication, ("Application item must not be null!\n")); 547 const QString strApplicationId = pItemApplication->id(); 548 549 /* Confirm cloud console application removal: */ 550 if (!msgCenter().confirmCloudConsoleApplicationRemoval(pItemApplication->name(), this)) 551 return; 552 553 /* Enumerate all the application profiles: */ 554 for (int i = 0; i < pItemApplication->childCount(); ++i) 555 { 556 /* Get console profile item: */ 557 QITreeWidgetItem *pItem = pItemApplication->childItem(i); 558 UIItemCloudConsoleProfile *pItemProfile = qobject_cast<UIItemCloudConsoleProfile*>(pItem); 559 AssertMsgReturnVoid(pItemProfile, ("Profile item must not be null!\n")); 560 561 /* Delete profile from extra-data: */ 562 gEDataManager->setCloudConsoleManagerProfile(strApplicationId, pItemProfile->id(), QString()); 563 } 564 565 /* Delete application from extra-data: */ 566 gEDataManager->setCloudConsoleManagerApplication(strApplicationId, QString()); 567 } 568 569 void UICloudConsoleManagerWidget::sltAddCloudConsoleProfile() 570 { 571 /* Check current-item type: */ 380 572 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 381 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pItem); 382 AssertMsgReturnVoid(pProviderItem, ("Current item must not be null!\n")); 383 384 /* If there are profiles exist => confirm cloud profile import. */ 385 if ( pProviderItem->childCount() != 0 386 && !msgCenter().confirmCloudProfilesImport(this)) 573 AssertMsgReturnVoid(pItem, ("Current item must not be null!\n")); 574 UIItemCloudConsoleApplication *pItemApplication = 0; 575 switch (pItem->data(Column_Name, Data_ItemType).value<CloudConsoleItemType>()) 576 { 577 case CloudConsoleItemType_Application: 578 pItemApplication = qobject_cast<UIItemCloudConsoleApplication*>(pItem); 579 break; 580 case CloudConsoleItemType_Profile: 581 pItemApplication = qobject_cast<UIItemCloudConsoleApplication*>(pItem->parentItem()); 582 break; 583 case CloudConsoleItemType_Invalid: 584 break; 585 } 586 AssertMsgReturnVoid(pItemApplication, ("Application item must not be null!\n")); 587 const QString strApplicationId = pItemApplication->id(); 588 589 /* Acquire profile attributes: */ 590 QString strId; 591 QString strProfileName; 592 QString strProfileArgument; 593 bool fCancelled = true; 594 QPointer<UIInputDialogCloudConsoleProfile> pDialog = new UIInputDialogCloudConsoleProfile(this); 595 if (pDialog) 596 { 597 if (pDialog->exec() == QDialog::Accepted) 598 { 599 strId = QUuid::createUuid().toString().remove(QRegExp("[{}]")); 600 strProfileName = pDialog->name(); 601 strProfileArgument = pDialog->argument(); 602 fCancelled = false; 603 } 604 delete pDialog; 605 } 606 if (fCancelled) 387 607 return; 388 608 389 /* Get VirtualBox for further activities: */ 390 const CVirtualBox comVBox = uiCommon().virtualBox(); 391 392 /* Get CloudProviderManager for further activities: */ 393 CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 394 /* Show error message if necessary: */ 395 if (!comVBox.isOk()) 396 msgCenter().cannotAcquireCloudProviderManager(comVBox, this); 397 else 398 { 399 /* Acquire provider ID: */ 400 const QUuid uId = pProviderItem->data(Column_Name, Data_ProviderID).toUuid(); 401 402 /* Look for corresponding provider: */ 403 CCloudProvider comCloudProvider = comCloudProviderManager.GetProviderById(uId); 404 /* Show error message if necessary: */ 405 if (!comCloudProviderManager.isOk()) 406 msgCenter().cannotFindCloudProvider(comCloudProviderManager, uId, this); 407 else 408 { 409 /* Import profiles: */ 410 comCloudProvider.ImportProfiles(); 411 412 /* Show error message if necessary: */ 413 if (!comCloudProvider.isOk()) 414 msgCenter().cannotImportCloudProfiles(comCloudProvider, this); 415 else 416 loadCloudStuff(); 417 } 418 } 419 420 /* Notify listeners: */ 421 emit sigChange(); 422 } 423 424 void UICloudProfileManagerWidget::sltRemoveCloudProfile() 425 { 426 /* Get profile item: */ 609 /* Update current-item definition: */ 610 m_strDefinition = QString("/%1/%2").arg(strApplicationId, strId); 611 /* Compose extra-data superset: */ 612 const QString strValue = QString("%1,%2").arg(strProfileName, strProfileArgument); 613 614 /* Save new console profile to extra-data: */ 615 gEDataManager->setCloudConsoleManagerProfile(strApplicationId, strId, strValue); 616 } 617 618 void UICloudConsoleManagerWidget::sltRemoveCloudConsoleProfile() 619 { 620 /* Get console profile item: */ 427 621 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 428 UIItemCloudProfile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pItem); 429 AssertMsgReturnVoid(pProfileItem, ("Current item must not be null!\n")); 430 431 /* Get profile name: */ 432 const QString strProfileName(pProfileItem->name()); 433 434 /* Confirm cloud profile removal: */ 435 if (!msgCenter().confirmCloudProfileRemoval(strProfileName, this)) 622 UIItemCloudConsoleProfile *pItemProfile = qobject_cast<UIItemCloudConsoleProfile*>(pItem); 623 AssertMsgReturnVoid(pItemProfile, ("Profile item must not be null!\n")); 624 625 /* Confirm cloud console profile removal: */ 626 if (!msgCenter().confirmCloudConsoleProfileRemoval(pItemProfile->name(), this)) 436 627 return; 437 628 438 /* Get VirtualBox for further activities: */ 439 const CVirtualBox comVBox = uiCommon().virtualBox(); 440 441 /* Get CloudProviderManager for further activities: */ 442 CCloudProviderManager comCloudProviderManager = comVBox.GetCloudProviderManager(); 443 /* Show error message if necessary: */ 444 if (!comVBox.isOk()) 445 msgCenter().cannotAcquireCloudProviderManager(comVBox, this); 446 else 447 { 448 /* Get provider item: */ 449 UIItemCloudProvider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pProfileItem->parentItem()); 450 /* Acquire provider ID: */ 451 const QUuid uId = pProviderItem->data(Column_Name, Data_ProviderID).toUuid(); 452 453 /* Look for corresponding provider: */ 454 CCloudProvider comCloudProvider = comCloudProviderManager.GetProviderById(uId); 455 /* Show error message if necessary: */ 456 if (!comCloudProviderManager.isOk()) 457 msgCenter().cannotFindCloudProvider(comCloudProviderManager, uId, this); 458 else 459 { 460 /* Look for corresponding profile: */ 461 CCloudProfile comCloudProfile = comCloudProvider.GetProfileByName(strProfileName); 462 /* Show error message if necessary: */ 463 if (!comCloudProvider.isOk()) 464 msgCenter().cannotFindCloudProfile(comCloudProvider, strProfileName, this); 465 else 466 { 467 /* Remove current profile: */ 468 comCloudProfile.Remove(); 469 /// @todo how do we check that? 470 471 /* Remove interface from the tree: */ 472 delete pProfileItem; 473 474 /* Save profile changes: */ 475 comCloudProvider.SaveProfiles(); 476 /* Show error message if necessary: */ 477 if (!comCloudProvider.isOk()) 478 msgCenter().cannotSaveCloudProfiles(comCloudProvider, this); 479 } 480 } 481 } 482 483 /* Notify listeners: */ 484 emit sigChange(); 485 } 486 487 void UICloudProfileManagerWidget::sltToggleCloudProfileDetailsVisibility(bool fVisible) 629 /* Delete profile from extra-data: */ 630 gEDataManager->setCloudConsoleManagerProfile(pItemProfile->applicationId(), pItemProfile->id(), QString()); 631 } 632 633 void UICloudConsoleManagerWidget::sltToggleCloudConsoleDetailsVisibility(bool fVisible) 488 634 { 489 635 /* Save the setting: */ 490 gEDataManager->setCloud ProfileManagerDetailsExpanded(fVisible);636 gEDataManager->setCloudConsoleManagerDetailsExpanded(fVisible); 491 637 /* Show/hide details area and Apply button: */ 492 638 m_pDetailsWidget->setVisible(fVisible); 493 639 /* Notify external lsiteners: */ 494 emit sigCloudProfileDetailsVisibilityChanged(fVisible); 495 } 496 497 void UICloudProfileManagerWidget::sltShowCloudProfileTryPage() 498 { 499 uiCommon().openURL("https://myservices.us.oraclecloud.com/mycloud/signup"); 500 } 501 502 void UICloudProfileManagerWidget::sltShowCloudProfileHelp() 503 { 504 uiCommon().openURL("https://docs.cloud.oracle.com/iaas/Content/API/Concepts/sdkconfig.htm"); 505 } 506 507 void UICloudProfileManagerWidget::sltPerformTableAdjustment() 640 emit sigCloudConsoleDetailsVisibilityChanged(fVisible); 641 } 642 643 void UICloudConsoleManagerWidget::sltPerformTableAdjustment() 508 644 { 509 645 AssertPtrReturnVoid(m_pTreeWidget); … … 513 649 } 514 650 515 void UICloud ProfileManagerWidget::sltHandleCurrentItemChange()651 void UICloudConsoleManagerWidget::sltHandleCurrentItemChange() 516 652 { 517 653 /* Check current-item type: */ 518 654 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->currentItem()); 519 UIItemCloud Provider *pItemProvider = qobject_cast<UIItemCloudProvider*>(pItem);520 UIItemCloud Profile *pItemProfile = qobject_cast<UIItemCloudProfile*>(pItem);655 UIItemCloudConsoleApplication *pItemApplication = qobject_cast<UIItemCloudConsoleApplication*>(pItem); 656 UIItemCloudConsoleProfile *pItemProfile = qobject_cast<UIItemCloudConsoleProfile*>(pItem); 521 657 522 658 /* Update actions availability: */ 523 m_pActionPool->action(UIActionIndexST_M_Cloud_S_Add)->setEnabled(!pItem || pItemProvider); 524 m_pActionPool->action(UIActionIndexST_M_Cloud_S_Import)->setEnabled(!pItem || pItemProvider); 525 m_pActionPool->action(UIActionIndexST_M_Cloud_S_Remove)->setEnabled(pItemProfile); 526 m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)->setEnabled(pItemProfile || pItemProvider); 527 528 /* If there is an item => update details data: */ 529 if (pItemProfile) 530 m_pDetailsWidget->setData(*pItemProfile); 531 /* Otherwise => clear details data: */ 659 m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationAdd)->setEnabled(!pItem || pItemApplication); 660 m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationRemove)->setEnabled(pItemApplication); 661 m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileAdd)->setEnabled(pItemApplication || pItemProfile); 662 m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileRemove)->setEnabled(pItemProfile); 663 m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details)->setEnabled(pItemApplication || pItemProfile); 664 665 /* Update current-item definition: */ 666 if (pItem) 667 m_strDefinition = pItem->data(Column_Name, Data_Definition).toString(); 668 669 /* Update details data: */ 670 if (pItemApplication) 671 m_pDetailsWidget->setApplicationData(*pItemApplication); 672 else if (pItemProfile) 673 m_pDetailsWidget->setProfileData(*pItemProfile); 532 674 else 533 m_pDetailsWidget-> setData(UIDataCloudProfile());675 m_pDetailsWidget->clearData(); 534 676 535 677 /* Update details area visibility: */ 536 sltToggleCloud ProfileDetailsVisibility(pItem && m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)->isChecked());537 } 538 539 void UICloud ProfileManagerWidget::sltHandleContextMenuRequest(const QPoint &position)540 { 541 /* Check clicked-item type: */678 sltToggleCloudConsoleDetailsVisibility(pItem && m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details)->isChecked()); 679 } 680 681 void UICloudConsoleManagerWidget::sltHandleContextMenuRequest(const QPoint &position) 682 { 683 /* Check item type: */ 542 684 QITreeWidgetItem *pItem = QITreeWidgetItem::toItem(m_pTreeWidget->itemAt(position)); 543 UIItemCloud Provider *pItemProvider = qobject_cast<UIItemCloudProvider*>(pItem);544 UIItemCloud Profile *pItemProfile = qobject_cast<UIItemCloudProfile*>(pItem);685 UIItemCloudConsoleApplication *pItemApplication = qobject_cast<UIItemCloudConsoleApplication*>(pItem); 686 UIItemCloudConsoleProfile *pItemProfile = qobject_cast<UIItemCloudConsoleProfile*>(pItem); 545 687 546 688 /* Compose temporary context-menu: */ 547 689 QMenu menu; 548 if (pItemProfile) 549 { 550 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Remove)); 551 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)); 552 } 553 else if (pItemProvider) 554 { 555 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Add)); 556 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Import)); 557 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)); 558 } 690 if (pItemApplication) 691 { 692 menu.addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationRemove)); 693 menu.addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileAdd)); 694 menu.addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details)); 695 } 696 else if (pItemProfile) 697 { 698 menu.addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileRemove)); 699 menu.addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details)); 700 } 701 else 702 menu.addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationAdd)); 559 703 560 704 /* And show it: */ … … 562 706 } 563 707 564 void UICloud ProfileManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem)708 void UICloudConsoleManagerWidget::sltHandleItemChange(QTreeWidgetItem *pItem) 565 709 { 566 710 /* Check item type: */ 567 711 QITreeWidgetItem *pChangedItem = QITreeWidgetItem::toItem(pItem); 568 UIItemCloud Provider *pProviderItem = qobject_cast<UIItemCloudProvider*>(pChangedItem);569 UIItemCloud Profile *pProfileItem = qobject_cast<UIItemCloudProfile*>(pChangedItem);570 571 /* Check whether item is of provideror profile type, then check whether it changed: */712 UIItemCloudConsoleApplication *pItemApplication = qobject_cast<UIItemCloudConsoleApplication*>(pChangedItem); 713 UIItemCloudConsoleProfile *pItemProfile = qobject_cast<UIItemCloudConsoleProfile*>(pChangedItem); 714 715 /* Check whether item is of application or profile type, then check whether it changed: */ 572 716 bool fChanged = false; 573 if (p ProviderItem)574 { 575 const UIDataCloud Provider oldData = *pProviderItem;576 if ( (oldData.m_fRestricted && p ProviderItem->checkState(Column_ListVMs) == Qt::Checked)577 || (!oldData.m_fRestricted && p ProviderItem->checkState(Column_ListVMs) == Qt::Unchecked))717 if (pItemApplication) 718 { 719 const UIDataCloudConsoleApplication oldData = *pItemApplication; 720 if ( (oldData.m_fRestricted && pItemApplication->checkState(Column_ListInMenu) == Qt::Checked) 721 || (!oldData.m_fRestricted && pItemApplication->checkState(Column_ListInMenu) == Qt::Unchecked)) 578 722 fChanged = true; 579 723 } 580 else if (p ProfileItem)581 { 582 const UIDataCloud Profile oldData = *pProfileItem;583 if ( (oldData.m_fRestricted && p ProfileItem->checkState(Column_ListVMs) == Qt::Checked)584 || (!oldData.m_fRestricted && p ProfileItem->checkState(Column_ListVMs) == Qt::Unchecked))724 else if (pItemProfile) 725 { 726 const UIDataCloudConsoleProfile oldData = *pItemProfile; 727 if ( (oldData.m_fRestricted && pItemProfile->checkState(Column_ListInMenu) == Qt::Checked) 728 || (!oldData.m_fRestricted && pItemProfile->checkState(Column_ListInMenu) == Qt::Unchecked)) 585 729 fChanged = true; 586 730 } 587 731 588 /* Gather Cloud Profile Manager restrictions and save them to extra-data: */732 /* Gather Cloud Console Manager restrictions and save them to extra-data: */ 589 733 if (fChanged) 590 gEDataManager->setCloud ProfileManagerRestrictions(gatherCloudProfileManagerRestrictions(m_pTreeWidget->invisibleRootItem()));591 } 592 593 void UICloud ProfileManagerWidget::prepare()734 gEDataManager->setCloudConsoleManagerRestrictions(gatherCloudConsoleManagerRestrictions(m_pTreeWidget->invisibleRootItem())); 735 } 736 737 void UICloudConsoleManagerWidget::prepare() 594 738 { 595 739 /* Prepare actions: */ … … 604 748 retranslateUi(); 605 749 606 /* Load cloud stuff: */607 loadCloud Stuff();608 } 609 610 void UICloud ProfileManagerWidget::prepareActions()750 /* Load cloud console stuff: */ 751 loadCloudConsoleStuff(); 752 } 753 754 void UICloudConsoleManagerWidget::prepareActions() 611 755 { 612 756 /* First of all, add actions which has smaller shortcut scope: */ 613 addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Add)); 614 addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Import)); 615 addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Remove)); 616 addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)); 617 addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_TryPage)); 618 addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Help)); 619 } 620 621 void UICloudProfileManagerWidget::prepareWidgets() 757 addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationAdd)); 758 addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationRemove)); 759 addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileAdd)); 760 addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileRemove)); 761 addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details)); 762 } 763 764 void UICloudConsoleManagerWidget::prepareWidgets() 622 765 { 623 766 /* Create main-layout: */ … … 645 788 } 646 789 647 void UICloud ProfileManagerWidget::prepareToolBar()790 void UICloudConsoleManagerWidget::prepareToolBar() 648 791 { 649 792 /* Create toolbar: */ … … 657 800 658 801 /* Add toolbar actions: */ 659 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Cloud _S_Add));660 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Cloud _S_Import));802 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationAdd)); 803 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationRemove)); 661 804 m_pToolBar->addSeparator(); 662 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Cloud _S_Remove));663 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Cloud _T_Details));805 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileAdd)); 806 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileRemove)); 664 807 m_pToolBar->addSeparator(); 665 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_TryPage)); 666 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Help)); 808 m_pToolBar->addAction(m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details)); 667 809 668 810 #ifdef VBOX_WS_MAC … … 680 822 } 681 823 682 void UICloud ProfileManagerWidget::prepareTreeWidget()824 void UICloudConsoleManagerWidget::prepareTreeWidget() 683 825 { 684 826 /* Create tree-widget: */ … … 702 844 } 703 845 704 void UICloud ProfileManagerWidget::prepareDetailsWidget()846 void UICloudConsoleManagerWidget::prepareDetailsWidget() 705 847 { 706 848 /* Create details-widget: */ 707 m_pDetailsWidget = new UICloud ProfileDetailsWidget(m_enmEmbedding);849 m_pDetailsWidget = new UICloudConsoleDetailsWidget(m_enmEmbedding); 708 850 if (m_pDetailsWidget) 709 851 { … … 717 859 } 718 860 719 void UICloud ProfileManagerWidget::prepareConnections()861 void UICloudConsoleManagerWidget::prepareConnections() 720 862 { 721 863 /* Action connections: */ 722 connect(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Add), &QAction::triggered, 723 this, &UICloudProfileManagerWidget::sltAddCloudProfile); 724 connect(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Import), &QAction::triggered, 725 this, &UICloudProfileManagerWidget::sltImportCloudProfiles); 726 connect(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Remove), &QAction::triggered, 727 this, &UICloudProfileManagerWidget::sltRemoveCloudProfile); 728 connect(m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details), &QAction::toggled, 729 this, &UICloudProfileManagerWidget::sltToggleCloudProfileDetailsVisibility); 730 connect(m_pActionPool->action(UIActionIndexST_M_Cloud_S_TryPage), &QAction::triggered, 731 this, &UICloudProfileManagerWidget::sltShowCloudProfileTryPage); 732 connect(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Help), &QAction::triggered, 733 this, &UICloudProfileManagerWidget::sltShowCloudProfileHelp); 864 connect(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationAdd), &QAction::triggered, 865 this, &UICloudConsoleManagerWidget::sltAddCloudConsoleApplication); 866 connect(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ApplicationRemove), &QAction::triggered, 867 this, &UICloudConsoleManagerWidget::sltRemoveCloudConsoleApplication); 868 connect(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileAdd), &QAction::triggered, 869 this, &UICloudConsoleManagerWidget::sltAddCloudConsoleProfile); 870 connect(m_pActionPool->action(UIActionIndexST_M_CloudConsole_S_ProfileRemove), &QAction::triggered, 871 this, &UICloudConsoleManagerWidget::sltRemoveCloudConsoleProfile); 872 connect(m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details), &QAction::toggled, 873 this, &UICloudConsoleManagerWidget::sltToggleCloudConsoleDetailsVisibility); 734 874 735 875 /* Tree-widget connections: */ 736 876 connect(m_pTreeWidget, &QITreeWidget::resized, 737 this, &UICloud ProfileManagerWidget::sltPerformTableAdjustment, Qt::QueuedConnection);877 this, &UICloudConsoleManagerWidget::sltPerformTableAdjustment, Qt::QueuedConnection); 738 878 connect(m_pTreeWidget->header(), &QHeaderView::sectionResized, 739 this, &UICloud ProfileManagerWidget::sltPerformTableAdjustment, Qt::QueuedConnection);879 this, &UICloudConsoleManagerWidget::sltPerformTableAdjustment, Qt::QueuedConnection); 740 880 connect(m_pTreeWidget, &QITreeWidget::currentItemChanged, 741 this, &UICloud ProfileManagerWidget::sltHandleCurrentItemChange);881 this, &UICloudConsoleManagerWidget::sltHandleCurrentItemChange); 742 882 connect(m_pTreeWidget, &QITreeWidget::customContextMenuRequested, 743 this, &UICloud ProfileManagerWidget::sltHandleContextMenuRequest);883 this, &UICloudConsoleManagerWidget::sltHandleContextMenuRequest); 744 884 connect(m_pTreeWidget, &QITreeWidget::itemDoubleClicked, 745 m_pActionPool->action(UIActionIndexST_M_Cloud _T_Details), &QAction::setChecked);885 m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details), &QAction::setChecked); 746 886 connect(m_pTreeWidget, &QITreeWidget::itemChanged, 747 this, &UICloud ProfileManagerWidget::sltHandleItemChange);887 this, &UICloudConsoleManagerWidget::sltHandleItemChange); 748 888 749 889 /* Details-widget connections: */ 750 connect(m_pDetailsWidget, &UICloud ProfileDetailsWidget::sigDataChanged,751 this, &UICloud ProfileManagerWidget::sigCloudProfileDetailsDataChanged);752 connect(m_pDetailsWidget, &UICloud ProfileDetailsWidget::sigDataChangeRejected,753 this, &UICloud ProfileManagerWidget::sltResetCloudProfileDetailsChanges);754 connect(m_pDetailsWidget, &UICloud ProfileDetailsWidget::sigDataChangeAccepted,755 this, &UICloud ProfileManagerWidget::sltApplyCloudProfileDetailsChanges);890 connect(m_pDetailsWidget, &UICloudConsoleDetailsWidget::sigDataChanged, 891 this, &UICloudConsoleManagerWidget::sigCloudConsoleDetailsDataChanged); 892 connect(m_pDetailsWidget, &UICloudConsoleDetailsWidget::sigDataChangeRejected, 893 this, &UICloudConsoleManagerWidget::sltResetCloudConsoleDetailsChanges); 894 connect(m_pDetailsWidget, &UICloudConsoleDetailsWidget::sigDataChangeAccepted, 895 this, &UICloudConsoleManagerWidget::sltApplyCloudConsoleDetailsChanges); 756 896 757 897 /* Extra-data connections: */ 758 connect(gEDataManager, &UIExtraDataManager::sigCloudProfileManagerRestrictionChange, 759 this, &UICloudProfileManagerWidget::sltLoadCloudStuff); 760 } 761 762 void UICloudProfileManagerWidget::loadSettings() 898 connect(gEDataManager, &UIExtraDataManager::sigCloudConsoleManagerDataChange, 899 this, &UICloudConsoleManagerWidget::sltLoadCloudConsoleStuff); 900 connect(gEDataManager, &UIExtraDataManager::sigCloudConsoleManagerRestrictionChange, 901 this, &UICloudConsoleManagerWidget::sltLoadCloudConsoleStuff); 902 } 903 904 void UICloudConsoleManagerWidget::loadSettings() 763 905 { 764 906 /* Details action/widget: */ 765 m_pActionPool->action(UIActionIndexST_M_Cloud _T_Details)->setChecked(gEDataManager->cloudProfileManagerDetailsExpanded());766 sltToggleCloud ProfileDetailsVisibility(m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)->isChecked());767 } 768 769 void UICloud ProfileManagerWidget::loadCloudStuff()907 m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details)->setChecked(gEDataManager->cloudConsoleManagerDetailsExpanded()); 908 sltToggleCloudConsoleDetailsVisibility(m_pActionPool->action(UIActionIndexST_M_CloudConsole_T_Details)->isChecked()); 909 } 910 911 void UICloudConsoleManagerWidget::loadCloudConsoleStuff() 770 912 { 771 913 /* Clear tree first of all: */ 772 914 m_pTreeWidget->clear(); 773 915 774 /* Acquire cloud profile manager restrictions: */775 const QStringList restrictions = gEDataManager->cloud ProfileManagerRestrictions();776 777 /* Iterate through existing providers: */778 foreach (const CCloudProvider &comCloudProvider, listCloudProviders())916 /* Acquire cloud console manager restrictions: */ 917 const QStringList restrictions = gEDataManager->cloudConsoleManagerRestrictions(); 918 919 /* Iterate through existing console applications: */ 920 foreach (const QString &strApplicationId, gEDataManager->cloudConsoleManagerApplications()) 779 921 { 780 922 /* Skip if we have nothing to populate: */ 781 if ( comCloudProvider.isNull())923 if (strApplicationId.isEmpty()) 782 924 continue; 783 925 784 /* Load provider data: */ 785 UIDataCloudProvider providerData; 786 loadCloudProvider(comCloudProvider, providerData); 787 const QString strProviderPath = QString("/%1").arg(providerData.m_strShortName); 788 providerData.m_fRestricted = restrictions.contains(strProviderPath); 789 createItemForCloudProvider(providerData, false); 790 791 /* Make sure provider item is properly inserted: */ 792 UIItemCloudProvider *pItem = searchItem(providerData.m_uId); 793 794 /* Iterate through provider's profiles: */ 795 foreach (const CCloudProfile &comCloudProfile, listCloudProfiles(comCloudProvider)) 926 /* Compose extra-data superset: */ 927 const QString strApplicationValue = gEDataManager->cloudConsoleManagerApplication(strApplicationId); 928 const QString strApplicationSuperset = QString("%1,%2").arg(strApplicationId, strApplicationValue); 929 930 /* Load console application data: */ 931 UIDataCloudConsoleApplication applicationData; 932 loadCloudConsoleApplication(strApplicationSuperset, applicationData); 933 const QString strApplicationDefinition = QString("/%1").arg(applicationData.m_strId); 934 applicationData.m_fRestricted = restrictions.contains(strApplicationDefinition); 935 createItemForCloudConsoleApplication(applicationData, false); 936 937 /* Make sure console applications item is properly inserted: */ 938 UIItemCloudConsoleApplication *pItem = searchApplicationItem(applicationData.m_strId); 939 940 /* Iterate through applications's profiles: */ 941 foreach (const QString &strProfileId, gEDataManager->cloudConsoleManagerProfiles(strApplicationId)) 796 942 { 797 943 /* Skip if we have nothing to populate: */ 798 if ( comCloudProfile.isNull())944 if (strProfileId.isEmpty()) 799 945 continue; 800 946 801 /* Load profile data: */ 802 UIDataCloudProfile profileData; 803 loadCloudProfile(comCloudProfile, providerData, profileData); 804 const QString strProfilePath = QString("/%1/%2").arg(providerData.m_strShortName).arg(profileData.m_strName); 805 profileData.m_fRestricted = restrictions.contains(strProfilePath); 806 createItemForCloudProfile(pItem, profileData, false); 807 } 808 809 /* Expand provider item finally: */ 947 /* Compose extra-data superset: */ 948 const QString strProfileValue = gEDataManager->cloudConsoleManagerProfile(strApplicationId, strProfileId); 949 const QString strProfileSuperset = QString("%1,%2").arg(strProfileId, strProfileValue); 950 951 /* Load console profile data: */ 952 UIDataCloudConsoleProfile profileData; 953 loadCloudConsoleProfile(strProfileSuperset, applicationData, profileData); 954 const QString strProfileDefinition = QString("/%1/%2").arg(applicationData.m_strId).arg(profileData.m_strId); 955 profileData.m_fRestricted = restrictions.contains(strProfileDefinition); 956 createItemForCloudConsoleProfile(pItem, profileData, false); 957 } 958 959 /* Expand console application item finally: */ 810 960 pItem->setExpanded(true); 811 961 } 812 962 813 /* Choose the 1st item as current initially: */ 814 m_pTreeWidget->setCurrentItem(m_pTreeWidget->topLevelItem(0)); 963 /* Choose previous current-item if possible: */ 964 if (!m_strDefinition.isEmpty()) 965 m_pTreeWidget->setCurrentItem(searchItemByDefinition(m_strDefinition)); 966 /* Choose the 1st item as current if nothing chosen: */ 967 if (!m_pTreeWidget->currentItem()) 968 m_pTreeWidget->setCurrentItem(m_pTreeWidget->childItem(0)); 969 /* Make sure current-item is fetched: */ 815 970 sltHandleCurrentItemChange(); 816 971 } 817 972 818 void UICloudProfileManagerWidget::loadCloudProvider(const CCloudProvider &comProvider, 819 UIDataCloudProvider &providerData) 820 { 821 /* Gather provider settings: */ 822 if (comProvider.isOk()) 823 providerData.m_uId = comProvider.GetId(); 824 if (comProvider.isOk()) 825 providerData.m_strShortName = comProvider.GetShortName(); 826 if (comProvider.isOk()) 827 providerData.m_strName = comProvider.GetName(); 828 foreach (const QString &strSupportedPropertyName, comProvider.GetSupportedPropertyNames()) 829 providerData.m_propertyDescriptions[strSupportedPropertyName] = comProvider.GetPropertyDescription(strSupportedPropertyName); 830 831 /* Show error message if necessary: */ 832 if (!comProvider.isOk()) 833 msgCenter().cannotAcquireCloudProviderParameter(comProvider, this); 834 } 835 836 void UICloudProfileManagerWidget::loadCloudProfile(const CCloudProfile &comProfile, 837 const UIDataCloudProvider &providerData, 838 UIDataCloudProfile &profileData) 839 { 840 /* Gather provider settings: */ 841 profileData.m_strProviderShortName = providerData.m_strShortName; 973 void UICloudConsoleManagerWidget::loadCloudConsoleApplication(const QString &strSuperset, 974 UIDataCloudConsoleApplication &applicationData) 975 { 976 /* Parse superset: */ 977 const QStringList values = strSuperset.split(','); 978 979 /* Gather application settings: */ 980 applicationData.m_strId = values.value(0); 981 applicationData.m_strName = values.value(1); 982 applicationData.m_strPath = values.value(2); 983 } 984 985 void UICloudConsoleManagerWidget::loadCloudConsoleProfile(const QString &strSuperset, 986 const UIDataCloudConsoleApplication &applicationData, 987 UIDataCloudConsoleProfile &profileData) 988 { 989 /* Gather application settings: */ 990 profileData.m_strApplicationId = applicationData.m_strId; 991 992 /* Parse superset: */ 993 const QStringList values = strSuperset.split(','); 842 994 843 995 /* Gather profile settings: */ 844 if (comProfile.isOk()) 845 profileData.m_strName = comProfile.GetName(); 846 847 if (comProfile.isOk()) 848 { 849 /* Acquire properties: */ 850 QVector<QString> keys; 851 QVector<QString> values; 852 QVector<QString> descriptions; 853 values = comProfile.GetProperties(QString(), keys); 854 855 /* Sync sizes: */ 856 values.resize(keys.size()); 857 descriptions.resize(keys.size()); 858 859 if (comProfile.isOk()) 860 { 861 /* Enumerate all the keys: */ 862 for (int i = 0; i < keys.size(); ++i) 863 profileData.m_data[keys.at(i)] = qMakePair(values.at(i), providerData.m_propertyDescriptions.value(keys.at(i))); 864 } 865 } 866 867 /* Show error message if necessary: */ 868 if (!comProfile.isOk()) 869 msgCenter().cannotAcquireCloudProfileParameter(comProfile, this); 870 } 871 872 UIItemCloudProvider *UICloudProfileManagerWidget::searchItem(const QUuid &uId) const 996 profileData.m_strId = values.value(0); 997 profileData.m_strName = values.value(1); 998 profileData.m_strArgument = values.value(2); 999 } 1000 1001 UIItemCloudConsoleApplication *UICloudConsoleManagerWidget::searchApplicationItem(const QString &strApplicationId) const 873 1002 { 874 1003 /* Iterate through tree-widget children: */ 875 1004 for (int i = 0; i < m_pTreeWidget->childCount(); ++i) 876 if (m_pTreeWidget->childItem(i)->data(Column_Name, Data_ ProviderID).toUuid() == uId)877 return qobject_cast<UIItemCloud Provider*>(m_pTreeWidget->childItem(i));1005 if (m_pTreeWidget->childItem(i)->data(Column_Name, Data_ItemID).toString() == strApplicationId) 1006 return qobject_cast<UIItemCloudConsoleApplication*>(m_pTreeWidget->childItem(i)); 878 1007 /* Null by default: */ 879 1008 return 0; 880 1009 } 881 1010 882 void UICloudProfileManagerWidget::createItemForCloudProvider(const UIDataCloudProvider &providerData, 883 bool fChooseItem) 884 { 885 /* Create new provider item: */ 886 UIItemCloudProvider *pItem = new UIItemCloudProvider; 1011 UIItemCloudConsoleProfile *UICloudConsoleManagerWidget::searchProfileItem(const QString &strApplicationId, 1012 const QString &strProfileId) const 1013 { 1014 /* Search for application item first: */ 1015 UIItemCloudConsoleApplication *pItemApplication = searchApplicationItem(strApplicationId); 1016 /* Iterate through application children: */ 1017 for (int i = 0; i < pItemApplication->childCount(); ++i) 1018 if (pItemApplication->childItem(i)->data(Column_Name, Data_ItemID).toString() == strProfileId) 1019 return qobject_cast<UIItemCloudConsoleProfile*>(pItemApplication->childItem(i)); 1020 /* Null by default: */ 1021 return 0; 1022 } 1023 1024 QITreeWidgetItem *UICloudConsoleManagerWidget::searchItemByDefinition(const QString &strDefinition) const 1025 { 1026 /* Parse definition: */ 1027 const QStringList parts = strDefinition.split('/', QString::SkipEmptyParts); 1028 /* Depending on parts amount: */ 1029 switch (parts.size()) 1030 { 1031 case 1: return searchApplicationItem(parts.at(0)); 1032 case 2: return searchProfileItem(parts.at(0), parts.at(1)); 1033 default: break; 1034 } 1035 /* Null by default: */ 1036 return 0; 1037 } 1038 1039 void UICloudConsoleManagerWidget::createItemForCloudConsoleApplication(const UIDataCloudConsoleApplication &applicationData, 1040 bool fChooseItem) 1041 { 1042 /* Create new console application item: */ 1043 UIItemCloudConsoleApplication *pItem = new UIItemCloudConsoleApplication; 887 1044 if (pItem) 888 1045 { 889 1046 /* Configure item: */ 890 pItem->UIDataCloud Provider::operator=(providerData);1047 pItem->UIDataCloudConsoleApplication::operator=(applicationData); 891 1048 pItem->updateFields(); 892 1049 /* Add item to the tree: */ … … 898 1055 } 899 1056 900 void UICloud ProfileManagerWidget::createItemForCloudProfile(QTreeWidgetItem *pParent,901 const UIDataCloudProfile &profileData,902 bool fChooseItem)903 { 904 /* Create new profile item: */905 UIItemCloud Profile *pItem = new UIItemCloudProfile;1057 void UICloudConsoleManagerWidget::createItemForCloudConsoleProfile(QTreeWidgetItem *pParent, 1058 const UIDataCloudConsoleProfile &profileData, 1059 bool fChooseItem) 1060 { 1061 /* Create new console profile item: */ 1062 UIItemCloudConsoleProfile *pItem = new UIItemCloudConsoleProfile; 906 1063 if (pItem) 907 1064 { 908 1065 /* Configure item: */ 909 pItem->UIDataCloud Profile::operator=(profileData);1066 pItem->UIDataCloudConsoleProfile::operator=(profileData); 910 1067 pItem->updateFields(); 911 1068 /* Add item to the parent: */ … … 917 1074 } 918 1075 919 void UICloudProfileManagerWidget::updateItemForCloudProfile(const UIDataCloudProfile &profileData, bool fChooseItem, UIItemCloudProfile *pItem) 920 { 921 /* Update passed item: */ 922 if (pItem) 923 { 924 /* Configure item: */ 925 pItem->UIDataCloudProfile::operator=(profileData); 926 pItem->updateFields(); 927 /* And choose it as current if necessary: */ 928 if (fChooseItem) 929 m_pTreeWidget->setCurrentItem(pItem); 930 } 931 } 932 933 QStringList UICloudProfileManagerWidget::gatherCloudProfileManagerRestrictions(QTreeWidgetItem *pParentItem) 1076 QStringList UICloudConsoleManagerWidget::gatherCloudConsoleManagerRestrictions(QTreeWidgetItem *pParentItem) 934 1077 { 935 1078 /* Prepare result: */ … … 940 1083 QITreeWidgetItem *pChangedItem = QITreeWidgetItem::toItem(pParentItem); 941 1084 if ( pChangedItem 942 && pChangedItem->checkState(Column_List VMs) == Qt::Unchecked)1085 && pChangedItem->checkState(Column_ListInMenu) == Qt::Unchecked) 943 1086 result << pChangedItem->data(Column_Name, Data_Definition).toString(); 944 1087 945 1088 /* Iterate through children recursively: */ 946 1089 for (int i = 0; i < pParentItem->childCount(); ++i) 947 result << gatherCloud ProfileManagerRestrictions(pParentItem->child(i));1090 result << gatherCloudConsoleManagerRestrictions(pParentItem->child(i)); 948 1091 949 1092 /* Return result: */ … … 953 1096 954 1097 /********************************************************************************************************************************* 955 * Class UICloud ProfileManagerFactory implementation. *1098 * Class UICloudConsoleManagerFactory implementation. * 956 1099 *********************************************************************************************************************************/ 957 1100 958 UICloud ProfileManagerFactory::UICloudProfileManagerFactory(UIActionPool *pActionPool /* = 0 */)1101 UICloudConsoleManagerFactory::UICloudConsoleManagerFactory(UIActionPool *pActionPool /* = 0 */) 959 1102 : m_pActionPool(pActionPool) 960 1103 { 961 1104 } 962 1105 963 void UICloud ProfileManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget)964 { 965 pDialog = new UICloud ProfileManager(pCenterWidget, m_pActionPool);1106 void UICloudConsoleManagerFactory::create(QIManagerDialog *&pDialog, QWidget *pCenterWidget) 1107 { 1108 pDialog = new UICloudConsoleManager(pCenterWidget, m_pActionPool); 966 1109 } 967 1110 968 1111 969 1112 /********************************************************************************************************************************* 970 * Class UICloud ProfileManager implementation. *1113 * Class UICloudConsoleManager implementation. * 971 1114 *********************************************************************************************************************************/ 972 1115 973 UICloud ProfileManager::UICloudProfileManager(QWidget *pCenterWidget, UIActionPool *pActionPool)1116 UICloudConsoleManager::UICloudConsoleManager(QWidget *pCenterWidget, UIActionPool *pActionPool) 974 1117 : QIWithRetranslateUI<QIManagerDialog>(pCenterWidget) 975 1118 , m_pActionPool(pActionPool) … … 977 1120 } 978 1121 979 void UICloud ProfileManager::sltHandleButtonBoxClick(QAbstractButton *pButton)1122 void UICloudConsoleManager::sltHandleButtonBoxClick(QAbstractButton *pButton) 980 1123 { 981 1124 /* Disable buttons first of all: */ … … 991 1134 } 992 1135 993 void UICloud ProfileManager::retranslateUi()1136 void UICloudConsoleManager::retranslateUi() 994 1137 { 995 1138 /* Translate window title: */ 996 setWindowTitle(tr("Cloud Profile Manager"));1139 setWindowTitle(tr("Cloud Console Manager")); 997 1140 998 1141 /* Translate buttons: */ … … 1000 1143 button(ButtonType_Apply)->setText(tr("Apply")); 1001 1144 button(ButtonType_Close)->setText(tr("Close")); 1002 button(ButtonType_Reset)->setStatusTip(tr("Reset changes in current cloud profile details"));1003 button(ButtonType_Apply)->setStatusTip(tr("Apply changes in current cloud profile details"));1145 button(ButtonType_Reset)->setStatusTip(tr("Reset changes in current cloud console details")); 1146 button(ButtonType_Apply)->setStatusTip(tr("Apply changes in current cloud console details")); 1004 1147 button(ButtonType_Close)->setStatusTip(tr("Close dialog without saving")); 1005 1148 button(ButtonType_Reset)->setShortcut(QString("Ctrl+Backspace")); … … 1011 1154 } 1012 1155 1013 void UICloud ProfileManager::configure()1156 void UICloudConsoleManager::configure() 1014 1157 { 1015 1158 /* Apply window icons: */ 1016 setWindowIcon(UIIconPool::iconSetFull(":/cloud_ profile_manager_32px.png", ":/cloud_profile_manager_16px.png"));1017 } 1018 1019 void UICloud ProfileManager::configureCentralWidget()1159 setWindowIcon(UIIconPool::iconSetFull(":/cloud_console_manager_32px.png", ":/cloud_console_manager_16px.png")); /// @todo use proper icon 1160 } 1161 1162 void UICloudConsoleManager::configureCentralWidget() 1020 1163 { 1021 1164 /* Create widget: */ 1022 UICloud ProfileManagerWidget *pWidget = new UICloudProfileManagerWidget(EmbedTo_Dialog, m_pActionPool, true, this);1165 UICloudConsoleManagerWidget *pWidget = new UICloudConsoleManagerWidget(EmbedTo_Dialog, m_pActionPool, true, this); 1023 1166 if (pWidget) 1024 1167 { … … 1029 1172 setWidgetToolbar(pWidget->toolbar()); 1030 1173 #endif 1031 connect(pWidget, &UICloudProfileManagerWidget::sigChange, 1032 this, &UICloudProfileManager::sigChange); 1033 connect(this, &UICloudProfileManager::sigDataChangeRejected, 1034 pWidget, &UICloudProfileManagerWidget::sltResetCloudProfileDetailsChanges); 1035 connect(this, &UICloudProfileManager::sigDataChangeAccepted, 1036 pWidget, &UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges); 1174 connect(this, &UICloudConsoleManager::sigDataChangeRejected, 1175 pWidget, &UICloudConsoleManagerWidget::sltResetCloudConsoleDetailsChanges); 1176 connect(this, &UICloudConsoleManager::sigDataChangeAccepted, 1177 pWidget, &UICloudConsoleManagerWidget::sltApplyCloudConsoleDetailsChanges); 1037 1178 1038 1179 /* Add into layout: */ … … 1041 1182 } 1042 1183 1043 void UICloud ProfileManager::configureButtonBox()1184 void UICloudConsoleManager::configureButtonBox() 1044 1185 { 1045 1186 /* Configure button-box: */ 1046 connect(widget(), &UICloud ProfileManagerWidget::sigCloudProfileDetailsVisibilityChanged,1187 connect(widget(), &UICloudConsoleManagerWidget::sigCloudConsoleDetailsVisibilityChanged, 1047 1188 button(ButtonType_Apply), &QPushButton::setVisible); 1048 connect(widget(), &UICloud ProfileManagerWidget::sigCloudProfileDetailsVisibilityChanged,1189 connect(widget(), &UICloudConsoleManagerWidget::sigCloudConsoleDetailsVisibilityChanged, 1049 1190 button(ButtonType_Reset), &QPushButton::setVisible); 1050 connect(widget(), &UICloud ProfileManagerWidget::sigCloudProfileDetailsDataChanged,1191 connect(widget(), &UICloudConsoleManagerWidget::sigCloudConsoleDetailsDataChanged, 1051 1192 button(ButtonType_Apply), &QPushButton::setEnabled); 1052 connect(widget(), &UICloud ProfileManagerWidget::sigCloudProfileDetailsDataChanged,1193 connect(widget(), &UICloudConsoleManagerWidget::sigCloudConsoleDetailsDataChanged, 1053 1194 button(ButtonType_Reset), &QPushButton::setEnabled); 1054 1195 connect(buttonBox(), &QIDialogButtonBox::clicked, 1055 this, &UICloud ProfileManager::sltHandleButtonBoxClick);1196 this, &UICloudConsoleManager::sltHandleButtonBoxClick); 1056 1197 // WORKAROUND: 1057 1198 // Since we connected signals later than extra-data loaded 1058 1199 // for signals above, we should handle that stuff here again: 1059 button(ButtonType_Apply)->setVisible(gEDataManager->cloud ProfileManagerDetailsExpanded());1060 button(ButtonType_Reset)->setVisible(gEDataManager->cloud ProfileManagerDetailsExpanded());1061 } 1062 1063 void UICloud ProfileManager::finalize()1200 button(ButtonType_Apply)->setVisible(gEDataManager->cloudConsoleManagerDetailsExpanded()); 1201 button(ButtonType_Reset)->setVisible(gEDataManager->cloudConsoleManagerDetailsExpanded()); 1202 } 1203 1204 void UICloudConsoleManager::finalize() 1064 1205 { 1065 1206 /* Apply language settings: */ … … 1067 1208 } 1068 1209 1069 UICloud ProfileManagerWidget *UICloudProfileManager::widget()1070 { 1071 return qobject_cast<UICloud ProfileManagerWidget*>(QIManagerDialog::widget());1072 } 1073 1074 1075 #include "UICloud ProfileManager.moc"1210 UICloudConsoleManagerWidget *UICloudConsoleManager::widget() 1211 { 1212 return qobject_cast<UICloudConsoleManagerWidget*>(QIManagerDialog::widget()); 1213 } 1214 1215 1216 #include "UICloudConsoleManager.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/consolemanager/UICloudConsoleManager.h
r85388 r85389 1 1 /* $Id$ */ 2 2 /** @file 3 * VBox Qt GUI - UICloud ProfileManager class declaration.3 * VBox Qt GUI - UICloudConsoleManager class declaration. 4 4 */ 5 5 … … 16 16 */ 17 17 18 #ifndef FEQT_INCLUDED_SRC_cloud_ profilemanager_UICloudProfileManager_h19 #define FEQT_INCLUDED_SRC_cloud_ profilemanager_UICloudProfileManager_h18 #ifndef FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleManager_h 19 #define FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleManager_h 20 20 #ifndef RT_WITHOUT_PRAGMA_ONCE 21 21 # pragma once … … 30 30 class QTreeWidgetItem; 31 31 class QITreeWidget; 32 class QITreeWidgetItem; 32 33 class UIActionPool; 33 class UICloud ProfileDetailsWidget;34 class UIItemCloud Profile;35 class UIItemCloud Provider;34 class UICloudConsoleDetailsWidget; 35 class UIItemCloudConsoleApplication; 36 class UIItemCloudConsoleProfile; 36 37 class UIToolBar; 37 struct UIDataCloudProfile; 38 struct UIDataCloudProvider; 39 class CCloudProfile; 40 class CCloudProvider; 41 42 43 /** QWidget extension providing GUI with the pane to control cloud profile related functionality. */ 44 class UICloudProfileManagerWidget : public QIWithRetranslateUI<QWidget> 38 struct UIDataCloudConsoleApplication; 39 struct UIDataCloudConsoleProfile; 40 41 42 /** QWidget extension providing GUI with the pane to control cloud console related functionality. */ 43 class UICloudConsoleManagerWidget : public QIWithRetranslateUI<QWidget> 45 44 { 46 45 Q_OBJECT; … … 48 47 signals: 49 48 50 /** Notifies listeners about dialog change. */ 51 void sigChange(); 52 53 /** Notifies listeners about cloud profile details-widget @a fVisible. */ 54 void sigCloudProfileDetailsVisibilityChanged(bool fVisible); 55 /** Notifies listeners about cloud profile details data @a fDiffers. */ 56 void sigCloudProfileDetailsDataChanged(bool fDiffers); 49 /** Notifies listeners about cloud console details-widget @a fVisible. */ 50 void sigCloudConsoleDetailsVisibilityChanged(bool fVisible); 51 /** Notifies listeners about cloud console details data @a fDiffers. */ 52 void sigCloudConsoleDetailsDataChanged(bool fDiffers); 57 53 58 54 public: 59 55 60 /** Constructs Cloud Profile Manager widget.56 /** Constructs Cloud Console Manager widget. 61 57 * @param enmEmbedding Brings the type of widget embedding. 62 58 * @param pActionPool Brings the action-pool reference. 63 59 * @param fShowToolbar Brings whether we should create/show toolbar. */ 64 UICloud ProfileManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool,60 UICloudConsoleManagerWidget(EmbedTo enmEmbedding, UIActionPool *pActionPool, 65 61 bool fShowToolbar = true, QWidget *pParent = 0); 66 62 … … 85 81 /** @name Details-widget stuff. 86 82 * @{ */ 87 /** Handles command to reset cloud profile details changes. */88 void sltResetCloud ProfileDetailsChanges();89 /** Handles command to apply cloud profile details changes. */90 void sltApplyCloud ProfileDetailsChanges();83 /** Handles command to reset cloud console details changes. */ 84 void sltResetCloudConsoleDetailsChanges(); 85 /** Handles command to apply cloud console details changes. */ 86 void sltApplyCloudConsoleDetailsChanges(); 91 87 /** @} */ 92 88 … … 95 91 /** @name Menu/action stuff. 96 92 * @{ */ 97 /** Handles command to add cloud profile. */ 98 void sltAddCloudProfile(); 99 /** Handles command to import cloud profiles. */ 100 void sltImportCloudProfiles(); 101 /** Handles command to remove cloud profile. */ 102 void sltRemoveCloudProfile(); 103 /** Handles command to make cloud profile details @a fVisible. */ 104 void sltToggleCloudProfileDetailsVisibility(bool fVisible); 105 /** Handles command to show cloud profile try page. */ 106 void sltShowCloudProfileTryPage(); 107 /** Handles command to show cloud profile help. */ 108 void sltShowCloudProfileHelp(); 93 /** Handles command to add cloud console application. */ 94 void sltAddCloudConsoleApplication(); 95 /** Handles command to remove cloud console application. */ 96 void sltRemoveCloudConsoleApplication(); 97 /** Handles command to add cloud console profile. */ 98 void sltAddCloudConsoleProfile(); 99 /** Handles command to remove cloud console profile. */ 100 void sltRemoveCloudConsoleProfile(); 101 /** Handles command to make cloud console details @a fVisible. */ 102 void sltToggleCloudConsoleDetailsVisibility(bool fVisible); 109 103 /** @} */ 110 104 111 105 /** @name Tree-widget stuff. 112 106 * @{ */ 113 /** Handles request to load cloud stuff. */114 void sltLoadCloud Stuff() { loadCloudStuff(); }107 /** Handles request to load cloud console stuff. */ 108 void sltLoadCloudConsoleStuff() { loadCloudConsoleStuff(); } 115 109 /** Adjusts tree-widget according content. */ 116 110 void sltPerformTableAdjustment(); … … 147 141 /** @name Loading stuff. 148 142 * @{ */ 149 /** Loads cloud stuff. */150 void loadCloud Stuff();151 /** Loads cloud @a comProvider data to passed @a providerData container. */152 void loadCloud Provider(const CCloudProvider &comProvider,153 UIDataCloudProvider &providerData);154 /** Loads cloud @a comProfile data to passed @a profileData container, using @a providerData as hint. */155 void loadCloud Profile(const CCloudProfile &comProfile,156 const UIDataCloudProvider &providerData,157 UIDataCloudProfile &profileData);143 /** Loads cloud console stuff. */ 144 void loadCloudConsoleStuff(); 145 /** Loads cloud console @a strSuperset data to passed @a applicationData container. */ 146 void loadCloudConsoleApplication(const QString &strSuperset, 147 UIDataCloudConsoleApplication &applicationData); 148 /** Loads cloud console @a strSuperset data to passed @a profileData container, using @a applicationData as hint. */ 149 void loadCloudConsoleProfile(const QString &strSuperset, 150 const UIDataCloudConsoleApplication &applicationData, 151 UIDataCloudConsoleProfile &profileData); 158 152 /** @} */ 159 153 160 154 /** @name Tree-widget stuff. 161 155 * @{ */ 162 /** Seearches a provider item with specified @a uId. */ 163 UIItemCloudProvider *searchItem(const QUuid &uId) const; 156 /** Searches an application item with specified @a strApplicationId. */ 157 UIItemCloudConsoleApplication *searchApplicationItem(const QString &strApplicationId) const; 158 /** Searches a profile child of application item with specified @a strApplicationId and @a strProfileId. */ 159 UIItemCloudConsoleProfile *searchProfileItem(const QString &strApplicationId, 160 const QString &strProfileId) const; 161 /** Searches an item with specified @a strDefinition. */ 162 QITreeWidgetItem *searchItemByDefinition(const QString &strDefinition) const; 164 163 165 164 /** Creates a new tree-widget item 166 * on the basis of passed @a providerData, @a fChooseItem if requested. */ 167 void createItemForCloudProvider(const UIDataCloudProvider &providerData, bool fChooseItem); 165 * on the basis of passed @a applicationData, @a fChooseItem if requested. */ 166 void createItemForCloudConsoleApplication(const UIDataCloudConsoleApplication &applicationData, 167 bool fChooseItem); 168 168 169 169 /** Creates a new tree-widget item as a child of certain @a pParent, 170 170 * on the basis of passed @a profileData, @a fChooseItem if requested. */ 171 void createItemForCloud Profile(QTreeWidgetItem *pParent, const UIDataCloudProfile &profileData, bool fChooseItem);172 /** Updates the passed tree-widget item on the basis of passed @a profileData, @a fChooseItem if requested. */173 void updateItemForCloudProfile(const UIDataCloudProfile &profileData, bool fChooseItem, UIItemCloudProfile *pItem);174 175 /* Gathers a list of Cloud Profile Manager restrictions starting from @a pParentItem. */176 QStringList gatherCloud ProfileManagerRestrictions(QTreeWidgetItem *pParentItem);171 void createItemForCloudConsoleProfile(QTreeWidgetItem *pParent, 172 const UIDataCloudConsoleProfile &profileData, 173 bool fChooseItem); 174 175 /* Gathers a list of Cloud Console Manager restrictions starting from @a pParentItem. */ 176 QStringList gatherCloudConsoleManagerRestrictions(QTreeWidgetItem *pParentItem); 177 177 /** @} */ 178 178 … … 185 185 /** Holds whether we should create/show toolbar. */ 186 186 const bool m_fShowToolbar; 187 /** Holds current item definition. */ 188 QString m_strDefinition; 187 189 /** @} */ 188 190 … … 198 200 QITreeWidget *m_pTreeWidget; 199 201 /** Holds the details-widget instance. */ 200 UICloud ProfileDetailsWidget *m_pDetailsWidget;202 UICloudConsoleDetailsWidget *m_pDetailsWidget; 201 203 /** @} */ 202 204 }; 203 205 204 206 205 /** QIManagerDialogFactory extension used as a factory for Cloud Profile Manager dialog. */206 class UICloud ProfileManagerFactory : public QIManagerDialogFactory207 /** QIManagerDialogFactory extension used as a factory for Cloud Console Manager dialog. */ 208 class UICloudConsoleManagerFactory : public QIManagerDialogFactory 207 209 { 208 210 public: 209 211 210 /** Constructs Cloud Profile Manager factory acquiring additional arguments.212 /** Constructs Cloud Console Manager actory acquiring additional arguments. 211 213 * @param pActionPool Brings the action-pool reference. */ 212 UICloud ProfileManagerFactory(UIActionPool *pActionPool = 0);214 UICloudConsoleManagerFactory(UIActionPool *pActionPool = 0); 213 215 214 216 protected: … … 223 225 224 226 225 /** QIManagerDialog extension providing GUI with the dialog to control cloud profile related functionality. */226 class UICloud ProfileManager : public QIWithRetranslateUI<QIManagerDialog>227 /** QIManagerDialog extension providing GUI with the dialog to control cloud console related functionality. */ 228 class UICloudConsoleManager : public QIWithRetranslateUI<QIManagerDialog> 227 229 { 228 230 Q_OBJECT; … … 245 247 private: 246 248 247 /** Constructs Cloud Profile Manager dialog.249 /** Constructs Cloud Console Manager dialog. 248 250 * @param pCenterWidget Brings the widget reference to center according to. 249 251 * @param pActionPool Brings the action-pool reference. */ 250 UICloud ProfileManager(QWidget *pCenterWidget, UIActionPool *pActionPool);252 UICloudConsoleManager(QWidget *pCenterWidget, UIActionPool *pActionPool); 251 253 252 254 /** @name Event-handling stuff. … … 271 273 * @{ */ 272 274 /** Returns the widget. */ 273 virtual UICloud ProfileManagerWidget *widget() /* override */;275 virtual UICloudConsoleManagerWidget *widget() /* override */; 274 276 /** @} */ 275 277 … … 281 283 282 284 /** Allow factory access to private/protected members: */ 283 friend class UICloud ProfileManagerFactory;285 friend class UICloudConsoleManagerFactory; 284 286 }; 285 287 286 #endif /* !FEQT_INCLUDED_SRC_cloud_ profilemanager_UICloudProfileManager_h */288 #endif /* !FEQT_INCLUDED_SRC_cloud_consolemanager_UICloudConsoleManager_h */ -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.cpp
r85035 r85389 113 113 const char *UIExtraDataDefs::GUI_CloudProfileManager_Restrictions = "GUI/CloudProfileManager/Restrictions"; 114 114 const char *UIExtraDataDefs::GUI_CloudProfileManager_Details_Expanded = "GUI/CloudProfileManager/Details/Expanded"; 115 116 /* Cloud Console Manager: */ 117 const char *UIExtraDataDefs::GUI_CloudConsoleManager_Application = "GUI/CloudConsoleManager/Application"; 118 const char *UIExtraDataDefs::GUI_CloudConsoleManager_Restrictions = "GUI/CloudConsoleManager/Restrictions"; 119 const char *UIExtraDataDefs::GUI_CloudConsoleManager_Details_Expanded = "GUI/CloudConsoleManager/Details/Expanded"; 115 120 116 121 #ifdef VBOX_GUI_WITH_EXTRADATA_MANAGER_UI -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataDefs.h
r85035 r85389 220 220 /** Holds whether Cloud Profile Manager details expanded. */ 221 221 SHARED_LIBRARY_STUFF extern const char *GUI_CloudProfileManager_Details_Expanded; 222 /** @} */ 223 224 /** @name Cloud Console Manager 225 * @{ */ 226 /** Holds Cloud Console Manager applications/profiles. */ 227 SHARED_LIBRARY_STUFF extern const char *GUI_CloudConsoleManager_Application; 228 /** Holds Cloud Console Manager restrictions. */ 229 SHARED_LIBRARY_STUFF extern const char *GUI_CloudConsoleManager_Restrictions; 230 /** Holds whether Cloud Console Manager details expanded. */ 231 SHARED_LIBRARY_STUFF extern const char *GUI_CloudConsoleManager_Details_Expanded; 222 232 /** @} */ 223 233 -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.cpp
r85035 r85389 578 578 /** @name Actions 579 579 * @{ */ 580 /** */580 /** Updates action availability. */ 581 581 void updateActionsAvailability(); 582 582 /** @} */ … … 1931 1931 << GUI_CloudProfileManager_Restrictions 1932 1932 << GUI_CloudProfileManager_Details_Expanded 1933 << GUI_CloudConsoleManager_Restrictions 1934 << GUI_CloudConsoleManager_Details_Expanded 1933 1935 << GUI_HideDescriptionForWizards 1934 1936 << GUI_HideFromManager << GUI_HideDetails … … 2997 2999 } 2998 3000 3001 QStringList UIExtraDataManager::cloudConsoleManagerApplications() 3002 { 3003 /* Gather a list of keys matching required expression: */ 3004 QStringList result; 3005 QRegExp re(QString("^%1/([^/]+)$").arg(GUI_CloudConsoleManager_Application)); 3006 foreach (const QString &strKey, m_data.value(GlobalID).keys()) 3007 if (re.indexIn(strKey) != -1) 3008 result << re.cap(1); 3009 return result; 3010 } 3011 3012 QStringList UIExtraDataManager::cloudConsoleManagerProfiles(const QString &strId) 3013 { 3014 /* Gather a list of keys matching required expression: */ 3015 QStringList result; 3016 QRegExp re(QString("^%1/%2/([^/]+)$").arg(GUI_CloudConsoleManager_Application, strId)); 3017 foreach (const QString &strKey, m_data.value(GlobalID).keys()) 3018 if (re.indexIn(strKey) != -1) 3019 result << re.cap(1); 3020 return result; 3021 } 3022 3023 QString UIExtraDataManager::cloudConsoleManagerApplication(const QString &strId) 3024 { 3025 return extraDataString(QString("%1/%2").arg(GUI_CloudConsoleManager_Application, strId)); 3026 } 3027 3028 void UIExtraDataManager::setCloudConsoleManagerApplication(const QString &strId, const QString &strDefinition) 3029 { 3030 setExtraDataString(QString("%1/%2").arg(GUI_CloudConsoleManager_Application, strId), strDefinition); 3031 } 3032 3033 QString UIExtraDataManager::cloudConsoleManagerProfile(const QString &strApplicationId, const QString &strProfileId) 3034 { 3035 return extraDataString(QString("%1/%2/%3").arg(GUI_CloudConsoleManager_Application, strApplicationId, strProfileId)); 3036 } 3037 3038 void UIExtraDataManager::setCloudConsoleManagerProfile(const QString &strApplicationId, const QString &strProfileId, const QString &strDefinition) 3039 { 3040 setExtraDataString(QString("%1/%2/%3").arg(GUI_CloudConsoleManager_Application, strApplicationId, strProfileId), strDefinition); 3041 } 3042 3043 QStringList UIExtraDataManager::cloudConsoleManagerRestrictions() 3044 { 3045 return extraDataStringList(GUI_CloudConsoleManager_Restrictions); 3046 } 3047 3048 void UIExtraDataManager::setCloudConsoleManagerRestrictions(const QStringList &restrictions) 3049 { 3050 return setExtraDataStringList(GUI_CloudConsoleManager_Restrictions, restrictions); 3051 } 3052 3053 bool UIExtraDataManager::cloudConsoleManagerDetailsExpanded() 3054 { 3055 /* 'False' unless feature allowed: */ 3056 return isFeatureAllowed(GUI_CloudConsoleManager_Details_Expanded); 3057 } 3058 3059 void UIExtraDataManager::setCloudConsoleManagerDetailsExpanded(bool fExpanded) 3060 { 3061 /* 'True' if feature allowed, null-string otherwise: */ 3062 return setExtraDataString(GUI_CloudConsoleManager_Details_Expanded, toFeatureAllowed(fExpanded)); 3063 } 3064 2999 3065 WizardMode UIExtraDataManager::modeForWizardType(WizardType type) 3000 3066 { … … 4582 4648 else if (strKey == GUI_CloudProfileManager_Restrictions) 4583 4649 emit sigCloudProfileManagerRestrictionChange(); 4650 /* Cloud Console Manager data changed: */ 4651 else if (strKey.startsWith(QString(GUI_CloudConsoleManager_Application) + '/')) 4652 emit sigCloudConsoleManagerDataChange(); 4653 /* Cloud Console Manager restrictions changed: */ 4654 else if (strKey == GUI_CloudConsoleManager_Restrictions) 4655 emit sigCloudConsoleManagerRestrictionChange(); 4584 4656 /* Details categories: */ 4585 4657 else if (strKey == GUI_Details_Elements) -
trunk/src/VBox/Frontends/VirtualBox/src/extradata/UIExtraDataManager.h
r85035 r85389 78 78 /** Notifies about Cloud Profile Manager restriction change. */ 79 79 void sigCloudProfileManagerRestrictionChange(); 80 81 /** Notifies about Cloud Console Manager data change. */ 82 void sigCloudConsoleManagerDataChange(); 83 /** Notifies about Cloud Console Manager restriction change. */ 84 void sigCloudConsoleManagerRestrictionChange(); 80 85 81 86 /** Notifies about VirtualBox Manager / Details pane categories change. */ … … 417 422 /** Defines whether Cloud Profile Manager details @a fExpanded. */ 418 423 void setCloudProfileManagerDetailsExpanded(bool fExpanded); 424 /** @} */ 425 426 /** @name Cloud Console Manager 427 * @{ */ 428 /** Returns registered Cloud Console Manager applications. */ 429 QStringList cloudConsoleManagerApplications(); 430 /** Returns registered Cloud Console Manager profiles for application with @a strId. */ 431 QStringList cloudConsoleManagerProfiles(const QString &strId); 432 433 /** Returns definition for Cloud Console Manager application with @a strId. */ 434 QString cloudConsoleManagerApplication(const QString &strId); 435 /** Defines @a strDefinition for Cloud Console Manager application with @a strId. */ 436 void setCloudConsoleManagerApplication(const QString &strId, const QString &strDefinition); 437 438 /** Returns definition for Cloud Console Manager profile with @a strProfileId for application with @a strApplicationId. */ 439 QString cloudConsoleManagerProfile(const QString &strApplicationId, const QString &strProfileId); 440 /** Returns @a strDefinition for Cloud Console Manager profile with @a strProfileId for application with @a strApplicationId. */ 441 void setCloudConsoleManagerProfile(const QString &strApplicationId, const QString &strProfileId, const QString &strDefinition); 442 443 /** Returns Cloud Console Manager restrictions. */ 444 QStringList cloudConsoleManagerRestrictions(); 445 /** Defines Cloud Console Manager @a restrictions. */ 446 void setCloudConsoleManagerRestrictions(const QStringList &restrictions); 447 448 /** Returns whether Cloud Console Manager details expanded. */ 449 bool cloudConsoleManagerDetailsExpanded(); 450 /** Defines whether Cloud Console Manager details @a fExpanded. */ 451 void setCloudConsoleManagerDetailsExpanded(bool fExpanded); 419 452 /** @} */ 420 453 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.cpp
r85362 r85389 2982 2982 } 2983 2983 }; 2984 2985 2986 /** Menu action extension, used as 'Cloud Console' menu class. */ 2987 class UIActionMenuSelectorCloudConsole : public UIActionMenu 2988 { 2989 Q_OBJECT; 2990 2991 public: 2992 2993 /** Constructs action passing @a pParent to the base-class. */ 2994 UIActionMenuSelectorCloudConsole(UIActionPool *pParent) 2995 : UIActionMenu(pParent) 2996 {} 2997 2998 protected: 2999 3000 /** Returns shortcut extra-data ID. */ 3001 virtual QString shortcutExtraDataID() const /* override */ 3002 { 3003 return QString("CloudConsoleMenu"); 3004 } 3005 3006 /** Handles translation event. */ 3007 virtual void retranslateUi() /* override */ 3008 { 3009 setName(QApplication::translate("UIActionPool", "&Console")); 3010 } 3011 }; 3012 3013 /** Simple action extension, used as 'Perform Console Application Add' action class. */ 3014 class UIActionMenuSelectorCloudConsolePerformApplicationAdd : public UIActionSimple 3015 { 3016 Q_OBJECT; 3017 3018 public: 3019 3020 /** Constructs action passing @a pParent to the base-class. */ 3021 UIActionMenuSelectorCloudConsolePerformApplicationAdd(UIActionPool *pParent) 3022 : UIActionSimple(pParent, 3023 ":/cloud_console_application_add_32px.png", ":/cloud_console_application_add_16px.png", 3024 ":/cloud_console_application_add_disabled_32px.png", ":/cloud_console_application_add_disabled_16px.png") /// @todo use proper icons 3025 { 3026 setShortcutContext(Qt::WidgetWithChildrenShortcut); 3027 } 3028 3029 protected: 3030 3031 /** Returns shortcut extra-data ID. */ 3032 virtual QString shortcutExtraDataID() const /* override */ 3033 { 3034 return QString("AddCloudConsoleApplication"); 3035 } 3036 3037 /** Handles translation event. */ 3038 virtual void retranslateUi() /* override */ 3039 { 3040 setName(QApplication::translate("UIActionPool", "&Add Application...")); 3041 setShortcutScope(QApplication::translate("UIActionPool", "Cloud Console Manager")); 3042 setStatusTip(QApplication::translate("UIActionPool", "Add new cloud console application")); 3043 setToolTip( QApplication::translate("UIActionPool", "Add Cloud Console Application") 3044 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 3045 } 3046 }; 3047 3048 /** Simple action extension, used as 'Perform Console Application Remove' action class. */ 3049 class UIActionMenuSelectorCloudConsolePerformApplicationRemove : public UIActionSimple 3050 { 3051 Q_OBJECT; 3052 3053 public: 3054 3055 /** Constructs action passing @a pParent to the base-class. */ 3056 UIActionMenuSelectorCloudConsolePerformApplicationRemove(UIActionPool *pParent) 3057 : UIActionSimple(pParent, 3058 ":/cloud_console_application_remove_32px.png", ":/cloud_console_application_remove_16px.png", 3059 ":/cloud_console_application_remove_disabled_32px.png", ":/cloud_console_application_remove_disabled_16px.png") /// @todo use proper icons 3060 { 3061 setShortcutContext(Qt::WidgetWithChildrenShortcut); 3062 } 3063 3064 protected: 3065 3066 /** Returns shortcut extra-data ID. */ 3067 virtual QString shortcutExtraDataID() const /* override */ 3068 { 3069 return QString("RemoveCloudConsoleApplication"); 3070 } 3071 3072 /** Handles translation event. */ 3073 virtual void retranslateUi() /* override */ 3074 { 3075 setName(QApplication::translate("UIActionPool", "&Remove Application...")); 3076 setShortcutScope(QApplication::translate("UIActionPool", "Cloud Console Manager")); 3077 setStatusTip(QApplication::translate("UIActionPool", "Remove selected cloud console application")); 3078 setToolTip( QApplication::translate("UIActionPool", "Remove Cloud Console Application") 3079 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 3080 } 3081 }; 3082 3083 /** Simple action extension, used as 'Perform Console Profile Add' action class. */ 3084 class UIActionMenuSelectorCloudConsolePerformProfileAdd : public UIActionSimple 3085 { 3086 Q_OBJECT; 3087 3088 public: 3089 3090 /** Constructs action passing @a pParent to the base-class. */ 3091 UIActionMenuSelectorCloudConsolePerformProfileAdd(UIActionPool *pParent) 3092 : UIActionSimple(pParent, 3093 ":/cloud_console_profile_add_32px.png", ":/cloud_console_profile_add_16px.png", 3094 ":/cloud_console_profile_add_disabled_32px.png", ":/cloud_console_profile_add_disabled_16px.png") /// @todo use proper icons 3095 { 3096 setShortcutContext(Qt::WidgetWithChildrenShortcut); 3097 } 3098 3099 protected: 3100 3101 /** Returns shortcut extra-data ID. */ 3102 virtual QString shortcutExtraDataID() const /* override */ 3103 { 3104 return QString("AddCloudConsoleProfile"); 3105 } 3106 3107 /** Handles translation event. */ 3108 virtual void retranslateUi() /* override */ 3109 { 3110 setName(QApplication::translate("UIActionPool", "&Add Profile...")); 3111 setShortcutScope(QApplication::translate("UIActionPool", "Cloud Console Manager")); 3112 setStatusTip(QApplication::translate("UIActionPool", "Add new cloud console profile")); 3113 setToolTip( QApplication::translate("UIActionPool", "Add Cloud Console Profile") 3114 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 3115 } 3116 }; 3117 3118 /** Simple action extension, used as 'Perform Console Profile Remove' action class. */ 3119 class UIActionMenuSelectorCloudConsolePerformProfileRemove : public UIActionSimple 3120 { 3121 Q_OBJECT; 3122 3123 public: 3124 3125 /** Constructs action passing @a pParent to the base-class. */ 3126 UIActionMenuSelectorCloudConsolePerformProfileRemove(UIActionPool *pParent) 3127 : UIActionSimple(pParent, 3128 ":/cloud_console_profile_remove_32px.png", ":/cloud_console_profile_remove_16px.png", 3129 ":/cloud_console_profile_remove_disabled_32px.png", ":/cloud_console_profile_remove_disabled_16px.png") /// @todo use proper icons 3130 { 3131 setShortcutContext(Qt::WidgetWithChildrenShortcut); 3132 } 3133 3134 protected: 3135 3136 /** Returns shortcut extra-data ID. */ 3137 virtual QString shortcutExtraDataID() const /* override */ 3138 { 3139 return QString("RemoveCloudConsoleProfile"); 3140 } 3141 3142 /** Handles translation event. */ 3143 virtual void retranslateUi() /* override */ 3144 { 3145 setName(QApplication::translate("UIActionPool", "&Remove Profile...")); 3146 setShortcutScope(QApplication::translate("UIActionPool", "Cloud Console Manager")); 3147 setStatusTip(QApplication::translate("UIActionPool", "Remove selected cloud console profile")); 3148 setToolTip( QApplication::translate("UIActionPool", "Remove Cloud Console Profile") 3149 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 3150 } 3151 }; 3152 3153 /** Toggle action extension, used as 'Toggle Cloud Console Properties' action class. */ 3154 class UIActionMenuSelectorCloudConsoleToggleProperties : public UIActionToggle 3155 { 3156 Q_OBJECT; 3157 3158 public: 3159 3160 /** Constructs action passing @a pParent to the base-class. */ 3161 UIActionMenuSelectorCloudConsoleToggleProperties(UIActionPool *pParent) 3162 : UIActionToggle(pParent) 3163 { 3164 setShortcutContext(Qt::WidgetWithChildrenShortcut); 3165 setIcon(UIIconPool::iconSetFull(":/cloud_console_edit_32px.png", ":/cloud_console_edit_16px.png", 3166 ":/cloud_console_edit_disabled_32px.png", ":/cloud_console_edit_disabled_16px.png")); /// @todo use proper icons with check-boxes 3167 } 3168 3169 protected: 3170 3171 /** Returns shortcut extra-data ID. */ 3172 virtual QString shortcutExtraDataID() const /* override */ 3173 { 3174 return QString("ToggleCloudConsoleProperties"); 3175 } 3176 3177 /** Returns default shortcut. */ 3178 virtual QKeySequence defaultShortcut(UIActionPoolType) const /* override */ 3179 { 3180 return QKeySequence("Ctrl+Shift+P"); 3181 } 3182 3183 /** Handles translation event. */ 3184 virtual void retranslateUi() /* override */ 3185 { 3186 setIconText(QApplication::translate("UIActionPool", "Properties")); 3187 setName(QApplication::translate("UIActionPool", "Console &Properties")); 3188 setShortcutScope(QApplication::translate("UIActionPool", "Cloud Console Manager")); 3189 setStatusTip(QApplication::translate("UIActionPool", "Open pane with selected cloud console properties")); 3190 setToolTip( QApplication::translate("UIActionPool", "Open Cloud Console Properties") 3191 + (shortcut().isEmpty() ? QString() : QString(" (%1)").arg(shortcut().toString()))); 3192 } 3193 }; 3194 2984 3195 2985 3196 /** Menu action extension, used as 'Resources' menu class. */ … … 3183 3394 m_pool[UIActionIndexST_M_Cloud_S_Help] = new UIActionMenuSelectorCloudShowHelp(this); 3184 3395 3396 /* Cloud Console Manager actions: */ 3397 m_pool[UIActionIndexST_M_CloudConsoleWindow] = new UIActionMenuSelectorCloudConsole(this); 3398 m_pool[UIActionIndexST_M_CloudConsole] = new UIActionMenuSelectorCloudConsole(this); 3399 m_pool[UIActionIndexST_M_CloudConsole_S_ApplicationAdd] = new UIActionMenuSelectorCloudConsolePerformApplicationAdd(this); 3400 m_pool[UIActionIndexST_M_CloudConsole_S_ApplicationRemove] = new UIActionMenuSelectorCloudConsolePerformApplicationRemove(this); 3401 m_pool[UIActionIndexST_M_CloudConsole_S_ProfileAdd] = new UIActionMenuSelectorCloudConsolePerformProfileAdd(this); 3402 m_pool[UIActionIndexST_M_CloudConsole_S_ProfileRemove] = new UIActionMenuSelectorCloudConsolePerformProfileRemove(this); 3403 m_pool[UIActionIndexST_M_CloudConsole_T_Details] = new UIActionMenuSelectorCloudConsoleToggleProperties(this); 3404 3185 3405 /* VM resource Monitor actions: */ 3186 3406 m_pool[UIActionIndexST_M_VMResourceMonitor] = new UIActionMenuVMResourceMonitor(this); … … 3220 3440 m_menuUpdateHandlers[UIActionIndexST_M_CloudWindow].ptfm = &UIActionPoolManager::updateMenuCloudWindow; 3221 3441 m_menuUpdateHandlers[UIActionIndexST_M_Cloud].ptfm = &UIActionPoolManager::updateMenuCloud; 3442 m_menuUpdateHandlers[UIActionIndexST_M_CloudConsoleWindow].ptfm = &UIActionPoolManager::updateMenuCloudConsoleWindow; 3443 m_menuUpdateHandlers[UIActionIndexST_M_CloudConsole].ptfm = &UIActionPoolManager::updateMenuCloudConsole; 3222 3444 m_menuUpdateHandlers[UIActionIndexST_M_VMResourceMonitor].ptfm = &UIActionPoolManager::updateMenuVMResourceMonitor; 3223 3445 m_menuUpdateHandlers[UIActionIndexST_M_Snapshot].ptfm = &UIActionPoolManager::updateMenuSnapshot; … … 3768 3990 /* 'Help' action: */ 3769 3991 fSeparator = addAction(pMenu, action(UIActionIndexST_M_Cloud_S_Help)) || fSeparator; 3992 } 3993 3994 void UIActionPoolManager::updateMenuCloudConsoleWindow() 3995 { 3996 /* Update corresponding menu: */ 3997 updateMenuCloudConsoleWrapper(action(UIActionIndexST_M_CloudConsoleWindow)->menu()); 3998 3999 /* Mark menu as valid: */ 4000 m_invalidations.remove(UIActionIndexST_M_CloudConsoleWindow); 4001 } 4002 4003 void UIActionPoolManager::updateMenuCloudConsole() 4004 { 4005 /* Update corresponding menu: */ 4006 updateMenuCloudConsoleWrapper(action(UIActionIndexST_M_CloudConsole)->menu()); 4007 4008 /* Mark menu as valid: */ 4009 m_invalidations.remove(UIActionIndexST_M_CloudConsole); 4010 } 4011 4012 void UIActionPoolManager::updateMenuCloudConsoleWrapper(UIMenu *pMenu) 4013 { 4014 /* Clear contents: */ 4015 pMenu->clear(); 4016 4017 /* Separator? */ 4018 bool fSeparator = false; 4019 4020 /* 'Add Application' action: */ 4021 fSeparator = addAction(pMenu, action(UIActionIndexST_M_CloudConsole_S_ApplicationAdd)) || fSeparator; 4022 /* 'Remove Application' action: */ 4023 fSeparator = addAction(pMenu, action(UIActionIndexST_M_CloudConsole_S_ApplicationRemove)) || fSeparator; 4024 4025 /* Separator? */ 4026 if (fSeparator) 4027 { 4028 pMenu->addSeparator(); 4029 fSeparator = false; 4030 } 4031 4032 /* 'Add Profile' action: */ 4033 fSeparator = addAction(pMenu, action(UIActionIndexST_M_CloudConsole_S_ProfileAdd)) || fSeparator; 4034 /* 'Remove Profile' action: */ 4035 fSeparator = addAction(pMenu, action(UIActionIndexST_M_CloudConsole_S_ProfileRemove)) || fSeparator; 4036 4037 /* Separator? */ 4038 if (fSeparator) 4039 { 4040 pMenu->addSeparator(); 4041 fSeparator = false; 4042 } 4043 4044 /* 'Properties' action: */ 4045 fSeparator = addAction(pMenu, action(UIActionIndexST_M_CloudConsole_T_Details)) || fSeparator; 3770 4046 } 3771 4047 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIActionPoolManager.h
r85192 r85389 174 174 UIActionIndexST_M_Cloud_S_Help, 175 175 176 /* Cloud Console Manager actions: */ 177 UIActionIndexST_M_CloudConsoleWindow, 178 UIActionIndexST_M_CloudConsole, 179 UIActionIndexST_M_CloudConsole_S_ApplicationAdd, 180 UIActionIndexST_M_CloudConsole_S_ApplicationRemove, 181 UIActionIndexST_M_CloudConsole_S_ProfileAdd, 182 UIActionIndexST_M_CloudConsole_S_ProfileRemove, 183 UIActionIndexST_M_CloudConsole_T_Details, 184 176 185 /* VM resource Monitor actions: */ 177 186 UIActionIndexST_M_VMResourceMonitor, … … 256 265 void updateMenuCloudWrapper(UIMenu *pMenu); 257 266 267 /** Updates 'Cloud Console' window menu. */ 268 void updateMenuCloudConsoleWindow(); 269 /** Updates 'Cloud Console' menu. */ 270 void updateMenuCloudConsole(); 271 /** Updates 'Cloud Console' @a pMenu. */ 272 void updateMenuCloudConsoleWrapper(UIMenu *pMenu); 273 258 274 /** Updates 'VM Resource Monitor' menu. */ 259 275 void updateMenuVMResourceMonitor(); -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r85111 r85389 2022 2022 } 2023 2023 2024 bool UIMessageCenter::confirmCloudConsoleApplicationRemoval(const QString &strName, QWidget *pParent /* = 0 */) const 2025 { 2026 return questionBinary(pParent, MessageType_Question, 2027 tr("<p>Do you want to remove the cloud console application <nobr><b>%1</b>?</nobr></p>") 2028 .arg(strName), 2029 0 /* auto-confirm id */, 2030 tr("Remove") /* ok button text */, 2031 QString() /* cancel button text */, 2032 false /* ok button by default? */); 2033 } 2034 2035 bool UIMessageCenter::confirmCloudConsoleProfileRemoval(const QString &strName, QWidget *pParent /* = 0 */) const 2036 { 2037 return questionBinary(pParent, MessageType_Question, 2038 tr("<p>Do you want to remove the cloud console profile <nobr><b>%1</b>?</nobr></p>") 2039 .arg(strName), 2040 0 /* auto-confirm id */, 2041 tr("Remove") /* ok button text */, 2042 QString() /* cancel button text */, 2043 false /* ok button by default? */); 2044 } 2045 2024 2046 bool UIMessageCenter::confirmHardDisklessMachine(QWidget *pParent /* = 0*/) const 2025 2047 { -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r85111 r85389 417 417 void cannotAssignFormValue(const CProgress &comProgress, QWidget *pParent = 0) const; 418 418 419 /* API: Cloud Console Manager warnings: */ 420 bool confirmCloudConsoleApplicationRemoval(const QString &strName, QWidget *pParent = 0) const; 421 bool confirmCloudConsoleProfileRemoval(const QString &strName, QWidget *pParent = 0) const; 422 419 423 /* API: Wizards warnings: */ 420 424 bool confirmHardDisklessMachine(QWidget *pParent = 0) const;
Note:
See TracChangeset
for help on using the changeset viewer.