Changeset 94030 in vbox for trunk/src/VBox
- Timestamp:
- Mar 1, 2022 11:15:22 AM (3 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/editors
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.cpp
r93996 r94030 55 55 , m_fSupportsHWVirtEx(false) 56 56 , m_fSupportsLongMode(false) 57 , m_p MainLayout(0)58 , m_p NameLabel(0)59 , m_p PathLabel(0)60 , m_p ImageLabel(0)61 , m_p EditionLabel(0)57 , m_pLayout(0) 58 , m_pLabelName(0) 59 , m_pLabelPath(0) 60 , m_pLabelImage(0) 61 , m_pLabelEdition(0) 62 62 , m_pLabelFamily(0) 63 63 , m_pLabelType(0) 64 64 , m_pIconType(0) 65 , m_p NameLineEdit(0)66 , m_p PathSelector(0)67 , m_p ImageSelector(0)68 , m_p EditionSelector(0)65 , m_pEditorName(0) 66 , m_pSelectorPath(0) 67 , m_pSelectorImage(0) 68 , m_pComboEdition(0) 69 69 , m_pComboFamily(0) 70 70 , m_pComboType(0) … … 75 75 void UINameAndSystemEditor::setMinimumLayoutIndent(int iIndent) 76 76 { 77 if (m_p MainLayout)78 m_p MainLayout->setColumnMinimumWidth(0, iIndent);77 if (m_pLayout) 78 m_pLayout->setColumnMinimumWidth(0, iIndent); 79 79 } 80 80 81 81 void UINameAndSystemEditor::setNameStuffEnabled(bool fEnabled) 82 82 { 83 if (m_p NameLabel)84 m_p NameLabel->setEnabled(fEnabled);85 if (m_p NameLineEdit)86 m_p NameLineEdit->setEnabled(fEnabled);83 if (m_pLabelName) 84 m_pLabelName->setEnabled(fEnabled); 85 if (m_pEditorName) 86 m_pEditorName->setEnabled(fEnabled); 87 87 } 88 88 89 89 void UINameAndSystemEditor::setPathStuffEnabled(bool fEnabled) 90 90 { 91 if (m_p PathLabel)92 m_p PathLabel->setEnabled(fEnabled);93 if (m_p PathSelector)94 m_p PathSelector->setEnabled(fEnabled);91 if (m_pLabelPath) 92 m_pLabelPath->setEnabled(fEnabled); 93 if (m_pSelectorPath) 94 m_pSelectorPath->setEnabled(fEnabled); 95 95 } 96 96 … … 111 111 void UINameAndSystemEditor::setName(const QString &strName) 112 112 { 113 if (!m_p NameLineEdit)113 if (!m_pEditorName) 114 114 return; 115 m_p NameLineEdit->setText(strName);115 m_pEditorName->setText(strName); 116 116 } 117 117 118 118 QString UINameAndSystemEditor::name() const 119 119 { 120 if (!m_p NameLineEdit)120 if (!m_pEditorName) 121 121 return QString(); 122 return m_p NameLineEdit->text();122 return m_pEditorName->text(); 123 123 } 124 124 125 125 void UINameAndSystemEditor::setPath(const QString &strPath) 126 126 { 127 if (!m_p PathSelector)127 if (!m_pSelectorPath) 128 128 return; 129 m_p PathSelector->setPath(strPath);129 m_pSelectorPath->setPath(strPath); 130 130 } 131 131 132 132 QString UINameAndSystemEditor::path() const 133 133 { 134 if (!m_p PathSelector)134 if (!m_pSelectorPath) 135 135 return uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 136 return m_p PathSelector->path();136 return m_pSelectorPath->path(); 137 137 } 138 138 139 139 QString UINameAndSystemEditor::ISOImagePath() const 140 140 { 141 if (!m_p ImageSelector)141 if (!m_pSelectorImage) 142 142 return QString(); 143 return m_p ImageSelector->path();143 return m_pSelectorImage->path(); 144 144 } 145 145 … … 266 266 void UINameAndSystemEditor::setNameFieldValidator(const QString &strValidator) 267 267 { 268 if (!m_p NameLineEdit)268 if (!m_pEditorName) 269 269 return; 270 m_p NameLineEdit->setValidator(new QRegularExpressionValidator(QRegularExpression(strValidator), this));270 m_pEditorName->setValidator(new QRegularExpressionValidator(QRegularExpression(strValidator), this)); 271 271 } 272 272 273 273 void UINameAndSystemEditor::markNameEditor(bool fError) 274 274 { 275 if (m_p NameLineEdit)276 m_p NameLineEdit->mark(fError, tr("Invalid name"));275 if (m_pEditorName) 276 m_pEditorName->mark(fError, tr("Invalid name")); 277 277 } 278 278 279 279 void UINameAndSystemEditor::markImageEditor(bool fError, const QString &strErrorMessage) 280 280 { 281 if (m_p ImageSelector)282 m_p ImageSelector->mark(fError, strErrorMessage);281 if (m_pSelectorImage) 282 m_pSelectorImage->mark(fError, strErrorMessage); 283 283 } 284 284 285 285 void UINameAndSystemEditor::setEditionNameAndIndices(const QVector<QString> &names, const QVector<ulong> &ids) 286 286 { 287 AssertReturnVoid(m_p EditionSelector&& names.size() == ids.size());288 m_p EditionSelector->clear();287 AssertReturnVoid(m_pComboEdition && names.size() == ids.size()); 288 m_pComboEdition->clear(); 289 289 for (int i = 0; i < names.size(); ++i) 290 m_p EditionSelector->addItem(names[i], QVariant::fromValue(ids[i]) /* user data */);290 m_pComboEdition->addItem(names[i], QVariant::fromValue(ids[i]) /* user data */); 291 291 } 292 292 293 293 void UINameAndSystemEditor::setEditionSelectorEnabled(bool fEnabled) 294 294 { 295 if (m_p EditionSelector)296 m_p EditionSelector->setEnabled(fEnabled);297 if (m_p EditionLabel)298 m_p EditionLabel->setEnabled(fEnabled);295 if (m_pComboEdition) 296 m_pComboEdition->setEnabled(fEnabled); 297 if (m_pLabelEdition) 298 m_pLabelEdition->setEnabled(fEnabled); 299 299 } 300 300 301 301 bool UINameAndSystemEditor::isEditionsSelectorEmpty() const 302 302 { 303 if (m_p EditionSelector)304 return m_p EditionSelector->count() == 0;303 if (m_pComboEdition) 304 return m_pComboEdition->count() == 0; 305 305 return true; 306 306 } … … 309 309 { 310 310 int iWidth = 0; 311 if (m_p NameLabel)312 iWidth = qMax(iWidth, m_p NameLabel->width());313 if (m_p PathLabel)314 iWidth = qMax(iWidth, m_p PathLabel->width());315 if (m_p ImageLabel)316 iWidth = qMax(iWidth, m_p ImageLabel->width());317 if (m_p EditionLabel)318 iWidth = qMax(iWidth, m_p EditionLabel->width());311 if (m_pLabelName) 312 iWidth = qMax(iWidth, m_pLabelName->width()); 313 if (m_pLabelPath) 314 iWidth = qMax(iWidth, m_pLabelPath->width()); 315 if (m_pLabelImage) 316 iWidth = qMax(iWidth, m_pLabelImage->width()); 317 if (m_pLabelEdition) 318 iWidth = qMax(iWidth, m_pLabelEdition->width()); 319 319 if (m_pLabelFamily) 320 320 iWidth = qMax(iWidth, m_pLabelFamily->width()); … … 326 326 void UINameAndSystemEditor::retranslateUi() 327 327 { 328 if (m_p NameLabel)329 m_p NameLabel->setText(tr("&Name:"));330 if (m_p PathLabel)331 m_p PathLabel->setText(tr("&Folder:"));332 if (m_p ImageLabel)333 m_p ImageLabel->setText(tr("&ISO Image:"));334 if (m_p EditionLabel)335 m_p EditionLabel->setText(tr("&Edition:"));328 if (m_pLabelName) 329 m_pLabelName->setText(tr("&Name:")); 330 if (m_pLabelPath) 331 m_pLabelPath->setText(tr("&Folder:")); 332 if (m_pLabelImage) 333 m_pLabelImage->setText(tr("&ISO Image:")); 334 if (m_pLabelEdition) 335 m_pLabelEdition->setText(tr("&Edition:")); 336 336 if (m_pLabelFamily) 337 337 m_pLabelFamily->setText(tr("&Type:")); … … 339 339 m_pLabelType->setText(tr("&Version:")); 340 340 341 if (m_pPathSelector) 342 m_pPathSelector->setToolTip(tr("Selects the folder hosting the virtual machine.")); 343 if (m_pNameLineEdit) 344 m_pNameLineEdit->setToolTip(tr("Holds the name for the new virtual machine.")); 345 341 if (m_pEditorName) 342 m_pEditorName->setToolTip(tr("Holds the name for new virtual machine.")); 343 if (m_pSelectorPath) 344 m_pSelectorPath->setToolTip(tr("Selects the folder hosting new virtual machine.")); 346 345 if (m_pComboFamily) 347 {348 m_pComboFamily->setWhatsThis(tr("Select the operating system family that "349 "you plan to install into this virtual machine."));350 346 m_pComboFamily->setToolTip(tr("Selects the operating system family that " 351 "you plan to install into this virtual machine.")); 352 } 353 347 "you plan to install into this virtual machine.")); 354 348 if (m_pComboType) 355 {356 m_pComboType->setWhatsThis(tr("Select the operating system type that "357 "you plan to install into this virtual machine "358 "(called a guest operating system)."));359 349 m_pComboType->setToolTip(tr("Selects the operating system type that " 360 361 362 }363 if (m_pImageSelector)364 m_pImageSelector->setToolTip(tr("Selects an ISO image to be attached to the newvirtual machine or used in attended install."));350 "you plan to install into this virtual machine " 351 "(called a guest operating system).")); 352 if (m_pSelectorImage) 353 m_pSelectorImage->setToolTip(tr("Selects an ISO image to be attached to the new " 354 "virtual machine or used in attended install.")); 365 355 } 366 356 … … 473 463 { 474 464 /* Prepare main-layout: */ 475 m_p MainLayout = new QGridLayout(this);476 if (m_p MainLayout)477 { 478 m_p MainLayout->setContentsMargins(0, 0, 0, 0);479 m_p MainLayout->setColumnStretch(0, 0);480 m_p MainLayout->setColumnStretch(1, 1);465 m_pLayout = new QGridLayout(this); 466 if (m_pLayout) 467 { 468 m_pLayout->setContentsMargins(0, 0, 0, 0); 469 m_pLayout->setColumnStretch(0, 0); 470 m_pLayout->setColumnStretch(1, 1); 481 471 482 472 int iRow = 0; … … 485 475 { 486 476 /* Prepare name label: */ 487 m_p NameLabel= new QLabel(this);488 if (m_p NameLabel)489 { 490 m_p NameLabel->setAlignment(Qt::AlignRight);491 m_p NameLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);492 493 m_p MainLayout->addWidget(m_pNameLabel, iRow, 0);477 m_pLabelName = new QLabel(this); 478 if (m_pLabelName) 479 { 480 m_pLabelName->setAlignment(Qt::AlignRight); 481 m_pLabelName->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 482 483 m_pLayout->addWidget(m_pLabelName, iRow, 0); 494 484 } 495 485 /* Prepare name editor: */ 496 m_p NameLineEdit= new QILineEdit(this);497 if (m_p NameLineEdit)498 { 499 m_p NameLabel->setBuddy(m_pNameLineEdit);500 m_p MainLayout->addWidget(m_pNameLineEdit, iRow, 1, 1, 2);486 m_pEditorName = new QILineEdit(this); 487 if (m_pEditorName) 488 { 489 m_pLabelName->setBuddy(m_pEditorName); 490 m_pLayout->addWidget(m_pEditorName, iRow, 1, 1, 2); 501 491 } 502 492 ++iRow; … … 506 496 { 507 497 /* Prepare path label: */ 508 m_p PathLabel= new QLabel(this);509 if (m_p PathLabel)510 { 511 m_p PathLabel->setAlignment(Qt::AlignRight);512 m_p PathLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);513 514 m_p MainLayout->addWidget(m_pPathLabel, iRow, 0);498 m_pLabelPath = new QLabel(this); 499 if (m_pLabelPath) 500 { 501 m_pLabelPath->setAlignment(Qt::AlignRight); 502 m_pLabelPath->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 503 504 m_pLayout->addWidget(m_pLabelPath, iRow, 0); 515 505 } 516 506 /* Prepare path selector: */ 517 m_p PathSelector= new UIFilePathSelector(this);518 if (m_p PathSelector)519 { 520 m_p PathLabel->setBuddy(m_pPathSelector->focusProxy());507 m_pSelectorPath = new UIFilePathSelector(this); 508 if (m_pSelectorPath) 509 { 510 m_pLabelPath->setBuddy(m_pSelectorPath->focusProxy()); 521 511 QString strDefaultMachineFolder = uiCommon().virtualBox().GetSystemProperties().GetDefaultMachineFolder(); 522 m_p PathSelector->setPath(strDefaultMachineFolder);523 m_p PathSelector->setDefaultPath(strDefaultMachineFolder);524 525 m_p MainLayout->addWidget(m_pPathSelector, iRow, 1, 1, 2);512 m_pSelectorPath->setPath(strDefaultMachineFolder); 513 m_pSelectorPath->setDefaultPath(strDefaultMachineFolder); 514 515 m_pLayout->addWidget(m_pSelectorPath, iRow, 1, 1, 2); 526 516 } 527 517 ++iRow; … … 531 521 { 532 522 /* Prepare image label: */ 533 m_p ImageLabel= new QLabel(this);534 if (m_p ImageLabel)535 { 536 m_p ImageLabel->setAlignment(Qt::AlignRight);537 m_p ImageLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);538 m_p MainLayout->addWidget(m_pImageLabel, iRow, 0);523 m_pLabelImage = new QLabel(this); 524 if (m_pLabelImage) 525 { 526 m_pLabelImage->setAlignment(Qt::AlignRight); 527 m_pLabelImage->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 528 m_pLayout->addWidget(m_pLabelImage, iRow, 0); 539 529 } 540 530 /* Prepare image selector: */ 541 m_p ImageSelector= new UIFilePathSelector(this);542 if (m_p ImageSelector)543 { 544 m_p ImageLabel->setBuddy(m_pImageSelector->focusProxy());545 m_p ImageSelector->setResetEnabled(false);546 m_p ImageSelector->setMode(UIFilePathSelector::Mode_File_Open);547 m_p ImageSelector->setFileDialogFilters("ISO Images(*.iso *.ISO)");548 m_p ImageSelector->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD));549 m_p ImageSelector->setRecentMediaListType(UIMediumDeviceType_DVD);550 m_p MainLayout->addWidget(m_pImageSelector, iRow, 1, 1, 2);531 m_pSelectorImage = new UIFilePathSelector(this); 532 if (m_pSelectorImage) 533 { 534 m_pLabelImage->setBuddy(m_pSelectorImage->focusProxy()); 535 m_pSelectorImage->setResetEnabled(false); 536 m_pSelectorImage->setMode(UIFilePathSelector::Mode_File_Open); 537 m_pSelectorImage->setFileDialogFilters("ISO Images(*.iso *.ISO)"); 538 m_pSelectorImage->setInitialPath(uiCommon().defaultFolderPathForType(UIMediumDeviceType_DVD)); 539 m_pSelectorImage->setRecentMediaListType(UIMediumDeviceType_DVD); 540 m_pLayout->addWidget(m_pSelectorImage, iRow, 1, 1, 2); 551 541 } 552 542 ++iRow; … … 556 546 { 557 547 /* Prepare edition label: */ 558 m_p EditionLabel= new QLabel(this);559 if (m_p EditionLabel)560 { 561 m_p EditionLabel->setAlignment(Qt::AlignRight);562 m_p EditionLabel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);563 564 m_p MainLayout->addWidget(m_pEditionLabel, iRow, 0);565 } 566 /* Prepare image selector: */567 m_p EditionSelector = new QIComboBox(this);568 if (m_p EditionSelector)569 { 570 m_p EditionLabel->setBuddy(m_pEditionSelector->focusProxy());571 m_p MainLayout->addWidget(m_pEditionSelector, iRow, 1, 1, 2);548 m_pLabelEdition = new QLabel(this); 549 if (m_pLabelEdition) 550 { 551 m_pLabelEdition->setAlignment(Qt::AlignRight); 552 m_pLabelEdition->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 553 554 m_pLayout->addWidget(m_pLabelEdition, iRow, 0); 555 } 556 /* Prepare edition combo: */ 557 m_pComboEdition = new QComboBox(this); 558 if (m_pComboEdition) 559 { 560 m_pLabelEdition->setBuddy(m_pComboEdition->focusProxy()); 561 m_pLayout->addWidget(m_pComboEdition, iRow, 1, 1, 2); 572 562 } 573 563 ++iRow; … … 583 573 m_pLabelFamily->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 584 574 585 m_p MainLayout->addWidget(m_pLabelFamily, iRow, 0);575 m_pLayout->addWidget(m_pLabelFamily, iRow, 0); 586 576 } 587 577 /* Prepare VM OS family combo: */ … … 590 580 { 591 581 m_pLabelFamily->setBuddy(m_pComboFamily); 592 m_p MainLayout->addWidget(m_pComboFamily, iRow, 1);582 m_pLayout->addWidget(m_pComboFamily, iRow, 1); 593 583 } 594 584 … … 603 593 m_pLabelType->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); 604 594 605 m_p MainLayout->addWidget(m_pLabelType, iRow, 0);595 m_pLayout->addWidget(m_pLabelType, iRow, 0); 606 596 } 607 597 /* Prepare VM OS type combo: */ … … 610 600 { 611 601 m_pLabelType->setBuddy(m_pComboType); 612 m_p MainLayout->addWidget(m_pComboType, iRow, 1);602 m_pLayout->addWidget(m_pComboType, iRow, 1); 613 603 } 614 604 … … 631 621 632 622 /* Add into layout: */ 633 m_p MainLayout->addLayout(pLayoutIcon, iIconRow, 2, 2, 1);623 m_pLayout->addLayout(pLayoutIcon, iIconRow, 2, 2, 1); 634 624 } 635 625 … … 640 630 } 641 631 /* Set top most widget of the 2nd column as focus proxy: */ 642 for (int i = 0; i < m_p MainLayout->rowCount(); ++i)643 { 644 QLayoutItem *pItem = m_p MainLayout->itemAtPosition(i, 1);632 for (int i = 0; i < m_pLayout->rowCount(); ++i) 633 { 634 QLayoutItem *pItem = m_pLayout->itemAtPosition(i, 1); 645 635 if (pItem && pItem->widget()) 646 636 { … … 688 678 { 689 679 /* Prepare connections: */ 690 if (m_p NameLineEdit)691 connect(m_p NameLineEdit, &QILineEdit::textChanged,680 if (m_pEditorName) 681 connect(m_pEditorName, &QILineEdit::textChanged, 692 682 this, &UINameAndSystemEditor::sigNameChanged); 693 if (m_p PathSelector)694 connect(m_p PathSelector, &UIFilePathSelector::pathChanged,683 if (m_pSelectorPath) 684 connect(m_pSelectorPath, &UIFilePathSelector::pathChanged, 695 685 this, &UINameAndSystemEditor::sigPathChanged); 696 686 if (m_pComboFamily) … … 700 690 connect(m_pComboType, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 701 691 this, &UINameAndSystemEditor::sltTypeChanged); 702 if (m_p ImageSelector)703 connect(m_p ImageSelector, &UIFilePathSelector::pathChanged,692 if (m_pSelectorImage) 693 connect(m_pSelectorImage, &UIFilePathSelector::pathChanged, 704 694 this, &UINameAndSystemEditor::sigImageChanged); 705 if (m_p EditionSelector)706 connect(m_p EditionSelector, static_cast<void(QIComboBox::*)(int)>(&QIComboBox::currentIndexChanged),695 if (m_pComboEdition) 696 connect(m_pComboEdition, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), 707 697 this, &UINameAndSystemEditor::sltSelectedEditionsChanged); 708 698 } … … 710 700 ulong UINameAndSystemEditor::selectedEditionIndex() const 711 701 { 712 if (!m_p EditionSelector || m_pEditionSelector->count() == 0)702 if (!m_pComboEdition || m_pComboEdition->count() == 0) 713 703 return 0; 714 return m_p EditionSelector->currentData().value<ulong>();715 } 704 return m_pComboEdition->currentData().value<ulong>(); 705 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UINameAndSystemEditor.h
r93990 r94030 37 37 class QGridLayout; 38 38 class QLabel; 39 class QIComboBox;40 39 class QILineEdit; 41 40 class QString; … … 204 203 205 204 /** Holds the main layout instance. */ 206 QGridLayout *m_p MainLayout;205 QGridLayout *m_pLayout; 207 206 208 207 /** Holds the VM name label instance. */ 209 QLabel *m_p NameLabel;208 QLabel *m_pLabelName; 210 209 /** Holds the VM path label instance. */ 211 QLabel *m_p PathLabel;210 QLabel *m_pLabelPath; 212 211 /** Holds the ISO image label instance. */ 213 QLabel *m_p ImageLabel;212 QLabel *m_pLabelImage; 214 213 /** Holds the edition label instance. */ 215 QLabel *m_p EditionLabel;214 QLabel *m_pLabelEdition; 216 215 /** Holds the VM OS family label instance. */ 217 216 QLabel *m_pLabelFamily; … … 222 221 223 222 /** Holds the VM name editor instance. */ 224 QILineEdit *m_p NameLineEdit;223 QILineEdit *m_pEditorName; 225 224 /** Holds the VM path editor instance. */ 226 UIFilePathSelector *m_p PathSelector;225 UIFilePathSelector *m_pSelectorPath; 227 226 /** Holds the file selector for ISO image (either for unattended install or to be attached to vm). */ 228 UIFilePathSelector *m_p ImageSelector;229 /** Combobox to select an image out of selected ISO image(currently only Windows ISO have this). */230 Q IComboBox *m_pEditionSelector;227 UIFilePathSelector *m_pSelectorImage; 228 /** Holds the VM OS edition combo (currently only Windows ISO have this). */ 229 QComboBox *m_pComboEdition; 231 230 /** Holds the VM OS family combo instance. */ 232 231 QComboBox *m_pComboFamily;
Note:
See TracChangeset
for help on using the changeset viewer.