Changeset 72009 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Apr 25, 2018 9:36:00 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 122269
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r71948 r72009 568 568 src/widgets/graphics/UIGraphicsToolBar.h \ 569 569 src/widgets/graphics/UIGraphicsTextPane.h \ 570 src/wizards/UIWizard.h \571 570 src/wizards/UIWizardPage.h \ 572 571 src/wizards/newvm/UIWizardNewVM.h \ … … 675 674 src/selector/UIActionPoolSelector.h \ 676 675 src/selector/UIVirtualBoxEventHandler.h \ 676 src/wizards/UIWizard.h \ 677 677 src/widgets/UIBootTable.h \ 678 678 src/widgets/UIFilePathSelector.h \ … … 774 774 src/selector/UIActionPoolSelector.h \ 775 775 src/selector/UIVirtualBoxEventHandler.h \ 776 src/wizards/UIWizard.h \ 776 777 src/widgets/UIBootTable.h \ 777 778 src/widgets/UIFilePathSelector.h \ … … 1067 1068 src/widgets/graphics/UIGraphicsToolBar.cpp \ 1068 1069 src/widgets/graphics/UIGraphicsTextPane.cpp \ 1069 src/wizards/UIWizard.cpp \1070 1070 src/wizards/UIWizardPage.cpp \ 1071 1071 src/wizards/newvm/UIWizardNewVM.cpp \ … … 1213 1213 src/selector/UIVirtualBoxEventHandler.cpp \ 1214 1214 src/settings/UISettingsDefs.cpp \ 1215 src/wizards/UIWizard.cpp \ 1215 1216 src/widgets/UIBootTable.cpp \ 1216 1217 src/widgets/UIFilePathSelector.cpp \ … … 1338 1339 src/selector/UIVirtualBoxEventHandler.cpp \ 1339 1340 src/settings/UISettingsDefs.cpp \ 1341 src/wizards/UIWizard.cpp \ 1340 1342 src/widgets/UIBootTable.cpp \ 1341 1343 src/widgets/UIFilePathSelector.cpp \ -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.cpp
r71355 r72009 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 35 35 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 36 36 37 #include <qmath.h> 38 39 40 void UIWizard::sltCurrentIdChanged(int iId) 41 { 42 /* Hide/show description button disabled by default: */ 43 bool fIsHideShowDescriptionButtonAvailable = false; 44 /* Enable hide/show description button for 1st page: */ 45 if (iId == 0) 46 fIsHideShowDescriptionButtonAvailable = true; 47 /* But first-run wizard has no such button anyway: */ 48 if (m_type == WizardType_FirstRun) 49 fIsHideShowDescriptionButtonAvailable = false; 50 /* Set a flag for hide/show description button finally: */ 51 setOption(QWizard::HaveCustomButton1, fIsHideShowDescriptionButtonAvailable); 52 } 53 54 void UIWizard::sltCustomButtonClicked(int iId) 55 { 56 /* Handle 1st button: */ 57 if (iId == CustomButton1) 58 { 59 /* Cleanup: */ 60 cleanup(); 61 62 /* Toggle mode: */ 63 switch (m_mode) 64 { 65 case WizardMode_Basic: m_mode = WizardMode_Expert; break; 66 case WizardMode_Expert: m_mode = WizardMode_Basic; break; 67 default: AssertMsgFailed(("Invalid mode: %d", m_mode)); break; 68 } 69 /* Save mode: */ 70 gEDataManager->setModeForWizardType(m_type, m_mode); 71 72 /* Prepare: */ 73 prepare(); 74 } 75 } 76 77 UIWizard::UIWizard(QWidget *pParent, WizardType type, WizardMode mode /* = WizardMode_Auto */) 37 /* Qt includes: */ 38 #include <QtMath> 39 40 41 void UIWizard::prepare() 42 { 43 /* Translate wizard: */ 44 retranslateUi(); 45 /* Translate wizard pages: */ 46 retranslatePages(); 47 48 /* Resize wizard to 'golden ratio': */ 49 resizeToGoldenRatio(); 50 51 /* Notify pages they are ready: */ 52 QList<int> ids = pageIds(); 53 for (int i = 0; i < ids.size(); ++i) 54 qobject_cast<UIWizardPage*>(page(ids[i]))->markReady(); 55 56 /* Make sure custom buttons shown even if final page is first to show: */ 57 sltCurrentIdChanged(startId()); 58 } 59 60 UIWizard::UIWizard(QWidget *pParent, WizardType enmType, WizardMode enmMode /* = WizardMode_Auto */) 78 61 : QIWithRetranslateUI<QWizard>(pParent) 79 , m_ type(type)80 , m_ mode(mode == WizardMode_Auto ? gEDataManager->modeForWizardType(m_type) : mode)62 , m_enmType(enmType) 63 , m_enmMode(enmMode == WizardMode_Auto ? gEDataManager->modeForWizardType(m_enmType) : enmMode) 81 64 { 82 65 #ifdef VBOX_WS_WIN 83 66 /* Hide window icon: */ 84 67 setWindowIcon(QIcon()); 85 #endif /* VBOX_WS_WIN */68 #endif 86 69 87 70 #ifdef VBOX_WS_MAC 88 /* Since wizards are now represented as Mac OS X Sheets 89 * we would like to have possibility to cancel them. */ 71 // WORKAROUND: 72 // Since wizards are now represented as Mac OS X Sheets 73 // we would like to have possibility to cancel them. 90 74 setOption(QWizard::NoCancelButton, false); 91 /* I'm really not sure why there shouldn't be any default button on Mac OS X. 92 * This prevents the using of Enter to jump to the next page. */ 75 76 // WORKAROUND: 77 // I'm really not sure why there shouldn't be any default button on Mac OS X. 78 // This prevents the using of Enter to jump to the next page. 93 79 setOptions(options() ^ QWizard::NoDefaultButton); 94 80 #endif /* VBOX_WS_MAC */ 95 81 96 /* All our wizards would like to have window-modality, 97 * Under Mac OS it will be represented as Mac OS Sheet. */ 82 /* Using window-modality: */ 98 83 setWindowModality(Qt::WindowModal); 99 84 … … 106 91 { 107 92 /* Translate basic/expert button: */ 108 switch (m_ mode)93 switch (m_enmMode) 109 94 { 110 95 case WizardMode_Basic: … … 116 101 button(QWizard::CustomButton1)->setToolTip(tr("Switch to <nobr><b>Guided Mode</b></nobr>, a step-by-step dialog with detailed explanations.")); 117 102 break; 118 default: AssertMsgFailed(("Invalid mode: %d", m_mode)); break; 119 } 120 } 121 122 void UIWizard::retranslatePages() 123 { 124 /* Translate all the pages: */ 125 QList<int> ids = pageIds(); 126 for (int i = 0; i < ids.size(); ++i) 127 qobject_cast<UIWizardPage*>(page(ids[i]))->retranslate(); 103 default: 104 AssertMsgFailed(("Invalid mode: %d", m_enmMode)); 105 break; 106 } 107 } 108 109 void UIWizard::showEvent(QShowEvent *pEvent) 110 { 111 /* Resize to minimum possible size: */ 112 resize(0, 0); 113 114 /* Call to base-class: */ 115 QWizard::showEvent(pEvent); 128 116 } 129 117 … … 136 124 } 137 125 138 void UIWizard::prepare()139 {140 /* Translate wizard: */141 retranslateUi();142 /* Translate wizard pages: */143 retranslatePages();144 145 /* Resize wizard to 'golden ratio': */146 resizeToGoldenRatio();147 148 /* Notify pages they are ready: */149 QList<int> ids = pageIds();150 for (int i = 0; i < ids.size(); ++i)151 qobject_cast<UIWizardPage*>(page(ids[i]))->markReady();152 153 /* Make sure custom buttons shown even if final page is first to show: */154 sltCurrentIdChanged(startId());155 }156 157 126 void UIWizard::cleanup() 158 127 { 159 128 /* Remove all the pages: */ 160 QList<int> ids = pageIds();129 const QList<int> ids = pageIds(); 161 130 for (int i = ids.size() - 1; i >= 0 ; --i) 162 131 { 163 132 /* Get enumerated page ID: */ 164 int iId = ids[i];133 const int iId = ids.at(i); 165 134 /* Get corresponding page: */ 166 135 QWizardPage *pWizardPage = page(iId); … … 176 145 if (!m_strWatermarkName.isEmpty()) 177 146 setPixmap(QWizard::WatermarkPixmap, QPixmap()); 178 #endif /* !VBOX_WS_MAC */147 #endif 179 148 } 180 149 … … 182 151 { 183 152 /* Check if wizard is in basic or expert mode: */ 184 if (m_mode == WizardMode_Expert) 185 { 186 /* Unfortunately QWizard hides some of useful API in private part, 187 * and also have few layouting bugs which could be easy fixed 188 * by that API, so we will use QWizard::restart() method 189 * to call the same functionality indirectly... 190 * Early call restart() which is usually goes on show()! */ 153 if (m_enmMode == WizardMode_Expert) 154 { 155 // WORKAROUND: 156 // Unfortunately QWizard hides some of useful API in private part, 157 // and also have few layouting bugs which could be easy fixed 158 // by that API, so we will use QWizard::restart() method 159 // to call the same functionality indirectly... 160 // Early call restart() which is usually goes on show()! 191 161 restart(); 192 162 193 /* Now we have correct label size-hint(s) for all the pages. 194 * We have to make sure all the pages uses maximum available size-hint. */ 163 // WORKAROUND: 164 // Now we have correct label size-hint(s) for all the pages. 165 // We have to make sure all the pages uses maximum available size-hint. 195 166 QSize maxOfSizeHints; 196 167 QList<UIWizardPage*> pages = findChildren<UIWizardPage*>(); … … 214 185 pLayout->activate(); 215 186 216 /* Unfortunately QWizard hides some of useful API in private part, 217 * BUT it also have few layouting bugs which could be easy fixed 218 * by that API, so we will use QWizard::restart() method 219 * to call the same functionality indirectly... 220 * And now we call restart() after layout activation procedure! */ 187 // WORKAROUND: 188 // Unfortunately QWizard hides some of useful API in private part, 189 // and also have few layouting bugs which could be easy fixed 190 // by that API, so we will use QWizard::restart() method 191 // to call the same functionality indirectly... 192 // And now we call restart() after layout activation procedure! 221 193 restart(); 222 194 … … 282 254 if (!m_strWatermarkName.isEmpty()) 283 255 assignWatermarkHelper(); 284 #endif /* !VBOX_WS_MAC */256 #endif 285 257 } 286 258 287 259 #ifndef VBOX_WS_MAC 260 288 261 void UIWizard::assignWatermark(const QString &strWatermark) 289 262 { 290 263 if (wizardStyle() != QWizard::AeroStyle 291 264 # ifdef VBOX_WS_WIN 292 /* There is a Qt bug about Windows7 do NOT match conditions for 'aero' wizard-style, 293 * so its silently fallbacks to 'modern' one without any notification, 294 * so QWizard::wizardStyle() returns QWizard::ModernStyle, while using aero, at least partially. */ 265 // WORKAROUND: 266 // There is a Qt bug about Windows7 do NOT match conditions for 'aero' wizard-style, 267 // so its silently fallbacks to 'modern' one without any notification, 268 // so QWizard::wizardStyle() returns QWizard::ModernStyle, while using aero, at least partially. 295 269 && QSysInfo::windowsVersion() != QSysInfo::WV_WINDOWS7 296 270 # endif /* VBOX_WS_WIN */ … … 298 272 m_strWatermarkName = strWatermark; 299 273 } 274 300 275 #else 276 301 277 void UIWizard::assignBackground(const QString &strBackground) 302 278 { 303 279 setPixmap(QWizard::BackgroundPixmap, strBackground); 304 280 } 281 305 282 #endif 306 283 307 void UIWizard::showEvent(QShowEvent *pShowEvent) 308 { 309 /* Resize to minimum possible size: */ 310 resize(0, 0); 311 312 /* Call to base-class: */ 313 QWizard::showEvent(pShowEvent); 284 void UIWizard::sltCurrentIdChanged(int iId) 285 { 286 /* Hide/show description button disabled by default: */ 287 bool fIsHideShowDescriptionButtonAvailable = false; 288 /* Enable hide/show description button for 1st page: */ 289 if (iId == 0) 290 fIsHideShowDescriptionButtonAvailable = true; 291 /* But first-run wizard has no such button anyway: */ 292 if (m_enmType == WizardType_FirstRun) 293 fIsHideShowDescriptionButtonAvailable = false; 294 /* Set a flag for hide/show description button finally: */ 295 setOption(QWizard::HaveCustomButton1, fIsHideShowDescriptionButtonAvailable); 296 } 297 298 void UIWizard::sltCustomButtonClicked(int iId) 299 { 300 /* Handle 1st button: */ 301 if (iId == CustomButton1) 302 { 303 /* Cleanup: */ 304 cleanup(); 305 306 /* Toggle mode: */ 307 switch (m_enmMode) 308 { 309 case WizardMode_Basic: m_enmMode = WizardMode_Expert; break; 310 case WizardMode_Expert: m_enmMode = WizardMode_Basic; break; 311 default: AssertMsgFailed(("Invalid mode: %d", m_enmMode)); break; 312 } 313 /* Save mode: */ 314 gEDataManager->setModeForWizardType(m_enmType, m_enmMode); 315 316 /* Prepare: */ 317 prepare(); 318 } 319 } 320 321 void UIWizard::retranslatePages() 322 { 323 /* Translate all the pages: */ 324 QList<int> ids = pageIds(); 325 for (int i = 0; i < ids.size(); ++i) 326 qobject_cast<UIWizardPage*>(page(ids[i]))->retranslate(); 314 327 } 315 328 … … 333 346 void UIWizard::resizeAccordingLabelWidth(int iLabelsWidth) 334 347 { 335 /* Unfortunately QWizard hides some of useful API in private part, 336 * and also have few layouting bugs which could be easy fixed 337 * by that API, so we will use QWizard::restart() method 338 * to call the same functionality indirectly... 339 * Early call restart() which is usually goes on show()! */ 348 // WORKAROUND: 349 // Unfortunately QWizard hides some of useful API in private part, 350 // and also have few layouting bugs which could be easy fixed 351 // by that API, so we will use QWizard::restart() method 352 // to call the same functionality indirectly... 353 // Early call restart() which is usually goes on show()! 340 354 restart(); 341 355 … … 366 380 pLayout->activate(); 367 381 368 /* Unfortunately QWizard hides some of useful API in private part, 369 * BUT it also have few layouting bugs which could be easy fixed 370 * by that API, so we will use QWizard::restart() method 371 * to call the same functionality indirectly... 372 * And now we call restart() after layout activation procedure! */ 382 // WORKAROUND: 383 // Unfortunately QWizard hides some of useful API in private part, 384 // and also have few layouting bugs which could be easy fixed 385 // by that API, so we will use QWizard::restart() method 386 // to call the same functionality indirectly... 387 // And now we call restart() after layout activation procedure! 373 388 restart(); 374 389 … … 377 392 } 378 393 379 double UIWizard::ratio() 394 double UIWizard::ratio() const 380 395 { 381 396 /* Default value: */ … … 387 402 case QWizard::ClassicStyle: 388 403 case QWizard::ModernStyle: 389 /* There is a Qt bug about Windows7 do NOT match conditions for 'aero' wizard-style, 390 * so its silently fallbacks to 'modern' one without any notification, 391 * so QWizard::wizardStyle() returns QWizard::ModernStyle, while using aero, at least partially. */ 404 // WORKAROUND: 405 // There is a Qt bug about Windows7 do NOT match conditions for 'aero' wizard-style, 406 // so its silently fallbacks to 'modern' one without any notification, 407 // so QWizard::wizardStyle() returns QWizard::ModernStyle, while using aero, at least partially. 392 408 if (QSysInfo::windowsVersion() != QSysInfo::WV_WINDOWS7) 393 409 { … … 403 419 #endif /* VBOX_WS_WIN */ 404 420 405 switch (m_ type)421 switch (m_enmType) 406 422 { 407 423 case WizardType_CloneVM: … … 442 458 /* Acquire wizard-layout top-margin: */ 443 459 int iTopMargin = 0; 444 if (m_ mode == WizardMode_Basic)460 if (m_enmMode == WizardMode_Basic) 445 461 { 446 462 if (wizardStyle() == QWizard::ModernStyle) … … 450 466 /* Acquire wizard-header height: */ 451 467 int iTitleHeight = 0; 452 if (m_ mode == WizardMode_Basic)468 if (m_enmMode == WizardMode_Basic) 453 469 { 454 470 /* We have no direct access to QWizardHeader inside QWizard private data... … … 462 478 /* Acquire spacing between wizard-header and wizard-page: */ 463 479 int iMarginBetweenTitleAndPage = 0; 464 if (m_ mode == WizardMode_Basic)480 if (m_enmMode == WizardMode_Basic) 465 481 { 466 482 /* We have no direct access to margin between QWizardHeader and wizard-pages... -
trunk/src/VBox/Frontends/VirtualBox/src/wizards/UIWizard.h
r71027 r72009 5 5 6 6 /* 7 * Copyright (C) 2009-201 7Oracle Corporation7 * Copyright (C) 2009-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIWizard_h__19 #define __ UIWizard_h__18 #ifndef ___UIWizard_h___ 19 #define ___UIWizard_h___ 20 20 21 21 /* Qt includes: */ 22 #include <QPointer> 22 23 #include <QWizard> 23 #include <QPointer>24 24 25 /* Localincludes: */25 /* GUI includes: */ 26 26 #include "QIWithRetranslateUI.h" 27 27 #include "UIExtraDataDefs.h" 28 #include "UILibraryDefs.h" 28 29 29 30 /* Forward declarations: */ 31 class QShowEvent; 32 class QString; 33 class QWidget; 30 34 class UIWizardPage; 31 35 32 /* QWizard class reimplementation with extended funtionality. */33 class UIWizard : public QIWithRetranslateUI<QWizard>36 /** QWizard extension with advanced functionality. */ 37 class SHARED_LIBRARY_STUFF UIWizard : public QIWithRetranslateUI<QWizard> 34 38 { 35 39 Q_OBJECT; … … 37 41 public: 38 42 39 /* Mode related stuff:*/40 WizardMode mode() { return m_mode; }43 /** Returns wizard mode. */ 44 WizardMode mode() const { return m_enmMode; } 41 45 42 /* Page related methods:*/46 /** Prepare all. */ 43 47 virtual void prepare(); 48 49 protected: 50 51 /** Constructs wizard passing @a pParent to the base-class. 52 * @param enmType Brings the wizard type. 53 * @param enmMode Brings the wizard mode. */ 54 UIWizard(QWidget *pParent, WizardType enmType, WizardMode enmMode = WizardMode_Auto); 55 56 /** Handles translation event. */ 57 virtual void retranslateUi() /* override */; 58 59 /** Handles show @a pEvent. */ 60 virtual void showEvent(QShowEvent *pEvent) /* override */; 61 62 /** Assigns @a pPage as a wizard page with certain @a iId. */ 63 void setPage(int iId, UIWizardPage *pPage); 64 /** Removes all the pages. */ 65 void cleanup(); 66 67 /** Resizes wizard to golden ratio. */ 68 void resizeToGoldenRatio(); 69 70 #ifndef VBOX_WS_MAC 71 /** Assigns @a strWaterMark. */ 72 void assignWatermark(const QString &strWaterMark); 73 #else 74 /** Assigns @a strBackground. */ 75 void assignBackground(const QString &strBackground); 76 #endif 44 77 45 78 protected slots: 46 79 47 /* Page change handler:*/80 /** Handles current-page change to page with @a iId. */ 48 81 virtual void sltCurrentIdChanged(int iId); 49 /* Custom button 1 click handler:*/82 /** Handles custome-button click for button with @a iId. */ 50 83 virtual void sltCustomButtonClicked(int iId); 51 52 protected:53 54 /* Constructor: */55 UIWizard(QWidget *pParent, WizardType type, WizardMode mode = WizardMode_Auto);56 57 /* Translation stuff: */58 void retranslateUi();59 void retranslatePages();60 61 /* Page related methods: */62 void setPage(int iId, UIWizardPage *pPage);63 void cleanup();64 65 /* Adjusting stuff: */66 void resizeToGoldenRatio();67 68 /* Design stuff: */69 #ifndef VBOX_WS_MAC70 void assignWatermark(const QString &strWaterMark);71 #else72 void assignBackground(const QString &strBackground);73 #endif74 75 /* Show event: */76 void showEvent(QShowEvent *pShowEvent);77 84 78 85 private: 79 86 80 /* Helpers: */ 87 /** Performs pages translation. */ 88 void retranslatePages(); 89 90 /** Configures certain @a pPage. */ 81 91 void configurePage(UIWizardPage *pPage); 92 93 /** Resizes wizard according certain @a iLabelWidth. */ 82 94 void resizeAccordingLabelWidth(int iLabelWidth); 83 double ratio(); 95 96 /** Returns ratio corresponding to current wizard type. */ 97 double ratio() const; 98 84 99 #ifndef VBOX_WS_MAC 100 /** Returns proposed watermark height. */ 85 101 int proposedWatermarkHeight(); 102 /** Assigns cached watermark. */ 86 103 void assignWatermarkHelper(); 87 #endif /* !VBOX_WS_MAC */104 #endif 88 105 89 /* Variables: */ 90 WizardType m_type; 91 WizardMode m_mode; 106 /** Holds the wizard type. */ 107 WizardType m_enmType; 108 /** Holds the wizard mode. */ 109 WizardMode m_enmMode; 92 110 #ifndef VBOX_WS_MAC 93 QString m_strWatermarkName; 94 #endif /* !VBOX_WS_MAC */ 111 /** Holds the watermark name. */ 112 QString m_strWatermarkName; 113 #endif 95 114 }; 96 115 116 /** Wizard interface safe-pointer. */ 97 117 typedef QPointer<UIWizard> UISafePointerWizard; 98 118 99 #endif // __UIWizard_h__ 100 119 #endif /* !___UIWizard_h___ */
Note:
See TracChangeset
for help on using the changeset viewer.