Changeset 74928 in vbox
- Timestamp:
- Oct 18, 2018 4:46:59 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 125937
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/cloud
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.cpp
r74910 r74928 21 21 22 22 /* Qt includes: */ 23 # include <QGridLayout> 23 24 # include <QHeaderView> 25 # include <QLabel> 26 # include <QLineEdit> 24 27 # include <QPushButton> 25 28 # include <QTableWidget> … … 54 57 /* Load data: */ 55 58 loadData(); 59 60 /* Translate linked widgets: */ 61 retranslateEditor(); 62 retranslateButtons(); 56 63 } 57 64 … … 60 67 /// @todo add description tool-tips 61 68 69 /* Translate name-editor label: */ 70 m_pLabelName->setText(tr("Name:")); 71 /* Translate name-editor: */ 72 retranslateEditor(); 73 74 /* Translate table-widget label: */ 75 m_pLabelTableWidget->setText(tr("Properties:")); 62 76 /* Translate table-widget: */ 63 77 m_pTableWidget->setToolTip(tr("Contains cloud profile settings")); 64 78 79 /* Translate buttons: */ 80 retranslateButtons(); 81 82 /* Retranslate validation: */ 83 retranslateValidation(); 84 85 /* Update table tool-tips: */ 86 updateTableToolTips(); 87 } 88 89 void UICloudProfileDetailsWidget::retranslateEditor() 90 { 91 /* Translate placeholders: */ 92 m_pEditorName->setPlaceholderText( m_oldData.m_strName.isNull() 93 ? tr("Enter a name for the new profile...") 94 : tr("Enter a name for this profile...")); 95 } 96 97 void UICloudProfileDetailsWidget::retranslateButtons() 98 { 65 99 /* Translate button-box: */ 66 100 if (m_pButtonBox) 67 101 { 102 /* Common: 'Reset' button: */ 68 103 m_pButtonBox->button(QDialogButtonBox::Cancel)->setText(tr("Reset")); 69 m_pButtonBox->button(QDialogButtonBox:: Ok)->setText(tr("Apply"));104 m_pButtonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Reset changes in current profile details")); 70 105 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 71 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));72 m_pButtonBox->button(QDialogButtonBox::Cancel)->setStatusTip(tr("Reset changes in current profile details"));73 m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current profile details"));74 106 m_pButtonBox->button(QDialogButtonBox::Cancel)-> 75 107 setToolTip(tr("Reset Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Cancel)->shortcut().toString())); 76 m_pButtonBox->button(QDialogButtonBox::Ok)-> 77 setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString())); 78 } 79 80 /* Retranslate validation: */ 81 retranslateValidation(); 82 83 /* Update table tool-tips: */ 84 updateTableToolTips(); 108 109 if (m_oldData.m_strName.isNull()) 110 { 111 /* Provider: 'Add' button: */ 112 m_pButtonBox->button(QDialogButtonBox::Ok)->setText(tr("Add")); 113 m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Add a new profile with following name")); 114 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return")); 115 m_pButtonBox->button(QDialogButtonBox::Ok)-> 116 setToolTip(tr("Add Profile (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString())); 117 } 118 else 119 { 120 /* Profile: 'Apply' button: */ 121 m_pButtonBox->button(QDialogButtonBox::Ok)->setText(tr("Apply")); 122 m_pButtonBox->button(QDialogButtonBox::Ok)->setStatusTip(tr("Apply changes in current profile details")); 123 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return")); 124 m_pButtonBox->button(QDialogButtonBox::Ok)-> 125 setToolTip(tr("Apply Changes (%1)").arg(m_pButtonBox->button(QDialogButtonBox::Ok)->shortcut().toString())); 126 } 127 } 128 } 129 130 void UICloudProfileDetailsWidget::sltNameChanged(const QString &strName) 131 { 132 /* Push changes back: */ 133 m_newData.m_strName = strName; 134 135 /* Revalidate: */ 136 revalidate(m_pEditorName); 137 /* Update button states: */ 138 updateButtonStates(); 85 139 } 86 140 … … 142 196 { 143 197 /* Create layout: */ 144 Q VBoxLayout *pLayout = new QVBoxLayout(this);198 QGridLayout *pLayout = new QGridLayout(this); 145 199 if (pLayout) 146 200 { 147 /* Configure layout: */ 148 pLayout->setContentsMargins(0, 0, 0, 0); 201 if (m_enmEmbedding == EmbedTo_Dialog) 202 { 203 pLayout->setContentsMargins(0, 0, 0, 0); 204 #ifdef VBOX_WS_MAC 205 pLayout->setSpacing(10); 206 #else 207 pLayout->setSpacing(qApp->style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing) / 2); 208 #endif 209 } 210 211 /* Create name editor: */ 212 m_pEditorName = new QLineEdit; 213 if (m_pEditorName) 214 { 215 connect(m_pEditorName, &QLineEdit::textChanged, this, &UICloudProfileDetailsWidget::sltNameChanged); 216 217 /* Add into layout: */ 218 pLayout->addWidget(m_pEditorName, 0, 1); 219 } 220 /* Create name label: */ 221 m_pLabelName = new QLabel; 222 if (m_pLabelName) 223 { 224 m_pLabelName->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 225 m_pLabelName->setBuddy(m_pEditorName); 226 227 /* Add into layout: */ 228 pLayout->addWidget(m_pLabelName, 0, 0); 229 } 149 230 150 231 /* Create tab-widget: */ … … 159 240 160 241 /* Add into layout: */ 161 pLayout->addWidget(m_pTableWidget); 242 pLayout->addWidget(m_pTableWidget, 1, 1); 243 } 244 /* Create tab-widget label: */ 245 m_pLabelTableWidget = new QLabel; 246 if (m_pLabelTableWidget) 247 { 248 m_pLabelTableWidget->setAlignment(Qt::AlignRight | Qt::AlignTop); 249 m_pLabelTableWidget->setBuddy(m_pTableWidget); 250 251 /* Add into layout: */ 252 pLayout->addWidget(m_pLabelTableWidget, 1, 0); 162 253 } 163 254 … … 184 275 185 276 /* Add into layout: */ 186 pLayout->addLayout(pButtonBoxLayout );277 pLayout->addLayout(pButtonBoxLayout, 2, 0, 1, 2); 187 278 } 188 279 } … … 194 285 /* Clear table initially: */ 195 286 m_pTableWidget->clear(); 287 288 /* Fill name editor: */ 289 m_pEditorName->setText(m_oldData.m_strName); 196 290 197 291 /* Configure table: */ -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileDetailsWidget.h
r74898 r74928 29 29 /* Forward declarations: */ 30 30 class QAbstractButton; 31 class QLabel; 32 class QLineEdit; 31 33 class QTableWidget; 32 34 class QTableWidgetItem; … … 122 124 /** Handles translation event. */ 123 125 virtual void retranslateUi() /* override */; 126 /** Handles editor translation. */ 127 void retranslateEditor(); 128 /** Handles buttons translation. */ 129 void retranslateButtons(); 124 130 125 131 private slots: … … 127 133 /** @name Change handling stuff. 128 134 * @{ */ 135 /** Handles name change. */ 136 void sltNameChanged(const QString &strName); 129 137 /** Handles table change. */ 130 138 void sltTableChanged(QTableWidgetItem *pItem); … … 178 186 /** @} */ 179 187 180 /** @name Interface variables. 181 * @{ */ 182 /** Holds the automatic interface configuration button. */ 188 /** @name Widget variables. 189 * @{ */ 190 /** Holds the name label instance. */ 191 QLabel *m_pLabelName; 192 /** Holds the name editor instance. */ 193 QLineEdit *m_pEditorName; 194 195 /** Holds the table-widget label instance. */ 196 QLabel *m_pLabelTableWidget; 197 /** Holds the table-widget instance. */ 183 198 QTableWidget *m_pTableWidget; 184 199 -
trunk/src/VBox/Frontends/VirtualBox/src/cloud/UICloudProfileManager.cpp
r74923 r74928 187 187 void UICloudProfileManagerWidget::sltApplyCloudProfileDetailsChanges() 188 188 { 189 /* Is can be that there is provider item, not profile item currently selected. 190 * In such case we are not applying parameters, we are creating new one profile. */ 191 UIItemCloudProvider *pMaybeProviderItem = static_cast<UIItemCloudProvider*>(m_pTreeWidget->currentItem()); 192 if (pMaybeProviderItem) 193 return sltAddCloudProfile(); 194 189 195 /* Get profile item: */ 190 196 UIItemCloudProfile *pProfileItem = static_cast<UIItemCloudProfile*>(m_pTreeWidget->currentItem()); … … 224 230 else 225 231 { 226 /* Iterate through old/new data: */ 227 foreach (const QString &strKey, oldData.m_data.keys()) 232 /* Set profile name, if necessary: */ 233 if (newData.m_strName != oldData.m_strName) 234 comCloudProfile.SetName(newData.m_strName); 235 /* Show error message if necessary: */ 236 if (!comCloudProfile.isOk()) 237 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 238 else 228 239 { 229 /* Get values: */ 230 const QString strOldValue = oldData.m_data.value(strKey).first; 231 const QString strNewValue = newData.m_data.value(strKey).first; 232 if (strNewValue != strOldValue) 240 /* Iterate through old/new data: */ 241 foreach (const QString &strKey, oldData.m_data.keys()) 233 242 { 234 /* Apply property: */235 co mCloudProfile.SetProperty(strKey, strNewValue);236 /* Show error message if necessary: */237 if ( !comCloudProfile.isOk())243 /* Get values: */ 244 const QString strOldValue = oldData.m_data.value(strKey).first; 245 const QString strNewValue = newData.m_data.value(strKey).first; 246 if (strNewValue != strOldValue) 238 247 { 239 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 240 break; 248 /* Apply property: */ 249 comCloudProfile.SetProperty(strKey, strNewValue); 250 /* Show error message if necessary: */ 251 if (!comCloudProfile.isOk()) 252 { 253 msgCenter().cannotAssignCloudProfileParameter(comCloudProfile, this); 254 break; 255 } 241 256 } 242 257 } … … 271 286 AssertMsgReturnVoid(pProviderItem, ("Current item must not be null!\n")); 272 287 273 /* Acquire profile name first of all: */ 274 QString strProfileName; 275 QPointer<QInputDialog> pDialog = new QInputDialog(this); 276 pDialog->setInputMode(QInputDialog::TextInput); 277 pDialog->setWindowIcon(UIIconPool::iconSet(":/cloud_profile_add_16px.png")); 278 pDialog->setWindowTitle(tr("Add Profile")); 279 pDialog->setLabelText(tr("Name:")); 280 bool fCancelled = false; 281 if (pDialog->exec() == QDialog::Accepted) 282 strProfileName = pDialog->textValue(); 283 else 284 fCancelled = true; 285 delete pDialog; 286 if (fCancelled) 287 return; 288 /* Acquire profile name if not proposed by details widget: */ 289 QString strProfileName = m_pDetailsWidget->data().m_strName; 290 if (strProfileName.isNull()) 291 { 292 QPointer<QInputDialog> pDialog = new QInputDialog(this); 293 pDialog->setInputMode(QInputDialog::TextInput); 294 pDialog->setWindowIcon(UIIconPool::iconSet(":/cloud_profile_add_16px.png")); 295 pDialog->setWindowTitle(tr("Add Profile")); 296 pDialog->setLabelText(tr("Name:")); 297 bool fCancelled = false; 298 if (pDialog->exec() == QDialog::Accepted) 299 strProfileName = pDialog->textValue(); 300 else 301 fCancelled = true; 302 delete pDialog; 303 if (fCancelled) 304 return; 305 } 288 306 289 307 /* Get VirtualBox for further activities: */ … … 465 483 m_pActionPool->action(UIActionIndexST_M_Cloud_S_Add)->setEnabled(!pItem || pItemProvider); 466 484 m_pActionPool->action(UIActionIndexST_M_Cloud_S_Remove)->setEnabled(pItemProfile); 467 m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)->setEnabled(pItemProfile );485 m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)->setEnabled(pItemProfile || pItemProvider); 468 486 m_pActionPool->action(UIActionIndexST_M_Cloud_S_Import)->setEnabled(!pItem || pItemProvider); 469 487 … … 500 518 { 501 519 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Add)); 520 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_T_Details)); 502 521 menu.addAction(m_pActionPool->action(UIActionIndexST_M_Cloud_S_Import)); 503 522 }
Note:
See TracChangeset
for help on using the changeset viewer.