Changeset 72059 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 27, 2018 2:33:48 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 122420
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r72057 r72059 520 520 src/selector/graphics/details/UIGDetailsElements.h \ 521 521 src/selector/graphics/details/UIGMachinePreview.h \ 522 src/settings/UISettingsDialog.h \523 522 src/settings/UISettingsDialogSpecific.h \ 524 523 src/settings/UISettingsPage.h \ … … 664 663 src/selector/UIActionPoolSelector.h \ 665 664 src/selector/UIVirtualBoxEventHandler.h \ 665 src/settings/UISettingsDialog.h \ 666 666 src/widgets/UIAddDiskEncryptionPasswordDialog.h \ 667 667 src/widgets/UIBootTable.h \ … … 777 777 src/selector/UIActionPoolSelector.h \ 778 778 src/selector/UIVirtualBoxEventHandler.h \ 779 src/settings/UISettingsDialog.h \ 779 780 src/widgets/UIAddDiskEncryptionPasswordDialog.h \ 780 781 src/widgets/UIBootTable.h \ … … 1034 1035 src/selector/graphics/details/UIGDetailsElements.cpp \ 1035 1036 src/selector/graphics/details/UIGMachinePreview.cpp \ 1036 src/settings/UISettingsDialog.cpp \1037 1037 src/settings/UISettingsDialogSpecific.cpp \ 1038 1038 src/settings/UISettingsPage.cpp \ … … 1219 1219 src/selector/UIVirtualBoxEventHandler.cpp \ 1220 1220 src/settings/UISettingsDefs.cpp \ 1221 src/settings/UISettingsDialog.cpp \ 1221 1222 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 1222 1223 src/widgets/UIBootTable.cpp \ … … 1359 1360 src/selector/UIVirtualBoxEventHandler.cpp \ 1360 1361 src/settings/UISettingsDefs.cpp \ 1362 src/settings/UISettingsDialog.cpp \ 1361 1363 src/widgets/UIAddDiskEncryptionPasswordDialog.cpp \ 1362 1364 src/widgets/UIBootTable.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.cpp
r71027 r72059 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 20 20 #else /* !VBOX_WITH_PRECOMPILED_HEADERS */ 21 21 22 /* Global includes */ 22 /* Qt includes: */ 23 # include <QCloseEvent> 23 24 # include <QProgressBar> 24 25 # include <QPushButton> 25 26 # include <QStackedWidget> 26 27 # include <QTimer> 27 # include <QCloseEvent> 28 29 /* Local includes */ 28 29 /* GUI includes: */ 30 # include "QIWidgetValidator.h" 31 # include "VBoxGlobal.h" 32 # include "UIConverter.h" 33 # include "UIIconPool.h" 34 # include "UIMessageCenter.h" 35 # include "UIModalWindowManager.h" 36 # include "UIPopupCenter.h" 30 37 # include "UISettingsDialog.h" 38 # include "UISettingsPage.h" 39 # include "UISettingsSelector.h" 40 # include "UISettingsSerializer.h" 41 # include "UIToolBar.h" 31 42 # include "UIWarningPane.h" 32 # include "VBoxGlobal.h"33 # include "UIMessageCenter.h"34 # include "UIPopupCenter.h"35 # include "QIWidgetValidator.h"36 # include "UISettingsSelector.h"37 # include "UIModalWindowManager.h"38 # include "UISettingsSerializer.h"39 # include "UISettingsPage.h"40 # include "UIToolBar.h"41 # include "UIIconPool.h"42 # include "UIConverter.h"43 43 # ifdef VBOX_WS_MAC 44 44 # include "VBoxUtils.h" 45 # endif /* VBOX_WS_MAC */45 # endif 46 46 47 47 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ … … 49 49 #ifdef VBOX_WS_MAC 50 50 # define VBOX_GUI_WITH_TOOLBAR_SETTINGS 51 #endif /* VBOX_WS_MAC */52 53 /* Settings Dialog Constructor: */ 51 #endif 52 53 54 54 UISettingsDialog::UISettingsDialog(QWidget *pParent) 55 /* Parent class: */56 55 : QIWithRetranslateUI<QIMainDialog>(pParent) 57 /* Protected variables: */58 56 , m_pSelector(0) 59 57 , m_pStack(0) 60 /* Common variables: */61 , m_configurationAccessLevel(ConfigurationAccessLevel_Null)62 58 , m_fPolished(false) 63 /* Serialization stuff: */59 , m_enmConfigurationAccessLevel(ConfigurationAccessLevel_Null) 64 60 , m_pSerializeProcess(0) 65 61 , m_fSerializationIsInProgress(false) 66 62 , m_fSerializationClean(true) 67 /* Status-bar stuff: */68 63 , m_pStatusBar(0) 69 /* Process-bar stuff: */70 64 , m_pProcessBar(0) 71 /* Warning-pane stuff: */72 65 , m_pWarningPane(0) 73 66 , m_fValid(true) 74 67 , m_fSilent(true) 75 /* Whats-this stuff: */76 68 , m_pWhatsThisTimer(new QTimer(this)) 77 , m_pWhatsThisCandidate(0) 78 { 79 /* Apply UI decorations: */ 80 Ui::UISettingsDialog::setupUi(this); 81 82 /* Page-title font is derived from the system font: */ 83 QFont pageTitleFont = font(); 84 pageTitleFont.setBold(true); 85 pageTitleFont.setPointSize(pageTitleFont.pointSize() + 2); 86 m_pLbTitle->setFont(pageTitleFont); 87 88 /* Prepare selector: */ 89 QGridLayout *pMainLayout = static_cast<QGridLayout*>(centralWidget()->layout()); 90 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 91 /* No page-title with tool-bar: */ 92 m_pLbTitle->hide(); 93 /* Create modern tool-bar selector: */ 94 m_pSelector = new UISettingsSelectorToolBar(this); 95 static_cast<UIToolBar*>(m_pSelector->widget())->enableMacToolbar(); 96 addToolBar(qobject_cast<QToolBar*>(m_pSelector->widget())); 97 /* No title in this mode, we change the title of the window: */ 98 pMainLayout->setColumnMinimumWidth(0, 0); 99 pMainLayout->setHorizontalSpacing(0); 100 #else 101 /* Create classical tree-view selector: */ 102 m_pSelector = new UISettingsSelectorTreeView(this); 103 pMainLayout->addWidget(m_pSelector->widget(), 0, 0, 2, 1); 104 m_pSelector->widget()->setFocus(); 105 #endif /* VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 106 connect(m_pSelector, SIGNAL(sigCategoryChanged(int)), this, SLOT(sltCategoryChanged(int))); 107 108 /* Prepare page-stack: */ 109 m_pStack = new QStackedWidget(m_pWtStackHandler); 110 popupCenter().setPopupStackOrientation(m_pStack, UIPopupStackOrientation_Bottom); 111 QVBoxLayout *pStackLayout = new QVBoxLayout(m_pWtStackHandler); 112 pStackLayout->setContentsMargins(0, 0, 0, 0); 113 pStackLayout->addWidget(m_pStack); 114 115 /* Prepare button-box: */ 116 m_pButtonBox->button(QDialogButtonBox::Ok)->setDefault(true); 117 connect(m_pButtonBox, SIGNAL(helpRequested()), &msgCenter(), SLOT(sltShowHelpHelpDialog())); 118 119 /* Prepare process-bar: */ 120 m_pProcessBar = new QProgressBar; 121 m_pProcessBar->setMaximum(100); 122 m_pProcessBar->setMinimum(0); 123 124 /* Prepare warning-pane: */ 125 m_pWarningPane = new UIWarningPane; 126 connect(m_pWarningPane, SIGNAL(sigHoverEnter(UIPageValidator*)), this, SLOT(sltHandleWarningPaneHovered(UIPageValidator*))); 127 connect(m_pWarningPane, SIGNAL(sigHoverLeave(UIPageValidator*)), this, SLOT(sltHandleWarningPaneUnhovered(UIPageValidator*))); 128 129 /* Prepare status-bar: */ 130 m_pStatusBar = new QStackedWidget; 131 /* Add empty widget: */ 132 m_pStatusBar->addWidget(new QWidget); 133 /* Add process-bar widget: */ 134 m_pStatusBar->addWidget(m_pProcessBar); 135 /* Add warning-pane: */ 136 m_pStatusBar->addWidget(m_pWarningPane); 137 /* Add status-bar to button-box: */ 138 m_pButtonBox->addExtraWidget(m_pStatusBar); 139 140 /* Setup whatsthis stuff: */ 141 qApp->installEventFilter(this); 142 m_pWhatsThisTimer->setSingleShot(true); 143 connect(m_pWhatsThisTimer, SIGNAL(timeout()), this, SLOT(sltUpdateWhatsThis())); 144 145 /* Translate UI: */ 146 retranslateUi(); 69 { 70 /* Prepare: */ 71 prepare(); 147 72 } 148 73 … … 185 110 } 186 111 112 void UISettingsDialog::reject() 113 { 114 if (!isSerializationInProgress()) 115 QIWithRetranslateUI<QIMainDialog>::reject(); 116 } 117 187 118 void UISettingsDialog::sltCategoryChanged(int cId) 188 119 { 189 int index = m_pages[cId]; 120 const int iIndex = m_pages.value(cId); 121 190 122 #ifdef VBOX_WS_MAC 191 123 /* If index is within the stored size list bounds: */ 192 if (i ndex < m_sizeList.count())124 if (iIndex < m_sizeList.count()) 193 125 { 194 126 /* Get current/stored size: */ 195 127 const QSize cs = size(); 196 const QSize ss = m_sizeList.at(i ndex);128 const QSize ss = m_sizeList.at(iIndex); 197 129 198 130 /* Switch to the new page first if we are shrinking: */ 199 131 if (cs.height() > ss.height()) 200 m_pStack->setCurrentIndex(i ndex);132 m_pStack->setCurrentIndex(iIndex); 201 133 202 134 /* Do the animation: */ … … 205 137 /* Switch to the new page last if we are zooming: */ 206 138 if (cs.height() <= ss.height()) 207 m_pStack->setCurrentIndex(i ndex);139 m_pStack->setCurrentIndex(iIndex); 208 140 209 141 /* Unlock all page policies but lock the current one: */ 210 142 for (int i = 0; i < m_pStack->count(); ++i) 211 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, i == index ? QSizePolicy::Minimum : QSizePolicy::Ignored); 143 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, i == iIndex ? QSizePolicy::Minimum : QSizePolicy::Ignored); 144 212 145 /* And make sure layouts are freshly calculated: */ 213 146 foreach (QLayout *pLayout, findChildren<QLayout*>()) … … 217 150 } 218 151 } 219 #else 220 m_pStack->setCurrentIndex(index); 221 #endif 152 #else /* !VBOX_WS_MAC */ 153 m_pStack->setCurrentIndex(iIndex); 154 #endif /* !VBOX_WS_MAC */ 155 222 156 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 223 157 setWindowTitle(title()); … … 271 205 } 272 206 207 bool UISettingsDialog::eventFilter(QObject *pObject, QEvent *pEvent) 208 { 209 /* Ignore objects which are NOT widgets: */ 210 if (!pObject->isWidgetType()) 211 return QIMainDialog::eventFilter(pObject, pEvent); 212 213 /* Ignore widgets which window is NOT settings window: */ 214 QWidget *pWidget = static_cast<QWidget*>(pObject); 215 if (pWidget->window() != this) 216 return QIMainDialog::eventFilter(pObject, pEvent); 217 218 /* Process different event-types: */ 219 switch (pEvent->type()) 220 { 221 /* Process enter/leave events to remember whats-this candidates: */ 222 case QEvent::Enter: 223 case QEvent::Leave: 224 { 225 if (pEvent->type() == QEvent::Enter) 226 m_pWhatsThisCandidate = pWidget; 227 else 228 m_pWhatsThisCandidate = 0; 229 230 m_pWhatsThisTimer->start(100); 231 break; 232 } 233 /* Process focus-in event to update whats-this pane: */ 234 case QEvent::FocusIn: 235 { 236 sltUpdateWhatsThis(true /* got focus? */); 237 break; 238 } 239 default: 240 break; 241 } 242 243 /* Base-class processing: */ 244 return QIMainDialog::eventFilter(pObject, pEvent); 245 } 246 247 void UISettingsDialog::retranslateUi() 248 { 249 /* Translate generated stuff: */ 250 Ui::UISettingsDialog::retranslateUi(this); 251 252 /* Translate warning stuff: */ 253 m_strWarningHint = tr("Invalid settings detected"); 254 if (!m_fValid || !m_fSilent) 255 m_pWarningPane->setWarningLabel(m_strWarningHint); 256 257 #ifndef VBOX_GUI_WITH_TOOLBAR_SETTINGS 258 /* Retranslate current page headline: */ 259 m_pLbTitle->setText(m_pSelector->itemText(m_pSelector->currentId())); 260 #endif 261 262 /* Retranslate all validators: */ 263 foreach (UIPageValidator *pValidator, findChildren<UIPageValidator*>()) 264 if (!pValidator->lastMessage().isEmpty()) 265 revalidate(pValidator); 266 revalidate(); 267 } 268 269 void UISettingsDialog::showEvent(QShowEvent *pEvent) 270 { 271 /* Base-class processing: */ 272 QIMainDialog::showEvent(pEvent); 273 274 /* One may think that QWidget::polish() is the right place to do things 275 * below, but apparently, by the time when QWidget::polish() is called, 276 * the widget style & layout are not fully done, at least the minimum 277 * size hint is not properly calculated. Since this is sometimes necessary, 278 * we provide our own "polish" implementation. */ 279 if (m_fPolished) 280 return; 281 282 m_fPolished = true; 283 284 int iMinWidth = m_pSelector->minWidth(); 285 286 #ifdef VBOX_WS_MAC 287 288 /* Remove all title bar buttons (Buggy Qt): */ 289 ::darwinSetHidesAllTitleButtons(this); 290 291 /* Unlock all page policies initially: */ 292 for (int i = 0; i < m_pStack->count(); ++i) 293 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); 294 295 /* Activate every single page to get the optimal size: */ 296 for (int i = m_pStack->count() - 1; i >= 0; --i) 297 { 298 /* Activate current page: */ 299 m_pStack->setCurrentIndex(i); 300 301 /* Lock current page policy temporary: */ 302 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 303 /* And make sure layouts are freshly calculated: */ 304 foreach (QLayout *pLayout, findChildren<QLayout*>()) 305 { 306 pLayout->update(); 307 pLayout->activate(); 308 } 309 310 /* Acquire minimum size-hint: */ 311 QSize s = minimumSizeHint(); 312 // WORKAROUND: 313 // Take into account the height of native tool-bar title. 314 // It will be applied only after widget is really shown. 315 // The height is 11pix * 2 (possible HiDPI support). 316 s.setHeight(s.height() + 11 * 2); 317 /* Also make sure that width is no less than tool-bar: */ 318 if (iMinWidth > s.width()) 319 s.setWidth(iMinWidth); 320 /* And remember the size finally: */ 321 m_sizeList.insert(0, s); 322 323 /* Unlock the policy for current page again: */ 324 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); 325 } 326 327 sltCategoryChanged(m_pSelector->currentId()); 328 329 #else /* VBOX_WS_MAC */ 330 331 /* Resize to the minimum possible size: */ 332 QSize s = minimumSize(); 333 if (iMinWidth > s.width()) 334 s.setWidth(iMinWidth); 335 resize(s); 336 337 #endif /* VBOX_WS_MAC */ 338 } 339 273 340 void UISettingsDialog::loadData(QVariant &data) 274 341 { … … 331 398 } 332 399 333 void UISettingsDialog::retranslateUi() 334 { 335 /* Translate generated stuff: */ 336 Ui::UISettingsDialog::retranslateUi(this); 337 338 /* Translate warning stuff: */ 339 m_strWarningHint = tr("Invalid settings detected"); 340 if (!m_fValid || !m_fSilent) 341 m_pWarningPane->setWarningLabel(m_strWarningHint); 342 343 #ifndef VBOX_GUI_WITH_TOOLBAR_SETTINGS 344 /* Retranslate current page headline: */ 345 m_pLbTitle->setText(m_pSelector->itemText(m_pSelector->currentId())); 346 #endif /* VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 347 348 /* Retranslate all validators: */ 349 foreach (UIPageValidator *pValidator, findChildren<UIPageValidator*>()) 350 if (!pValidator->lastMessage().isEmpty()) 351 revalidate(pValidator); 352 revalidate(); 353 } 354 355 void UISettingsDialog::setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel) 400 void UISettingsDialog::setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel) 356 401 { 357 402 /* Make sure something changed: */ 358 if (m_ configurationAccessLevel == newConfigurationAccessLevel)403 if (m_enmConfigurationAccessLevel == enmConfigurationAccessLevel) 359 404 return; 360 405 361 406 /* Apply new configuration access level: */ 362 m_ configurationAccessLevel = newConfigurationAccessLevel;407 m_enmConfigurationAccessLevel = enmConfigurationAccessLevel; 363 408 364 409 /* And propagate it to settings-page(s): */ … … 516 561 } 517 562 518 void UISettingsDialog::sltUpdateWhatsThis(bool fGotFocus /* = false */)563 void UISettingsDialog::sltUpdateWhatsThis(bool fGotFocus) 519 564 { 520 565 QString strWhatsThisText; … … 548 593 } 549 594 550 void UISettingsDialog::reject() 551 { 552 if (!isSerializationInProgress()) 553 QIMainDialog::reject(); 554 } 555 556 bool UISettingsDialog::eventFilter(QObject *pObject, QEvent *pEvent) 557 { 558 /* Ignore objects which are NOT widgets: */ 559 if (!pObject->isWidgetType()) 560 return QIMainDialog::eventFilter(pObject, pEvent); 561 562 /* Ignore widgets which window is NOT settings window: */ 563 QWidget *pWidget = static_cast<QWidget*>(pObject); 564 if (pWidget->window() != this) 565 return QIMainDialog::eventFilter(pObject, pEvent); 566 567 /* Process different event-types: */ 568 switch (pEvent->type()) 569 { 570 /* Process enter/leave events to remember whats-this candidates: */ 571 case QEvent::Enter: 572 case QEvent::Leave: 573 { 574 if (pEvent->type() == QEvent::Enter) 575 m_pWhatsThisCandidate = pWidget; 576 else 577 m_pWhatsThisCandidate = 0; 578 579 m_pWhatsThisTimer->start(100); 580 break; 581 } 582 /* Process focus-in event to update whats-this pane: */ 583 case QEvent::FocusIn: 584 { 585 sltUpdateWhatsThis(true /* got focus? */); 586 break; 587 } 588 default: 589 break; 590 } 591 592 /* Base-class processing: */ 593 return QIMainDialog::eventFilter(pObject, pEvent); 594 } 595 596 void UISettingsDialog::showEvent(QShowEvent *pEvent) 597 { 598 /* Base-class processing: */ 599 QIMainDialog::showEvent(pEvent); 600 601 /* One may think that QWidget::polish() is the right place to do things 602 * below, but apparently, by the time when QWidget::polish() is called, 603 * the widget style & layout are not fully done, at least the minimum 604 * size hint is not properly calculated. Since this is sometimes necessary, 605 * we provide our own "polish" implementation. */ 606 if (m_fPolished) 607 return; 608 609 m_fPolished = true; 610 611 int iMinWidth = m_pSelector->minWidth(); 612 #ifdef VBOX_WS_MAC 613 /* Remove all title bar buttons (Buggy Qt): */ 614 ::darwinSetHidesAllTitleButtons(this); 615 616 /* Unlock all page policies initially: */ 617 for (int i = 0; i < m_pStack->count(); ++i) 618 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); 619 620 /* Activate every single page to get the optimal size: */ 621 for (int i = m_pStack->count() - 1; i >= 0; --i) 622 { 623 /* Activate current page: */ 624 m_pStack->setCurrentIndex(i); 625 626 /* Lock current page policy temporary: */ 627 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 628 /* And make sure layouts are freshly calculated: */ 629 foreach (QLayout *pLayout, findChildren<QLayout*>()) 630 { 631 pLayout->update(); 632 pLayout->activate(); 633 } 634 635 /* Acquire minimum size-hint: */ 636 QSize s = minimumSizeHint(); 637 /* HACK ALERT! 638 * Take into account the height of native tool-bar title. 639 * It will be applied only after widget is really shown. 640 * The height is 11pix * 2 (possible HiDPI support). */ 641 s.setHeight(s.height() + 11 * 2); 642 /* Also make sure that width is no less than tool-bar: */ 643 if (iMinWidth > s.width()) 644 s.setWidth(iMinWidth); 645 /* And remember the size finally: */ 646 m_sizeList.insert(0, s); 647 648 /* Unlock the policy for current page again: */ 649 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); 650 } 651 652 sltCategoryChanged(m_pSelector->currentId()); 653 #else /* VBOX_WS_MAC */ 654 /* Resize to the minimum possible size: */ 655 QSize s = minimumSize(); 656 if (iMinWidth > s.width()) 657 s.setWidth(iMinWidth); 658 resize(s); 659 #endif /* VBOX_WS_MAC */ 595 void UISettingsDialog::prepare() 596 { 597 /* Apply UI decorations: */ 598 Ui::UISettingsDialog::setupUi(this); 599 600 /* Configure title: */ 601 if (m_pLbTitle) 602 { 603 /* Page-title font is bold and larger but derived from the system font: */ 604 QFont pageTitleFont = font(); 605 pageTitleFont.setBold(true); 606 pageTitleFont.setPointSize(pageTitleFont.pointSize() + 2); 607 m_pLbTitle->setFont(pageTitleFont); 608 } 609 610 /* Prepare selector: */ 611 QGridLayout *pMainLayout = static_cast<QGridLayout*>(centralWidget()->layout()); 612 if (pMainLayout) 613 { 614 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 615 616 /* No page-title with tool-bar: */ 617 m_pLbTitle->hide(); 618 619 /* Create modern tool-bar selector: */ 620 m_pSelector = new UISettingsSelectorToolBar(this); 621 if (m_pSelector) 622 { 623 /* Configure tool-bar: */ 624 static_cast<UIToolBar*>(m_pSelector->widget())->enableMacToolbar(); 625 626 /* Add tool-bar into page: */ 627 addToolBar(qobject_cast<QToolBar*>(m_pSelector->widget())); 628 } 629 630 /* No title in this mode, we change the title of the window: */ 631 pMainLayout->setColumnMinimumWidth(0, 0); 632 pMainLayout->setHorizontalSpacing(0); 633 634 #else /* !VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 635 636 /* Create classical tree-view selector: */ 637 m_pSelector = new UISettingsSelectorTreeView(this); 638 if (m_pSelector) 639 { 640 /* Add into layout: */ 641 pMainLayout->addWidget(m_pSelector->widget(), 0, 0, 2, 1); 642 643 /* Set focus: */ 644 m_pSelector->widget()->setFocus(); 645 } 646 647 #endif /* !VBOX_GUI_WITH_TOOLBAR_SETTINGS */ 648 649 connect(m_pSelector, SIGNAL(sigCategoryChanged(int)), this, SLOT(sltCategoryChanged(int))); 650 } 651 652 /* Prepare stack-handler: */ 653 if (m_pWtStackHandler) 654 { 655 /* Create page-stack layout: */ 656 QVBoxLayout *pStackLayout = new QVBoxLayout(m_pWtStackHandler); 657 if (pStackLayout) 658 { 659 /* Confugre page-stack layout: */ 660 pStackLayout->setContentsMargins(0, 0, 0, 0); 661 662 /* Create page-stack: */ 663 m_pStack = new QStackedWidget; 664 if (m_pStack) 665 { 666 /* Configure page-stack: */ 667 popupCenter().setPopupStackOrientation(m_pStack, UIPopupStackOrientation_Bottom); 668 669 /* Add into layout: */ 670 pStackLayout->addWidget(m_pStack); 671 } 672 } 673 } 674 675 /* Prepare button-box: */ 676 if (m_pButtonBox) 677 { 678 m_pButtonBox->button(QDialogButtonBox::Ok)->setDefault(true); 679 connect(m_pButtonBox, &QIDialogButtonBox::helpRequested, 680 &msgCenter(), &UIMessageCenter::sltShowHelpHelpDialog); 681 682 /* Create status-bar: */ 683 m_pStatusBar = new QStackedWidget; 684 if (m_pStatusBar) 685 { 686 /* Add empty widget: */ 687 m_pStatusBar->addWidget(new QWidget); 688 689 /* Create process-bar: */ 690 m_pProcessBar = new QProgressBar; 691 if (m_pProcessBar) 692 { 693 /* Configure process-bar: */ 694 m_pProcessBar->setMinimum(0); 695 m_pProcessBar->setMaximum(100); 696 697 /* Add into status-bar: */ 698 m_pStatusBar->addWidget(m_pProcessBar); 699 } 700 701 /* Create warning-pane: */ 702 m_pWarningPane = new UIWarningPane; 703 if (m_pWarningPane) 704 { 705 /* Configure warning-pane: */ 706 connect(m_pWarningPane, &UIWarningPane::sigHoverEnter, 707 this, &UISettingsDialog::sltHandleWarningPaneHovered); 708 connect(m_pWarningPane, &UIWarningPane::sigHoverLeave, 709 this, &UISettingsDialog::sltHandleWarningPaneUnhovered); 710 711 /* Add into status-bar: */ 712 m_pStatusBar->addWidget(m_pWarningPane); 713 } 714 715 /* Add status-bar to button-box: */ 716 m_pButtonBox->addExtraWidget(m_pStatusBar); 717 } 718 } 719 720 /* Setup what's this stuff: */ 721 qApp->installEventFilter(this); 722 m_pWhatsThisTimer->setSingleShot(true); 723 connect(m_pWhatsThisTimer, &QTimer::timeout, 724 this, &UISettingsDialog::sltUpdateWhatsThisNoFocus); 725 726 /* Apply language settings: */ 727 retranslateUi(); 660 728 } 661 729 … … 672 740 pPage->setOrderAfter(m_pSelector->widget()); 673 741 } 674 -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UISettingsDialog.h
r71027 r72059 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __UISettingsDialog_h__ 19 #define __UISettingsDialog_h__ 20 21 /* VBox includes: */ 18 #ifndef ___UISettingsDialog_h___ 19 #define ___UISettingsDialog_h___ 20 21 /* Qt includes: */ 22 #include <QPointer> 23 #include <QVariant> 24 25 /* GUI includes: */ 22 26 #include "QIMainDialog.h" 23 27 #include "QIWithRetranslateUI.h" 28 #include "UISettingsDefs.h" 24 29 #include "UISettingsDialog.gen.h" 25 #include "UISettingsDefs.h"26 30 27 31 /* Forward declarations: */ 28 class UIPageValidator; 32 class QEvent; 33 class QObject; 29 34 class QProgressBar; 35 class QShowEvent; 30 36 class QStackedWidget; 31 37 class QTimer; 38 class UIPageValidator; 39 class UISettingsPage; 40 class UISettingsSelector; 41 class UISettingsSerializer; 32 42 class UIWarningPane; 33 class UISettingsSelector;34 class UISettingsPage;35 class UISettingsSerializer;36 43 37 44 /* Using declarations: */ 38 45 using namespace UISettingsDefs; 39 46 40 /* Base dialog class for both Global & VM settings which encapsulates most of their similar functionalities */ 41 class UISettingsDialog : public QIWithRetranslateUI<QIMainDialog>, public Ui::UISettingsDialog 47 /** QIMainDialog aubclass used as 48 * base dialog class for both Global & VM settings which encapsulates most of their common functionality. */ 49 class SHARED_LIBRARY_STUFF UISettingsDialog : public QIWithRetranslateUI<QIMainDialog>, public Ui::UISettingsDialog 42 50 { 43 51 Q_OBJECT; … … 45 53 public: 46 54 47 /* Settings Dialog Constructor/Destructor:*/55 /** Constructs settings dialog passing @a pParent to the base-class. */ 48 56 UISettingsDialog(QWidget *pParent); 49 ~UISettingsDialog(); 50 51 /* Execute API: */ 57 /** Destructs settings dialog. */ 58 virtual ~UISettingsDialog() /* override */; 59 60 /** Performs modal dialog call. */ 52 61 void execute(); 53 62 … … 55 64 56 65 /** Hides the modal dialog and sets the result code to Accepted. */ 57 virtual void accept(); 58 59 /* Category-change slot: */ 66 virtual void accept() /* override */; 67 /** Hides the modal dialog and sets the result code to Rejected. */ 68 virtual void reject() /* override */; 69 70 /** Handles category change to @a cId. */ 60 71 virtual void sltCategoryChanged(int cId); 61 72 62 /* Mark dialog as loaded:*/73 /** Marks dialog loaded. */ 63 74 virtual void sltMarkLoaded(); 64 /* Mark dialog as saved:*/75 /** Marks dialog saved. */ 65 76 virtual void sltMarkSaved(); 66 77 67 /* Handlers for process bar:*/78 /** Handles process start. */ 68 79 void sltHandleProcessStarted(); 80 /** Handles process progress change to @a iValue. */ 69 81 void sltHandleProcessProgressChange(int iValue); 70 82 71 83 protected: 72 84 85 /** Preprocesses any Qt @a pEvent for passed @a pObject. */ 86 virtual bool eventFilter(QObject *pObject, QEvent *pEvent) /* override */; 87 /** Handles translation event. */ 88 virtual void retranslateUi() /* override */; 89 /** Handles show @a pEvent. */ 90 virtual void showEvent(QShowEvent *pEvent) /* override */; 91 73 92 /** Returns the serialize process instance. */ 74 UISettingsSerializer *serializeProcess() const { return m_pSerializeProcess; }93 UISettingsSerializer *serializeProcess() const { return m_pSerializeProcess; } 75 94 /** Returns whether the serialization is in progress. */ 76 95 bool isSerializationInProgress() const { return m_fSerializationIsInProgress; } … … 88 107 virtual void saveOwnData() = 0; 89 108 90 /* UI translator: */91 virtual void retranslateUi();92 93 109 /** Returns configuration access level. */ 94 ConfigurationAccessLevel configurationAccessLevel() { return m_configurationAccessLevel; }110 ConfigurationAccessLevel configurationAccessLevel() const { return m_enmConfigurationAccessLevel; } 95 111 /** Defines configuration access level. */ 96 void setConfigurationAccessLevel(ConfigurationAccessLevel newConfigurationAccessLevel);112 void setConfigurationAccessLevel(ConfigurationAccessLevel enmConfigurationAccessLevel); 97 113 98 114 /** Returns the dialog title extension. */ … … 101 117 virtual QString title() const = 0; 102 118 103 /* Add settings page: */ 119 /** Adds an item (page). 120 * @param strBigIcon Brings the big icon. 121 * @param strMediumIcon Brings the medium icon. 122 * @param strSmallIcon Brings the small icon. 123 * @param cId Brings the page ID. 124 * @param strLink Brings the page link. 125 * @param pSettingsPage Brings the page reference. 126 * @param iParentId Brings the page parent ID. */ 104 127 void addItem(const QString &strBigIcon, const QString &strMediumIcon, const QString &strSmallIcon, 105 128 int cId, const QString &strLink, 106 129 UISettingsPage* pSettingsPage = 0, int iParentId = -1); 107 130 108 /* Helpers: Validation stuff:*/131 /** Verifies data integrity between certain @a pSettingsPage and other pages. */ 109 132 virtual void recorrelate(UISettingsPage *pSettingsPage) { Q_UNUSED(pSettingsPage); } 133 134 /** Validates data correctness using certain @a pValidator. */ 110 135 void revalidate(UIPageValidator *pValidator); 136 /** Validates data correctness. */ 111 137 void revalidate(); 112 138 113 /* Protected variables:*/139 /** Holds the page selector instance. */ 114 140 UISettingsSelector *m_pSelector; 115 QStackedWidget *m_pStack; 141 /** Holds the page stack instance. */ 142 QStackedWidget *m_pStack; 116 143 117 144 private slots: 118 145 119 /* Handlers: Validation stuff:*/146 /** Handles validity change for certain @a pValidator. */ 120 147 void sltHandleValidityChange(UIPageValidator *pValidator); 148 149 /** Handles hover enter for warning pane specified by @a pValidator. */ 121 150 void sltHandleWarningPaneHovered(UIPageValidator *pValidator); 151 /** Handles hover leave for warning pane specified by @a pValidator. */ 122 152 void sltHandleWarningPaneUnhovered(UIPageValidator *pValidator); 123 153 124 /* Slot to update whats-this: */ 125 void sltUpdateWhatsThis(bool fGotFocus = false); 126 127 /* Slot to handle reject: */ 128 void reject(); 154 /** Updates watch this information depending on whether we have @a fGotFocus. */ 155 void sltUpdateWhatsThis(bool fGotFocus); 156 /** Updates watch this information. */ 157 void sltUpdateWhatsThisNoFocus() { sltUpdateWhatsThis(false); } 129 158 130 159 private: 131 160 132 /* Event-handlers: */ 133 bool eventFilter(QObject *pObject, QEvent *pEvent); 134 void showEvent(QShowEvent *pEvent); 135 136 /* Helper: Validation stuff: */ 161 /** Prepares all. */ 162 void prepare(); 163 164 /** Assigns validater for passed @a pPage. */ 137 165 void assignValidator(UISettingsPage *pPage); 138 166 167 /** Holds whether the dialog is polished. */ 168 bool m_fPolished; 169 139 170 /** Holds configuration access level. */ 140 ConfigurationAccessLevel m_configurationAccessLevel; 141 142 /* Global Flags: */ 143 bool m_fPolished; 171 ConfigurationAccessLevel m_enmConfigurationAccessLevel; 144 172 145 173 /** Holds the serialize process instance. */ 146 174 UISettingsSerializer *m_pSerializeProcess; 175 147 176 /** Holds whether the serialization is in progress. */ 148 bool m_fSerializationIsInProgress;177 bool m_fSerializationIsInProgress; 149 178 /** Holds whether there were no serialization errors. */ 150 bool m_fSerializationClean;151 152 /* Status bar widget:*/179 bool m_fSerializationClean; 180 181 /** Holds the status-bar widget instance. */ 153 182 QStackedWidget *m_pStatusBar; 154 155 /* Process bar widget: */ 156 QProgressBar *m_pProcessBar; 157 158 /* Error & Warning stuff: */ 159 UIWarningPane *m_pWarningPane; 160 bool m_fValid; 161 bool m_fSilent; 162 QString m_strWarningHint; 163 164 /* Whats-This stuff: */ 165 QTimer *m_pWhatsThisTimer; 166 QPointer<QWidget> m_pWhatsThisCandidate; 167 168 QMap<int, int> m_pages; 183 /** Holds the process-bar widget instance. */ 184 QProgressBar *m_pProcessBar; 185 /** Holds the warning-pane instance. */ 186 UIWarningPane *m_pWarningPane; 187 188 /** Holds whether settings dialog is valid (no errors, can be warnings). */ 189 bool m_fValid; 190 /** Holds whether settings dialog is silent (no errors and no warnings). */ 191 bool m_fSilent; 192 193 /** Holds the warning hint. */ 194 QString m_strWarningHint; 195 196 /** Holds the what's this hover timer instance. */ 197 QTimer *m_pWhatsThisTimer; 198 /** Holds the what's this hover timer instance. */ 199 QPointer<QWidget> m_pWhatsThisCandidate; 200 201 /** Holds the map of settings pages. */ 202 QMap<int, int> m_pages; 203 169 204 #ifdef VBOX_WS_MAC 170 QList<QSize> m_sizeList; 171 #endif /* VBOX_WS_MAC */ 205 /** Holds the list of settings page sizes for animation purposes. */ 206 QList<QSize> m_sizeList; 207 #endif 172 208 }; 173 209 174 #endif // __UISettingsDialog_h__ 175 210 #endif /* !___UISettingsDialog_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.