Changeset 82820 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Jan 22, 2020 11:20:36 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp
r80736 r82820 122 122 void sltGbSerialToggled(bool fOn); 123 123 void sltCbNumberActivated(const QString &strText); 124 void sltCbModeActivated(const QString &strText); 124 /** Handles port mode change to item with certain @a iIndex. */ 125 void sltHandlePortModeChange(int iIndex); 125 126 126 127 private: … … 129 130 void prepareValidation(); 130 131 132 /** Populates combo-boxes. */ 133 void populateComboboxes(); 134 135 /** Holds the parent page reference. */ 131 136 UIMachineSettingsSerialPage *m_pParent; 132 int m_iSlot; 137 138 /** Holds the port slot number. */ 139 int m_iSlot; 140 /** Holds the port mode. */ 141 KPortMode m_enmPortMode; 133 142 }; 134 143 … … 142 151 , m_pParent(pParent) 143 152 , m_iSlot(-1) 153 , m_enmPortMode(KPortMode_Max) 144 154 { 145 155 /* Apply UI decorations: */ … … 159 169 mCbNumber->insertItem(0, uiCommon().toCOMPortName(0, 0)); 160 170 mCbNumber->insertItems(0, uiCommon().COMPortNames()); 161 162 mCbMode->addItem(""); /* KPortMode_Disconnected */163 mCbMode->addItem(""); /* KPortMode_HostPipe */164 mCbMode->addItem(""); /* KPortMode_HostDevice */165 mCbMode->addItem(""); /* KPortMode_RawFile */166 mCbMode->addItem(""); /* KPortMode_TCP */167 171 168 172 /* Setup connections: */ … … 171 175 connect(mCbNumber, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::activated), 172 176 this, &UIMachineSettingsSerial::sltCbNumberActivated); 173 connect(mCbMode, static_cast<void(QComboBox::*)( const QString&)>(&QComboBox::activated),174 this, &UIMachineSettingsSerial::slt CbModeActivated);177 connect(mCbMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), 178 this, &UIMachineSettingsSerial::sltHandlePortModeChange); 175 179 176 180 /* Prepare validation: */ … … 186 190 ulong uIRQ, uIOBase; 187 191 const bool fStd = uiCommon().toCOMPortNumbers(mCbNumber->currentText(), uIRQ, uIOBase); 188 const KPortMode enmMode = gpConverter->fromString<KPortMode>(mCbMode->currentText());192 const KPortMode enmMode = mCbMode->currentData().value<KPortMode>(); 189 193 mGbSerial->setEnabled(m_pParent->isMachineOffline()); 190 194 mLbNumber->setEnabled(m_pParent->isMachineOffline()); … … 198 202 mCbPipe->setEnabled( (enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP) 199 203 && m_pParent->isMachineOffline()); 200 mLbPath->setEnabled(m_pParent->isMachineOffline()); 201 mLePath->setEnabled(enmMode != KPortMode_Disconnected && m_pParent->isMachineOffline()); 204 mLbPath->setEnabled( enmMode != KPortMode_Disconnected 205 && m_pParent->isMachineOffline()); 206 mLePath->setEnabled( enmMode != KPortMode_Disconnected 207 && m_pParent->isMachineOffline()); 202 208 } 203 209 … … 212 218 mLeIRQ->setText(QString::number(portData.m_uIRQ)); 213 219 mLeIOPort->setText("0x" + QString::number(portData.m_uIOBase, 16).toUpper()); 214 m CbMode->setCurrentIndex(mCbMode->findText(gpConverter->toString(portData.m_hostMode)));220 m_enmPortMode = portData.m_hostMode; 215 221 mCbPipe->setChecked(!portData.m_fServer); 216 222 mLePath->setText(portData.m_strPath); 217 223 224 /* Repopulate combo-boxes content: */ 225 populateComboboxes(); 218 226 /* Ensure everything is up-to-date */ 219 227 sltGbSerialToggled(mGbSerial->isChecked()); … … 227 235 portData.m_uIOBase = mLeIOPort->text().toULong(NULL, 0); 228 236 portData.m_fServer = !mCbPipe->isChecked(); 229 portData.m_hostMode = gpConverter->fromString<KPortMode>(mCbMode->currentText());237 portData.m_hostMode = mCbMode->currentData().value<KPortMode>(); 230 238 portData.m_strPath = QDir::toNativeSeparators(mLePath->text()); 231 239 } … … 261 269 mCbNumber->setItemText(mCbNumber->count() - 1, uiCommon().toCOMPortName(0, 0)); 262 270 263 mCbMode->setItemText(4, gpConverter->toString(KPortMode_TCP)); 264 mCbMode->setItemText(3, gpConverter->toString(KPortMode_RawFile)); 265 mCbMode->setItemText(2, gpConverter->toString(KPortMode_HostDevice)); 266 mCbMode->setItemText(1, gpConverter->toString(KPortMode_HostPipe)); 267 mCbMode->setItemText(0, gpConverter->toString(KPortMode_Disconnected)); 271 /* Translate combo-boxes content: */ 272 populateComboboxes(); 268 273 } 269 274 … … 273 278 { 274 279 sltCbNumberActivated(mCbNumber->currentText()); 275 slt CbModeActivated(mCbMode->currentText());280 sltHandlePortModeChange(mCbMode->currentIndex()); 276 281 } 277 282 … … 297 302 } 298 303 299 void UIMachineSettingsSerial::slt CbModeActivated(const QString &strText)300 { 301 KPortMode enmMode = gpConverter->fromString<KPortMode>(strText);304 void UIMachineSettingsSerial::sltHandlePortModeChange(int iIndex) 305 { 306 const KPortMode enmMode = mCbMode->itemData(iIndex).value<KPortMode>(); 302 307 mCbPipe->setEnabled(enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP); 303 308 mLePath->setEnabled(enmMode != KPortMode_Disconnected); 309 mLbPath->setEnabled(enmMode != KPortMode_Disconnected); 304 310 305 311 /* Revalidate: */ … … 313 319 connect(mLeIOPort, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate); 314 320 connect(mLePath, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate); 321 } 322 323 void UIMachineSettingsSerial::populateComboboxes() 324 { 325 /* Port mode: */ 326 { 327 /* Clear the port mode combo-box: */ 328 mCbMode->clear(); 329 330 /* Load currently supported port moded: */ 331 CSystemProperties comProperties = uiCommon().virtualBox().GetSystemProperties(); 332 QVector<KPortMode> supportedModes = comProperties.GetSupportedPortModes(); 333 /* Take currently requested mode into account if it's sane: */ 334 if (!supportedModes.contains(m_enmPortMode) && m_enmPortMode != KPortMode_Max) 335 supportedModes.prepend(m_enmPortMode); 336 337 /* Populate port modes: */ 338 int iPortModeIndex = 0; 339 foreach (const KPortMode &enmMode, supportedModes) 340 { 341 mCbMode->insertItem(iPortModeIndex, gpConverter->toString(enmMode)); 342 mCbMode->setItemData(iPortModeIndex, QVariant::fromValue(enmMode)); 343 mCbMode->setItemData(iPortModeIndex, mCbMode->itemText(iPortModeIndex), Qt::ToolTipRole); 344 ++iPortModeIndex; 345 } 346 347 /* Choose requested port mode: */ 348 const int iIndex = mCbMode->findData(m_enmPortMode); 349 mCbMode->setCurrentIndex(iIndex != -1 ? iIndex : 0); 350 } 315 351 } 316 352 … … 493 529 ports << pair; 494 530 495 const KPortMode enmMode = gpConverter->fromString<KPortMode>(pPage->mCbMode->currentText());531 const KPortMode enmMode = pPage->mCbMode->currentData().value<KPortMode>(); 496 532 if (enmMode != KPortMode_Disconnected) 497 533 {
Note:
See TracChangeset
for help on using the changeset viewer.