Changeset 100989 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 28, 2023 3:28:43 PM (17 months ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r100979 r100989 1077 1077 src/medium/viso/UIVisoCreator.cpp \ 1078 1078 src/notificationcenter/UINotificationCenter.cpp \ 1079 src/settings/UIAdvancedSettingsDialog.cpp \ 1079 1080 src/settings/editors/UIBaseMemoryEditor.cpp \ 1080 1081 src/settings/editors/UIBootOrderEditor.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.cpp
r100988 r100989 32 32 #include <QProgressBar> 33 33 #include <QPushButton> 34 #include <QScrollArea> 35 #include <QScrollBar> 34 36 #include <QStackedWidget> 35 37 #include <QVariant> … … 60 62 #endif 61 63 64 65 /** QScrollArea extension to be used for 66 * advanced settings dialog. The idea is to make 67 * vertical scroll-bar always visible, keeping 68 * horizontal scroll-bar always hidden. */ 69 class UIVerticalScrollArea : public QScrollArea 70 { 71 Q_OBJECT; 72 73 public: 74 75 /** Constructs vertical scroll-area passing @a pParent to the base-class. */ 76 UIVerticalScrollArea(QWidget *pParent); 77 78 protected: 79 80 /** Holds the minimum widget size. */ 81 virtual QSize minimumSizeHint() const RT_OVERRIDE; 82 }; 83 84 85 /********************************************************************************************************************************* 86 * Class UIVerticalScrollArea implementation. * 87 *********************************************************************************************************************************/ 88 89 UIVerticalScrollArea::UIVerticalScrollArea(QWidget *pParent) 90 : QScrollArea(pParent) 91 { 92 /* Make vertical scroll-bar always visible. */ 93 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); 94 } 95 96 QSize UIVerticalScrollArea::minimumSizeHint() const 97 { 98 /* To make horizontal scroll-bar always hidden we'll 99 * have to make sure minimum size-hint updated accordingly. */ 100 const int iMinWidth = viewportSizeHint().width() 101 + verticalScrollBar()->sizeHint().width() 102 + frameWidth() * 2; 103 const int iMinHeight = qMax(QScrollArea::minimumSizeHint().height(), 104 (int)(iMinWidth / 1.6)); 105 return QSize(iMinWidth, iMinHeight); 106 } 107 108 109 /********************************************************************************************************************************* 110 * Class UIAdvancedSettingsDialog implementation. * 111 *********************************************************************************************************************************/ 62 112 63 113 UIAdvancedSettingsDialog::UIAdvancedSettingsDialog(QWidget *pParent, … … 80 130 , m_fSilent(true) 81 131 , m_pLayoutMain(0) 82 , m_pStack(0) 132 , m_pScrollArea(0) 133 , m_pScrollViewport(0) 83 134 , m_pButtonBox(0) 84 135 { … … 110 161 void UIAdvancedSettingsDialog::sltCategoryChanged(int cId) 111 162 { 112 #ifndef VBOX_WS_MAC113 if (m_pButtonBox)114 uiCommon().setHelpKeyword(m_pButtonBox->button(QDialogButtonBox::Help), m_pageHelpKeywords[cId]);115 #endif116 const int iIndex = m_pages.value(cId);117 118 #ifdef VBOX_WS_MAC119 /* If index is within the stored size list bounds: */120 if (iIndex < m_sizeList.count())121 {122 /* Get current/stored size: */123 const QSize cs = size();124 const QSize ss = m_sizeList.at(iIndex);125 126 /* Switch to the new page first if we are shrinking: */127 if (cs.height() > ss.height())128 m_pStack->setCurrentIndex(iIndex);129 130 /* Do the animation: */131 ::darwinWindowAnimateResize(this, QRect (x(), y(), ss.width(), ss.height()));132 133 /* Switch to the new page last if we are zooming: */134 if (cs.height() <= ss.height())135 m_pStack->setCurrentIndex(iIndex);136 137 /* Unlock all page policies but lock the current one: */138 for (int i = 0; i < m_pStack->count(); ++i)139 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, i == iIndex ? QSizePolicy::Minimum : QSizePolicy::Ignored);140 141 /* And make sure layouts are freshly calculated: */142 foreach (QLayout *pLayout, findChildren<QLayout*>())143 {144 pLayout->update();145 pLayout->activate();146 }147 }148 #else /* !VBOX_WS_MAC */149 m_pStack->setCurrentIndex(iIndex);150 #endif /* !VBOX_WS_MAC */151 152 163 #ifdef VBOX_GUI_WITH_TOOLBAR_SETTINGS 153 164 setWindowTitle(title()); 165 #endif 166 167 /* Let's calculate scroll-bar shift: */ 168 int iShift = 0; 169 /* We'll have to take upper content's margin into account: */ 170 int iL, iT, iR, iB; 171 m_pScrollViewport->layout()->getContentsMargins(&iL, &iT, &iR, &iB); 172 iShift -= iT; 173 /* And actual page position according to parent: */ 174 const QPoint pnt = m_pages.value(cId)->pos(); 175 iShift += pnt.y(); 176 /* Make sure corresponding page is visible: */ 177 m_pScrollArea->verticalScrollBar()->setValue(iShift); 178 179 #ifndef VBOX_WS_MAC 180 uiCommon().setHelpKeyword(m_pButtonBox->button(QDialogButtonBox::Help), m_pageHelpKeywords.value(cId)); 154 181 #endif 155 182 } … … 209 236 void UIAdvancedSettingsDialog::polishEvent() 210 237 { 211 /* Check what's the minimum selector size: */ 212 const int iMinWidth = m_pSelector->minWidth(); 213 214 #ifdef VBOX_WS_MAC 215 216 /* Remove all title bar buttons (Buggy Qt): */ 217 ::darwinSetHidesAllTitleButtons(this); 218 219 /* Unlock all page policies initially: */ 220 for (int i = 0; i < m_pStack->count(); ++i) 221 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); 222 223 /* Activate every single page to get the optimal size: */ 224 for (int i = m_pStack->count() - 1; i >= 0; --i) 225 { 226 /* Activate current page: */ 227 m_pStack->setCurrentIndex(i); 228 229 /* Lock current page policy temporary: */ 230 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); 231 /* And make sure layouts are freshly calculated: */ 232 foreach (QLayout *pLayout, findChildren<QLayout*>()) 233 { 234 pLayout->update(); 235 pLayout->activate(); 236 } 237 238 /* Acquire minimum size-hint: */ 239 QSize s = minimumSizeHint(); 240 // WORKAROUND: 241 // Take into account the height of native tool-bar title. 242 // It will be applied only after widget is really shown. 243 // The height is 11pix * 2 (possible HiDPI support). 244 s.setHeight(s.height() + 11 * 2); 245 /* Also make sure that width is no less than tool-bar: */ 246 if (iMinWidth > s.width()) 247 s.setWidth(iMinWidth); 248 /* And remember the size finally: */ 249 m_sizeList.insert(0, s); 250 251 /* Unlock the policy for current page again: */ 252 m_pStack->widget(i)->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Ignored); 253 } 254 255 sltCategoryChanged(m_pSelector->currentId()); 256 257 #else /* VBOX_WS_MAC */ 258 259 /* Resize to the minimum possible size: */ 260 QSize s = minimumSize(); 261 if (iMinWidth > s.width()) 262 s.setWidth(iMinWidth); 263 resize(s); 264 265 #endif /* VBOX_WS_MAC */ 238 /* Resize to minimum size: */ 239 resize(minimumSizeHint()); 240 241 /* Choose page/tab finally: */ 242 choosePageAndTab(); 266 243 267 244 /* Explicit centering according to our parent: */ … … 298 275 if (!m_strControl.isNull()) 299 276 { 300 if (QWidget *pWidget = m_pS tack->findChild<QWidget*>(m_strControl))277 if (QWidget *pWidget = m_pScrollViewport->findChild<QWidget*>(m_strControl)) 301 278 { 302 279 QList<QWidget*> parents; … … 415 392 cId, strLink, pSettingsPage, iParentId)) 416 393 { 417 /* Add stack-widget page if created: */ 418 m_pages[cId] = m_pStack->addWidget(pPage); 419 } 394 /* Add page to scroll-viewport layout: */ 395 m_pScrollViewport->layout()->addWidget(pPage); 396 397 /* Remember widget for referencing: */ 398 m_pages[cId] = pPage; 399 } 400 420 401 /* Assign validator if necessary: */ 421 402 if (pSettingsPage) … … 523 504 /* Show corresponding popup: */ 524 505 if (!m_fValid || !m_fSilent) 525 popupCenter().popup(m_pS tack, "SettingsDialogWarning",506 popupCenter().popup(m_pScrollArea, "SettingsDialogWarning", 526 507 pValidator->lastMessage()); 527 508 } … … 532 513 533 514 /* Recall corresponding popup: */ 534 popupCenter().recall(m_pS tack, "SettingsDialogWarning");515 popupCenter().recall(m_pScrollArea, "SettingsDialogWarning"); 535 516 } 536 517 … … 547 528 /* Prepare widgets: */ 548 529 prepareSelector(); 549 prepareS tack();530 prepareScrollArea(); 550 531 prepareButtonBox(); 551 532 } … … 588 569 } 589 570 590 void UIAdvancedSettingsDialog::prepareStack() 591 { 592 /* Prepare page-stack: */ 593 m_pStack = new QStackedWidget(centralWidget()); 594 if (m_pStack) 595 { 596 /* Configure page-stack: */ 597 popupCenter().setPopupStackOrientation(m_pStack, UIPopupStackOrientation_Bottom); 598 599 /* Add page-stack into main layout: */ 600 m_pLayoutMain->addWidget(m_pStack, 1, 1); 571 void UIAdvancedSettingsDialog::prepareScrollArea() 572 { 573 /* Prepare scroll-area: */ 574 m_pScrollArea = new UIVerticalScrollArea(centralWidget()); 575 if (m_pScrollArea) 576 { 577 /* Configure popup-stack: */ 578 popupCenter().setPopupStackOrientation(m_pScrollArea, UIPopupStackOrientation_Bottom); 579 580 m_pScrollArea->setWidgetResizable(true); 581 m_pScrollArea->setFrameShape(QFrame::NoFrame); 582 583 /* Prepare scroll-viewport: */ 584 m_pScrollViewport = new QWidget(m_pScrollArea); 585 if (m_pScrollViewport) 586 { 587 QVBoxLayout *pLayout = new QVBoxLayout(m_pScrollViewport); 588 int iL, iT, iR, iB; 589 pLayout->getContentsMargins(&iL, &iT, &iR, &iB); 590 pLayout->setContentsMargins(0, 0, iR, 0); 591 int iSpacing = pLayout->spacing(); 592 pLayout->setSpacing(2 * iSpacing); 593 m_pScrollArea->setWidget(m_pScrollViewport); 594 } 595 596 /* Add scroll-area into main layout: */ 597 m_pLayoutMain->addWidget(m_pScrollArea, 1, 1); 601 598 } 602 599 } … … 670 667 671 668 /* Recall popup-pane if any: */ 672 popupCenter().recall(m_pS tack, "SettingsDialogWarning");669 popupCenter().recall(m_pScrollArea, "SettingsDialogWarning"); 673 670 674 671 /* Delete selector early! */ 675 672 delete m_pSelector; 676 673 } 674 675 #include "UIAdvancedSettingsDialog.moc" -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.h
r100988 r100989 42 42 class QGridLayout; 43 43 class QProgressBar; 44 class QScrollArea; 44 45 class QShowEvent; 45 46 class QStackedWidget; … … 188 189 /** Prepares selector. */ 189 190 void prepareSelector(); 190 /** Prepare s tack. */191 void prepareS tack();191 /** Prepare scroll-area. */ 192 void prepareScrollArea(); 192 193 /** Prepare button-box. */ 193 194 void prepareButtonBox(); … … 228 229 229 230 /** Holds the map of settings pages. */ 230 QMap<int, int>m_pages;231 /** Stores the help tag per page. Key is the page type (either GlobalSettingsPageType or MachineSettingsPageType) 232 * and value is the help tag. Used in context sensitive help:*/231 QMap<int, QWidget*> m_pages; 232 233 /** Stores the help tag per page. */ 233 234 QMap<int, QString> m_pageHelpKeywords; 234 235 #ifdef VBOX_WS_MAC236 /** Holds the list of settings page sizes for animation purposes. */237 QList<QSize> m_sizeList;238 #endif239 235 240 236 /** @name Widgets 241 237 * @{ */ 242 238 /** Holds the main layout instance. */ 243 QGridLayout *m_pLayoutMain; 244 /** Holds the page-stack instance. */ 245 QStackedWidget *m_pStack; 239 QGridLayout *m_pLayoutMain; 240 241 /** Holds the scroll-area instance. */ 242 QScrollArea *m_pScrollArea; 243 /** Holds the scroll-viewport instance. */ 244 QWidget *m_pScrollViewport; 245 246 246 /** Holds the button-box instance. */ 247 247 QIDialogButtonBox *m_pButtonBox; -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialogSpecific.cpp
r100985 r100989 287 287 /* Apply language settings: */ 288 288 retranslateUi(); 289 290 /* Choose page/tab finally: */291 choosePageAndTab();292 289 } 293 290 … … 768 765 /* Apply language settings: */ 769 766 retranslateUi(); 770 771 /* Choose page/tab finally: */772 choosePageAndTab();773 767 } 774 768
Note:
See TracChangeset
for help on using the changeset viewer.