Changeset 100923 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 21, 2023 1:23:49 PM (16 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/settings
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r100902 r100923 67 67 , m_strControl(strControl) 68 68 , m_pSelector(0) 69 , m_pStack(0)70 69 , m_enmConfigurationAccessLevel(ConfigurationAccessLevel_Null) 71 70 , m_pSerializeProcess(0) … … 79 78 , m_fValid(true) 80 79 , m_fSilent(true) 80 , m_pLayoutMain(0) 81 81 , m_pLabelTitle(0) 82 , m_pStack(0) 82 83 , m_pButtonBox(0) 83 , m_pWidgetStackHandler(0) 84 { 85 /* Prepare: */ 84 { 86 85 prepare(); 87 86 } … … 208 207 void UISettingsDialog::retranslateUi() 209 208 { 210 m_pLabelTitle->setText(QString()); 209 #ifndef VBOX_GUI_WITH_TOOLBAR_SETTINGS 210 /* Retranslate current page headline: */ 211 m_pLabelTitle->setText(m_pSelector->itemText(m_pSelector->currentId())); 212 #endif 211 213 212 214 /* Translate warning stuff: */ … … 214 216 if (!m_fValid || !m_fSilent) 215 217 m_pWarningPane->setWarningLabel(m_strWarningHint); 216 217 #ifndef VBOX_GUI_WITH_TOOLBAR_SETTINGS218 /* Retranslate current page headline: */219 m_pLabelTitle->setText(m_pSelector->itemText(m_pSelector->currentId()));220 #endif221 218 222 219 /* Retranslate all validators: */ … … 600 597 void UISettingsDialog::prepare() 601 598 { 602 prepareWidgets(); 603 604 /* Configure title: */ 599 /* Prepare central-widget: */ 600 setCentralWidget(new QWidget); 601 if (centralWidget()) 602 { 603 /* Prepare main layout: */ 604 m_pLayoutMain = new QGridLayout(centralWidget()); 605 if (m_pLayoutMain) 606 { 607 /* Prepare widgets: */ 608 prepareSelector(); 609 prepareStack(); 610 prepareButtonBox(); 611 } 612 } 613 614 /* Apply language settings: */ 615 retranslateUi(); 616 } 617 618 void UISettingsDialog::prepareSelector() 619 { 620 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 621 /* Prepare modern tool-bar selector: */ 622 m_pSelector = new UISettingsSelectorToolBar(this); 623 if (m_pSelector) 624 { 625 static_cast<QIToolBar*>(m_pSelector->widget())->enableMacToolbar(); 626 addToolBar(qobject_cast<QToolBar*>(m_pSelector->widget())); 627 } 628 629 /* No title in this mode, we change the title of the window: */ 630 m_pLayoutMain->setColumnMinimumWidth(0, 0); 631 m_pLayoutMain->setHorizontalSpacing(0); 632 633 #else /* !VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 634 635 /* Prepare classical tree-view selector: */ 636 m_pSelector = new UISettingsSelectorTreeView(centralWidget()); 637 if (m_pSelector) 638 { 639 m_pLayoutMain->addWidget(m_pSelector->widget(), 0, 0, 2, 1); 640 m_pSelector->widget()->setFocus(); 641 } 642 643 /* Prepare title label: */ 644 m_pLabelTitle = new QLabel(centralWidget()); 605 645 if (m_pLabelTitle) 606 646 { 607 /* Page-title font is bold and larger but derived from the system font: */ 608 QFont pageTitleFont = font(); 609 pageTitleFont.setBold(true); 610 pageTitleFont.setPointSize(pageTitleFont.pointSize() + 2); 611 m_pLabelTitle->setFont(pageTitleFont); 612 } 613 614 /* Prepare selector: */ 615 QGridLayout *pMainLayout = static_cast<QGridLayout*>(centralWidget()->layout()); 616 if (pMainLayout) 617 { 618 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 619 620 /* No page-title with tool-bar: */ 621 m_pLabelTitle->hide(); 622 623 /* Create modern tool-bar selector: */ 624 m_pSelector = new UISettingsSelectorToolBar(this); 625 if (m_pSelector) 626 { 627 /* Configure tool-bar: */ 628 static_cast<QIToolBar*>(m_pSelector->widget())->enableMacToolbar(); 629 630 /* Add tool-bar into page: */ 631 addToolBar(qobject_cast<QToolBar*>(m_pSelector->widget())); 632 } 633 634 /* No title in this mode, we change the title of the window: */ 635 pMainLayout->setColumnMinimumWidth(0, 0); 636 pMainLayout->setHorizontalSpacing(0); 637 638 #else /* !VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 639 640 /* Create classical tree-view selector: */ 641 m_pSelector = new UISettingsSelectorTreeView(this); 642 if (m_pSelector) 643 { 644 /* Add into layout: */ 645 pMainLayout->addWidget(m_pSelector->widget(), 0, 0, 2, 1); 646 647 /* Set focus: */ 648 m_pSelector->widget()->setFocus(); 649 } 650 647 m_pLabelTitle->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 648 QPalette pal = QApplication::palette(); 649 pal.setColor(QPalette::Active, QPalette::Window, pal.color(QPalette::Active, QPalette::Base)); 650 m_pLabelTitle->setPalette(pal); 651 QFont fnt; 652 fnt.setFamily(QStringLiteral("Sans Serif")); 653 // fnt.setPointSize(11); 654 fnt.setPointSize(fnt.pointSize() + 2); 655 fnt.setBold(true); 656 fnt.setWeight(QFont::ExtraBold); 657 m_pLabelTitle->setFont(fnt); 658 m_pLabelTitle->setAutoFillBackground(true); 659 m_pLabelTitle->setFrameShadow(QFrame::Sunken); 660 m_pLabelTitle->setMargin(9); 661 662 /* Add title-label into main layout: */ 663 m_pLayoutMain->addWidget(m_pLabelTitle, 0, 1); 664 } 651 665 #endif /* !VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 652 666 653 connect(m_pSelector, &UISettingsSelectorTreeView::sigCategoryChanged, this, &UISettingsDialog::sltCategoryChanged); 654 } 655 656 /* Prepare stack-handler: */ 657 if (m_pWidgetStackHandler) 658 { 659 /* Create page-stack layout: */ 660 QVBoxLayout *pStackLayout = new QVBoxLayout(m_pWidgetStackHandler); 661 if (pStackLayout) 662 { 663 /* Confugre page-stack layout: */ 664 pStackLayout->setContentsMargins(0, 0, 0, 0); 665 666 /* Create page-stack: */ 667 m_pStack = new QStackedWidget; 668 if (m_pStack) 669 { 670 /* Configure page-stack: */ 671 popupCenter().setPopupStackOrientation(m_pStack, UIPopupStackOrientation_Bottom); 672 673 /* Add into layout: */ 674 pStackLayout->addWidget(m_pStack); 675 } 676 } 677 } 678 667 /* Configure selector created above: */ 668 if (m_pSelector) 669 connect(m_pSelector, &UISettingsSelectorTreeView::sigCategoryChanged, 670 this, &UISettingsDialog::sltCategoryChanged); 671 } 672 673 void UISettingsDialog::prepareStack() 674 { 675 /* Prepare page-stack: */ 676 m_pStack = new QStackedWidget(centralWidget()); 677 if (m_pStack) 678 { 679 /* Configure page-stack: */ 680 popupCenter().setPopupStackOrientation(m_pStack, UIPopupStackOrientation_Bottom); 681 682 /* Add page-stack into main layout: */ 683 m_pLayoutMain->addWidget(m_pStack, 1, 1); 684 } 685 } 686 687 void UISettingsDialog::prepareButtonBox() 688 { 679 689 /* Prepare button-box: */ 690 m_pButtonBox = new QIDialogButtonBox(centralWidget()); 680 691 if (m_pButtonBox) 681 692 { 682 /* Create status-bar: */ 683 m_pStatusBar = new QStackedWidget; 693 #ifndef VBOX_WS_MAC 694 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | 695 QDialogButtonBox::NoButton | QDialogButtonBox::Help); 696 m_pButtonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents); 697 #else 698 // WORKAROUND: 699 // No Help button on macOS for now, conflict with old Qt. 700 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | 701 QDialogButtonBox::NoButton); 702 #endif 703 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::Key_Return); 704 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 705 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UISettingsDialog::close); 706 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UISettingsDialog::accept); 707 #ifndef VBOX_WS_MAC 708 connect(m_pButtonBox->button(QDialogButtonBox::Help), &QAbstractButton::pressed, 709 m_pButtonBox, &QIDialogButtonBox::sltHandleHelpRequest); 710 #endif 711 712 /* Prepare status-bar: */ 713 m_pStatusBar = new QStackedWidget(m_pButtonBox); 684 714 if (m_pStatusBar) 685 715 { … … 687 717 m_pStatusBar->addWidget(new QWidget); 688 718 689 /* Create process-bar: */690 m_pProcessBar = new QProgressBar ;719 /* Prepare process-bar: */ 720 m_pProcessBar = new QProgressBar(m_pStatusBar); 691 721 if (m_pProcessBar) 692 722 { 693 /* Configure process-bar: */694 723 m_pProcessBar->setMinimum(0); 695 724 m_pProcessBar->setMaximum(100); 696 697 /* Add into status-bar: */698 725 m_pStatusBar->addWidget(m_pProcessBar); 699 726 } 700 727 701 /* Create warning-pane: */702 m_pWarningPane = new UIWarningPane ;728 /* Prepare warning-pane: */ 729 m_pWarningPane = new UIWarningPane(m_pStatusBar); 703 730 if (m_pWarningPane) 704 731 { 705 /* Configure warning-pane: */706 732 connect(m_pWarningPane, &UIWarningPane::sigHoverEnter, 707 733 this, &UISettingsDialog::sltHandleWarningPaneHovered); 708 734 connect(m_pWarningPane, &UIWarningPane::sigHoverLeave, 709 735 this, &UISettingsDialog::sltHandleWarningPaneUnhovered); 710 711 /* Add into status-bar: */712 736 m_pStatusBar->addWidget(m_pWarningPane); 713 737 } … … 716 740 m_pButtonBox->addExtraWidget(m_pStatusBar); 717 741 } 718 } 719 720 /* Apply language settings: */ 721 retranslateUi(); 722 } 723 724 void UISettingsDialog::prepareWidgets() 725 { 726 /* Prepare central-widget: */ 727 setCentralWidget(new QWidget); 728 if (centralWidget()) 729 { 730 /* Prepare main layout: */ 731 QGridLayout *pLayoutMain = new QGridLayout(centralWidget()); 732 if (pLayoutMain) 733 { 734 /* Prepare title label: */ 735 m_pLabelTitle = new QLabel(centralWidget()); 736 if (m_pLabelTitle) 737 { 738 m_pLabelTitle->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed)); 739 QPalette pal = QApplication::palette(); 740 pal.setColor(QPalette::Active, QPalette::Window, pal.color(QPalette::Active, QPalette::Base)); 741 m_pLabelTitle->setPalette(pal); 742 QFont fnt; 743 fnt.setFamily(QStringLiteral("Sans Serif")); 744 fnt.setPointSize(11); 745 fnt.setBold(true); 746 fnt.setWeight(QFont::ExtraBold); 747 m_pLabelTitle->setFont(fnt); 748 m_pLabelTitle->setAutoFillBackground(true); 749 m_pLabelTitle->setFrameShadow(QFrame::Sunken); 750 m_pLabelTitle->setMargin(9); 751 752 pLayoutMain->addWidget(m_pLabelTitle, 0, 1); 753 } 754 755 /* Prepare widget stack handler: */ 756 m_pWidgetStackHandler = new QWidget(centralWidget()); 757 if (m_pWidgetStackHandler) 758 { 759 m_pWidgetStackHandler->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); 760 pLayoutMain->addWidget(m_pWidgetStackHandler, 1, 1); 761 } 762 763 /* Prepare button-box: */ 764 m_pButtonBox = new QIDialogButtonBox(centralWidget()); 765 if (m_pButtonBox) 766 { 767 #ifndef VBOX_WS_MAC 768 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | 769 QDialogButtonBox::NoButton | QDialogButtonBox::Help); 770 m_pButtonBox->button(QDialogButtonBox::Help)->setShortcut(QKeySequence::HelpContents); 771 #else 772 // WORKAROUND: 773 // No Help button on macOS for now, conflict with old Qt. 774 m_pButtonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | 775 QDialogButtonBox::NoButton); 776 #endif 777 m_pButtonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::Key_Return); 778 m_pButtonBox->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape); 779 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &UISettingsDialog::close); 780 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &UISettingsDialog::accept); 781 #ifndef VBOX_WS_MAC 782 connect(m_pButtonBox->button(QDialogButtonBox::Help), &QAbstractButton::pressed, 783 m_pButtonBox, &QIDialogButtonBox::sltHandleHelpRequest); 784 #endif 785 786 pLayoutMain->addWidget(m_pButtonBox, 2, 0, 1, 2); 787 } 788 } 742 743 /* Add button-box into main layout: */ 744 m_pLayoutMain->addWidget(m_pButtonBox, 2, 0, 1, 2); 789 745 } 790 746 } -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h
r100902 r100923 41 41 /* Forward declarations: */ 42 42 class QEvent; 43 class QGridLayout; 43 44 class QObject; 44 45 class QLabel; … … 174 175 /** Holds the page selector instance. */ 175 176 UISettingsSelector *m_pSelector; 176 /** Holds the page stack instance. */177 QStackedWidget *m_pStack;178 177 179 178 private slots: … … 189 188 private: 190 189 191 /** Prepares all. */ 192 void prepare(); 193 /** Prepares widgets. */ 194 void prepareWidgets(); 190 /** @name Prepare/cleanup cascade. 191 * @{ */ 192 /** Prepares all. */ 193 void prepare(); 194 /** Prepares selector. */ 195 void prepareSelector(); 196 /** Prepare stack. */ 197 void prepareStack(); 198 /** Prepare button-box. */ 199 void prepareButtonBox(); 200 /** @} */ 201 195 202 /** Assigns validater for passed @a pPage. */ 196 203 void assignValidator(UISettingsPage *pPage); … … 239 246 /** @name Widgets 240 247 * @{ */ 241 QLabel *m_pLabelTitle; 242 QIDialogButtonBox *m_pButtonBox; 243 QWidget *m_pWidgetStackHandler; 248 /** Holds the main layout instance. */ 249 QGridLayout *m_pLayoutMain; 250 /** Holds the title-label instance. */ 251 QLabel *m_pLabelTitle; 252 /** Holds the page-stack instance. */ 253 QStackedWidget *m_pStack; 254 /** Holds the button-box instance. */ 255 QIDialogButtonBox *m_pButtonBox; 244 256 /** @} */ 245 257 };
Note:
See TracChangeset
for help on using the changeset viewer.