- Timestamp:
- Oct 26, 2023 12:56:21 PM (15 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings/machine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.cpp
r101497 r101604 125 125 /** Constructs tab passing @a pParent to the base-class. 126 126 * @param pParentPage Holds the parent page reference allowing to access some of API there. */ 127 UIMachineSettingsSerial( QITabWidget*pParent, UIMachineSettingsSerialPage *pParentPage);127 UIMachineSettingsSerial(UIEditor *pParent, UIMachineSettingsSerialPage *pParentPage); 128 128 129 129 /** Loads port data from @a portCache. */ … … 181 181 *********************************************************************************************************************************/ 182 182 183 UIMachineSettingsSerial::UIMachineSettingsSerial( QITabWidget*pParent, UIMachineSettingsSerialPage *pParentPage)183 UIMachineSettingsSerial::UIMachineSettingsSerial(UIEditor *pParent, UIMachineSettingsSerialPage *pParentPage) 184 184 : UIEditor(pParent) 185 185 , m_pParentPage(pParentPage) … … 379 379 if (pLayout) 380 380 { 381 #ifdef VBOX_WS_MAC 382 /* On Mac OS X we can do a bit of smoothness: */ 383 int iLeft, iTop, iRight, iBottom; 384 pLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom); 385 pLayout->setContentsMargins(iLeft / 2, iTop / 2, iRight / 2, iBottom / 2); 386 #endif 381 pLayout->setContentsMargins(0, 0, 0, 0); 387 382 388 383 /* Prepare settings editor: */ … … 508 503 { 509 504 /* Get port page: */ 510 UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));511 AssertPtrReturnVoid(pTab );505 UIMachineSettingsSerial *pTabEditor = m_tabEditors.at(iSlot); 506 AssertPtrReturnVoid(pTabEditor); 512 507 513 508 /* Load old data from cache: */ 514 pTab ->getPortDataFromCache(m_pCache->child(iSlot));509 pTabEditor->getPortDataFromCache(m_pCache->child(iSlot)); 515 510 516 511 /* Setup tab order: */ 517 pLastFocusWidget = pTab ->setOrderAfter(pLastFocusWidget);512 pLastFocusWidget = pTabEditor->setOrderAfter(pLastFocusWidget); 518 513 } 519 514 … … 542 537 { 543 538 /* Getting port page: */ 544 UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));545 AssertPtrReturnVoid(pTab );539 UIMachineSettingsSerial *pTabEditor = m_tabEditors.at(iSlot); 540 AssertPtrReturnVoid(pTabEditor); 546 541 547 542 /* Gather new data: */ 548 pTab ->putPortDataToCache(m_pCache->child(iSlot));543 pTabEditor->putPortDataToCache(m_pCache->child(iSlot)); 549 544 } 550 545 … … 575 570 576 571 /* Delegate validation to adapter tabs: */ 577 for (int i Index = 0; iIndex < m_pTabWidget->count(); ++iIndex)578 { 579 UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iIndex));580 AssertPtrReturn(pTab , false);581 if (!pTab ->validate(messages))572 for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot) 573 { 574 UIMachineSettingsSerial *pTabEditor = m_tabEditors.at(iSlot); 575 AssertPtrReturn(pTabEditor, false); 576 if (!pTabEditor->validate(messages)) 582 577 fValid = false; 583 578 } … … 595 590 for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot) 596 591 { 597 UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));598 AssertPtrReturnVoid(pTab );599 m_pTabWidget->setTabText(iSlot, pTab ->tabTitle());592 UIMachineSettingsSerial *pTabEditor = m_tabEditors.at(iSlot); 593 AssertPtrReturnVoid(pTabEditor); 594 m_pTabWidget->setTabText(iSlot, pTabEditor->tabTitle()); 600 595 } 601 596 } … … 615 610 m_pCache->childCount() > iSlot && 616 611 m_pCache->child(iSlot).base().m_fPortEnabled)); 617 UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));618 AssertPtrReturnVoid(pTab );619 pTab ->polishTab();612 UIMachineSettingsSerial *pTabEditor = m_tabEditors.at(iSlot); 613 AssertPtrReturnVoid(pTabEditor); 614 pTabEditor->polishTab(); 620 615 } 621 616 } … … 639 634 AssertPtrReturnVoid(m_pCache); 640 635 641 /* Create main layout: */ 636 /* Prepare everything: */ 637 prepareWidgets(); 638 639 /* Apply language settings: */ 640 retranslateUi(); 641 } 642 643 void UIMachineSettingsSerialPage::prepareWidgets() 644 { 645 /* Prepare main layout: */ 642 646 QVBoxLayout *pLayoutMain = new QVBoxLayout(this); 643 647 if (pLayoutMain) 644 648 { 645 /* Creatingtab-widget: */646 m_pTabWidget = new QITabWidget ;649 /* Prepare tab-widget: */ 650 m_pTabWidget = new QITabWidget(this); 647 651 if (m_pTabWidget) 648 652 { … … 652 656 /* Create corresponding port tabs: */ 653 657 for (ulong uSlot = 0; uSlot < uCount; ++uSlot) 654 { 655 /* Create port tab: */ 656 UIMachineSettingsSerial *pTab = new UIMachineSettingsSerial(m_pTabWidget, this); 657 if (pTab) 658 { 659 /* Tab connections: */ 660 connect(pTab, &UIMachineSettingsSerial::sigPortChanged, 661 this, &UIMachineSettingsSerialPage::sltHandlePortChange); 662 connect(pTab, &UIMachineSettingsSerial::sigPathChanged, 663 this, &UIMachineSettingsSerialPage::sltHandlePathChange); 664 connect(pTab, &UIMachineSettingsSerial::sigValidityChanged, 665 this, &UIMachineSettingsSerialPage::revalidate); 666 667 /* Add tab into tab-widget: */ 668 addEditor(pTab); 669 m_pTabWidget->addTab(pTab, pTab->tabTitle()); 670 } 671 } 672 673 /* Add tab-widget into layout: */ 658 prepareTab(); 659 674 660 pLayoutMain->addWidget(m_pTabWidget); 675 661 } 676 662 } 663 } 664 665 void UIMachineSettingsSerialPage::prepareTab() 666 { 667 /* Prepare tab: */ 668 UIEditor *pTab = new UIEditor(m_pTabWidget); 669 if (pTab) 670 { 671 /* Prepare tab layout: */ 672 QVBoxLayout *pLayout = new QVBoxLayout(pTab); 673 if (pLayout) 674 { 675 #ifdef VBOX_WS_MAC 676 /* On Mac OS X we can do a bit of smoothness: */ 677 int iLeft, iTop, iRight, iBottom; 678 pLayout->getContentsMargins(&iLeft, &iTop, &iRight, &iBottom); 679 pLayout->setContentsMargins(iLeft / 2, iTop / 2, iRight / 2, iBottom / 2); 680 #endif 681 682 /* Create port tab-editor: */ 683 UIMachineSettingsSerial *pEditor = new UIMachineSettingsSerial(pTab, this); 684 if (pEditor) 685 { 686 m_tabEditors << pEditor; 687 prepareConnections(pEditor); 688 pTab->addEditor(pEditor); 689 pLayout->addWidget(pEditor); 690 } 691 692 pLayout->addStretch(); 693 } 694 695 addEditor(pTab); 696 m_pTabWidget->addTab(pTab, QString()); 697 } 698 } 699 700 void UIMachineSettingsSerialPage::prepareConnections(UIMachineSettingsSerial *pTabEditor) 701 { 702 /* Tab connections: */ 703 connect(pTabEditor, &UIMachineSettingsSerial::sigPortChanged, 704 this, &UIMachineSettingsSerialPage::sltHandlePortChange); 705 connect(pTabEditor, &UIMachineSettingsSerial::sigPathChanged, 706 this, &UIMachineSettingsSerialPage::sltHandlePathChange); 707 connect(pTabEditor, &UIMachineSettingsSerial::sigValidityChanged, 708 this, &UIMachineSettingsSerialPage::revalidate); 677 709 } 678 710 … … 696 728 for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot) 697 729 { 698 UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));699 AssertPtrReturnVoid(pTab );700 m_ports[iSlot] = pTab ->isPortEnabled() ? qMakePair(pTab->irq(), pTab->ioAddress()) : qMakePair(QString(), QString());730 UIMachineSettingsSerial *pTabEditor = m_tabEditors.at(iSlot); 731 AssertPtrReturnVoid(pTabEditor); 732 m_ports[iSlot] = pTabEditor->isPortEnabled() ? qMakePair(pTabEditor->irq(), pTabEditor->ioAddress()) : qMakePair(QString(), QString()); 701 733 } 702 734 } … … 714 746 for (int iSlot = 0; iSlot < m_pTabWidget->count(); ++iSlot) 715 747 { 716 UIMachineSettingsSerial *pTab = qobject_cast<UIMachineSettingsSerial*>(m_pTabWidget->widget(iSlot));717 AssertPtrReturnVoid(pTab );718 m_paths[iSlot] = pTab ->isPortEnabled() ? pTab->path() : QString();748 UIMachineSettingsSerial *pTabEditor = m_tabEditors.at(iSlot); 749 AssertPtrReturnVoid(pTabEditor); 750 m_paths[iSlot] = pTabEditor->isPortEnabled() ? pTabEditor->path() : QString(); 719 751 } 720 752 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsSerial.h
r98103 r101604 37 37 /* Forward declarations: */ 38 38 class QITabWidget; 39 class UIMachineSettingsSerial Page;39 class UIMachineSettingsSerial; 40 40 struct UIDataSettingsMachineSerial; 41 41 struct UIDataSettingsMachineSerialPort; … … 99 99 /** Prepares all. */ 100 100 void prepare(); 101 /** Prepares widgets. */ 102 void prepareWidgets(); 103 /** Prepare tab. */ 104 void prepareTab(); 105 /** Prepares connections. */ 106 void prepareConnections(UIMachineSettingsSerial *pTabEditor); 101 107 /** Cleanups all. */ 102 108 void cleanup(); … … 122 128 /** Holds the tab-widget instance. */ 123 129 QITabWidget *m_pTabWidget; 130 131 /** Holds the list of tab-editors. */ 132 QList<UIMachineSettingsSerial*> m_tabEditors; 124 133 }; 125 134
Note:
See TracChangeset
for help on using the changeset viewer.