- Timestamp:
- Aug 27, 2020 7:54:18 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp
r85750 r85909 131 131 private: 132 132 133 /* Prepares widgets: */ 133 /** Prepares all. */ 134 void prepare(); 135 /** Prepares widgets. */ 134 136 void prepareWidgets(); 135 136 /* Helper: Prepare stuff: */ 137 void prepareValidation(); 137 /** Prepares connections. */ 138 void prepareConnections(); 138 139 139 140 /** Populates combo-boxes. */ … … 150 151 /** @name Widgets 151 152 * @{ */ 152 QLineEdit *m_pLineEditIRQ; 153 QLineEdit *m_pLineEditIOPort; 154 QLineEdit *m_pLineEditPath; 155 QComboBox *m_ComboBoxNumber; 156 QComboBox *m_pComboBoxMode; 157 QCheckBox *m_pCheckBoxSerial; 158 QCheckBox *m_pComboBoxPipe; 159 QLabel *m_pLabelNumber; 160 QLabel *m_pLabelIRQ; 161 QLabel *m_pLabelIOPort; 162 QLabel *m_pLabelMode; 163 QLabel *m_pLabelPath; 153 /** Holds the port check-box instance. */ 154 QCheckBox *m_pCheckBoxPort; 155 /** Holds the port settings widget instance. */ 156 QWidget *m_pWidgetPortSettings; 157 /** Holds the number label instance. */ 158 QLabel *m_pLabelNumber; 159 /** Holds the number combo instance. */ 160 QComboBox *m_pComboNumber; 161 /** Holds the IRQ label instance. */ 162 QLabel *m_pLabelIRQ; 163 /** Holds the IRQ editor instance. */ 164 QLineEdit *m_pLineEditIRQ; 165 /** Holds the IO port label instance. */ 166 QLabel *m_pLabelIOPort; 167 /** Holds the IO port editor instance. */ 168 QLineEdit *m_pLineEditIOPort; 169 /** Holds the mode label instance. */ 170 QLabel *m_pLabelMode; 171 /** Holds the mode combo instance. */ 172 QComboBox *m_pComboMode; 173 /** Holds the pipe check-box instance. */ 174 QCheckBox *m_pCheckBoxPipe; 175 /** Holds the path label instance. */ 176 QLabel *m_pLabelPath; 177 /** Holds the path editor instance. */ 178 QLineEdit *m_pEditorPath; 164 179 /** @} */ 165 180 … … 177 192 , m_iSlot(-1) 178 193 , m_enmPortMode(KPortMode_Max) 194 , m_pCheckBoxPort(0) 195 , m_pWidgetPortSettings(0) 196 , m_pLabelNumber(0) 197 , m_pComboNumber(0) 198 , m_pLabelIRQ(0) 179 199 , m_pLineEditIRQ(0) 200 , m_pLabelIOPort(0) 180 201 , m_pLineEditIOPort(0) 181 , m_pLineEditPath(0)182 , m_ComboBoxNumber(0)183 , m_pComboBoxMode(0)184 , m_pCheckBoxSerial(0)185 , m_pComboBoxPipe(0)186 , m_pLabelNumber(0)187 , m_pLabelIRQ(0)188 , m_pLabelIOPort(0)189 202 , m_pLabelMode(0) 203 , m_pComboMode(0) 204 , m_pCheckBoxPipe(0) 190 205 , m_pLabelPath(0) 191 { 192 prepareWidgets(); 193 194 /* Setup validation: */ 195 m_pLineEditIRQ->setValidator(new QIULongValidator(0, 255, this)); 196 m_pLineEditIOPort->setValidator(new QIULongValidator(0, 0xFFFF, this)); 197 m_pLineEditPath->setValidator(new QRegExpValidator(QRegExp(".+"), this)); 198 199 /* Setup constraints: */ 200 m_pLineEditIRQ->setFixedWidth(m_pLineEditIRQ->fontMetrics().width("8888")); 201 m_pLineEditIOPort->setFixedWidth(m_pLineEditIOPort->fontMetrics().width("8888888")); 202 203 /* Set initial values: */ 204 /* Note: If you change one of the following don't forget retranslateUi. */ 205 m_ComboBoxNumber->insertItem(0, uiCommon().toCOMPortName(0, 0)); 206 m_ComboBoxNumber->insertItems(0, uiCommon().COMPortNames()); 207 208 /* Setup connections: */ 209 connect(m_pCheckBoxSerial, &QCheckBox::toggled, 210 this, &UIMachineSettingsSerial::sltGbSerialToggled); 211 connect(m_ComboBoxNumber, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::activated), 212 this, &UIMachineSettingsSerial::sltCbNumberActivated); 213 connect(m_pComboBoxMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), 214 this, &UIMachineSettingsSerial::sltHandlePortModeChange); 215 216 /* Prepare validation: */ 217 prepareValidation(); 218 219 /* Apply language settings: */ 220 retranslateUi(); 221 } 222 223 void UIMachineSettingsSerial::prepareWidgets() 224 { 225 if (objectName().isEmpty()) 226 setObjectName(QStringLiteral("UIMachineSettingsSerial")); 227 resize(357, 179); 228 QGridLayout *pMainLayout = new QGridLayout(this); 229 pMainLayout->setObjectName(QStringLiteral("pMainLayout")); 230 m_pCheckBoxSerial = new QCheckBox(); 231 m_pCheckBoxSerial->setObjectName(QStringLiteral("m_pCheckBoxSerial")); 232 m_pCheckBoxSerial->setChecked(true); 233 234 pMainLayout->addWidget(m_pCheckBoxSerial, 0, 0, 1, 2); 235 236 QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); 237 pMainLayout->addItem(pSpacerItem, 1, 0, 1, 1); 238 239 QWidget *pWidgetSerialChild = new QWidget(); 240 pWidgetSerialChild->setObjectName(QStringLiteral("pWidgetSerialChild")); 241 QGridLayout *pGridLayout1 = new QGridLayout(pWidgetSerialChild); 242 pGridLayout1->setObjectName(QStringLiteral("pGridLayout1")); 243 pGridLayout1->setContentsMargins(0, 0, 0, 0); 244 m_pLabelNumber = new QLabel(pWidgetSerialChild); 245 m_pLabelNumber->setObjectName(QStringLiteral("m_pLabelNumber")); 246 m_pLabelNumber->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 247 pGridLayout1->addWidget(m_pLabelNumber, 0, 0, 1, 1); 248 249 m_ComboBoxNumber = new QComboBox(pWidgetSerialChild); 250 m_ComboBoxNumber->setObjectName(QStringLiteral("m_ComboBoxNumber")); 251 pGridLayout1->addWidget(m_ComboBoxNumber, 0, 1, 1, 1); 252 253 m_pLabelIRQ = new QLabel(pWidgetSerialChild); 254 m_pLabelIRQ->setObjectName(QStringLiteral("m_pLabelIRQ")); 255 pGridLayout1->addWidget(m_pLabelIRQ, 0, 2, 1, 1); 256 257 m_pLineEditIRQ = new QLineEdit(pWidgetSerialChild); 258 m_pLineEditIRQ->setObjectName(QStringLiteral("m_pLineEditIRQ")); 259 pGridLayout1->addWidget(m_pLineEditIRQ, 0, 3, 1, 1); 260 261 m_pLabelIOPort = new QLabel(pWidgetSerialChild); 262 m_pLabelIOPort->setObjectName(QStringLiteral("m_pLabelIOPort")); 263 pGridLayout1->addWidget(m_pLabelIOPort, 0, 4, 1, 1); 264 265 m_pLineEditIOPort = new QLineEdit(pWidgetSerialChild); 266 m_pLineEditIOPort->setObjectName(QStringLiteral("m_pLineEditIOPort")); 267 pGridLayout1->addWidget(m_pLineEditIOPort, 0, 5, 1, 1); 268 269 QSpacerItem *pSpacerItem1 = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); 270 pGridLayout1->addItem(pSpacerItem1, 0, 6, 1, 1); 271 272 m_pLabelMode = new QLabel(pWidgetSerialChild); 273 m_pLabelMode->setObjectName(QStringLiteral("m_pLabelMode")); 274 m_pLabelMode->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 275 pGridLayout1->addWidget(m_pLabelMode, 1, 0, 1, 1); 276 277 m_pComboBoxMode = new QComboBox(pWidgetSerialChild); 278 m_pComboBoxMode->setObjectName(QStringLiteral("m_pComboBoxMode")); 279 pGridLayout1->addWidget(m_pComboBoxMode, 1, 1, 1, 1); 280 281 QSpacerItem *pSpacerItem2 = new QSpacerItem(131, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); 282 pGridLayout1->addItem(pSpacerItem2, 1, 2, 1, 4); 283 284 m_pComboBoxPipe = new QCheckBox(pWidgetSerialChild); 285 m_pComboBoxPipe->setObjectName(QStringLiteral("m_pComboBoxPipe")); 286 pGridLayout1->addWidget(m_pComboBoxPipe, 2, 1, 1, 5); 287 288 m_pLabelPath = new QLabel(pWidgetSerialChild); 289 m_pLabelPath->setObjectName(QStringLiteral("m_pLabelPath")); 290 m_pLabelPath->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); 291 pGridLayout1->addWidget(m_pLabelPath, 3, 0, 1, 1); 292 293 m_pLineEditPath = new QLineEdit(pWidgetSerialChild); 294 m_pLineEditPath->setObjectName(QStringLiteral("m_pLineEditPath")); 295 pGridLayout1->addWidget(m_pLineEditPath, 3, 1, 1, 6); 296 297 pMainLayout->addWidget(pWidgetSerialChild, 1, 1, 1, 1); 298 QSpacerItem *pSpacerItem3 = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); 299 pMainLayout->addItem(pSpacerItem3, 2, 0, 1, 2); 300 301 m_pLabelNumber->setBuddy(m_ComboBoxNumber); 302 m_pLabelIRQ->setBuddy(m_pLineEditIRQ); 303 m_pLabelIOPort->setBuddy(m_pLineEditIOPort); 304 m_pLabelMode->setBuddy(m_pComboBoxMode); 305 m_pLabelPath->setBuddy(m_pLineEditPath); 306 307 QObject::connect(m_pCheckBoxSerial, &QCheckBox::toggled, pWidgetSerialChild, &QLineEdit::setEnabled); 206 , m_pEditorPath(0) 207 { 208 prepare(); 308 209 } 309 210 … … 312 213 /* Polish port page: */ 313 214 ulong uIRQ, uIOBase; 314 const bool fStd = uiCommon().toCOMPortNumbers(m_ ComboBoxNumber->currentText(), uIRQ, uIOBase);315 const KPortMode enmMode = m_pCombo BoxMode->currentData().value<KPortMode>();316 m_pCheckBox Serial->setEnabled(m_pParent->isMachineOffline());215 const bool fStd = uiCommon().toCOMPortNumbers(m_pComboNumber->currentText(), uIRQ, uIOBase); 216 const KPortMode enmMode = m_pComboMode->currentData().value<KPortMode>(); 217 m_pCheckBoxPort->setEnabled(m_pParent->isMachineOffline()); 317 218 m_pLabelNumber->setEnabled(m_pParent->isMachineOffline()); 318 m_ ComboBoxNumber->setEnabled(m_pParent->isMachineOffline());219 m_pComboNumber->setEnabled(m_pParent->isMachineOffline()); 319 220 m_pLabelIRQ->setEnabled(m_pParent->isMachineOffline()); 320 221 m_pLineEditIRQ->setEnabled(!fStd && m_pParent->isMachineOffline()); … … 322 223 m_pLineEditIOPort->setEnabled(!fStd && m_pParent->isMachineOffline()); 323 224 m_pLabelMode->setEnabled(m_pParent->isMachineOffline()); 324 m_pCombo BoxMode->setEnabled(m_pParent->isMachineOffline());325 m_pC omboBoxPipe->setEnabled( (enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP)225 m_pComboMode->setEnabled(m_pParent->isMachineOffline()); 226 m_pCheckBoxPipe->setEnabled( (enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP) 326 227 && m_pParent->isMachineOffline()); 327 228 m_pLabelPath->setEnabled( enmMode != KPortMode_Disconnected 328 229 && m_pParent->isMachineOffline()); 329 m_p LineEditPath->setEnabled( enmMode != KPortMode_Disconnected230 m_pEditorPath->setEnabled( enmMode != KPortMode_Disconnected 330 231 && m_pParent->isMachineOffline()); 331 232 } … … 337 238 338 239 /* Load port data: */ 339 m_pCheckBox Serial->setChecked(portData.m_fPortEnabled);340 m_ ComboBoxNumber->setCurrentIndex(m_ComboBoxNumber->findText(uiCommon().toCOMPortName(portData.m_uIRQ, portData.m_uIOBase)));240 m_pCheckBoxPort->setChecked(portData.m_fPortEnabled); 241 m_pComboNumber->setCurrentIndex(m_pComboNumber->findText(uiCommon().toCOMPortName(portData.m_uIRQ, portData.m_uIOBase))); 341 242 m_pLineEditIRQ->setText(QString::number(portData.m_uIRQ)); 342 243 m_pLineEditIOPort->setText("0x" + QString::number(portData.m_uIOBase, 16).toUpper()); 343 244 m_enmPortMode = portData.m_hostMode; 344 m_pC omboBoxPipe->setChecked(!portData.m_fServer);345 m_p LineEditPath->setText(portData.m_strPath);245 m_pCheckBoxPipe->setChecked(!portData.m_fServer); 246 m_pEditorPath->setText(portData.m_strPath); 346 247 347 248 /* Repopulate combo-boxes content: */ 348 249 populateComboboxes(); 349 250 /* Ensure everything is up-to-date */ 350 sltGbSerialToggled(m_pCheckBox Serial->isChecked());251 sltGbSerialToggled(m_pCheckBoxPort->isChecked()); 351 252 } 352 253 … … 354 255 { 355 256 /* Save port data: */ 356 portData.m_fPortEnabled = m_pCheckBox Serial->isChecked();257 portData.m_fPortEnabled = m_pCheckBoxPort->isChecked(); 357 258 portData.m_uIRQ = m_pLineEditIRQ->text().toULong(NULL, 0); 358 259 portData.m_uIOBase = m_pLineEditIOPort->text().toULong(NULL, 0); 359 portData.m_fServer = !m_pC omboBoxPipe->isChecked();360 portData.m_hostMode = m_pCombo BoxMode->currentData().value<KPortMode>();361 portData.m_strPath = QDir::toNativeSeparators(m_p LineEditPath->text());260 portData.m_fServer = !m_pCheckBoxPipe->isChecked(); 261 portData.m_hostMode = m_pComboMode->currentData().value<KPortMode>(); 262 portData.m_strPath = QDir::toNativeSeparators(m_pEditorPath->text()); 362 263 } 363 264 364 265 QWidget *UIMachineSettingsSerial::setOrderAfter(QWidget *pAfter) 365 266 { 366 setTabOrder(pAfter, m_pCheckBox Serial);367 setTabOrder(m_pCheckBox Serial, m_ComboBoxNumber);368 setTabOrder(m_ ComboBoxNumber, m_pLineEditIRQ);267 setTabOrder(pAfter, m_pCheckBoxPort); 268 setTabOrder(m_pCheckBoxPort, m_pComboNumber); 269 setTabOrder(m_pComboNumber, m_pLineEditIRQ); 369 270 setTabOrder(m_pLineEditIRQ, m_pLineEditIOPort); 370 setTabOrder(m_pLineEditIOPort, m_pCombo BoxMode);371 setTabOrder(m_pCombo BoxMode, m_pComboBoxPipe);372 setTabOrder(m_pC omboBoxPipe, m_pLineEditPath);373 return m_p LineEditPath;271 setTabOrder(m_pLineEditIOPort, m_pComboMode); 272 setTabOrder(m_pComboMode, m_pCheckBoxPipe); 273 setTabOrder(m_pCheckBoxPipe, m_pEditorPath); 274 return m_pEditorPath; 374 275 } 375 276 … … 382 283 { 383 284 ulong a, b; 384 return !uiCommon().toCOMPortNumbers(m_ ComboBoxNumber->currentText(), a, b);285 return !uiCommon().toCOMPortNumbers(m_pComboNumber->currentText(), a, b); 385 286 } 386 287 387 288 void UIMachineSettingsSerial::retranslateUi() 388 289 { 389 m_pCheckBox Serial->setWhatsThis(tr("When checked, enables the given serial port of the virtual machine."));390 m_pCheckBox Serial->setText(tr("&Enable Serial Port"));290 m_pCheckBoxPort->setWhatsThis(tr("When checked, enables the given serial port of the virtual machine.")); 291 m_pCheckBoxPort->setText(tr("&Enable Serial Port")); 391 292 m_pLabelNumber->setText(tr("Port &Number:")); 392 m_ ComboBoxNumber->setWhatsThis(tr("Selects the serial port number. You can choose one of the standard serial ports or "293 m_pComboNumber->setWhatsThis(tr("Selects the serial port number. You can choose one of the standard serial ports or " 393 294 "select <b>User-defined</b> and specify port parameters manually.")); 394 295 m_pLabelIRQ->setText(tr("&IRQ:")); … … 400 301 "range from <tt>0</tt> to <tt>0xFFFF</tt>.")); 401 302 m_pLabelMode->setText(tr("Port &Mode:")); 402 m_pCombo BoxMode->setWhatsThis(tr("Selects the working mode of this serial port. If you select <b>Disconnected</b>, the guest "303 m_pComboMode->setWhatsThis(tr("Selects the working mode of this serial port. If you select <b>Disconnected</b>, the guest " 403 304 "OS will detect the serial port but will not be able to operate it.")); 404 m_pC omboBoxPipe->setWhatsThis(tr("When checked, the virtual machine will assume that the pipe or socket specified in the "305 m_pCheckBoxPipe->setWhatsThis(tr("When checked, the virtual machine will assume that the pipe or socket specified in the " 405 306 "<b>Path/Address</b> field exists and try to use it. Otherwise, the pipe or socket will be " 406 307 "created by the virtual machine when it starts.")); 407 m_pC omboBoxPipe->setText(tr("&Connect to existing pipe/socket"));308 m_pCheckBoxPipe->setText(tr("&Connect to existing pipe/socket")); 408 309 m_pLabelPath->setText(tr("&Path/Address:")); 409 m_p LineEditPath->setWhatsThis(tr("<p>In <b>Host Pipe</b> mode: Holds the path to the serial port's pipe on the host. "310 m_pEditorPath->setWhatsThis(tr("<p>In <b>Host Pipe</b> mode: Holds the path to the serial port's pipe on the host. " 410 311 "Examples: \"\\\\.\\pipe\\myvbox\" or \"/tmp/myvbox\", for Windows and UNIX-like systems " 411 312 "respectively.</p><p>In <b>Host Device</b> mode: Holds the host serial device name. " … … 414 315 "the TCP \"port\" when in server mode, or \"hostname:port\" when in client mode.")); 415 316 416 m_ ComboBoxNumber->setItemText(m_ComboBoxNumber->count() - 1, uiCommon().toCOMPortName(0, 0));317 m_pComboNumber->setItemText(m_pComboNumber->count() - 1, uiCommon().toCOMPortName(0, 0)); 417 318 418 319 /* Translate combo-boxes content: */ … … 422 323 void UIMachineSettingsSerial::sltGbSerialToggled(bool fOn) 423 324 { 325 /* Update availability: */ 326 m_pWidgetPortSettings->setEnabled(m_pCheckBoxPort->isChecked()); 327 424 328 if (fOn) 425 329 { 426 sltCbNumberActivated(m_ ComboBoxNumber->currentText());427 sltHandlePortModeChange(m_pCombo BoxMode->currentIndex());330 sltCbNumberActivated(m_pComboNumber->currentText()); 331 sltHandlePortModeChange(m_pComboMode->currentIndex()); 428 332 } 429 333 … … 451 355 void UIMachineSettingsSerial::sltHandlePortModeChange(int iIndex) 452 356 { 453 const KPortMode enmMode = m_pCombo BoxMode->itemData(iIndex).value<KPortMode>();454 m_pC omboBoxPipe->setEnabled(enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP);455 m_p LineEditPath->setEnabled(enmMode != KPortMode_Disconnected);357 const KPortMode enmMode = m_pComboMode->itemData(iIndex).value<KPortMode>(); 358 m_pCheckBoxPipe->setEnabled(enmMode == KPortMode_HostPipe || enmMode == KPortMode_TCP); 359 m_pEditorPath->setEnabled(enmMode != KPortMode_Disconnected); 456 360 m_pLabelPath->setEnabled(enmMode != KPortMode_Disconnected); 457 361 … … 460 364 } 461 365 462 void UIMachineSettingsSerial::prepareValidation() 463 { 464 /* Prepare validation: */ 366 void UIMachineSettingsSerial::prepare() 367 { 368 /* Prepare everything: */ 369 prepareWidgets(); 370 prepareConnections(); 371 372 /* Apply language settings: */ 373 retranslateUi(); 374 } 375 376 void UIMachineSettingsSerial::prepareWidgets() 377 { 378 /* Prepare main layout: */ 379 QGridLayout *pMainLayout = new QGridLayout(this); 380 if (pMainLayout) 381 { 382 pMainLayout->setRowStretch(2, 1); 383 384 /* Prepare port check-box: */ 385 m_pCheckBoxPort = new QCheckBox(this); 386 if (m_pCheckBoxPort) 387 pMainLayout->addWidget(m_pCheckBoxPort, 0, 0, 1, 2); 388 389 /* Prepare 20-px shifting spacer: */ 390 QSpacerItem *pSpacerItem = new QSpacerItem(20, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); 391 if (pSpacerItem) 392 pMainLayout->addItem(pSpacerItem, 1, 0); 393 394 /* Prepare adapter settings widget: */ 395 m_pWidgetPortSettings = new QWidget(this); 396 if (m_pWidgetPortSettings) 397 { 398 /* Prepare adapter settings widget layout: */ 399 QGridLayout *pLayoutPortSettings = new QGridLayout(m_pWidgetPortSettings); 400 if (pLayoutPortSettings) 401 { 402 pLayoutPortSettings->setContentsMargins(0, 0, 0, 0); 403 pLayoutPortSettings->setColumnStretch(6, 1); 404 405 /* Prepare number label: */ 406 m_pLabelNumber = new QLabel(m_pWidgetPortSettings); 407 if (m_pLabelNumber) 408 { 409 m_pLabelNumber->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 410 pLayoutPortSettings->addWidget(m_pLabelNumber, 0, 0); 411 } 412 /* Prepare number combo: */ 413 m_pComboNumber = new QComboBox(m_pWidgetPortSettings); 414 if (m_pComboNumber) 415 { 416 m_pLabelNumber->setBuddy(m_pComboNumber); 417 m_pComboNumber->insertItem(0, uiCommon().toCOMPortName(0, 0)); 418 m_pComboNumber->insertItems(0, uiCommon().COMPortNames()); 419 pLayoutPortSettings->addWidget(m_pComboNumber, 0, 1); 420 } 421 /* Prepare IRQ label: */ 422 m_pLabelIRQ = new QLabel(m_pWidgetPortSettings); 423 if (m_pLabelIRQ) 424 pLayoutPortSettings->addWidget(m_pLabelIRQ, 0, 2); 425 /* Prepare IRQ label: */ 426 m_pLineEditIRQ = new QLineEdit(m_pWidgetPortSettings); 427 if (m_pLineEditIRQ) 428 { 429 m_pLabelIRQ->setBuddy(m_pLineEditIRQ); 430 m_pLineEditIRQ->setFixedWidth(m_pLineEditIRQ->fontMetrics().width("8888")); 431 m_pLineEditIRQ->setValidator(new QIULongValidator(0, 255, this)); 432 pLayoutPortSettings->addWidget(m_pLineEditIRQ, 0, 3); 433 } 434 /* Prepare IO port label: */ 435 m_pLabelIOPort = new QLabel(m_pWidgetPortSettings); 436 if (m_pLabelIOPort) 437 pLayoutPortSettings->addWidget(m_pLabelIOPort, 0, 4); 438 /* Prepare IO port label: */ 439 m_pLineEditIOPort = new QLineEdit(m_pWidgetPortSettings); 440 if (m_pLineEditIOPort) 441 { 442 m_pLabelIOPort->setBuddy(m_pLineEditIOPort); 443 m_pLineEditIOPort->setFixedWidth(m_pLineEditIOPort->fontMetrics().width("8888888")); 444 m_pLineEditIOPort->setValidator(new QIULongValidator(0, 0xFFFF, this)); 445 pLayoutPortSettings->addWidget(m_pLineEditIOPort, 0, 5); 446 } 447 448 /* Prepare mode label: */ 449 m_pLabelMode = new QLabel(m_pWidgetPortSettings); 450 if (m_pLabelMode) 451 { 452 m_pLabelMode->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 453 pLayoutPortSettings->addWidget(m_pLabelMode, 1, 0); 454 } 455 /* Prepare mode combo: */ 456 m_pComboMode = new QComboBox(m_pWidgetPortSettings); 457 if (m_pComboMode) 458 { 459 m_pLabelMode->setBuddy(m_pComboMode); 460 pLayoutPortSettings->addWidget(m_pComboMode, 1, 1); 461 } 462 463 /* Prepare pipe check-box: */ 464 m_pCheckBoxPipe = new QCheckBox(m_pWidgetPortSettings); 465 if (m_pCheckBoxPipe) 466 pLayoutPortSettings->addWidget(m_pCheckBoxPipe, 2, 1, 1, 5); 467 468 /* Prepare path label: */ 469 m_pLabelPath = new QLabel(m_pWidgetPortSettings); 470 if (m_pLabelPath) 471 { 472 m_pLabelPath->setAlignment(Qt::AlignRight | Qt::AlignVCenter); 473 pLayoutPortSettings->addWidget(m_pLabelPath, 3, 0); 474 } 475 /* Prepare path editor: */ 476 m_pEditorPath = new QLineEdit(m_pWidgetPortSettings); 477 if (m_pEditorPath) 478 { 479 m_pLabelPath->setBuddy(m_pEditorPath); 480 m_pEditorPath->setValidator(new QRegExpValidator(QRegExp(".+"), this)); 481 pLayoutPortSettings->addWidget(m_pEditorPath, 3, 1, 1, 6); 482 } 483 } 484 485 pMainLayout->addWidget(m_pWidgetPortSettings, 1, 1); 486 } 487 } 488 } 489 490 void UIMachineSettingsSerial::prepareConnections() 491 { 492 connect(m_pCheckBoxPort, &QCheckBox::toggled, this, &UIMachineSettingsSerial::sltGbSerialToggled); 493 connect(m_pComboNumber, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::activated), 494 this, &UIMachineSettingsSerial::sltCbNumberActivated); 465 495 connect(m_pLineEditIRQ, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate); 466 496 connect(m_pLineEditIOPort, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate); 467 connect(m_pLineEditPath, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate); 497 connect(m_pComboMode, static_cast<void(QComboBox::*)(int)>(&QComboBox::activated), 498 this, &UIMachineSettingsSerial::sltHandlePortModeChange); 499 connect(m_pEditorPath, &QLineEdit::textChanged, m_pParent, &UIMachineSettingsSerialPage::revalidate); 468 500 } 469 501 … … 473 505 { 474 506 /* Clear the port mode combo-box: */ 475 m_pCombo BoxMode->clear();507 m_pComboMode->clear(); 476 508 477 509 /* Load currently supported port moded: */ … … 486 518 foreach (const KPortMode &enmMode, supportedModes) 487 519 { 488 m_pCombo BoxMode->insertItem(iPortModeIndex, gpConverter->toString(enmMode));489 m_pCombo BoxMode->setItemData(iPortModeIndex, QVariant::fromValue(enmMode));490 m_pCombo BoxMode->setItemData(iPortModeIndex, m_pComboBoxMode->itemText(iPortModeIndex), Qt::ToolTipRole);520 m_pComboMode->insertItem(iPortModeIndex, gpConverter->toString(enmMode)); 521 m_pComboMode->setItemData(iPortModeIndex, QVariant::fromValue(enmMode)); 522 m_pComboMode->setItemData(iPortModeIndex, m_pComboMode->itemText(iPortModeIndex), Qt::ToolTipRole); 491 523 ++iPortModeIndex; 492 524 } 493 525 494 526 /* Choose requested port mode: */ 495 const int iIndex = m_pCombo BoxMode->findData(m_enmPortMode);496 m_pCombo BoxMode->setCurrentIndex(iIndex != -1 ? iIndex : 0);527 const int iIndex = m_pComboMode->findData(m_enmPortMode); 528 m_pComboMode->setCurrentIndex(iIndex != -1 ? iIndex : 0); 497 529 } 498 530 } … … 646 678 QWidget *pTab = m_pTabWidget->widget(iIndex); 647 679 UIMachineSettingsSerial *pPage = static_cast<UIMachineSettingsSerial*>(pTab); 648 if (!pPage->m_pCheckBox Serial->isChecked())680 if (!pPage->m_pCheckBoxPort->isChecked()) 649 681 continue; 650 682 … … 676 708 ports << pair; 677 709 678 const KPortMode enmMode = pPage->m_pCombo BoxMode->currentData().value<KPortMode>();710 const KPortMode enmMode = pPage->m_pComboMode->currentData().value<KPortMode>(); 679 711 if (enmMode != KPortMode_Disconnected) 680 712 { 681 const QString strPath(pPage->m_p LineEditPath->text());713 const QString strPath(pPage->m_pEditorPath->text()); 682 714 683 715 if (strPath.isEmpty())
Note:
See TracChangeset
for help on using the changeset viewer.